update: pivot to cix-mainline
This commit is contained in:
1 parent
946301c928
commit
3b52a9ccf9
3 files changed
+83
-85
No files matched your search
@@ -3,13 +3,13 @@
|
||||
# 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"
|
||||
BUILD_VERSION=${KERNEL_VERSION:=6.19.10}-300.fc${DISTRO_VERSION}.ms-r1
|
||||
BUILD_VERSION=${KERNEL_VERSION:=7.3}-300.fc${DISTRO_VERSION}.ms-r1
|
||||
HEADERS=/usr/src/kernels/$BUILD_VERSION
|
||||
JOBS=$(nproc)
|
||||
BUILD=$(pwd)
|
||||
CMDLINE="console=tty0 console=ttyAMA0,115200n8 pcie_aspm=off cma=512M clk_ignore_unused=1 cpufreq.default_governor=schedutil"
|
||||
KERNEL_TREE=$BUILD/linux-${KERNEL_VERSION}
|
||||
KERNEL_PATCHES=$BUILD/linux-sky1
|
||||
KERNEL_PATCHES=$BUILD/linux-cix-main
|
||||
DRIVERS=$BUILD/drivers
|
||||
LOGS=$BUILD/logs
|
||||
|
||||
CMDLINE_COMMON="console=tty0 console=ttyAMA0,115200n8 cma=512M clk_ignore_unused=1 cpufreq.default_governor=schedutil"
|
||||
@@ -18,7 +18,7 @@ CMDLINE="pcie_aspm=off $CMDLINE_COMMON"
|
||||
|
||||
log() { printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*"; }
|
||||
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"; }
|
||||
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 +34,61 @@ setup() {
|
||||
purge
|
||||
log "copying header files"
|
||||
cp -r "$KERNEL_TREE" "$HEADERS" || die "failed"
|
||||
|
||||
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"
|
||||
grubby --update-kernel=/boot/vmlinuz-$BUILD_VERSION --args="$CMDLINE"
|
||||
|
||||
local id="$(grubby --info=$(grubby --default-index) | grep 'id=' | awk -F'\"' '{print $2}')"
|
||||
local conf=/boot/loader/entries/$id.powersave.conf
|
||||
cp /boot/loader/entries/$id.conf $conf
|
||||
sed -i "s/$CMDLINE/$CMDLINE_POWERSAVE/" $conf
|
||||
sed -i "/^title/s/$/ Powersave Mode/" $conf
|
||||
local c1=/boot/loader/entries/$id.conf
|
||||
local c2=/boot/loader/entries/$id.powersave.conf
|
||||
cp $c1 $c2
|
||||
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" ] || { pkexec bash -c "$(sub purge)" && log "done"; exit 0; }
|
||||
[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_PATCHES $LOGS
|
||||
[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_PATCHES $DRIVERS $LOGS
|
||||
|
||||
mkdir -p "$LOGS"
|
||||
log "building linux kernel ${KERNEL_VERSION} (arm64) with sky1-${TAG:=latest} patches"
|
||||
|
||||
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
|
||||
}
|
||||
mkdir -p "$DRIVERS" "$LOGS"
|
||||
log "building linux kernel ${KERNEL_VERSION} (arm64) with CIX mainline patches"
|
||||
|
||||
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
|
||||
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
|
||||
log "cloning linux-sky1 repository"
|
||||
run git clone --depth=1 https://github.com/Sky1-Linux/linux-sky1.git
|
||||
log "cloning CIX linux mainline"
|
||||
run git clone --depth=1 https://github.com/cixtech/cix-linux-main.git $KERNEL_PATCHES
|
||||
cd $KERNEL_PATCHES
|
||||
# see <https://github.com/Sky1-Linux/linux-sky1/pulls>
|
||||
git config user.email "build@ms-r1.local"
|
||||
git config user.name "Build"
|
||||
rebase srcshelton main # patches: fix Kconfig deps and module reachability
|
||||
rebase peppergrayxyz v6.19.10 # Update patch for 6.19.10
|
||||
rebase grkml config/cilium-ipsec-prereqs # config: enable Cilium IPsec prerequisites across all tracks
|
||||
rebase hotschmoe cdnsp-sky1-reboot-hang # usb: cdnsp-sky1: drop the shutdown hook that hangs reboot on the MS-R1
|
||||
rebase hotschmoe sky1-gpt-clock-names # arm64: dts: cix: sky1: name the GPT clocks so the broadcast timer probes
|
||||
rebase hotschmoe minisforum-ms-r1 # arm64: dts: cix: add the Minisforum MS-R1- #38
|
||||
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
|
||||
rebase hotschmoe panthor-devfreq-no-clk-poll # drm/panthor: don't poll the SCMI core clock for devfreq status
|
||||
rebase hotschmoe scmi-cpufreq-boost-param # cpufreq: scmi: add a boost parameter that holds from policy creation
|
||||
rebase lpennisi73-tech usb-cdns3-null-guards # patches: add cdns3 NULL guards for the early role switch and runtime …
|
||||
rebase lpennisi73-tech amvx-mmu-flexible-array-vb2-lock # patches: add amvx MMU flexible-array and vb2 queue lock fixes (6.18)
|
||||
log "head: $(git show -s --oneline)"
|
||||
fi
|
||||
|
||||
if [ ! -d "$DRIVERS/npu" ]; then
|
||||
log "cloning NPU driver"
|
||||
run git clone --depth=1 --branch=cix_mainline_dev https://github.com/cixtech/cix_opensource__npu_driver.git $DRIVERS/npu
|
||||
cd $DRIVERS/npu
|
||||
log "head: $(git show -s --oneline)"
|
||||
fi
|
||||
|
||||
if [ ! -d "$DRIVERS/vpu" ]; then
|
||||
log "cloning VPU driver"
|
||||
run git clone --depth=1 --branch=cix_mainline_dev https://github.com/cixtech/cix_opensource__vpu_driver.git $DRIVERS/vpu
|
||||
cd $DRIVERS/vpu
|
||||
rebase EvilOlaf fix-strncpy # v4l2: replace strncpy with strscpy
|
||||
log "head: $(git show -s --oneline)"
|
||||
fi
|
||||
|
||||
if [ ! -d "$KERNEL_TREE" ]; then
|
||||
@@ -94,44 +97,50 @@ if [ ! -d "$KERNEL_TREE" ]; then
|
||||
| tar -xf - --xz -C $BUILD
|
||||
fi
|
||||
|
||||
if [ ! -f "$KERNEL_TREE/.config-fedora" ] && [ -z "$LOCAL" ]; 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
|
||||
if [ ! -f "$KERNEL_TREE/.config-stock" ] && [ -z "$CONFIG" ]; then
|
||||
log "loading local kernel config"
|
||||
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
|
||||
|
||||
if [ ! -f "$KERNEL_TREE/.patches-sky1" ]; then
|
||||
if [ ! -f "$KERNEL_TREE/.patches-cix" ]; then
|
||||
log "applying patches"
|
||||
output="$LOGS/patches.log"; echo "" >$output
|
||||
for p in "$KERNEL_PATCHES/patches-${TAG}"/*.patch; do
|
||||
patch -d "$KERNEL_TREE" -p1 --forward --batch -s <"$p" >>$output || die "could not apply patch: $p (see logs/patches.log)"
|
||||
err=0; output="$LOGS/patches.log"; echo "" >$output
|
||||
for p in "$KERNEL_PATCHES/patches-${KERNEL_VERSION:0:3}"/*.patch; do
|
||||
if ! patch -d "$KERNEL_TREE" -p1 --forward --batch -s <"$p" >>$output 2>&1
|
||||
then log "warning: patch failed: $p"; err=$((err+1)); fi
|
||||
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
|
||||
touch "$KERNEL_TREE/.patches-sky1"
|
||||
touch "$KERNEL_TREE/.patches-cix"
|
||||
fi
|
||||
|
||||
if [ ! -f "$KERNEL_TREE/.config.ms-r1" ] || [ -n "$REBUILD" ]; then
|
||||
log "configuring kernel"
|
||||
cd $KERNEL_TREE
|
||||
make mrproper >/dev/null
|
||||
cp $KERNEL_PATCHES/config/config.sky1-${TAG} ".config-sky1"
|
||||
run ./scripts/kconfig/merge_config.sh -m -O . .config-sky1 .config-$(if [ -n "$LOCAL" ]; then echo "local"; else echo "fedora"; fi)
|
||||
cp $KERNEL_PATCHES/config/config-${KERNEL_VERSION:0:3}.defconfig .config-cix
|
||||
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"
|
||||
CROSS=$(if [ -z "$LOCAL" ]; then echo "aarch64-linux-gnu-"; fi)
|
||||
CROSS=$(if [[ "$(uname -m)" != "aarch64" ]]; then echo "aarch64-linux-gnu-"; fi)
|
||||
make ARCH=arm64 CROSS_COMPILE=$CROSS olddefconfig >/dev/null 2>&1
|
||||
cp .config .config.ms-r1
|
||||
fi
|
||||
|
||||
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)"
|
||||
|
||||
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; }
|
||||
log "done"
|
||||
log "note: run this script with INSTALL=1 to trigger kernel install (requires root privileges)"
|
||||
Reference in new issue
Block a user