Illusory stillness

mumble mumble techblog

Compiling a Raspberry Pi Kernel via Ubuntu

Previously, I set up a crosstools-NG build environment on OSX and then tried to compile a kernel. The kernel compilation process was a bit much to adjust to. Easier to just install Ubuntu in a VirtualBox image and do compilation there.

After installing Ubuntu on the image, I did (mostly via this stackexchange answer):

1
sudo apt-get install git ncurses-dev make gcc-arm-linux-gnueabi
1
git clone https://github.com/petli/linux.git -b rpi-3.10-usb-sound-backport raspi-linux
1
2
cd raspi-linux
ssh pi@raspberrypi.local zcat /proc/config.gz > .config

Note that I had to set VirtualBox to “bridged adapter” mode in order to see the ‘local’ devices on the network.

1
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig
1
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
1
2
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -j8
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- modules -j8

NB. I configured VirtualBox to see as 8 cores for -jN to produce a speedup.

That…. was straightforward.

Now to install it on the Pi. I’ll just take my SD card and mount it on the Ubuntu host for this. This required installing the VirtualBox Extension Pack. And using a USB SD card reader since I couldn’t figure out how to work the Mac’s builtin reader in VirtualBox.

1
2
3
4
mv /media/BOOT/kernel.img /media/BOOT/kernel_old.img
cp arch/arm/boot/Image /media/BOOT/kernel.img
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-  INSTALL_MOD_PATH=~/modules modules_install
sudo cp -r ~/modules/lib/* /media/root/lib/

Upon booting I got some errors about “disagrees about version of symbol module_layout”. This made no sense, as modinfo showed the same version as uname -a, but then I added gcc to the make-modules-install option (this had previously ended in “-” like I would have expected), and made sure all modules were owned and writable only by root. That combination appeared to work (I was less than scientific in doing both at once.)