Monday, 28 May 2012

Debian on Pandaboard: Building Ubuntu kernel

Setting up basic build environment:

There is a nice package, called "build-essential", by installing which you should have all the tools needed to compile and packed applications/kernels from their respective sources:
sudo apt-get install build-essential libncurses5-dev
(You would want to have libncurses5-dev - without it, you would be unable to run "menuconfig".)
If that didn't work, use this:
sudo apt-get install gcc g++ make libncurses5-dev

Building your kernel: (with enabled WiFi, Bluetooth, etc)

In this tutorial, we are going to use Ubuntu kernel source. Why ? Because Ubuntu kernels are officially supported by TI devs - we will get all the fixes Ubuntu has and all nice features. But the most important point is: GPU driver binaries are built for specific versions of Ubuntu kernels. (If I am correct, the only binary blobs provided are for Ubuntu and Android. Source.) We want GPU drivers, right ?
There are very nice tutorials provided by armin76 about installing and configuring Gentoo Linux on Pandaboard. ( They had really helped me.
We will use the kernel source of Ubuntu Precise (we obviously want hard float).
(Run everything in this paragraph as a normal user - non-root. Don't use su.)

Step-by-step process: (Skip it, if you just want to build the kernel, without running menuconfig.)

1) Download the kernel source:
wget --no-check-certificate wget --no-check-certificate$KERNELVERSION/+files/linux-ti-omap4_$KERNELVERSION.tar.gz
2) Extract:
tar zxvf linux-ti-omap4_$KERNELVERSION.tar.gz
3) Change to ubuntu-precise directory:
cd ubuntu-precise
4) Download a nice .config, provided again by armin76.
wget -O .config
5) Solve annoying CONFIG_SCSI_WAIT_SCAN=m "damn persistent module" problem (will set it as built-in - will explain why we want this):
sed -i 's/default m/default y/g' drivers/scsi/Kconfig
6) Force the kernel to built no modules (not even that scsi_wait_scan.ko module):
sed -i 's/=m/=y/g' .config
So, why do we need this ? Well, having no modules around makes the installation process hell like easy. More importantly, however, as reported by a number of users, is that you need to have modules built into your kernel or use initrd to have a normal booting procedure. ( - post by Pavol Cupka)
(By the way, the kernel that armin76 provides didn't boot for me on Debian - waited 15 mins - no login, no read/write activity. In fact it happened on Angstrom also. The reason, I think, is that it fails to find a number of modules and stops booting. My usb keyboard + mouse were completely unresponsive. But then it works just fine on Gentoo ... I don't get it.)
7) Edit your kernel configuration (optional):
make menuconfig
(Make sure NOT to disable debug in display section. My picture was a mess after I disabled it.)
8) Build you kernel:
make -j2 ARCH=arm uImage
This will take a while. Find something to do for an hour or so. (Depends on your card speed.) After that you will get your uImage file (this is our new kernel).

Single-step process: (No menuconfig - will just build the kernel.)

Run this:
wget --no-check-certificate$KERNELVERSION/+files/linux-ti-omap4_$KERNELVERSION.tar.gz && tar zxvf linux-ti-omap4_$KERNELVERSION.tar.gz && cd ubuntu-precise && wget -O .config && sed -i 's/default m/default y/g' drivers/scsi/Kconfig && sed -i 's/=m/=y/g' .config && make -j2 ARCH=arm uImage
and you should get your uImage.

Installing your kernel:

1) Make a backup of your boot files to "backup" folder on "boot" volume and clean "boot" volume:
sudo mv -f /boot/uboot/MLO /boot/uboot/u-boot.img /boot/uboot/zImage /boot/uboot/initrd.img /boot/uboot/uEnv.txt /boot/uboot/ /boot/uboot/backup
2) Restore MLO and u-boot.img:
sudo cp -f /boot/uboot/backup/MLO /boot/uboot/backup/u-boot.img /boot/uboot
3) Install your new kernel (make sure you are in ubuntu-precise directory):
sudo cp -f arch/arm/boot/uImage /boot/uboot
4) Just reboot the system:
sudo reboot
NOTE: It could take 2 - 4 minutes before you get to the login screen with the new kernel. During this time, you may or may not have video signal. If you have a signal, you will most likely see only 2 penguins on a black background, with no other output.

My comments about my new kernel:

- Version: 3.2.0-1416.22
- Boot time with this kernel (from cold to login screen): 2 - 4 minutes
- HDMI out: yes, 1080p - default, but can change if you disconnect and then reconnect the cable or change the source from your TV (tested with fbdev video driver). Ony one resolution is available.
- DVI out: not tested
- Bluetooth: not tested
- Wifi: Works
- Ethernet: Not tested, should work
- SGX drivers:  Work, but with issues, more to come ...
- Audio: Not tested
- CPU frequency scaling: Not tested

Thanks to: armin76 for awesome tutorials.


  1. After running menuconfig to disable some unnecessary wireless drivers, I got following message:
    warning: (VIDEO_OMAP2_VOUT && DRM_OMAP) selects OMAP2_DSS which has unmet direct dependencies (HAS_IOMEM && ARCH_OMAP2PLUS)

    Can I ignore this warning, or did I maybe break something in menuconfig?

  2. Sorry for the late replay ... A video output related warning - I don't think you should ignore it. But I can't say for sure, because I will need to compile the kernel again to see for myself

  3. Replies
    1. Haha, glad you found it useful :) Too bad I couldn't finish the graphics part ...

  4. great work i really like this more than faster

    1. Same, I love Debian speed. I wonder what the latest kernel is like though ...