2010-02-15

Setup sb2 enviroment for mini2440

1) download CodeSourcery cross-compiler toolchain from http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite Note: Select the toolchain of Linux/GNU.

2) Extract the tar ball and arm-2009q3 is generated
>tar -jxvf arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

3) Extract the root_qtopia root
>mkdir root_qtopia
>cd root_qtopia
>tar xvfz ../root_qtopia.tar.gz

4) Copy following directory to root_qtopia
>cp -a $HOME/arm-2008q3/arm-none-linux-gnueabi/libc/{lib,etc,usr} ${root_qtopia}

5) Generate sb2 target
>cd ${root_qtopia}
>sb2-init mini2440_qtopia /disk1/packages/arm-2009q3/bin/arm-none-linux-gnueabi-gcc
>sb2-config -d mini2440_qtopia

6) Compile an example code test.c

#include <stdio.h>
int factorial(int n)
{
if (n == 0) return 1;
return n * factorial (n - 1);
}

int main () {
int i;
int n;
for (i = 0; i < 10; ++i) {
n = factorial (i);
printf ("factorial(%d) = %d\n", i, n);
}
return 0;
}


>sb2
>gcc test.c -o test

7) To execute it, you need install qemu-arm
>git clone git://git.savannah.nongnu.org/qemu.git
>cd qemu
>./configure --target-list=arm-linux-user
>make
>make install
>make && make install

Then /usr/local/bin/qemu-arm is installed.




8) Try to execute
>sb2 test
/bin/bash: ./factorial: No such file or directory

9) run sb2-show to find out a library is missing in path
>sb2-show
sb2-show: error while loading shared libraries: libsb2.so.1: cannot open shared object file: No such file or directory,
due to the bug of sb2 package in debain

Solution: download the newest version and reinstall sb2
... to be continued

No comments:

Post a Comment