Programming for A13 in debian



Programming for A13 in debian

There are 2 main methods to create programs for your A13 board.

  • Cross compiling - Setting up a tool chain to compile on another system, which is typically faster and easier to manage.
  • Programming on board - installing a compiler to compile directly on the board

The sections below contain instructions for these 2 methods

Cross Compiling

Cross compiling is usually performed on another linux machine, it seems the most common for doing this is ubuntu.

If you have compiled the kernel and setup the SD card you will already have most of the tool chain setup on your machine

Setting up the tool chain

The following instructions are to be performed on a linux machine which is not the A13 board.

Complete the following steps to setup the tool chain.

These instructions have been tested on ubuntu only however they may work for other distributions.

Install eclipse

Eclipse is a GUI which enables easy compilation and debugging when the appropriate tools have been installed.

This may be able to be installed using the package manager on your linux system.

Manual eclipes install
To manually install the most up to date eclipse perform the following

Go to the eclipse download section

Eclipse download Download to your linux machine the suitable eclipse version.

Decompress the downloaded file into any directory you like by moving the downloaded file to your desired directory. Open a terminal, go to the directory and decompress with the command

tar -xzvf FILENAME.

This will create a directory in this location called eclipse Within this directory is the executable eclipse.exe

It is recommended to create a launcher on your desktop which points to this executable file to make it easier to start.

Manual Java runtime install
As eclipse is written in java the jave runtime is required as well.

Download the java runtime.

Java download page Download the java RPM file that your eclipse version requires.

Follow the instructions on the java download page beside the download to install

Your eclipse installation should now start up.

Install the tool chain

The instructions contained in this wiki were originally sourced from this page Debugging on embedded using opensource tools

To compile code for the A13 the ArmV5 tool chain is required.

Change to super user
# sudo su

Install compilers, libs and make # apt-get install gcc g++ make libncurses5-dev

Open the repository file

Add the following line
deb squeeze main

update the repository info
# apt-get update

install some packages
# apt-get install linux-libc-dev-armel-cross
# apt-get install libc6-armel-cross
# apt-get install libc6-dev-armel-cross
# apt-get install binutils-arm-linux-gnueabi
# apt-get install gcc-4.4-arm-linux-gnueabi
# apt-get install g++-4.4-arm-linux-gnueabi
# apt-get install uboot-mkimage

The tool chain should now be installed

Creating a hello world program using eclipse

Follow this tutorial to create a hello world program Debugging on embedded using opensource tools

Some issues found for some users:

- Issue : After having installed eclipse and the toolchain the path and prefix for the compiler as listed in the example could not be found.

Solution : Look for the same prefix in a different path, /usr/bin is likely to hold the files.

- Issue : Having built the program and copied it to the A13 board it will not run resulting in "permission denied"

Solution: Check the permissions for the file are set to allow execution by typing #ls -l . if you dont see a lot of x's (3) in the first column its likely your cause. To change the permissions type #chmod ugo+x FileName

- Issue : executing the file returns "command not found"

Solution: A library file can not be found this is either /lib/ or /lib/ . To find the specific one your file is looking for open the executable in a text editor on the first line or 2 you will find the file name its looking for .

Programming on the A13 board

Below is a way to create a hello world program on your A13 olinuxino board

in a suitable folder create your code file by typing
nano hello.c

type the following into the program

#include <stdio.h>

main ()
printf("hello world\n");

save by pressing ctrl o
exit by pressing ctrl x

compile the program in the command line by typing
gcc -o hello hello.c
gcc-4.6 -o hello hello.c

make the file executable by typing
chmod z+x hello

Execute the binary file

this should print out hello world

if it has this means you have created a program on your A13 olinuxino board