Compile the Linux kernel for Chip: my personal HOWTO

Da raspibo.
Jump to navigation Jump to search

This is my personal "How to compile a new kernel for CHIP on Debian". (My laptop is debian SID)


You'll need a number of packets. I don't know if this list is complete. It you are used to compiling kernels you already have all what you need.

apt-get install git build-essential fakeroot kernel-package zlib1g-dev libncurses5-dev lzop

You'll need the cross compiling toolchain.

apt-get install gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf


Create a working dir and enter it. Mine is /extra/tmp/chip/LINUX. Then clone git repositories from NTC.

cd /extra/tmp/chip/LINUX
git clone

checkout the same version provided by NTC's Debian repo.

cd CHIP-linux
git checkout -b debian/4.3.0-ntc-4 origin/debian/4.3.0-ntc-4

Copy the config file from your chip. My chip is connected as

scp .

Configure the kernel:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- menuconfig

IMPORTANT: add a local version suffix. Follow the menus:

    General setup  --->
    () Local version - append to kernel release

my personal suffix is rd235.

You may want to pass through the menus and add a lot of modules. (As a first experiment I suggest to compile the same standard configuration and test if everything is stable, then in a second time I'd add the modules).

Now it is possible to compile the kernel. The parameter -j should be set to the number of cores of your computer + 1. I have an 8-core (4 real cores + 4 hyperthreads), so I use 9.

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -j 9

I install the modules on /tmp/lib (just to have a fake hierarchy to be copied on chip).

mkdir /tmp/lib
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=/tmp/lib modules_install

RTL8723BS is an out-of-tree module

Everything is provided by the CHIP-linux tree but the RTL8723BS module. This is a bit harder.

Clone the repository.

cd /extra/tmp/chip/LINUX
git clone

switch to the debian branch:

cd RTL8723BS
git checkout -b debian origin/debian

apply debian patches:

for i in debian/patches/0*; do  echo $i; patch -p 1 <$i ; done

compile the module:

make -j 9 CONFIG_PLATFORM_ARM_SUNxI=y ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -C /extra/tmp/chip/LINUX/CHIP-linux/ M=$PWD CONFIG_RTL8723BS=m  INSTALL_MOD_PATH=/tmp/lib
make -j 9 CONFIG_PLATFORM_ARM_SUNxI=y ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -C /extra/tmp/chip/LINUX/CHIP-linux/ M=$PWD CONFIG_RTL8723BS=m  INSTALL_MOD_PATH=/tmp/lib modules_install

Move everything on chip

It is a jigsaw-puzzle.

scp /extra/tmp/chip/LINUX/CHIP-linux/arch/arm/boot/zImage root@
scp /extra/tmp/chip/LINUX/CHIP-linux/.config root@
scp /extra/tmp/chip/LINUX/CHIP-linux/ root@
cd /tmp/lib/lib/modules
tar cf - 4.3.0rd235+ | ssh root@ 'cd /lib/modules; tar xf -'
cd ../firmware/
tar cf - . | ssh root@ 'mkdir /lib/firmware/4.3.0rd235+; cd /lib/firmware/4.3.0rd235+; tar xf -'

boot your new kernel

Use this previous howto of mine to boot your new kernel. The image name in this example is:


The command to run the new kernel is:

sunxi# setenv bootcmd 'source ${scriptaddr}; nand slc-mode on; mtdparts; ubi part UBI; ubifsmount ubi0:rootfs; ubifsload $fdt_addr_r /boot/sun5i-r8-chip.dtb; ubifsload $kernel_addr_r /boot/vmlinuz-4.3.0rd235+; bootz $kernel_addr_r - $fdt_addr_r'

(i.e. copy the entire output of "printenv bootcmd" changing "/boot/zImage" in "/boot/vmlinuz-4.3.0rd235+")

When you are confident enough to use your new kernel as th default one copy /boot/vmlinuz-4.3.0rd235+ to /boot/zImage.

clean up after a failed test

In case you want to delete your kernel on chip:

rm -rf /boot/vmlinuz-4.3.0rd235+ /boot/config-4.3.0rd/boot235+ boot/ /lib/modules/4.3.0rd235+ /lib/firmware/4.3.0rd235+

My config file

This is a config file providing about 1300 modules. Among the others support for NAT for IPV4, all USB-gadget submodules, USB dongles for networking and multimedia. config-4.3.0rd235+

... if you want to test my kernel


cd /tmp
cd /
sudo tar zxf /tmp/chiplinux4.3.0rd235+.tgz

Now if you have a USB console cable you can test my kernel as explained above.

Otherwise it is possible to set my kernel as the default kernel: Warning: in this way if chip does not boot you need a USB console cable to reboot using /boot/zImage.bak (or you must reflash chip)

sudo cp /boot/vmlinuz-4.3.0rd235+ /boot/zImage

If you want to revert back to NTC provided kernel:

sudo cp /boot/xImage.bak /boot/zImage