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 www.kernel.org that matched the bananian one I was running. At this time that is kernel 4.4.26
Unpacked it to /usr/src.
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
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 26
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.
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.
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
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.
It should now be possible to do
Which will load the module.
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
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.