Quick and dirty kernel build for the Next Thing Co's C.H.I.P. $9 single board computer.
This builds the kernel on the C.H.I.P. itself.
Alternatively grab this gist and put it in a directory of it's own. It will pull down the sources and build everything you need. To cross compile on a Debian or Ubuntu system apt-get install crossbuild-essentials-armhf
first.
Install dev tools
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential zlib1g-dev libncurses5-dev loop
sudo apt-get clean
Kernel Build
# Create a directory to hold the source files
cd ~
mkdir src
# Clone the NTC Kernel source
cd src
git clone --single-branch --branch debian/4.4.11-ntc-1 --depth 1 https://github.com/NextThingCo/CHIP-linux.git
# Configure the kernel
cp /boot/config-4.4.11-ntc CHIP-linux/.config
cd CHIP-linux
make oldconfig
# Add any extra modules you might want and kernel version here
make menuconf
# Build the kernel (this will take a loooong time)
make
# Install the modules
sudo make install modules_install
RTL8723BS Wireless Build
# Clone the source code
cd ~/src
git clone --single-branch --branch debian https://github.com/NextThingCo/RTL8723BS.git
# Apply patches
cd RTL8723BS/
for f in debian/patches/0*; do echo "Applying ${f}"; patch -p 1 < $f; done
# Build the source
make CONFIG_PLATFORM_ARM_SUNxI=y -C /home/chip/src/CHIP-linux/ M=$PWD CONFIG_RTL8723BS=m
# Install the module
sudo make -C /home/chip/src/CHIP-linux/ M=$PWD modules_install
Install kernel
Name the kernel file with the version that you built. If you added an extra version information in the kernel config then include this as well.
Copy the new kernel to /boot
export KV=4.4.11-td1+
cd ~/src/CHIP-linux
sudo cp arch/arm/boot/zImage /boot/vmlinuz-$KV
sudo cp .config /boot/config-$KV
sudo cp System.map /boot/System.map-$KV
Copy the device tree files to /boot
export KV=4.4.11-td1+
sudo mkdir /boot/dtbs/$KV
sudo cp arch/arm/boot/dts/sun5i-r8-chip.dtb /boot/dtbs/$KV/
Create symlinks
This makes it easier to change your kernel, all you need to do is change the symlink that zImage points to.
cd /boot
# Backup existing kernel and other files
for F in config zImage System.map dtb; do sudo mv $F $F-$(uname -r); done
sudo mkdir dtbs/$(uname -r)
sudo mv sun5i-r8-chip.dtb dtbs/$(uname -r)/
# Create links to new kernel and other files
export KV=4.4.11-td1+
for F in config zImage System.map; do sudo ln -sf $F-$KV $F; done
sudo ln -sf sun5i-r8-chip.dtb dtbs/$KV/sun5i-r8-chip.dtb
Check links
chip@chip-one:/boot$ ls -la config System.map zImage sun5i-r8-chip.dtb
lrwxrwxrwx 1 root root 18 Jul 5 21:33 config -> config-4.4.11-td1+
lrwxrwxrwx 1 root root 15 Jul 5 21:32 sun5i-r8-chip.dtb -> dtb-4.4.11-td1+
lrwxrwxrwx 1 root root 22 Jul 5 21:33 System.map -> System.map-4.4.11-td1+
lrwxrwxrwx 1 root root 19 Jul 5 21:31 zImage -> vmlinuz-4.4.11-td1+
Reboot
systemctl reboot
Your C.H.I.P. should now reboot and be running your new kernel