GPIO User Space App describes user space application to test the GPIO.

Another related link is Linux GPIO Driver.

This would be running on a xilinx zynq board having an ARM Cortex A 9 processor.

I am unable to understand why they are asking to compile this source code using gcc:

// the following bash script to toggle the gpio is also handy for
// testing
// while [ 1 ]; do
//  echo 1 > /sys/class/gpio/gpio240/value
//  echo 0 > /sys/class/gpio/gpio240/value
// done

// to compile this, use the following command
// gcc gpio.c -o gpio

Should it not be ARM-linux-gcc. instead of gcc?

Or these commands are to be typed on the target once the kernel boots?

2 Answers 2


The compiler has to target your ARM-based system. It doesn't have to be a cross-compiler — you could be running the compiler on the same or another ARM platform. The name of the cross-compiler is somewhat variable, so the instructions can't cater for all the names that people have used out there. For the intended audience of this document, this is a no-brainer: of course you compile the program for the target that you want to run it on.


Or these commands are to be typed on the target...

Presumably, yes. It is only a few dozen lines of code, there is no point cross-compiling it unless you have no other choice.

...once the kernel boots?

Just to be clear, you don't have to do this over and over again. You only need to do it once and then it is compiled. The executable (gpio) will be left in the same directory until you erase it.

  • But do I have gcc on my target board (ARM) ? Apr 16, 2014 at 9:29
  • 2
    How would I know? You are obviously going to need to need to be able to log into the board and access the command line there somehow, or this whole exercise will be impossible (do you have echo? How are you going to run and control the app? etc.) So from the command line you can check pretty easily: gcc -v will tell you the default version installed, or say "command not found".
    – goldilocks
    Apr 16, 2014 at 10:00
  • It is saying command not found. It means I have to install gcc, but how , since niether apt-get nor yum works on petalinux Apr 16, 2014 at 10:06
  • I don't know if you can (searching for "petalinux package mangager doesn't turn anything up), meaning maybe you do have to cross-compile. Looking at this page, it only mentions gcc for the host. Since petalinux and that GPIO app are both distributed via xilinx, you'd one would be applicable to the other, but the fact that it just says "gcc" there is still not incorrect. If you have a cross-compiler named "arm-foo-bar-gcc" or whatever it is still gcc.
    – goldilocks
    Apr 16, 2014 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.