Mainline Kernel Howto

This page describes how you can compile and use the Linux mainline kernel.

= Current status =

Please refer to the Linux mainlining effort page for detailed status of mainlining effort, and supported boards and driver coverage. The upstream code does not support various drivers and lacks sound, display, 3D, 2D and media support.

If you simply want a more-or-less usable device for multimedia support, then use our own 3.4 branch.

= Prerequisites =

You should not attempt anything on this page, unless you are first comfortable with our Manual build howto which uses our sunxi-3.4 kernel. This Manual build howto will guide you through setting up a full working system, and once you have that, you can start thinking about replacing the kernel with the mainline kernel. Apart from a fully set up SD-Card, this howto will also get you a working toolchain and a recent U-Boot.

= Kernel source =

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

= Kernel Configuration =

To get a working kernel, just use the following for configuration make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig

If you wish to alter configuration, run: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Enable modules
If you need certain drivers as modules, at the top level menu, enable:

[*] Enable loadable module support --->

Remember to build modules as well later on, next to uImage and dtbs. Then, also remember to install your modules into your rootfs.

Early printk
If and only if your kernel does nothing, it pays to enable early printk support.

Go to: Kernel hacking --->

Then enable: [*] Kernel debugging

To actually get early printk, you need to also enable: [*] Kernel low-level debugging functions (read help!) Kernel low-level debugging port (Kernel low-level debugging messages via sunXi UART0) --->

On all supported SoCs, a good rule of thumb is that you will need UART0, unless you are on the A13 (UART1) or the A23 (R_UART).

simplefb
While a KMS driver still is being worked on, a quick and easy way to get a display up on a HDMI monitor is to build (upcoming) U-Boot with sunxi cfb console support.

The kernel side support can be enabled through: Device Drivers ---> End then: Graphics support ---> Followed by: Frame buffer Devices ---> Enabled frame buffer devices, and descend into that menu: [*] Support for frame buffer devices ---> Then enable simplefb: [*]  Simple framebuffer support

= Kernel Compilation =

To build the kernel, now run:

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 (.dtb) in arch/arm/boot/dts.

This device tree blob (or simply dtb) 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.

To identify the dtb file that you will use on your board, first look into arch/arm/boot/dts. You should see a whole bunch of them, most being irrelevant to us because targeting boards based on other ARM SoCs. All the sunxi dtb follow the pattern - - .dtb (for example sun5i-a13-olinuxino.dtb, refer to Allwinner SoC Family for an exhaustive list).

= Boot =

SD-Card Boot partition
Like with our Manual build howto, you need to set up the boot partition. Instead of script.bin, you need install your boards dtb to the boot partition.

boot.cmd
Like in the Manual build howto, create a boot.cmd with the following contents:

fatload mmc 0 0x46000000 uImage fatload mmc 0 0x49000000 .dtb

setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p rootwait panic=10 ${extra}

bootm 0x46000000 - 0x49000000

Replace fatload with ext2load if needed.

If you are using an older U-Boot (you shouldn't - ), you might require the following line, to keep the extracted kernel from overwriting the device tree configuration: setenv fdt_high ffffffff

If you wish to use an initramfs, then the bootm command becomes: bootm 0x46000000 0x 0x49000000

Now generate boot.scr. Don't forget to copy over your uImage and .dtb files as well.

Network boot setup
Fold in Possible setups for hacking on mainline.

=See also=
 * Manual build howto
 * Linux mainlining effort
 * Possible setups for hacking on mainline