EBC Exercise 08a Cross-Compiling
I'm still working on this...
This class is about developing software for embedded Linux. So far we have been doing all of our development on the Beagle. This works well for small (and not so small) programs. However, we are now moving into kernel development and that's best done on a more powerful host computer. Here you learned how to download and install the cross-compilers and the source for kernel and u-boot. Now we'll use those tools.
First we'll check everything by compiling the Hello World program, then we'll try the kernel and u-boot.
Cross-compiling Hello World
Listing 2-4 on page 29 of the text is an embedded version of Hello World. If you've set up your git repository you will find it in helloWorld.c when you do a git pull. Compile and run it on your host to be sure it works.
host$ gcc helloWorld.c host$ ./a.out
Now that you know it's working, let's cross compile it. First set the paths to find the cross-compilers. Put the following in a file, call it ~/.oe/crossCompileEnv.sh. Make sure the path is correct for your system. This is for a 32-bit linux.
PATH=~/BeagleBoard/oe/build/tmp-angstrom_2010_x-eglibc/sysroots/i686-linux/usr/armv7a/bin:$PATH # add cross tools to your path export ARCH=arm export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
Here is for 64-bit
PATH=~/BeagleBoard/oe/build/tmp-angstrom_2010_x-eglibc/sysroots/x86_64-linux/usr/armv7a/bin:$PATH # add cross tools to your path export ARCH=arm export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
Note from Brian: On my machine I had to add ~/BeagleBoard/oe/build/tmp-angstrom_2008_1/sysroots/x86_64-linux/usr/armv7a/bin to $PATH
Then source the file and cd to the kernel directory and try a make.
Finding the Kernel to copy it
Once your compile has finished, where is uImage? One way to find it is
$ cd ~/BeagleBoard/oe $ find . -name "*uImage*"
You'll find several files with uImage in the name. The one you want is
$ cd ~/BeagleBoard/oe/build/tmp-angstrom_2008 $ ls
Here you'll see several directories here. If you cd work
you will find the source code. We are going to go this way.
$ cd deploy/glibc
Here you will find some more directories worth exploring. What do you find in sources
? Finally
$ cd images/beagleboard
Now you have found uImage. Load away.
Compile via make
When you use bitbake it sets up all the paths to use the correct cross compilers. You can also build the kernel or u-boot by using make if you set the paths yourself. Here's what you need to do. Put the following in a file, call it ~/BeagleBoard/oe/crossCompileEnv.sh. Make sure the path is correct for your system.
PATH=~/BeagleBoard/oe/build/tmp-angstrom_2008_1/sysroots/i686-linux/usr/armv7a/bin:$PATH # add cross tools to your path export ARCH=arm export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
Note from Brian: On my machine I had to add ~/BeagleBoard/oe/build/tmp-angstrom_2008_1/sysroots/x86_64-linux/usr/armv7a/bin to $PATH
Then source the file and cd to the kernel directory and try a make.
$ source ~/BeagleBoard/oe/crossCompileEnv.sh $ cd ~/BeagleBoard/oe/build/tmp-angstrom_2008_1/work/beagleboard-angstrom-linux-gnueabi/linux-omap-psp-2.6.32-r88+gitra6bad4464f985fdd3bed72e1b82dcbfc004d7869/git $ make xconfig
To make the kernel and u-boot run
$ make uImage $ make u-boot
Where do these put the new uImage? It's not where bitbake puts them. Here's how I found them.
$ find . -name uImage
If you would prefer to maintain your own kernel source tree outside of OE, see these directions: BeagleBoardLinuxKernel Alternatively it is possible to run the official omap branch of the linux kernel. Take a peek at this page: BeagleBoard#Linux_kernel.