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:

  • Retrieve the kernel source:

  • Install the packages required to build the Linux kernel:

  • Build the kernel:

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:

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX Rockchip RK3588 mini-ITX motherboard

10 Replies to “Cross-compiling the ARM Linux Kernel in Ubuntu 12.04 LTS”

  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
    sander@R540:~$

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

  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:
    http://kernel.ubuntu.com/git-repos/ubuntu/ubuntu-karmic-meta.git
    Need to get 12.8 kB of source archives.
    Get:1 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux-meta 3.0.0.16.19 (dsc) [4,487 B]
    Get:2 http://nl.archive.ubuntu.com/ubuntu/ oneiric-updates/main linux-meta 3.0.0.16.19 (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.0.0.16.19.dsc
    dpkg-source: info: extracting linux-meta in linux-meta-3.0.0.16.19
    dpkg-source: info: unpacking linux-meta_3.0.0.16.19.tar.gz
    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-3.0.0.16.19/
    -rw-rw-r– 1 sander sander 4487 2012-01-27 10:03 linux-meta_3.0.0.16.19.dsc
    -rw-rw-r– 1 sander sander 8316 2012-01-27 10:03 linux-meta_3.0.0.16.19.tar.gz
    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
    sander@R540:~/arm-linux$

  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:
    http://kernel.ubuntu.com/git-repos/ubuntu/ubuntu-oneiric.git
    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. 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:
    http://wiki.debian.org/ArmHardFloatPort

  5. @ 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.

  6. @ 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.

  7. @ 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.

  8. 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?

Leave a Reply

Your email address will not be published. Required fields are marked *

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...
Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...