|
|
@@ -2,14 +2,15 @@
|
|
|
|
# script requires: git tar xz cpio make patch rpm python3 wget
|
|
|
|
# script requires: git tar xz cpio make patch rpm python3 wget
|
|
|
|
# kernel requires: gcc flex bison make openssl-devel elfutils-libelf-devel bc perl-devel double-conversion-devel qt5-qtbase-devel libXi-devel rpm-build
|
|
|
|
# kernel requires: gcc flex bison make openssl-devel elfutils-libelf-devel bc perl-devel double-conversion-devel qt5-qtbase-devel libXi-devel rpm-build
|
|
|
|
|
|
|
|
|
|
|
|
DISTRO_VERSION="44"
|
|
|
|
LOCAL_VERSION=-300.fc${VERSION:-"$(cat /etc/fedora-release | awk '{print $3}')"}.ms-r1
|
|
|
|
BUILD_VERSION=${KERNEL_VERSION:=6.19.10}-300.fc${DISTRO_VERSION}.ms-r1
|
|
|
|
BUILD_VERSION=${KERNEL_VERSION:=7.3}${LOCAL_VERSION}
|
|
|
|
HEADERS=/usr/src/kernels/$BUILD_VERSION
|
|
|
|
HEADERS=/usr/src/kernels/$BUILD_VERSION
|
|
|
|
JOBS=$(nproc)
|
|
|
|
JOBS=$(nproc)
|
|
|
|
BUILD=$(pwd)
|
|
|
|
BUILD=$(pwd)
|
|
|
|
CMDLINE="console=tty0 console=ttyAMA0,115200n8 pcie_aspm=off cma=512M clk_ignore_unused=1 cpufreq.default_governor=schedutil"
|
|
|
|
CROSS=$(if [[ "$(uname -m)" != "aarch64" ]]; then echo "aarch64-linux-gnu-"; fi)
|
|
|
|
KERNEL_TREE=$BUILD/linux-${KERNEL_VERSION}
|
|
|
|
KERNEL_TREE=$BUILD/linux-${KERNEL_VERSION}
|
|
|
|
KERNEL_PATCHES=$BUILD/linux-sky1
|
|
|
|
KERNEL_PATCHES=$BUILD/linux-cix-main
|
|
|
|
|
|
|
|
DRIVERS=$BUILD/drivers
|
|
|
|
LOGS=$BUILD/logs
|
|
|
|
LOGS=$BUILD/logs
|
|
|
|
|
|
|
|
|
|
|
|
CMDLINE_COMMON="console=tty0 console=ttyAMA0,115200n8 cma=512M clk_ignore_unused=1 cpufreq.default_governor=schedutil"
|
|
|
|
CMDLINE_COMMON="console=tty0 console=ttyAMA0,115200n8 cma=512M clk_ignore_unused=1 cpufreq.default_governor=schedutil"
|
|
|
@@ -18,7 +19,7 @@ CMDLINE="pcie_aspm=off $CMDLINE_COMMON"
|
|
|
|
|
|
|
|
|
|
|
|
log() { printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*"; }
|
|
|
|
log() { printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*"; }
|
|
|
|
die() { printf '[%s] ERROR: %s\n' "$(date '+%H:%M:%S')" "$*"; exit 1; }
|
|
|
|
die() { printf '[%s] ERROR: %s\n' "$(date '+%H:%M:%S')" "$*"; exit 1; }
|
|
|
|
run() { local l=/tmp/$BUILD_VERSION.build.run.log; "$@" 2>&1 > "$l" || die "failed: $(cat $l | tail -n 1)"; }
|
|
|
|
run() { local l=/tmp/$BUILD_VERSION.build.run.log; "$@" > "$l" 2>&1 || die "failed: $(cat $l | tail -n 1)"; }
|
|
|
|
sub() { local s=/tmp/$BUILD_VERSION.build.sub.sh; echo "$(declare -p); $(declare -f)" > $s; echo "source $s 2>/dev/null && $1"; }
|
|
|
|
sub() { local s=/tmp/$BUILD_VERSION.build.sub.sh; echo "$(declare -p); $(declare -f)" > $s; echo "source $s 2>/dev/null && $1"; }
|
|
|
|
get() { local d=/tmp/$1; [ -f "$d" ] || { run wget -q -O $d "$2/$1"; cat $d; return; }; log "using cached file $d" >&2; cat $d; }
|
|
|
|
get() { local d=/tmp/$1; [ -f "$d" ] || { run wget -q -O $d "$2/$1"; cat $d; return; }; log "using cached file $d" >&2; cat $d; }
|
|
|
|
|
|
|
|
|
|
|
@@ -34,58 +35,62 @@ setup() {
|
|
|
|
purge
|
|
|
|
purge
|
|
|
|
log "copying header files"
|
|
|
|
log "copying header files"
|
|
|
|
cp -r "$KERNEL_TREE" "$HEADERS" || die "failed"
|
|
|
|
cp -r "$KERNEL_TREE" "$HEADERS" || die "failed"
|
|
|
|
|
|
|
|
|
|
|
|
log "installing kernel modules"
|
|
|
|
log "installing kernel modules"
|
|
|
|
make -C "$HEADERS" ARCH=arm64 -j"$JOBS" modules_install install clean </dev/null >"$LOGS/install.log" 2>&1 || die "failed (see logs/install.log)"
|
|
|
|
make -C "$HEADERS" -j"$JOBS" modules_install install >"$LOGS/install.log" 2>&1 || die "failed (see logs/install.log)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log "installing drivers"
|
|
|
|
|
|
|
|
for drv in "${DRV[@]}"; do
|
|
|
|
|
|
|
|
make -C "$HEADERS" -j"$JOBS" M=$drv modules_install install >>"$LOGS/install.log" 2>&1 || die "failed (see logs/install.log)"
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
log "updating bootloader configuration"
|
|
|
|
log "updating bootloader configuration"
|
|
|
|
grubby --update-kernel=/boot/vmlinuz-$BUILD_VERSION --args="$CMDLINE"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local id="$(grubby --info=$(grubby --default-index) | grep 'id=' | awk -F'\"' '{print $2}')"
|
|
|
|
local id="$(grubby --info=$(grubby --default-index) | grep 'id=' | awk -F'\"' '{print $2}')"
|
|
|
|
local conf=/boot/loader/entries/$id.powersave.conf
|
|
|
|
local c1=/boot/loader/entries/$id.conf
|
|
|
|
cp /boot/loader/entries/$id.conf $conf
|
|
|
|
local c2=/boot/loader/entries/$id.powersave.conf
|
|
|
|
sed -i "s/$CMDLINE/$CMDLINE_POWERSAVE/" $conf
|
|
|
|
cp $c1 $c2
|
|
|
|
sed -i "/^title/s/$/ Powersave Mode/" $conf
|
|
|
|
sed -i "/^options/s/$/ $CMDLINE/" $c1
|
|
|
|
|
|
|
|
sed -i "/^options/s/$/ $CMDLINE_POWERSAVE/" $c2
|
|
|
|
|
|
|
|
sed -i "/^title/s/$/ Powersave Mode/" $c2
|
|
|
|
|
|
|
|
log "cleaning up"
|
|
|
|
|
|
|
|
make -C "$HEADERS" clean >/dev/null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ -z "$LOCAL" ] || [[ "$(uname -m)" == "aarch64" ]] || die "LOCAL (=$LOCAL) can only be enabled on aarch64 machines"
|
|
|
|
[ -z "$UNINSTALL" ] || { log "uninstalling kernel ${BUILD_VERSION}"; pkexec bash -c "$(sub purge)" && log "done"; exit 0; }
|
|
|
|
[ -z "$UNINSTALL" ] || { pkexec bash -c "$(sub purge)" && log "done"; exit 0; }
|
|
|
|
[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_PATCHES $DRIVERS $LOGS
|
|
|
|
[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_PATCHES $LOGS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "$LOGS"
|
|
|
|
mkdir -p "$DRIVERS" "$LOGS"
|
|
|
|
log "building linux kernel ${KERNEL_VERSION} (arm64) with sky1-${TAG:=latest} patches"
|
|
|
|
log "building linux kernel ${KERNEL_VERSION} (arm64) with CIX mainline patches"
|
|
|
|
|
|
|
|
trap "log '\ninterrupted by user'; exit 1" INT
|
|
|
|
append() {
|
|
|
|
|
|
|
|
local series=$KERNEL_PATCHES/patches/series
|
|
|
|
|
|
|
|
echo "$(grep -v -e'^<<<<<<<' -e '^>>>>>>>' -e'=======' $series)" >$series
|
|
|
|
|
|
|
|
git add $series >/dev/null 2>&1
|
|
|
|
|
|
|
|
GIT_EDITOR=true git rebase --continue >/dev/null 2>&1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rebase() {
|
|
|
|
rebase() {
|
|
|
|
run git remote add $1 https://github.com/$1/linux-sky1.git
|
|
|
|
run git remote add $1 https://github.com/$1/$(basename $(git remote get-url origin))
|
|
|
|
run git fetch $1
|
|
|
|
run git fetch $1
|
|
|
|
git rebase $1/$2 >/dev/null 2>&1 || append || die "could not rebase branch $1:$2"
|
|
|
|
git config user.email "build@ms-r1.local"
|
|
|
|
|
|
|
|
git config user.name "Build"
|
|
|
|
|
|
|
|
git rebase $1/$2 >/dev/null 2>&1 || die "could not rebase branch $1:$2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -d "$KERNEL_PATCHES" ]; then
|
|
|
|
if [ ! -d "$KERNEL_PATCHES" ]; then
|
|
|
|
log "cloning linux-sky1 repository"
|
|
|
|
log "cloning CIX linux mainline"
|
|
|
|
run git clone --depth=1 https://github.com/Sky1-Linux/linux-sky1.git
|
|
|
|
run git clone --depth=1 https://github.com/cixtech/cix-linux-main.git $KERNEL_PATCHES
|
|
|
|
cd $KERNEL_PATCHES
|
|
|
|
cd $KERNEL_PATCHES
|
|
|
|
# see <https://github.com/Sky1-Linux/linux-sky1/pulls>
|
|
|
|
log "head: $(git show -s --oneline)"
|
|
|
|
git config user.email "build@ms-r1.local"
|
|
|
|
fi
|
|
|
|
git config user.name "Build"
|
|
|
|
|
|
|
|
rebase srcshelton main # patches: fix Kconfig deps and module reachability
|
|
|
|
if [ ! -d "$DRIVERS/npu" ]; then
|
|
|
|
rebase peppergrayxyz v6.19.10 # Update patch for 6.19.10
|
|
|
|
log "cloning NPU driver"
|
|
|
|
rebase grkml config/cilium-ipsec-prereqs # config: enable Cilium IPsec prerequisites across all tracks
|
|
|
|
run git clone --depth=1 --branch=cix_mainline_dev https://github.com/cixtech/cix_opensource__npu_driver.git $DRIVERS/npu
|
|
|
|
rebase hotschmoe cdnsp-sky1-reboot-hang # usb: cdnsp-sky1: drop the shutdown hook that hangs reboot on the MS-R1
|
|
|
|
cd $DRIVERS/npu
|
|
|
|
rebase hotschmoe sky1-gpt-clock-names # arm64: dts: cix: sky1: name the GPT clocks so the broadcast timer probes
|
|
|
|
log "head: $(git show -s --oneline)"
|
|
|
|
rebase hotschmoe minisforum-ms-r1 # arm64: dts: cix: add the Minisforum MS-R1- #38
|
|
|
|
fi
|
|
|
|
rebase hotschmoe armchina-npu-libnoe # misc: armchina-npu: run CIX libnoe 0.5 jobs; fix cache maintenance and devfreq panic
|
|
|
|
|
|
|
|
rebase hotschmoe mvx-devfreq-perf-domain # media: cix: mvx: drive the SCMI perf domain from devfreq
|
|
|
|
if [ ! -d "$DRIVERS/vpu" ]; then
|
|
|
|
rebase hotschmoe panthor-devfreq-no-clk-poll # drm/panthor: don't poll the SCMI core clock for devfreq status
|
|
|
|
log "cloning VPU driver"
|
|
|
|
rebase hotschmoe scmi-cpufreq-boost-param # cpufreq: scmi: add a boost parameter that holds from policy creation
|
|
|
|
run git clone --depth=1 --branch=cix_mainline_dev https://github.com/cixtech/cix_opensource__vpu_driver.git $DRIVERS/vpu
|
|
|
|
rebase lpennisi73-tech usb-cdns3-null-guards # patches: add cdns3 NULL guards for the early role switch and runtime …
|
|
|
|
cd $DRIVERS/vpu
|
|
|
|
rebase lpennisi73-tech amvx-mmu-flexible-array-vb2-lock # patches: add amvx MMU flexible-array and vb2 queue lock fixes (6.18)
|
|
|
|
rebase EvilOlaf fix-strncpy # v4l2: replace strncpy with strscpy
|
|
|
|
|
|
|
|
log "head: $(git show -s --oneline)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -d "$KERNEL_TREE" ]; then
|
|
|
|
if [ ! -d "$KERNEL_TREE" ]; then
|
|
|
@@ -94,44 +99,50 @@ if [ ! -d "$KERNEL_TREE" ]; then
|
|
|
|
| tar -xf - --xz -C $BUILD
|
|
|
|
| tar -xf - --xz -C $BUILD
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$KERNEL_TREE/.config-fedora" ] && [ -z "$LOCAL" ]; then
|
|
|
|
if [ ! -f "$KERNEL_TREE/.config-stock" ] && [ -z "$CONFIG" ]; then
|
|
|
|
log "downloading fedora kernel core"
|
|
|
|
|
|
|
|
get "kernel-core-${KERNEL_VERSION}-300.fc${DISTRO_VERSION}.aarch64.rpm" "https://download.fedoraproject.org/pub/fedora/linux/releases/${DISTRO_VERSION}/Everything/aarch64/os/Packages/k/" \
|
|
|
|
|
|
|
|
| rpm2cpio - \
|
|
|
|
|
|
|
|
| cpio -i --quiet --to-stdout "./lib/modules/*/config" \
|
|
|
|
|
|
|
|
> $KERNEL_TREE/.config-fedora
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$KERNEL_TREE/.config-local" ] && [ -n "$LOCAL" ]; then
|
|
|
|
|
|
|
|
log "loading local kernel config"
|
|
|
|
log "loading local kernel config"
|
|
|
|
yes "" | make -C "$KERNEL_TREE" localmodconfig >/dev/null 2>&1
|
|
|
|
yes "" | make -C "$KERNEL_TREE" localmodconfig >/dev/null 2>&1
|
|
|
|
mv $KERNEL_TREE/.config $KERNEL_TREE/.config-local
|
|
|
|
cp $KERNEL_TREE/.config $KERNEL_TREE/.config-stock
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$KERNEL_TREE/.patches-sky1" ]; then
|
|
|
|
if [ ! -f "$KERNEL_TREE/.patches-cix" ]; then
|
|
|
|
log "applying patches"
|
|
|
|
log "applying patches"
|
|
|
|
output="$LOGS/patches.log"; echo "" >$output
|
|
|
|
err=0; output="$LOGS/patches.log"; echo "" >$output
|
|
|
|
for p in "$KERNEL_PATCHES/patches-${TAG}"/*.patch; do
|
|
|
|
for p in "$KERNEL_PATCHES/patches-${KERNEL_VERSION:0:3}"/*.patch; do
|
|
|
|
patch -d "$KERNEL_TREE" -p1 --forward --batch -s <"$p" >>$output || die "could not apply patch: $p (see logs/patches.log)"
|
|
|
|
if ! patch -d "$KERNEL_TREE" -p1 --forward --batch -s <"$p" >>$output 2>&1
|
|
|
|
|
|
|
|
then log "warning: patch failed: $p"; err=$((err+1)); fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
log $(if (( err == 0 )); then echo "all patches applied"; else echo "warning: $err error(s) reported (see logs/patches.log)"; fi)
|
|
|
|
find "$KERNEL_TREE" \( -name '*.orig' -o -name '*.rej' \) -delete
|
|
|
|
find "$KERNEL_TREE" \( -name '*.orig' -o -name '*.rej' \) -delete
|
|
|
|
touch "$KERNEL_TREE/.patches-sky1"
|
|
|
|
touch "$KERNEL_TREE/.patches-cix"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$KERNEL_TREE/.config.ms-r1" ] || [ -n "$REBUILD" ]; then
|
|
|
|
if [ ! -f "$KERNEL_TREE/.config.ms-r1" ] || [ -n "$REBUILD" ]; then
|
|
|
|
log "configuring kernel"
|
|
|
|
log "configuring kernel"
|
|
|
|
cd $KERNEL_TREE
|
|
|
|
cd $KERNEL_TREE
|
|
|
|
make mrproper >/dev/null
|
|
|
|
make mrproper >/dev/null
|
|
|
|
cp $KERNEL_PATCHES/config/config.sky1-${TAG} ".config-sky1"
|
|
|
|
cp $KERNEL_PATCHES/config/config-${KERNEL_VERSION:0:3}.defconfig .config-cix
|
|
|
|
run ./scripts/kconfig/merge_config.sh -m -O . .config-sky1 .config-$(if [ -n "$LOCAL" ]; then echo "local"; else echo "fedora"; fi)
|
|
|
|
cp $CONFIG .config-stock 2>/dev/null
|
|
|
|
|
|
|
|
run ./scripts/kconfig/merge_config.sh -m -O . .config-cix .config-stock
|
|
|
|
run ./scripts/kconfig/merge_config.sh -m -O . .config "$BUILD/config/ms-r1.fragment"
|
|
|
|
run ./scripts/kconfig/merge_config.sh -m -O . .config "$BUILD/config/ms-r1.fragment"
|
|
|
|
CROSS=$(if [ -z "$LOCAL" ]; then echo "aarch64-linux-gnu-"; fi)
|
|
|
|
sed -i -E "s/^(CONFIG_LOCALVERSION=)[^ ]*/\1\"$LOCAL_VERSION\"/" .config
|
|
|
|
make ARCH=arm64 CROSS_COMPILE=$CROSS olddefconfig >/dev/null 2>&1
|
|
|
|
make ARCH=arm64 CROSS_COMPILE=$CROSS olddefconfig >/dev/null 2>&1
|
|
|
|
cp .config .config.ms-r1
|
|
|
|
cp .config .config.ms-r1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
log "compiling kernel"
|
|
|
|
log "compiling kernel"
|
|
|
|
make -C "$KERNEL_TREE" ARCH=arm64 CROSS_COMPILE=$CROSS -j"$JOBS" </dev/null >"$LOGS/build.log" 2>&1 || die "failed (see logs/build.log)"
|
|
|
|
make -C "$KERNEL_TREE" ARCH=arm64 CROSS_COMPILE=$CROSS -j"$JOBS" </dev/null >"$LOGS/build.log" 2>&1 || die "failed (see logs/build.log)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log "compiling drivers"
|
|
|
|
|
|
|
|
for m in $(find $DRIVERS -name "dkms.conf" -print); do
|
|
|
|
|
|
|
|
cd "$(dirname $m)"; log "in: $PWD"
|
|
|
|
|
|
|
|
options=$(bash -c "source $m && echo \$MAKE" | cut -d' ' -f4- -)
|
|
|
|
|
|
|
|
IFS=' ' read -ra array <<< "$options"
|
|
|
|
|
|
|
|
make clean >/dev/null 2>&1
|
|
|
|
|
|
|
|
make -C "$KERNEL_TREE" -j"$JOBS" M=$PWD "${array[@]}" >>"$LOGS/build.log" 2>&1 || die "failed (see logs/build.log)"
|
|
|
|
|
|
|
|
DRV+=($PWD)
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
[ -z "$INSTALL" ] || { pkexec bash -c "$(sub setup)" && log "done"; exit 0; }
|
|
|
|
[ -z "$INSTALL" ] || { pkexec bash -c "$(sub setup)" && log "done"; exit 0; }
|
|
|
|
log "done"
|
|
|
|
log "done"
|
|
|
|
log "note: run this script with INSTALL=1 to trigger kernel install (requires root privileges)"
|
|
|
|
log "note: run this script with INSTALL=1 to trigger kernel install (requires root privileges)"
|