Compiling the Linux Kernel for Bananian

I recently wanted to alter a module and recompile it for Bananian.  I had also just upgraded to Bananina 4.4.26.  I think the Banana Pi can now use the stock Kernel for 4.4.x but I am not 100% sure.   Bananian allows a 4.4.x kernel to be used, the balance of probability is that the modules do not have any custom changes, so I figured I could simply use the stock kernel sources and then use the modules with the kernel shipped in Bananian.

This is how I went about doing it.   Bananian only ships the headers not the kernel source it used, which again suggests it really is using the stock kernel.

I downloaded the linux kernel from that matched the bananian one I was running.  At this time that is kernel 4.4.26

Unpacked it to /usr/src.

I ran

make menuconfig

Checked it over and as necessary made changes and added any missing modules, in my case I had changed an existing module so no changes were necessary.

Then changed the Makefile

EXTRAVERSION = -bananian

The -bananian is the only addition necessary.  If this isn’t done the module that results will have a different vermagic identifier and won’t load cleanly, or my case at all.

Then make the kernel – I use my cluster and distcc.   Setting up distcc is covered here.  I would like to use distcc-pump, but I can’t get it to work with kernel building.

make -j 25 CC=distcc

On my cluster it takes 50 minutes to build the kernel.  If I could offload the preprocessing with pump I reckon I could half this time.

Time to build Kernel
Time to build Kernel

Once built find the module(s) you want and copy to the modules directory used by the running kernel.  Which is located in the following directory tree.


Then there is a choice depending upon which module type is being added.

I’ll work an example you can download a pre-built ecryptfs from here (it’s gziped so will need uncompressing).

Ecryptfs is missing from the standard bananian delivery.  This is a filesystem module so it needs to end up in the ecrypt directory under fs.  This won’t exist so you’ll need to create it

mkdir  /lib/modules/linux-4.4.26/fs/ecryptfs

Copy it over like this

cp /usr/src/linux-4.4.26/fs/ecryptfs/ecryptfs.ko /lib/modules/4.4.26-bananian/kernel/fs/ecryptfs/.

Setup the module mappings using depmod.

depmod -a

It should now be possible to do

modprobe ecryptfs

Which will load the module.

ecyrptfs module loaded

All this compiling was really aboutn generating compatible modules.  What though if you want to boot on the new kernel?

Then then I did the following.

make -j2 uImage LOADADDR=0x40008000 modules
make modules_install
mount /dev/mmcblk0p1 /boot
cp arch/arm/boot/uImage /boot/uImage-next

Given I was using the same kernel version I didn’t need to do any more.  I’ve yet to try a newer one, see of anything additional needs to be done.