Home > Linux, Linux 3.0, Texas Instruments OMAP 4 > Cross-compiling the ARM Linux Kernel in Ubuntu 12.04 LTS

Cross-compiling the ARM Linux Kernel in Ubuntu 12.04 LTS

Yesterday I installed Ubuntu 12.04 ‘Precise’ Beta 1 in Virtual Box to give it a try (I could not manage to have HUD working btw), and today, I’ve noticed an article entitled “Ubuntu 12.04 ‘precise’ and cross compilation of ARM kernels” explaining how to build Linaro ARM kernel in Ubuntu 12.04. So I’ve decided to give it a try, especially it seems straightforward. I followed the instructions in the aforementioned link,  it basically worked except I had to install dpkg-dev package that also installed the build essentials (gcc, g++, etc…) and use sudo for some commands.

You’ll notice the name change for the ARM gcc toolchain as it now uses hard-float by default which seems to provide quite a boost in performance for the Pandaboard.

Here are the steps I followed:

  • Install the ARM GCC cross compiler and the development package of dpkg:
sudo apt-get install gcc-arm-linux-gnueabihf dpkg-dev
  • Retrieve the kernel source:
apt-get source linux-source-3.2.0
  • Install the packages required to build the Linux kernel:
sudo apt-get build-dep linux-source-3.2.0
  • Build the kernel:
cd linux-3.2.0; dpkg-buildpackage -b -aarmhf

That’s it. The build took an awful lot of time (5 to 6 hours) in my machine as many features and modules (2288) are enabled. The binary images (presumably for TI OMAP 4) are located in ./debian/build/build-omap/arch/arm/boot:

