Mainline Kernel Howto

This articles describes how you can compile and use the Linux mainline kernel. For work done and to do read Linux mainlining effort please.

Prerequisites

 * An initramfs image (for example generated using buildroot)
 * An ARM toolchain
 * U-boot supporting device tree (if unsure, use a fresh build from the sunxi branch of u-boot-sunxi)

Supported boards
As of 3.10, the boards and SoC supported are:
 * A10
 * Cubieboard
 * Mini X-plus
 * Hackberry


 * A13
 * A13-olinuxino

For boards using these SoCs, adding a new device tree should be trivial. For other unsupported SoCs (A10s, A20, A31), more work is required.

Stable releases
The stable releases are released by Linus Torvalds. Since Linux 3.8, the Allwinner support is added gradually. It is still quite sparse, but we are making good progress. This is probably what you should choose if you are looking for stability.

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

Patches merged in the next stable release
There is also a sunxi-next branch maintained with all the inclusions that have been accepted, merged and will included in the next stable release. If you want to do some development, it's probably the best pick.

git clone git://github.com/mripard/linux.git -b sunxi-next

Patches not yet merged in the next release
You can find a sunxi-devel branch on linux-sunxi. This branch contains functional patches that are currently being reviewed on the kernel lists. If you want to do bleeding-edge mainline testing, this should probably be your pick. Please do not use this branch for development, as it is frequently rebased and the code is likely to change.

git clone git://github.com/linux-sunxi/linux-sunxi.git -b sunxi-devel

Configuration
ARCH=arm make multi_v7_defconfig ARCH=arm make menuconfig

Once there, fill the option CONFIG_INITRAMFS_SOURCE (General Setup / Initramfs source file(s)) to your initramfs image.

Compilation
ARCH=arm CROSS_COMPILE= LOADADDR=0x40008000 make uImage dtbs

After the compilation ended, you should have generated both the uImage in arch/arm/boot, and a device tree blob in arch/arm/boot/dts.

This device tree blob gives to the kernel the description of the hardware it's currently running on. In its goal, it's pretty similar to the FEX scripts that Allwinner uses, yet far more generic. It allows to compile a single kernel image that will run on several platforms.

Kernel Loading
Now copies the relevant dtb and uImage somewhere that you can load it from on your board, like a tftp server, a SD Card, etc.

Once you get to the U-boot prompt, stop the autoboot, and add the device tree loading.

Depending on where you store it, you will have something like fatload mmc 0 0x4100000 .dtb

Once it's loaded into memory, you only need to tell u-boot to boot the kernel using: bootm 0x 0x 0x

The kernel should start booting up to a shell.