diff --git a/.gitignore b/.gitignore index ebfba81..a2b3d54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /logs +/core-* /linux-* -/kernel-core diff --git a/build.sh b/build.sh index 428a70a..5c108e7 100755 --- a/build.sh +++ b/build.sh @@ -7,45 +7,51 @@ JOBS=$(nproc) BUILD=$(pwd) CROSS="aarch64-linux-gnu-" KERNEL_TREE=$BUILD/linux-${KERNEL_VERSION} -KERNEL_CORE=$BUILD/kernel-core +KERNEL_CORE=$BUILD/core-${KERNEL_VERSION} KERNEL_PATCHES=$BUILD/linux-sky1 LOGS=$BUILD/logs log() { printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*"; } die() { printf '[%s] ERROR: %s\n' "$(date '+%H:%M:%S')" "$*"; exit 1; } -apply() { - git remote add $1 https://github.com/$1/linux-sky1.git > /dev/null 2>&1 - git fetch $1 > /dev/null - git merge $1/$2 > /dev/null || die "could not apply merge from $1:$2" +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 } -[ -d "$LOGS" ] || mkdir -p "$LOGS" +rebase() { + git remote add $1 https://github.com/$1/linux-sky1.git > /dev/null 2>&1 + git fetch $1 > /dev/null 2>&1 + git rebase $1/$2 > /dev/null 2>&1 || append || die "could not rebase branch $1:$2" +} + +[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_CORE $KERNEL_PATCHES $LOGS +mkdir -p "$LOGS" log "building linux kernel ${KERNEL_VERSION} with sky1-${TAG} patches" if [ ! -d "$KERNEL_TREE" ]; then - log "downloading kernel source" - src=/tmp/linux-${KERNEL_VERSION}.tar.xz - [ -f "$src" ] || wget -q -O "$src" "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${KERNEL_VERSION}.tar.xz" || die "failed" - tar -xf "$src" -C . + log "cloning linux kernel repository" + git clone --depth=1 --branch=v$KERNEL_VERSION https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git "$KERNEL_TREE" > /dev/null 2>&1 || die "failed" fi if [ ! -d "$KERNEL_PATCHES" ]; then log "preparing for patching" - git clone --depth=1 https://github.com/Sky1-Linux/linux-sky1.git > /dev/null || die "repository cloning failed" + git clone --depth=1 https://github.com/Sky1-Linux/linux-sky1.git > /dev/null 2>&1 || die "failed" cd $KERNEL_PATCHES - apply srcshelton main # patches: fix Kconfig deps and module reachability - apply peppergrayxyz v6.19.10 # Update patch for 6.19.10 - apply grkml config/cilium-ipsec-prereqs # config: enable Cilium IPsec prerequisites across all tracks - apply hotschmoe cdnsp-sky1-reboot-hang # usb: cdnsp-sky1: drop the shutdown hook that hangs reboot on the MS-R1 - apply hotschmoe sky1-gpt-clock-names # arm64: dts: cix: sky1: name the GPT clocks so the broadcast timer probes - apply hotschmoe minisforum-ms-r1 # arm64: dts: cix: add the Minisforum MS-R1- #38 - apply hotschmoe armchina-npu-libnoe # misc: armchina-npu: run CIX libnoe 0.5 jobs; fix cache maintenance and devfreq panic - apply hotschmoe mvx-devfreq-perf-domain # media: cix: mvx: drive the SCMI perf domain from devfreq - apply hotschmoe panthor-devfreq-no-clk-poll # drm/panthor: don't poll the SCMI core clock for devfreq status - apply hotschmoe scmi-cpufreq-boost-param # cpufreq: scmi: add a boost parameter that holds from policy creation - apply lpennisi73-tech usb-cdns3-null-guards # patches: add cdns3 NULL guards for the early role switch and runtime … - apply lpennisi73-tech amvx-mmu-flexible-array-vb2-lock # patches: add amvx MMU flexible-array and vb2 queue lock fixes (6.18) + 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 "applying patches" output="$LOGS/patches.log"; echo "" > $output for p in "$KERNEL_PATCHES/patches-${TAG}"/*.patch; do @@ -57,30 +63,31 @@ fi if [ ! -d "$KERNEL_CORE" ]; then log "downloading fedora kernel core" rpm=/tmp/kernel-core.aarch64.rpm - [ -f "$rpm" ] || wget -q -O "$rpm" "https://download.fedoraproject.org/pub/fedora/linux/releases/44/Everything/aarch64/os/Packages/k/kernel-core-${KERNEL_VERSION}-${LOCAL_VERSION}.aarch64.rpm" || die "failed" + if [ -f "$rpm" ]; then log "using cached file $rpm" + else wget -q -O "$rpm" "https://download.fedoraproject.org/pub/fedora/linux/releases/44/Everything/aarch64/os/Packages/k/kernel-core-${KERNEL_VERSION}-${LOCAL_VERSION}.aarch64.rpm" || die "failed"; fi mkdir -p $KERNEL_CORE cd $KERNEL_CORE rpm2cpio "$rpm" | cpio -idm --quiet "./lib/modules/*" fi -if [ ! -f "$KERNEL_TREE/.config" ]; then +if [ ! -f "$KERNEL_TREE/.config.ms-r1" ] || [ -n "$REBUILD" ]; then log "configuring kernel" - cp "$KERNEL_CORE/lib/modules/${KERNEL_VERSION}-${LOCAL_VERSION}.aarch64/config" "$KERNEL_TREE/.config-fedora" - cp "$KERNEL_PATCHES/config/config.sky1-${TAG}" "$KERNEL_TREE/.config-sky1" cd $KERNEL_TREE + make mrproper > /dev/null 2>&1 + cp "$KERNEL_CORE/lib/modules/${KERNEL_VERSION}-${LOCAL_VERSION}.aarch64/config" .config-fedora + cp "$KERNEL_PATCHES/config/config.sky1-${TAG}" .config-sky1 ./scripts/kconfig/merge_config.sh -m -O . .config-fedora .config-sky1 > /dev/null ./scripts/kconfig/merge_config.sh -m -O . .config "$BUILD/config/ms-r1.fragment" > /dev/null - - # Fedora's config names an absolute firmware directory that only exists - # inside the RPM build root; building outside it makes kbuild fail. - sed -i -e '/^CONFIG_EXTRA_FIRMWARE=/d' -e '/^CONFIG_EXTRA_FIRMWARE_DIR=/d' .config + cp .config .config.ms-r1 + make ARCH=arm64 CROSS_COMPILE=$CROSS olddefconfig > /dev/null 2>&1 fi -log "compilling kernel" -output=$LOGS/build.log -make ARCH=arm64 CROSS_COMPILE=$CROSS olddefconfig > $output 2>&1 -make -C "$KERNEL_TREE" ARCH=arm64 CROSS_COMPILE=$CROSS -j"$JOBS" Image modules >> $output 2>&1 || die "build failed; see logs/build.log" +log "compiling kernel" +make -C "$KERNEL_TREE" ARCH=arm64 CROSS_COMPILE=$CROSS -j"$JOBS" Image modules > "$LOGS/build.log" 2>&1 || die "failed (see logs/build.log)" log "done" -log "note: run this script with INSTALL=1 will trigger kernel install (requires root privileges)" -[ -z $INSTALL ] || pkexec make -C "$KERNEL_TREE" ARCH=arm64 install +log "note: run this script with INSTALL=1 to trigger kernel install (requires root privileges)" +[ -n "$INSTALL" ] || exit 0 + +log "installing kernel" +pkexec make -C "$KERNEL_TREE" ARCH=arm64 modules_install install diff --git a/config/ms-r1.fragment b/config/ms-r1.fragment index 1ba3fdb..cf0f1eb 100644 --- a/config/ms-r1.fragment +++ b/config/ms-r1.fragment @@ -4,9 +4,27 @@ CONFIG_DEBUG_INFO_NONE=y # CONFIG_DEBUG_INFO_BTF is not set # CONFIG_DEBUG_INFO_DWARF5 is not set # CONFIG_DEBUG_KERNEL is not set +CONFIG_CMDLINE_BOOL=y +CONFIG_CMDLINE="console=tty0 console=ttyAMA0,115200n8 pcie_aspm=off cma=512M clk_ignore_unused=1 cpufreq.default_governor=schedutil" CONFIG_FW_LOADER_COMPRESS=y CONFIG_FW_LOADER_COMPRESS_XZ=y CONFIG_FW_LOADER_COMPRESS_ZSTD=y +CONFIG_R8169=m +CONFIG_R8169_LEDS=y +CONFIG_NETFILTER_NETLINK_QUEUE=m +CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m +CONFIG_NETFILTER_XT_NAT=m +CONFIG_NET_CLS_CGROUP=m +CONFIG_CFS_BANDWIDTH=y +CONFIG_BLK_DEV_THROTTLING=y +CONFIG_OVERLAY_FS_REDIRECT_DIR=y +CONFIG_OVERLAY_FS_INDEX=y +CONFIG_OVERLAY_FS_XATTR_SUPPORT=y +CONFIG_OVERLAY_FS_METACOPY=y +CONFIG_ANDROID_BINDER_IPC=y +CONFIG_ANDROID_BINDERFS=y +CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder" +CONFIG_EXTRA_FIRMWARE="" CONFIG_EROFS_FS=m CONFIG_EROFS_FS_ZIP=y CONFIG_SQUASHFS=m