Skip to content

Instantly share code, notes, and snippets.

@stvhay
Created December 29, 2022 15:22
Show Gist options
  • Save stvhay/6075404c20f5cc92f68fb17660fee160 to your computer and use it in GitHub Desktop.
Save stvhay/6075404c20f5cc92f68fb17660fee160 to your computer and use it in GitHub Desktop.
manual build script for rock5b kernel
#!/bin/bash
typeset -A overlay kernel bsp
defconfig="linux-defconfig-full.config"
overlay=(
[name]="overlay"
[repo]="https://github.com/radxa/overlays.git"
[commit]="main"
)
kernel=(
[name]="kernel"
[repo]="https://github.com/radxa/kernel.git"
[commit]="linux-5.10-gen-rkr3.4"
)
bsp=(
[name]="bsp"
[repo]="https://github.com/radxa-repo/bsp.git"
[commit]="main"
)
patches=(
../bsp/linux/rockchip/0010-backport/000[345]*
../bsp/linux/rockchip/0020-rock4/000[2345]*
../bsp/linux/rockchip/0100-vendor/000[1-9]*
../bsp/linux/rockchip/0100-vendor/0010*
../bsp/linux/rockchip/0100-vendor/0012*
)
git_clone() {
declare -n src=$1
local repo=${src[repo]}
local commit=${src[commit]}
if [ ! -f ".${src[name]}_clone.stamp" ]; then
echo "Cloning Radxa $name repository..."
git clone --depth=1 --branch=$commit $repo || exit 1
touch ".${src[name]}_clone.stamp" || exit 1
fi
}
git_clone overlay
git_clone kernel
git_clone bsp
if [ ! -f ".kernel_overlay.stamp" ]; then
echo "Applying Radxa overlay..."
pushd kernel || exit 1
git checkout -b "${kernel[commit]}-rock5b" || exit 1
mv -v arch/arm64/boot/dts/rockchip/overlay{,s} || exit 1
cp -rv ../overlays/arch . || exit 1
git add -A || exit 1
git commit -m "Adding overlays from ${kernel[repo]}" || exit 1
popd || exit 1
touch ".kernel_overlay.stamp" || exit 1
fi
if [ ! -f ".kernel_patch.stamp" ]; then
echo "Applying Radxa kernel patches..."
pushd kernel || exit 1
for patch in ${patches[@]}; do
echo "Patch $patch..."
git am --reject --whitespace=fix "$patch" || exit 1
done
popd
touch ".kernel_patch.stamp" || exit 1
fi
echo "Making the kernel"
cp $defconfig kernel/.config
pushd kernel || exit 1
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j9 || exit 1
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j9 modules || exit 1
popd || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment