Introduction to Cross Compilation
If you need a customized root filesystem or need to compile packages that have many dependencies, see the How To explaining the OpenEmbedded Build System. If you need to rapidly iterate in developing a small piece of C/C++ code, check out the guide to native compilation on a Gumstix COM. The following guide explains how to set up a basic cross-compilation environment. These instructions are given for a Debian-based host system, however they are similar for other Linux OS distributions.
Cross-Compiling the Linux Kernel
First, we explain how to cross-compile the Linux kernel and run it on your Gumstix device without using the full OpenEmbedded system.
Getting the Cross-Compiler
First, we need to get the cross-compiler. From Debian, Ubuntu, or Mint, use the following command:
sudo apt-get install gcc-arm-linux-gnueabi uboot-mkimage
Getting the Kernel Source Code
Next, we need to grab the kernel source code. Make sure you have git installed and type the following lines:
git clone git://www.sakoman.com/git/linux-omap-2.6 linux
If git freezes, it likely means that the server is busy. Kill git (Ctrl-C) and try again later. Next, check out the code we need:
cd linux
git checkout omap-3.2
Building the Kernel
Grab Sakoman's kernel configuration from here . Save it as omap3_defconfig in arch/arm/configs. Overwrite anything already there. Run the configuration:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap3_defconfig
Then configure the kernel to your needs:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
Compile it:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j4
Replace the -j4 option with however many threads you want GNU make to utilize. Usually using twice as many threads as CPU cores available is good practice. When finished, the uImage kernel file can be found in the arch/arm/boot directory.
Kernel modules can be similarly compiled:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
The following command would then install these modules to a preformatted microSD card where the root file system is mounted at /media/rootfs. Run depmod on the gumstix to make sure these new modules can be found.
sudo INSTALL_MOD_PATH=/media/rootfs make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules_install
Testing the Kernel on Physical Hardware
You can use your custom uImage with the guide here: http://gumstix.org/create-a-bootable-microsd-card.html
Grab any binary files that you don't build yourself from cumulus: http://cumulus.gumstix.org/ . I used these files: http://cumulus.gumstix.org/images/angstrom/misc/daily/
You may want to write a script that copies over the kernel automatically each time you build. If your kernel doesn't load, try using an earlier version. If you can't login or Angstrom freezes, try using a different rootfs.
Testing the Kernel on Emulated Hardware (Qemu)
If you want to test the kernel without access to physical hardware, you can emulate the system using Qemu. You can make images for Qemu using this script: http://wiki.gumstix.org/index.php?title=Overo_qemu_script . You use it like this:
# assemble-image.sh $OVEROTOP/overo.img $OEDONE/MLO-overo $OEDONE/u-boot-overo.bin $OEDONE/uImage-overo.bin $OEDONE/omap3-console-image-overo.tar.bz2
Again, use a combination of your custom files and prebuilt binaries from cumulus.
To run qemu, install it (see https://launchpad.net/qemu-linaro/ for details), and then run the following command:
qemu-system-arm -M overo -m 256 -sd ./overo.img -clock unix -serial stdio -device usb-mouse -device usb-kbd
If the qemu version you're using doesn't support the overo, try using qemu-linaro (https://launchpad.net/qemu-linaro/)
Note: this article is not yet finished and requires additional content. ·Thanks for your patience and check back soon.
Useful Links
A common case is building the Linux Kernel. ·These blogs offer good information and can be a valuable resource.
Introduction to cross-compilation