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):

sudo apt-get install git ncurses-dev make gcc-arm-linux-gnueabi
git clone -b rpi-3.10-usb-sound-backport raspi-linux
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.

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
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.

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