Writing a simple program

It is possible to use the toolchain provided with the DevelBoard BSP to cross-compile executables for DevelBoard from a host PC.

In this section, we will show how to cross-compile and run a simple Hello World! example on DevelBoard.

Setup toolchain

Before compiling the program, it is necessary to download and setup the cross-compilation toolchain.

The toolchain is available for download in its own repository. If the BSP has been previously downloaded and built, the same toolchain will be available in the ./buildroot/dl/ folder, inside the BSP repository.

To setup the toolchain, refer to this section.

Write the source code

We will write a standard C Hello world program:

#include <stdio.h>

int main(int argc, char ** argv)
{
    printf("Hello World!\n");
    return 0;
}

Assuming the file is names helloworld.c, the build is simply:

$ arm-linux-gcc -o helloworld helloworld.c

The file command will confirm that helloworld is an ARM executable:

$ file helloworld
helloworld: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

Run on DevelBoard

Finally, to run the program on DevelBoard, it is required to upload the executable to the board. There are different ways to do this.

A possibility is to set up a TFTP server on the local network, and retrieve the file remotely from a network-connected DevelBoard.

Another option is to use the dboard tool to overlay the file on the target filesystem. More info on dboard can be found here.

Finally, on DevelBoard, all that is needed to be done is:

$ chmod +x helloworld
$ ./helloworld
Hello World!