RPi Upstream Kernel Compilation

This page describes how to compile an upstream or mainline kernel for the Raspberry Pi. It is mainly useful for upstream kernel maintainers/developers, or distribution kernel package maintainers.

As of 20140211, all of UART (serial), SD card, HDMI (via simple-framebuffer), and USB should work. Not all SD cards will work (it may depend on the transfer modes the card supports, and timing tolerances). Not all USB devices will work (it may depend on the type of transfer, interrupt/control/bulk, the device uses, etc.)

This page is kept deliberately terse, so as not to duplicate RPi_Kernel_Compilation, which describes how to compile the Raspberry Pi Foundation's downstream kernel. Read that page for some background if this page doesn't make sense to you.

Get the mainline source:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd linux

Compile:

export CROSS_COMPILE=/path/to/cross_compiler- make ARCH=arm bcm2835_defconfig make -s ARCH=arm zImage -j8 -s && make -s ARCH=arm dtbs

Copy to SD card: Copy arch/arm/boot/zImage (renamed to kernel.img) and arch/arm/boot/dts/bcm2835-rpi-b.dtb.

The file config.txt is not needed when using U-Boot. I suggest deleting it, or rather, renaming it to disable it, but still keep it around if you need to go back.

You'll likely want to use upstream U-Boot to boot the upstream kernel. See RPi_U-Boot. U-Boot has known-working support for Device Tree. I'm not sure what state the binary firmware has for DT.