Last active
February 28, 2023 19:47
-
-
Save tdack/5b87a20225d239a6240e8f3964b8d290 to your computer and use it in GitHub Desktop.
Build the kernel for the Next Thing Co C.H.I.P.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Desktop build | |
MAKE="make -j 4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-" | |
# C.H.I.P. build | |
#MAKE="make" | |
CDIR=$PWD | |
LINUX=$CDIR/CHIP-linux | |
WIFI=$CDIR/RTL8723BS | |
# Clone NTC C.H.I.P. kernel source | |
if [[ -d $LINUX ]]; then | |
cd $LINUX | |
git checkout debian/4.4.11-ntc-1 | |
else | |
git clone --single-branch --branch debian/4.4.11-ntc-1 --depth 1 https://github.com/NextThingCo/CHIP-linux.git $LINUX | |
cd $LINUX | |
fi | |
# Get default NTC C.H.I.P. kernel config | |
curl https://gist.githubusercontent.com/tdack/344f25bb4fd7ca3b1078bbf2dedc1371/raw/d40e77812d8253ffa9240af0a98c51555951b1c1/config -o .config | |
# Configure the kernel | |
$MAKE oldconfig | |
$MAKE menuconfig | |
# Build the kernel and modules | |
$MAKE | |
$MAKE modules | |
# Install modules | |
KR=$($MAKE kernelrelease) | |
INSTALLDIR=$CDIR/$KR | |
if [[ -d $INSTALLDIR ]]; then | |
rm -fr $INSTALLDIR | |
mkdir -p $INSTALLDIR | |
fi | |
$MAKE INSTALL_MOD_PATH=$INSTALLDIR modules_install | |
rm $INSTALLDIR/lib/modules/$KR/{build,source} | |
# Clone NTC WiFi module | |
if [[ -d $WIFI ]]; then | |
cd $WIFI | |
git checkout debian | |
else | |
git clone --single-branch --branch debian https://github.com/NextThingCo/RTL8723BS.git $WIFI | |
cd $WIFI | |
for f in debian/patches/0*; do echo "Applying ${f}"; patch -p 1 < $f; done | |
fi | |
# Build & install NTC WiFi module | |
$MAKE CONFIG_PLATFORM_ARM_SUNxI=y CONFIG_RTL8723BS=m M=$PWD -C $LINUX | |
$MAKE CONFIG_PLATFORM_ARM_SUNxI=y CONFIG_RTL8723BS=m M=$PWD -C $LINUX INSTALL_MOD_PATH=$INSTALLDIR modules_install | |
# Install kernel, System.map, config and dtb | |
mkdir -p $INSTALLDIR/boot/dtbs/$KR | |
cp $LINUX/arch/arm/boot/zImage $INSTALLDIR/boot/vmlinuz-$KR | |
cp $LINUX/System.map $INSTALLDIR/boot/System.map-$KR | |
cp $LINUX/.config $INSTALLDIR/boot/config-$KR | |
cp $LINUX/arch/arm/boot/dts/sun5i-r8-chip.dtb $INSTALLDIR/boot/dtbs/$KR/ | |
# Create tar file | |
tar -cjvf $CDIR/$KR.tar.bz2 -C $INSTALLDIR . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment