306 lines
7.5 KiB
Bash
Executable File
306 lines
7.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
ARMBIAN_KERNEL_PATCH_RELEASE=$(cat "armbian-rk-6.1-rkr5-patch-release")
|
|
COOLPI_KERNEL_PATCH_RELEASE=$(cat "coolpi-linux-6.1-stan-rkr3.1-patch-release")
|
|
|
|
VERSION=$(awk 'NR==2 {print $3}' Makefile)
|
|
PATCHLEVEL=$(awk 'NR==3 {print $3}' Makefile)
|
|
SUBLEVEL=$(awk 'NR==4 {print $3}' Makefile)
|
|
|
|
K_VER="$VERSION.$PATCHLEVEL.$SUBLEVEL"
|
|
K_SRC=`pwd`
|
|
|
|
WELCOME_MESSAGE="Welcome to the CoolPi Linux LTS v$K_VER kernel deployment tool!"
|
|
MESSAGE_LENGTH=${#WELCOME_MESSAGE}
|
|
|
|
ARCH=`uname -m`
|
|
if [ "$ARCH" == "x86_64" ]; then
|
|
export CROSS_COMPILE=aarch64-linux-gnu-
|
|
TOOLCHAIN_ARM64=$K_SRC/toolchain/bin
|
|
export PATH=$TOOLCHAIN_ARM64:$PATH
|
|
fi
|
|
|
|
export ARCH=arm64
|
|
echo
|
|
echo "$WELCOME_MESSAGE"
|
|
printf '%*s\n' "$MESSAGE_LENGTH" | tr ' ' '-'
|
|
echo
|
|
echo "Armbian Kernel Patch Release: $ARMBIAN_KERNEL_PATCH_RELEASE (Branch: rk-6.1-rkr5)"
|
|
echo "CoolPi Kernel Patch Release: $COOLPI_KERNEL_PATCH_RELEASE (Branch: linux-6.1-stan-rkr3.1)"
|
|
echo
|
|
echo "Please enter a number to select your machine"
|
|
echo
|
|
echo "0. Reset Directory"
|
|
echo "1. cp4b/4b-skh"
|
|
echo "2. cp4b-hdmi-in"
|
|
echo "3. cm5-evb"
|
|
echo "4. cm5-evb-v11"
|
|
echo "5. cm5-minipc"
|
|
echo "6. cm5-notebook"
|
|
echo "7. cm5-notebook-v20/genbook"
|
|
echo "8. cm5-8uart"
|
|
echo "9. cpnano"
|
|
echo "10. cm5-lz"
|
|
echo "11. Exit Script"
|
|
echo
|
|
read -rp "Option: " choice
|
|
|
|
case $choice in
|
|
0)
|
|
make clean mrproper
|
|
echo
|
|
echo "----------------"
|
|
echo "Action Completed"
|
|
echo "----------------"
|
|
echo
|
|
./build-kernel.sh
|
|
;;
|
|
1)
|
|
echo "BOARD=cp4b-skh"
|
|
BOARD="cp4b-skh"
|
|
;;
|
|
2)
|
|
echo "BOARD=cp4b-hdmi-in"
|
|
BOARD="cp4b-hdmi-in"
|
|
;;
|
|
3)
|
|
echo "BOARD=cm5-evb"
|
|
BOARD="cm5-evb"
|
|
;;
|
|
4)
|
|
echo "BOARD=cm5-evb-v11"
|
|
BOARD="cm5-evb-v11"
|
|
;;
|
|
5)
|
|
echo "BOARD=cm5-minipc"
|
|
BOARD="cm5-minipc"
|
|
;;
|
|
6)
|
|
echo "BOARD=cm5-notebook"
|
|
BOARD="cm5-notebook"
|
|
;;
|
|
7)
|
|
echo "BOARD=cm5-genbook"
|
|
BOARD="cm5-genbook"
|
|
;;
|
|
8)
|
|
echo "BOARD=cm5-8uart"
|
|
BOARD="cm5-8uart"
|
|
;;
|
|
9)
|
|
echo "BOARD=cpnano"
|
|
BOARD="cpnano"
|
|
;;
|
|
10)
|
|
echo "BOARD=cm5-lz"
|
|
BOARD="cm5-lz"
|
|
;;
|
|
11)
|
|
echo "exit"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Invalid number, please re-enter!"
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
GEN_DEBS="NO"
|
|
|
|
case "$BOARD" in
|
|
cp4b-skh)
|
|
cfg="coolpi_linux_defconfig"
|
|
dtb="rk3588s-cp4-skh.dtb"
|
|
txt_extconf_file="extlinux_cp4b.conf"
|
|
;;
|
|
cp4b-hdmi-in)
|
|
cfg="rk3588s_cp4b_defconfig"
|
|
dtb="rk3588s-cp4-hdmi-in.dtb"
|
|
txt_extconf_file="extlinux_cp4b_hdmi_in.conf"
|
|
;;
|
|
cm5-evb)
|
|
cfg="rk3588_cpcm5_evb_defconfig"
|
|
dtb="rk3588-cpcm5-evb.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_evb.conf"
|
|
;;
|
|
cm5-evb-v11)
|
|
cfg="rk3588_cpcm5_evb_defconfig"
|
|
dtb="rk3588-cpcm5-evb-v11.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_evb_v11.conf"
|
|
;;
|
|
cm5-minipc)
|
|
cfg="rk3588_cpcm5_minipc_defconfig"
|
|
dtb="rk3588-cpcm5-minipc.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_minipc.conf"
|
|
;;
|
|
cm5-notebook)
|
|
cfg="rk3588_cpcm5_notebook_defconfig"
|
|
dtb="rk3588-cpcm5-notebook.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_notebook.conf"
|
|
;;
|
|
cm5-genbook)
|
|
cfg="rk3588_cpcm5_genbook_defconfig"
|
|
dtb="rk3588-cpcm5-genbook.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_genbook.conf"
|
|
;;
|
|
cm5-8uart)
|
|
cfg="rk3588_cpcm5_defconfig"
|
|
dtb="rk3588-cpcm5-8uart.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_8uart.conf"
|
|
;;
|
|
cm5-lz)
|
|
cfg="rk3588_cpcm5_lz_defconfig"
|
|
dtb="rk3588-cpcm5-lz.dtb"
|
|
txt_extconf_file="extlinux_cpcm5_lz.conf"
|
|
;;
|
|
cpnano)
|
|
cfg="rv1106_cpnano_defconfig"
|
|
dtb="rv1106-cpnano.dtb"
|
|
txt_extconf_file="extlinux_cpnano.conf"
|
|
RV1106="1"
|
|
export ARCH=arm
|
|
;;
|
|
*)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
for dtb_f in $dtb
|
|
do
|
|
rm -rf arch/arm64/boot/dts/rockchip/$dtb_f
|
|
done
|
|
|
|
if [ "$RV1106" == "1" ]; then
|
|
GEN_DEBS="NO"
|
|
ARCH=`uname -m`
|
|
if [ "$ARCH" == "x86_64" ]; then
|
|
export CROSS_COMPILE=arm-rockchip830-linux-uclibcgnueabihf-
|
|
TOOLCHAIN_ARM32=$K_SRC/toolchain32uc/bin
|
|
export PATH=$TOOLCHAIN_ARM32:$PATH
|
|
fi
|
|
if [ "$ARCH" == "aarch64" ]; then
|
|
export CROSS_COMPILE=arm-linux-gnueabi-
|
|
fi
|
|
make ARCH=arm LOCALVERSION= $cfg
|
|
make ARCH=arm LOCALVERSION= -j8
|
|
cp arch/arm/boot/zImage vmlinuz
|
|
for dtb_f in $dtb
|
|
do
|
|
cp arch/arm/boot/dts/$dtb_f .
|
|
done
|
|
|
|
rm -rf out_modules
|
|
mkdir -p out_modules
|
|
|
|
cd $K_SRC
|
|
make ARCH=arm modules_install INSTALL_MOD_PATH=out_modules
|
|
rm -rf out
|
|
mkdir -p out/extlinux
|
|
else
|
|
make ARCH=arm64 LOCALVERSION= $cfg
|
|
make ARCH=arm64 LOCALVERSION= -j8
|
|
make ARCH=arm64 LOCALVERSION= modules -j8
|
|
cp arch/arm64/boot/Image.gz vmlinuz
|
|
cp arch/arm64/boot/Image Image
|
|
for dtb_f in $dtb
|
|
do
|
|
cp arch/arm64/boot/dts/rockchip/$dtb_f .
|
|
done
|
|
|
|
rm -rf out_modules
|
|
mkdir -p out_modules
|
|
rm -rf out_headers
|
|
mkdir -p out_headers/usr/src/linux-headers-$K_VER
|
|
|
|
cd $K_SRC
|
|
make ARCH=arm64 modules_install INSTALL_MOD_PATH=out_modules
|
|
make ARCH=arm64 headers_install INSTALL_HDR_PATH=out_headers/usr/src/linux-headers-$K_VER
|
|
rm -rf out
|
|
mkdir -p out/extlinux
|
|
cp vmlinuz out/
|
|
cp Image out/
|
|
cp demo-cfgs/$txt_extconf_file out/extlinux/extlinux.conf
|
|
fi
|
|
|
|
cd $K_SRC/out_modules/lib/modules/$K_VER
|
|
unlink source
|
|
unlink build
|
|
ln -sf /usr/src/linux-headers-$K_VER/ build
|
|
ln -sf /usr/src/linux-headers-$K_VER/ source
|
|
cd $K_SRC/out_modules/lib/
|
|
tar -czf ../../modules.tar.gz *
|
|
cd $K_SRC/out_headers/usr/
|
|
tar -czf ../../headers.tar.gz *
|
|
|
|
cd $K_SRC
|
|
for dtb_f in $dtb
|
|
do
|
|
cp $dtb_f out/
|
|
done
|
|
cp modules.tar.gz out/
|
|
cp headers.tar.gz out/
|
|
|
|
case "$GEN_DEBS" in
|
|
[yY][eE][sS]|[yY])
|
|
echo "Create coolpi kernel deb packages..."
|
|
;;
|
|
*)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
KDEB_DIR=$K_SRC/.tmp
|
|
rm -rf $KDEB_DIR
|
|
mkdir -m 0755 -p $KDEB_DIR/DEBIAN
|
|
cd $KDEB_DIR
|
|
mkdir -p boot/firmware && cp -a $K_SRC/out/* boot/firmware/
|
|
mkdir -p usr/lib && cp -a $K_SRC/out_modules/lib/modules usr/lib/
|
|
cat << EOF > $KDEB_DIR/DEBIAN/control
|
|
Package: linux-image-$K_VER
|
|
Source: linux-$K_VER
|
|
Version: 100
|
|
Architecture: arm64
|
|
Maintainer: rockchip <service@rock-chips.com> armbian <info@armbian.com> nathan <nathan@thesourcevaultproject.com> coolpi <coolpi@coolpi>
|
|
Section: kernel
|
|
Priority: optional
|
|
Homepage: https://www.kernel.org/
|
|
Description: Linux kernel, version $K_VER
|
|
This package contains the Linux kernel, modules and corresponding other
|
|
files, version: $K_VER.
|
|
EOF
|
|
cd $KDEB_DIR && dpkg-deb "--root-owner-group" --build . ..
|
|
|
|
cd $K_SRC
|
|
KHDEB_DIR=$K_SRC/.tmp_h
|
|
HDR_DIR=$KHDEB_DIR/usr/src/linux-headers-$K_VER
|
|
rm -rf $KHDEB_DIR
|
|
mkdir -m 0755 -p $KHDEB_DIR/DEBIAN
|
|
mkdir -p $HDR_DIR
|
|
cat << EOF > $KHDEB_DIR/DEBIAN/control
|
|
Package: linux-headers-$K_VER
|
|
Source: linux-$K_VER
|
|
Version: 100
|
|
Architecture: arm64
|
|
Maintainer: rockchip <service@rock-chips.com> armbian <info@armbian.com> nathan <nathan@thesourcevaultproject.com> coolpi <coolpi@coolpi>
|
|
Section: kernel
|
|
Priority: optional
|
|
Homepage: https://www.kernel.org/
|
|
Description: Linux kernel headers, version $K_VER
|
|
This package contains the Linux kernel, modules and corresponding other
|
|
files, version: $K_VER.
|
|
EOF
|
|
(
|
|
cd $K_SRC
|
|
find . arch/arm64 -maxdepth 1 -name Makefile\*
|
|
find include scripts -type f -o -type l
|
|
find arch/arm64 -name Kbuild.platforms -o -name Platform
|
|
find $(find arch/arm64 -name include -o -name scripts -type d) -type f
|
|
) > .hdrsrcfiles
|
|
tar -c -f - -C $K_SRC -T $K_SRC/.hdrsrcfiles | tar -xf - -C $HDR_DIR
|
|
cp $K_SRC/.config $HDR_DIR
|
|
cp $K_SRC/Module.symvers $HDR_DIR
|
|
rm $K_SRC/.hdrsrcfiles
|
|
cd $KHDEB_DIR && dpkg-deb "--root-owner-group" --build . ..
|
|
|
|
exit 0
|