Yann Dupont A techophile

Thu 27 August 2015


Banana pi custom Kernel (Part II, cross compiling)

I'm back ! Long time ago (March 2015) in banana pi custom kernel part I, I promised a follow-up to explain how to cleanly compile a kernel for such beasts. This part was delayed, but here it is at last ! So this article is the follow-up of previous article.

I maintain .config for my bestiary of exotic computers : ARM computers (Bananapi, Odroid, Raspberry pi, Dockstar), MIPS (nexx WT3020), Risc-V (qemu and spikes for the moment).

These .config are available on github : https://github.com/objoo/custom-linux-kernels

More on that later, for the moment, let's focus on bananapi.

Please note that this particular .config is based on vanilla kernel 4.1 and targeted for particular small server duties (samba, lxc, XFS and ceph/kRBD support). I personally use this for an ARM ceph cluster.

Nice professional looking ceph cluster, ehhh ?

Please note, there is NO video code on this kernel. Don't use it if you need a graphical environment.

Allwinner A20 chip powering bananapi is a quite capable processor and is able to compile a kernel, but it may take ages. A faster way is to use a more powerful machine, for example a X86 based PC, and use it to generate programs targeted for ARM. That's cross compilation.

Cross compilation is fast, but it's a complex and sometimes tricky process which requires the installation of lots of specific packages (when they're already available on the distribution and specific recompilations when they're not). A clean way to do this and not mess with the installed system is to use docker containers specially for this.

on the same github repository, there are scripts and Dockerfile to build all necessary parts.

On the building computer, git and docker need to be installed. Choose a clean directory, and check there is enough place for docker. Then :

git clone git://github.com/objoo/custom-Linux-kernels
cd custom-Linux-kernels/docker/DockerFiles/X86-64/cross/Debian

This will take lot of time for the first build, because this script creates a Debian Jessie docker image, with all cross-compile tools. When this image is run, it fetch uboot and Linux git repositories and compiles all with a pre-defined .config. uboot and linux kernel sources are installed on a persistant storage on the host computer, so next runs are far more speedier.

Upon termination of all these processes, you'll find the resulting files in :


uboot install is optional, it only need to be installed if the current version sd-card is too ancient.

Installation of uboot is :

dd if=u-boot-sunxi-with-spl.bin of of=DEVICE_OF_THE_SDCARD bs=1024 seek=8

Then, install the modules from / (they go to /lib/modules) and install uImage , sun7i-a20-bananapi.dtb in /boot and you're done. No need to build an Initrd.

If all goes well you'll see :

root@banana-one:~# uname -a
Linux banana-one 4.1.6YDoSHM #2 SMP Wed Aug 26 23:24:00 UTC 2015 armv7l GNU/Linux

Have a nice hack !

Go Top
comments powered by Disqus