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. For a comprehensive how-to, please refer to RPI_Upstreaming article.

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 and arch/arm/boot/dts/bcm2835-rpi-b.dtb.

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. If you try booting with the binary firmware, make sure the rename zImage to kernel.img when copying to the SD card. If booting with U-Boot, keeping the zImage name is best; certainly don't rename it to kernel.img, since U-Boot will be installed to that file.