ls -l ./debian/build/build-omap/arch/arm/boot:
drwxrwxr-x 2 jaufranc jaufranc 4096 Mar 27 22:15 compressed
-rwxrwxr-x 1 jaufranc jaufranc 7668532 Mar 27 22:15 Image
-rwxrwxr-x 1 jaufranc jaufranc 3728392 Mar 27 22:15 zImage
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

  1. Sander
    March 28th, 2012 at 01:56 | #1

    With the second command, on my Ubuntu 11.10, I get the error message below:

    sander@R540:~$ apt-get source linux-source-3.2.0
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to find a source package for linux-source-3.2.0

    Is Ubuntu 11.10 the reason of this error message, or … ?

  2. Sander
    March 28th, 2012 at 02:00 | #2

    A plain “apt-get source linux-source” does something, but does not give the kernel source: just a few bytes. :-(

    sander@R540:~/arm-linux$ apt-get source linux-source
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Picking ‘linux-meta’ as source package instead of ‘linux-source’
    NOTICE: ‘linux-meta’ packaging is maintained in the ‘Git’ version control system at:
    Need to get 12.8 kB of source archives.
    Get:1 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux-meta (dsc) [4,487 B]
    Get:2 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux-meta (tar) [8,316 B]
    Fetched 12.8 kB in 0s (62.0 kB/s)
    gpgv: Signature made Wed 25 Jan 2012 06:58:06 PM CET using RSA key ID ABB9E055
    gpgv: Can’t check signature: public key not found
    dpkg-source: warning: failed to verify signature on ./linux-meta_3.
    dpkg-source: info: extracting linux-meta in linux-meta-
    dpkg-source: info: unpacking linux-meta_3.
    sander@R540:~/arm-linux$ ll
    total 44
    drwxrwxr-x 3 sander sander 4096 2012-03-27 20:58 ./
    drwxr-xr-x 136 sander sander 16384 2012-03-27 20:52 ../
    drwxrwxr-x 3 sander sander 4096 2011-10-17 21:22 linux-meta-
    -rw-rw-r– 1 sander sander 4487 2012-01-27 10:03 linux-meta_3.
    -rw-rw-r– 1 sander sander 8316 2012-01-27 10:03 linux-meta_3.
    sander@R540:~/arm-linux$ uname -a
    Linux R540 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

  3. Sander
    March 28th, 2012 at 02:07 | #3

    Ah, I think I found it: it looks like you can get the source version that’s running on your Ubuntu (which you can check with uname -a) . So on my Ubuntu 11.10 that’s 3.0.0:

    sander@R540:~/arm-linux$ apt-get source linux-source-3.0.0
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Picking ‘linux’ as source package instead of ‘linux-source-3.0.0’
    NOTICE: ‘linux’ packaging is maintained in the ‘Git’ version control system at:
    Need to get 99.9 MB of source archives.
    Get:1 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux 3.0.0-16.29 (dsc) [10.6 kB]
    Get:2 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux 3.0.0-16.29 (tar) [96.7 MB]
    Get:3 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux 3.0.0-16.29 (diff) [3,197 kB]
    Fetched 99.9 MB in 48s (2,068 kB/s)

  4. March 28th, 2012 at 09:31 | #4

    @ Sander
    Those are instructions for ubuntu 12.04, so I’m not sure this will work for Ubuntu 11.10 since there are other instructions for Ubuntu 11.10: http://marcin.juszkiewicz.com.pl/2010/10/19/how-to-cross-compile-arm-kernel-under-ubuntu-10-10/

    Anyway, let me know if you can build it successfully on Ubuntu 11.10.

  5. Nikolay Nikolaev
    March 29th, 2012 at 15:49 | #5

    What is your machine? 5-6 hours looks a lot!

    What google says:
    “Try tmpfs. It enables you to mount any folder in your file system in RAM, so theoretically speeding up the compilation. Try mounting your build folder with tmpfs like this $sudo mount -t tmpfs -o size=500M,mode=0777 tmpfs /usr/src/linux-build.”

    Also you surely noticed that this is building a Hard Float ABI kernel. If you aim for a regular kernel just remove the ‘hf’ suffix in the related commands.
    Here’s an explanation of what HF is:

  6. March 29th, 2012 at 17:05 | #6

    @ Nikolay Nikolaev
    My machine is based on Intel Core 2 Duo 4300 with 3GB of memory. Since this processor does not support HW virtualization, only one core is used in VirtualBox. I have 1 GB Memory enabled in Virtual Box. The virtual machine is in an USB harddisk, so I wonder if this may also impact performance.

    Do you think using an hard-float compiler would make the compilation last longer?

    I have to say, it has never taken me so much time to build a kernel.

  7. Nikolay Nikolaev
    March 29th, 2012 at 19:16 | #7

    @ cnxsoft

    You cross-compile in a virtual machine on a USB harddisk … wow :) And you don’t have the virt extensions on your CPU.

    I can suggest you to try to partition the USB disk and install Linux (Ubuntu) on the second partition.
    Than you’ll have all your 3GB at the disposal of Linux.
    So you can do the tmpfs trick like that:

    mkdir /cross-compile
    sudo mount -t tmpfs -o size=1500M,mode=0777 tmpfs /cross-compile
    cd /cross-compile
    apt-get source linux-source-3.2.0
    cd linux-3.2.0; dpkg-buildpackage -b -aarm

    And no – the HF has nothing to do with the speed of the compilation. I just pointed it out so the people know what they are compiling.

    Good luck.

  8. March 29th, 2012 at 19:24 | #8

    @ Nikolay Nikolaev
    Thanks for the advice. I already have Ubuntu installed on the main hard drive (dual boot), but for some reasons I have to use Windows XP most of the time.

    I found the performance in VirtualBox is very similar to native performance. The main problem is that I lose one core, so it is probably the main reason it increases build times.

  9. May 1st, 2012 at 01:39 | #9

    Am trying to build for Nook Tablet 7 inch TI4430.
    I need some help to boot from sd card.
    How i implement wifi,touch controller,and lcd panel?

  10. May 1st, 2012 at 08:38 | #10

    @ Demetris
    Some people already have made a basic Ubuntu boot from SD card on the nook – http://forum.xda-developers.com/showthread.php?t=1470910

    For WiFi, Touch controller and LCD Panel, you would need to find the drivers either in source code or binary form, as well as installing a few packages to enable it.

  1. May 2nd, 2012 at 18:43 | #1