73 lines
1.3 KiB
Bash
Executable file
73 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
function usage {
|
|
|
|
cat <<EOF
|
|
|
|
Compile Kernel for MNT Reform
|
|
---
|
|
This script compile Linux kernel for the MNT Reform2 laptop.
|
|
|
|
USAGE:
|
|
make_kernel.sh <version>
|
|
|
|
<version> : kernel version to compile. This argument is not require if you
|
|
define KERNEL_VERSION environment variable.
|
|
EOF
|
|
|
|
}
|
|
|
|
function error {
|
|
>&2 printf "\e[31mE\e[0m %s\n" "$1"
|
|
}
|
|
|
|
export ARCH=arm64
|
|
#export LOADADDR=0x40480000
|
|
export CROSS_COMPILE=aarch64-linux-gnu-
|
|
GIT_URL="https://github.com/torvalds/linux/"
|
|
|
|
if [ ! -z $1 ]
|
|
then
|
|
KERNEL_VERSION="$1"
|
|
fi
|
|
|
|
if [ -z "$KERNEL_VERSION" ]
|
|
then
|
|
error "You need to define KERNEL_VERSION env variable"
|
|
usage
|
|
exit 10
|
|
fi
|
|
|
|
if [ ! -d linux ]
|
|
then
|
|
printf "Cloning Linux...\n"
|
|
# temporary linux 5.11rc7 commit
|
|
if ! git clone --depth 1 --branch=v${KERNEL_VERSION} $GIT_URL
|
|
then
|
|
error "Can't clone Linux, check version"
|
|
exit 11
|
|
fi
|
|
fi
|
|
|
|
cp ./dts/*.dts ./linux/arch/arm64/boot/dts/freescale/
|
|
cp ./kernel-config ./linux/.config
|
|
|
|
cd linux
|
|
|
|
for PATCHFILE in ../patches/*.patch
|
|
do
|
|
printf "Apply patch %s\n" $PATCHFILE
|
|
if git apply --check $PATCHFILE
|
|
then
|
|
git apply $PATCHFILE
|
|
else
|
|
error "Kernel patch already applied or cannot apply: $PATCHFILE"
|
|
fi
|
|
done
|
|
|
|
make -j$(nproc) Image freescale/imx8mq-mnt-reform2.dtb freescale/imx8mq-mnt-reform2-hdmi.dtb
|
|
cd ..
|
|
|
|
exit 0
|