How to cross compile ARM kernel under Ubuntu 10.10

So you got ARM device and want to build kernel for it? There are few ways how you can do it under Ubuntu 10.10 (or higher).

First you need proper cross compiler. After “apt-get install gcc-arm-linux-gnueabi” you will get proper one.

Next step is compilation of kernel. I will cover 2 things: Ubuntu kernel packages and own kernel.

So… to cross compile Ubuntu kernel we need to have some libraries installed in ARM versions. Simplest way is to use “xdeb” for it:

# apt-get install xdeb
# xdeb -aarmel --only-explicit --apt-source linux-linaro

This will fetch some libraries and install it in host system. But it will not build kernel for us 🙁 Filled bug to not lose track of it.

NOTE: check “dpkg -l *elf*-armel-cross” after xdeb run. If it does not return anything then you need to edit “/etc/apt/source.list” and add line with “deb-src” so APT will know where to go for sources. Do not forget to run “apt-get update” after edit.

Next step is quite simple — all is needed is:

$ cd linux-linaro-2.6.35
$ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel

After some time kernel will be cross compiled and packaged.

If you want official Ubuntu kernel instead of Linaro one then use:

$ apt-get source linux-source-2.6.35
$ cd linux-2.6.35
$ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel

Other way (not supported by Ubuntu developers) is to build kernel from source outside of Ubuntu. Once you got sources unpacked and configured you need just one command: “ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make uImage modules” to build kernel (replace uImage with zImage if your device does not use U-Boot).

20 thoughts on “How to cross compile ARM kernel under Ubuntu 10.10”

  1. Hey,

    This is not a xdeb bug but a linux-linaro bug; the packaging was fixed to set CROSS_COMPILE correctly, but only in later versions of linux, and this didn’t reach linux-linaro yet.

    If you try to cross-build the linux source package from Ubuntu natty (e.g. linux_2.6.36-0.4.dsc), it should work fine. You can even cross-build most of it without xdeb: apt-get source linux apt-get build-dep linux apt-get install gcc-arm-linux-gnueabi cd linux-*/ debuild -aarmel -b

    this will kick a cross-build with CROSS_COMPILE set to arm-linux-gnueabi- automatically. You only need to set CROSS_COMPILE if you want to use a toolchain with a non-Debian/Ubuntu triplet (e.g. arm-none-linux-gnuaebi).


  2. Hi, i need to compile the uClinux on ubuntu 10.10 for lpc-2478-stk (ARM 7TDMI). But i cannot get the necessary images (vmlinux.bin and romfs_5.img), there is always an error. I dont know what the error is about? I use snapgear-cross compiling tool and uclinux-dist2010…

    I dont what to do? Please help!

  3. What if I want to cross-compile the efika MX (standalone, non-linaro) kernel freshly checked out from their repository ?:

    Now I can’t dpkg-buildpackage because the “debian” folder is not there:

    tail: cannot open `debian/changelog’ for reading: No such file or directory dpkg-buildpackage: error: tail of debian/changelog gave error exit status 1

    How should I create a suitable “debian” metadata for Efika MX kernel ?

    Thanks in advance !

    1. Follow instructions from last paragraph. Kernel will be in arch/arm/boot/uImage and modules can be installed into any dir with “make modules_install” + proper arguments.

  4. Yes that’s what I ended up doing, but I wanted to have the kernel pkg built as well :-/

    OTOH, something is wrong with either my build environment (most probable) or the kernel tree:

    CC drivers/staging/android/lowmemorykiller.o drivers/staging/android/lowmemorykiller.c: In function ‘lowmem_shrink’: drivers/staging/android/lowmemorykiller.c:76: error: ‘ZONE_DMA’ undeclared (first use in this function) drivers/staging/android/lowmemorykiller.c:76: error: (Each undeclared identifier is reported only once drivers/staging/android/lowmemorykiller.c:76: error: for each function it appears in.) make[3]: *** [drivers/staging/android/lowmemorykiller.o] Fel 1 make[2]: *** [drivers/staging/android] Fel 2 make[1]: *** [drivers/staging] Fel 2

  5. Hi Marcin,

    $ cd linux-linaro $ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel creates packages that install to /boot

    Is there a way to create a package that contains the uImage and uInitrd? Or do they have to be built and installed manually?

    1. uImage is generated on device by “flash-kernel” script

      uInitrd is generated by “update-initramfs” script

      Both should be started automatically after package installation.

  6. initrd.gz is generated by update-initramfs, then flash-kernel generates and potentially flashes an uImage and an uInitrd from vmlinuz and initrd.gz

  7. Hi

    I’m a quite newbie in this area. As embedded software developer had handled some task in embedded linux. One I cant figure out is the setting for the arm configuration. To be more, I have board with arm926ej-s core and write now building the linearo as you described above. But in the command for compile is specified just arm, not specific arm arch. Is some tips and tricks regarding this, or I should just build as described and it will work on many arm arch (this is some non-logical for me). Please help.

    thanks in advance. Ljupco

  8. I did the build as described in this article but where I can find the images. And second do you have some link to a nice described article how to mount on qemu the image?


  9. Hi mates

    I need help on building an Embedded Ubuntu on Overo (ARM TI OMAP3). I have installed linux-source-2.6.35_2.6.35-22.33_all.deb (69 MB in size) from I have apt-get installed “gcc version 4.5.1 (Ubuntu/Linaro 4.5.1-7ubuntu1)” the cross compiler is in /usr/bin and in the source tree, I have done below:

    sudo make clean sudo make ARCH=arm overo_defconfig

    sudo make ARCH=arm menuconfig [I have selected more features of extended 3 file system to be included in Kernel. sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage modules]

    I have rootstock-ed my root file system as below sudo rootstock –fqdn overo –login ubuntu –password temp –imagesize 5G –seed linux-image-2.6.35-22-omap,gcc,g++,make,build-essential,openssh-server,nano,apt,usbutils,linux-kernel-headers,linux-firmware,wireless-tools,wpasupplicant,zip, linux-source-2.6.35, netbook-launcher-efl,onboard,ubuntu-netbook-efl-default-settings,wicd,wicd-curses,wicd-cli –components “main universe multiverse” –dist maverick –serial ttyS2 –copy-package-cache –restore-package-cache

    That rootfile system came with kernel image, vmLinuz. It was mkimage-d into uImage for UBOOT. First boot with the prebuild kernel, it was fine. I have logged into the root file system. Then powered down, took SD/MMC card and copied custom compiled uImage and modules install as follows: sudo cp arch/arm/boot/uImage /media/$BOOT sudo make ARCH=arm modules_install INSTALL_MOD_PATH=/media/$ROOTFS

    Then reboot but the system hung at the point below can be seen as follow:

    ……………uboot and kernel messages……………….. lib80211: common routines for IEEE802.11drivers ThumbEE CPU extension supported. VFP support v0.3: implementor 41 architecture 3 part 30 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Waiting for root device /dev/mmcblk0p2… <—- stuck there

    I have worked with Monta Vista Linux where compiling was a bit straight forward. I will appreciate if you can give me some pointers and cheers!

  10. I want to install ARM Developer Studio 5 tool-chain on Ubuntu 10.10 (64 bit). Will it be possible to use DS-5 on Ubuntu 10.10. The reason I am asking this is because the ARM website mentions only support for Ubuntu 10.04, which is 32 bit.

  11. Brian, do not run make with sudo. Why on earth would you want do do something like that?

Comments are closed.