DKMS package that fetches the in-tree rtw89 source for the target kernel, applies the steam-frame patches, and builds/installs the patched RTL8852CU modules for the Valve Steam Frame wireless adapter. - dkms.conf: module list + install locations - build.sh: fetch (gregkh/linux) + patch + build + verify - register.sh: clone upstream patches, stage into /usr/src, dkms add/build/install GPL-2.0-only.
69 lines
3.1 KiB
Bash
Executable File
69 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
# rtw89-steam-frame DKMS build step.
|
|
#
|
|
# Fetches the in-tree rtw89 source for the *target* kernel from gregkh/linux,
|
|
# applies the steam-frame patches, and builds in the current directory.
|
|
#
|
|
# Invoked by DKMS: CWD = DKMS build dir, $kernelver exported by DKMS.
|
|
# Also runnable standalone: kernelver=7.2.8-arch1-2 bash build.sh
|
|
#
|
|
# Exit non-zero on any failure so DKMS marks the build failed (module not
|
|
# installed for that kernel -> kernel keeps its stock rtw89). See plan for
|
|
# the modprobe.d recovery note.
|
|
set -euo pipefail
|
|
|
|
KVER="${kernelver:-${1:-}}"
|
|
[ -n "$KVER" ] || { echo "ERROR: kernelver not set (DKMS exports it; else pass as \$1)"; exit 1; }
|
|
BASE="${KVER%%-*}"
|
|
TAG="v${BASE%.0}"
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
BUILD="${PWD}"
|
|
KBUILD="/lib/modules/$KVER/build"
|
|
API="https://api.github.com/repos/gregkh/linux/contents/drivers/net/wireless/realtek/rtw89?ref=$TAG"
|
|
MODS="rtw89_8852cu rtw89_usb rtw89_8852c rtw89_core"
|
|
|
|
echo "== rtw89-steam-frame DKMS build: kernel=$KVER tag=$TAG =="
|
|
[ -d "$KBUILD" ] || { echo "ERROR: kernel headers missing at $KBUILD (install linux-headers-$KVER)"; exit 1; }
|
|
|
|
# clear any previous fetch leftovers
|
|
find "$BUILD" -maxdepth 1 -type f \( -name '*.c' -o -name '*.h' -o -name 'Kconfig' -o -name 'Makefile' -o -name '*.files' \) -delete 2>/dev/null || true
|
|
|
|
echo "-- fetch rtw89 source for $TAG (gregkh/linux)"
|
|
curl -sf "$API" | python3 -c '
|
|
import json, sys
|
|
for f in json.load(sys.stdin):
|
|
if f["type"] == "file":
|
|
print(f["name"], f["download_url"])' > "$BUILD/rtw89.files"
|
|
n=$(wc -l < "$BUILD/rtw89.files")
|
|
[ "$n" -gt 0 ] || { echo "ERROR: no source files for $TAG (network? tag missing?)"; exit 1; }
|
|
(cd "$BUILD" && xargs -P 8 -n 2 sh -c 'curl -sf -o "$0" "$1"' < rtw89.files) \
|
|
|| { echo "ERROR: source download failed"; exit 1; }
|
|
[ "$(ls "$BUILD"/*.c "$BUILD"/*.h 2>/dev/null | wc -l)" -gt 0 ] || { echo "ERROR: download incomplete"; exit 1; }
|
|
|
|
echo "-- apply patches"
|
|
for p in "$HERE"/patches/*.patch; do
|
|
if ! (cd "$BUILD" && patch -p1 --no-backup-if-mismatch -s < "$p"); then
|
|
echo "ERROR: $(basename "$p") does not apply to $TAG"
|
|
echo " -> module NOT built for $KVER; kernel stock rtw89 will be used."
|
|
echo " -> RECOVERY: remove /etc/modprobe.d/rtw89-steam-frame.conf before reloading WiFi"
|
|
exit 1
|
|
fi
|
|
echo " applied $(basename "$p")"
|
|
done
|
|
|
|
echo "-- build against $KVER headers"
|
|
make -s -j"$(nproc)" -C "$KBUILD" M="$BUILD" modules 2>&1 \
|
|
| grep -vE 'BTF|pahole|was built with|You are using \(out of date\)' || true
|
|
|
|
for m in $MODS; do
|
|
[ -f "$BUILD/$m.ko" ] || { echo "ERROR: $m.ko not produced"; exit 1; }
|
|
done
|
|
grep -q 'parm: *reg6_pwr_override:' <<< "$(modinfo "$BUILD/rtw89_core.ko")" \
|
|
|| { echo "ERROR: patched param reg6_pwr_override missing -> wrong/old source"; exit 1; }
|
|
[ "$(modinfo -F vermagic "$BUILD/rtw89_core.ko" | cut -d' ' -f1)" = "$KVER" ] \
|
|
|| { echo "ERROR: vermagic mismatch ($(modinfo -F vermagic "$BUILD/rtw89_core.ko" | cut -d' ' -f1) != $KVER)"; exit 1; }
|
|
|
|
echo "== BUILD OK: $(ls "$BUILD"/rtw89_*.ko | wc -l) module files for $KVER =="
|