From f2e4a4c030e45a47eb3f1fb2974cb984e6e25cbf Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Thu, 24 Sep 2026 17:05:07 -0700 Subject: [PATCH] ac-os: ship SOF platform aliases, carry regulatory.db in the chromebook stub The Lenovo 500e (Gemini Lake) still had no sound after the re-probe because the initramfs never contained sof-glk.ri: sof-bin ships it as a symlink to sof-apl.ri and the firmware copy used `find -type f`, which skips links. Copy links too (cp -L dereferences them into real files). cfg80211 loads regulatory.db once at kernel init, before the stub can offer the unpacked tree, so the Chromebook path stayed on the world regdomain. The stub now carries regulatory.db itself (~6 KB). The stub's readiness wait used grep and tr, which its busybox does not link, so every wait ran the full 8 s. Use globs and tests instead, and link grep and tr for the log line. --- fedac/native/docker-build.sh | 23 ++++++++++++++++++++--- fedac/native/initramfs-stub/init | 14 +++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/fedac/native/docker-build.sh b/fedac/native/docker-build.sh index 6c11555c97..f8d7f52e2f 100644 --- a/fedac/native/docker-build.sh +++ b/fedac/native/docker-build.sh @@ -548,7 +548,11 @@ if [ -n "$FWDIR" ]; then src="$FWDIR/$subdir" if [ -d "$src" ]; then mkdir -p "$IROOT/lib/firmware/$subdir" - (cd "$src" && find . -type f \ + # Symlinks matter: sof-bin ships platform aliases as links + # (community/sof-glk.ri -> sof-apl.ri), and `-type f` alone + # left the Lenovo 500e (Gemini Lake) with no DSP firmware. + # cp -L dereferences, so each alias lands as a real file. + (cd "$src" && find . \( -type f -o -type l \) \ \( -name '*.ri' -o -name '*.tplg' \ -o -name '*.ri.xz' -o -name '*.tplg.xz' \ -o -name '*.ri.zst' -o -name '*.tplg.zst' \) \ @@ -826,15 +830,28 @@ if ! file "$BUSYBOX" | grep -q "statically linked"; then err "busybox at $BUSYBOX is not statically linked — the Chromebook stub cannot use it" exit 1 fi -for applet in sh mount umount gzip cpio switch_root sleep; do +for applet in sh mount umount gzip cpio switch_root sleep grep tr; do "$BUSYBOX" --list 2>/dev/null | grep -qx "$applet" \ || { err "busybox lacks the '$applet' applet the Chromebook stub needs"; exit 1; } done cp "$BUSYBOX" "$STUB_ROOT/bin/busybox" -for cmd in sh mount umount gzip cpio sleep mkdir cat echo ls; do +for cmd in sh mount umount gzip cpio sleep mkdir cat echo ls grep tr; do ln -sf busybox "$STUB_ROOT/bin/$cmd" done ln -sf ../bin/busybox "$STUB_ROOT/sbin/switch_root" +# cfg80211 loads regulatory.db once, at kernel init — before the stub can +# offer anything — so the world regdomain would stick for the whole session +# on the Chromebook path. It is ~6 KB; carry it in the stub. +mkdir -p "$STUB_ROOT/lib/firmware" +for f in regulatory.db regulatory.db.p7s; do + for cand in "$FWDIR/$f" "$FWDIR/$f.xz" "$FWDIR/$f.zst"; do + [ -f "$cand" ] || continue + cp -L "$cand" "$STUB_ROOT/lib/firmware/" + case "$cand" in *.xz) xz -d "$STUB_ROOT/lib/firmware/$f.xz" ;; *.zst) zstd -d --rm "$STUB_ROOT/lib/firmware/$f.zst" ;; esac + break + done +done +[ -f "$STUB_ROOT/lib/firmware/regulatory.db" ] && log " Stub carries regulatory.db" || log " WARNING: regulatory.db not found in $FWDIR — Chromebook path stays on the world regdomain" cp "$NATIVE/initramfs-stub/init" "$STUB_ROOT/init" chmod 755 "$STUB_ROOT/init" sh -n "$STUB_ROOT/init" || { err "initramfs-stub/init has a syntax error"; exit 1; } diff --git a/fedac/native/initramfs-stub/init b/fedac/native/initramfs-stub/init index 0d9ea97c7e..9ab80c192c 100755 --- a/fedac/native/initramfs-stub/init +++ b/fedac/native/initramfs-stub/init @@ -108,13 +108,21 @@ if [ -w /sys/module/firmware_class/parameters/path ]; then waited=0 while [ "$waited" -lt 40 ]; do ok=1 - if [ "$want_wlan" = 1 ]; then ls /sys/class/net 2>/dev/null | grep -q '^wl' || ok=0; fi - if [ "$want_snd" = 1 ]; then grep -q '^ *[0-9]' /proc/asound/cards 2>/dev/null || ok=0; fi + # Plain globs and tests: the stub's busybox has no reason to carry + # more than it must, and a missing tool here would silently turn the + # wait into a fixed 8 s (as it did on 2026-09-24 without grep). + if [ "$want_wlan" = 1 ]; then + have_wl=0; for n in /sys/class/net/wl*; do [ -e "$n" ] && have_wl=1; done + [ "$have_wl" = 1 ] || ok=0 + fi + if [ "$want_snd" = 1 ]; then [ -d /proc/asound/card0 ] || ok=0; fi [ "$ok" = 1 ] && break waited=$((waited + 1)) sleep 0.2 done - say "firmware re-probe done after $((waited / 5)).$((waited % 5 * 2)) s (wlan wanted=$want_wlan, sound wanted=$want_snd): net=[$(ls /sys/class/net 2>/dev/null | tr '\n' ' ')] cards=$(grep -c '^ *[0-9]' /proc/asound/cards 2>/dev/null || echo 0)" + nets=""; for n in /sys/class/net/*; do [ -e "$n" ] && nets="$nets ${n##*/}"; done + cards=""; for c in /proc/asound/card[0-9]*; do [ -d "$c" ] && cards="$cards ${c##*/}"; done + say "firmware re-probe done after $((waited / 5)).$((waited % 5 * 2)) s (wlan wanted=$want_wlan, sound wanted=$want_snd): net=[$nets ] cards=[$cards ]" fi # Hand the live mounts to the new root, then pivot. The real /init mounts -- 2.51.2