Building a custom kernel

From BubbaWiki
Jump to: navigation, search

Introduction

This a very quick-and-dirty how-to to build (and customize) a kernel for your bubba 3 device. It also works for bubba 2 providing some small differences I will point out.

OK, but what about compiling modules for this custom kernel? How can one compile and install kernel modules for Bubba 2 or 3 device using this method ( by configuring, compiling on the guest operating system installed on VirtualBox )?

The command 'make modules_install' does not install modules ob Bubba device, but want to install on that guest operating system on the VirtualBox.

Preparing a compilation host

You could compile direclty on the B3 (resp. B2) itself, but it would take HOURS. That's why we will use a host which will be cross-compiling the kernel much quicker. Personnaly I use a virtual host in VirtualBox, but you can use whatever machine/virtualization technology.

OS install

The host must run debian squeeze, either i386 or amd64. I will not detail the OS install phase, if you want a custom kernel, you probably know how to do that. Nothing fancy here just a plain debian install. The desktop environment is obviously not needed ;-) .

Installing the compilation tools

After the install is completed, install the compiling tools :

  • emdebian cross-compilation toolchain:
apt-get install emdebian-archive-keyring
echo "deb http://www.emdebian.org/debian/ squeeze main" > /etc/apt/sources.list.d/emdebian.list
apt-get update

For the B3:

apt-get install gcc-4.4-arm-linux-gnueabi

For the B2:

apt-get install gcc-4.4-powerpc-linux-gnu

Note: you can install both toolchains if you have both platforms as I do :-)

  • native compiler and debian package utils :
apt-get install build-essential devscripts
  • platform specific tools :
apt-get install device-tree-compiler uboot-mkimage
  • development files for ncurses :
apt-get install libncurses5-dev

Build a custom kernel

Download and prepare the excito kernel source

The next operations can be done as a regular user.

  • Prepare the environment :
    • For the B3:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
    • For the B2:
export ARCH=powerpc
export CROSS_COMPILE=powerpc-linux-gnu-
  • Download the source files
dget -xu http://b3.update.excito.org/pool/main/l/linux/linux_2.6.39.4-13.dsc

Note: the above link will work as long as excito does not upgrade the kernel.

Customizing the kernel

Now everything is in place, time to customize the kernel:

  • Move into the source directory :
cd linux-2.6.39.4
  • Run the curses-based configuration tool (if you wish to use xconfig, be my guest, there are a few more dependencies to install):
make menuconfig
  • Load the default excito configuration: From the menu, select Load an Alternate Configuration File and enter the following path:
arch/arm/configs/bubba3_defconfig

For the B2:

arch/powerpc/configs/bubbatwo_defconfig
  • From now on you can customize the configuration to suit your needs (even patch the source if you're in the mood ...).
  • When you're satisfied, you may exit and save the configuration (it will be written in the path loaded above).

Note: whenever you customize the kernel, the resulting configuration must be placed in arch/arm/configs/bubba3_defconfig (arch/powerpc/configs/bubbatwo_defconfig for the B2); only this file will be used during the compilation phase to configure the kernel.

Compiling and packaging

From the same directory, build the debian package:

dpkg-buildpackage -us -uc -b -aarmel

Note: If anyone knows the distinction between arm and armel, and why it's used here and not there, I'm very much interested !

For the B2 :

dpkg-buildpackage -us -uc -b -apowerpc

The resulting package will be found in the parent directory, bubba3-kernel_2.6.39.4-13_armel.deb or bubba3-kernel_2.6.39.4-13_powerpc.deb

But how can one compiling and packaging kernel modules?

Installing the new kernel on the device

Now you can send the debian package to your device, using scp or whatever you're confortable with. Then install it with a plain:

dpkg -i bubba3-kernel_2.6.39.4-13_armel.deb

(or the obvious adapt for the b2)

You can now reboot your device. If your kernel panics during the boot, use your rescue key to reinstall the original excito kernel from http://b3.update.excito.org/pool/main/l/linux/