Tutorial 1: Manually building a binary for the device
Overview
This tutorial will show you how to build classic "Hello world" application suitable to run on device and run it.
It is assumed that you've set up development environment as described in Documentation/BuildEnvironment.
Introduction
Unlike regular development when both compiler and program are run on same machine, embedded development uses cross-compilation — compiler is run on your PC, and it produces binaries for target platform.
GNU toolchain (in use by OpenInkpot) uses prefixes to distinguish native and cross-compilers: mipsel-ip-linux-gnu-gcc or arm-ip-linux-gnueabi-gcc, same applies to ld, ar and other tools.
Development environment
After setting up development environment you should have executable file enter in the root of directory you choose. Let's enter the development environment:
[user@host] $ cd $chroot # name of development environment directory [user@host] $ ./enter build@host:~$
As you see, the prompt has changed. You've been chrooted into a separated Linux environment (Debian stable) with a set of tools for cross-compilation and OpenInkpot-specific helpers.
Let's check that cross-compiler is here (use arm-ip-linux-gnueabi-gcc for V3 and other ARM-based devices):
build@host:~$ mipsel-ip-linux-gnu-gcc --version mipsel-ip-linux-gnu-gcc (Debian 4.3.2-1.ip2) 4.3.2 ... build@host:~$
If there is no cross-compiler, then install it (armel-cross-toolchain for ARM-based devices):
build@host:~$ sudo apt-get install mipsel-cross-toolchain ... build@host:~$
Hello world
Using your favorite editor, create helloworld.c with the famous content:
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}
Compilation
Copy the helloworld.c to home directory of build user in development environment:
[user@host] $ cp helloworld.c $chroot/build
Compile helloworld (again, use arm-ip-linux-gneabi-gcc for ARM-based devices):
build@host:~$ mipsel-ip-linux-gnu-gcc -o helloworld helloworld.c build@host:~$ file helloworld helloworld: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, with unknown capability 0xf41 = 0x756e6700, stripped build@host:~$
Running
As you see, helloworld is a binary for MIPS (or ARM) architecture. Copy it to device and run:
[user@host] $ rsync $chroot/build/helloworld 192.168.111.1: [user@host] $ ssh root@192.168.111.1 /mnt/storage/.home/user # ./helloworld Hello world! /mnt/storage/.home/user #
It works!
Further reading
Proceed to next tutorial for learning how to deal with shared libraries on OpenInkpot.

