From fa675941191a3461fb433b5466903aba0cdf72e6 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 11:20:20 -0647 Subject: [PATCH] tools/extract-vendor-firmware: the Pixel 9a's firmware A -d tegu mode, so a fresh install on the palmtop gets its firmware from the owner's own factory image as the 7 Pro and the 6 Pro do: the BCM4383 A3 Wi-Fi firmware, NVRAM, CLM and TX capability blob under brcmfmac's board-suffixed names, the Bluetooth patch for btbcm, the AoC firmware as aoc-tegu.bin (the name the 9a's AoC start script requests, so a 7 Pro aoc.bin can never be fed to its GSA), the CS40L26 haptics files and the AoC's sensor registry. Stock's _4383_a3 files are the production silicon's; fw_bcmdhd.bin is the same file as its _4383_a3 twin. Two of the 9a's needs come from linux-firmware rather than the image and are left out on purpose: the Mali CSF firmware (arch11.8) and the TAS2572 amplifiers' RCA profile, since stock's tismartpa_driver_tuning.bin is in a different format and must not be renamed into one (device/tegu/AUDIO-PLAN.md). The header says so. The CS35L41 checks now run only for the phones that have those amplifiers, the CS40L26 checks for cheetah and tegu, and the output directories come from the map instead of a fixed brcm and cirrus pair. For cheetah and raven the staged tree and the messages are unchanged. Run on the owner's bp3a image: all twelve entries found, the four Wi-Fi files identical to the ones the palmtop runs today and the AoC firmware identical to the one GSA-PLAN F1 records. --- tools/extract-vendor-firmware | 120 ++++++++++++++++++++++++++-------- 1 file changed, 93 insertions(+), 27 deletions(-) diff --git a/tools/extract-vendor-firmware b/tools/extract-vendor-firmware index b0d0d7d14..bb4029f5f 100755 --- a/tools/extract-vendor-firmware +++ b/tools/extract-vendor-firmware @@ -1,8 +1,9 @@ #!/bin/bash # SPDX-License-Identifier: MIT # extract-vendor-firmware: copy the Wi-Fi, Bluetooth, haptics and speaker -# amplifier firmware the Pixel 7 Pro (cheetah) needs out of a Google factory -# image, on the user's own machine. +# amplifier firmware the Pixel 7 Pro (cheetah), the Pixel 6 Pro (raven, -d raven) +# or the Pixel 9a (tegu, -d tegu) needs out of a Google factory image, on the +# user's own machine. # # Google's firmware is not ours to redistribute, so Omarchy Mobile never ships it. # Like LineageOS's extract-files, this pulls it from an image the user already @@ -36,6 +37,34 @@ # missing tuning fails to load instead of falling back to the other speaker's # (or to linux-firmware's generic cirrus/cs35l41-dsp1-spk-prot.bin). # +# The Pixel 9a (-d tegu; is "google,zumapro-tegu"): +# +# vendor/firmware/fw_bcmdhd.bin -> brcm/brcmfmac4383-pcie..bin (brcmfmac) +# vendor/firmware/bcmdhd.cal_4383_a3 -> brcm/brcmfmac4383-pcie..txt (NVRAM) +# vendor/firmware/bcmdhd_clm.blob_4383_a3 -> brcm/brcmfmac4383-pcie..clm_blob (regulatory) +# vendor/firmware/bcmdhd_txcap.blob_4383_a3 -> brcm/brcmfmac4383-pcie..txcap_blob (TX capabilities) +# vendor/firmware/brcm/BCM.hcd -> brcm/BCM..hcd (btbcm) +# vendor/firmware/aoc.bin -> aoc-tegu.bin (the AoC DSP, under the 9a's own name) +# vendor/etc/sensors/registry/ -> /usr/share/omamobile/sensors/registry/ +# vendor/firmware/cs40l26*.{wmfw,bin} -> the same five files as cheetah's +# +# The 9a's radio is a BCM4383 A3, and stock's "_4383_a3" NVRAM, CLM and TX +# capability files are the production silicon's (fw_bcmdhd.bin is the same +# file as fw_bcmdhd.bin_4383_a3; the _EVT and _PROTO NVRAMs are pre-production +# boards'). brcmfmac requests the txcap_blob on this chip, through the same +# board-name lookup as the other three, so all four get the board suffix: +# linux-firmware ships nothing for the 4383 today, and a generic file that +# lands there later must not shadow the owner's. The AoC firmware is named +# aoc-tegu.bin because the 9a's AoC start script requests that name +# (device/tegu/GSA-PLAN.md F1): the AoC firmware is matched to its SoC and +# authenticated by the GSA, and the name keeps a 7 Pro aoc.bin from ever +# being fed to the 9a. Two of the 9a's needs come from linux-firmware, not +# from the image: the Mali CSF firmware (arm/mali/arch11.8/mali_csffw.bin) +# and the TAS2572 amplifiers' RCA profile (ti/audio/tas257x/tas2572-1-1amp-reg.bin, +# installed as Top- and Bottom-tas2572RCA1.bin; stock's tismartpa_driver_tuning.bin +# is in another format, device/tegu/AUDIO-PLAN.md). The modem's and GNSS's +# files are tools/extract-vendor-chroot's. +# # Output is a tree rooted at /, under usr/lib/firmware/updates (searched before # linux-firmware's files, and not owned by any package). Nothing touches the phone. # @@ -48,6 +77,10 @@ export PATH=$PATH:/usr/sbin:/sbin BOARD="google,gs201-cheetah" DEVICE="cheetah" FW_BASE="brcmfmac4389c1-pcie" +# The chip strings the sanity checks expect in fw_bcmdhd.bin ("-roml") +# and in BCM.hcd ("BCM ") +WIFI_CHIP="4389c1" +BT_CHIP="BCM4389C1" DEST_REL="usr/lib/firmware/updates" # source path in the vendor partition -> path under $DEST_REL @@ -73,11 +106,11 @@ usage() { cat <-*-factory-*.zip), the image--*.zip inside it, or a raw/sparse vendor.img -o DIR staging root to write into (default: ./out/vendor-firmware) -w DIR scratch directory for the ~1 GB vendor.img (default: a temp dir in \$TMPDIR) - -d DEV cheetah (default) or raven + -d DEV cheetah (default), raven or tegu -f skip the android-info.txt board=$DEVICE check -c FILE also copy the camera HAL APEX (/vendor/apex/com.google.pixel.camera.hal.apex) to FILE, for tools/extract-camera-data --apex (tools/phone-provision uses it) @@ -125,7 +158,30 @@ case $DEVICE_OPT in "firmware/cs35l41-dsp1-spk-prot.bin|cirrus/cs35l41-dsp1-spk-prot-$DEVICE-top.bin" "firmware/R-cs35l41-dsp1-spk-prot.bin|cirrus/cs35l41-dsp1-spk-prot-$DEVICE-bottom.bin" ) ;; - *) die "unknown device $DEVICE_OPT (cheetah or raven)" ;; + tegu) + # Pixel 9a: Wi-Fi (BCM4383 A3, with the TX capability blob brcmfmac + # requests on this chip), Bluetooth, the AoC under the 9a's own name, + # the haptics files and the AoC's sensor registry (the header). Its + # speaker amplifiers (TAS2572) and GPU take linux-firmware's files. + BOARD="google,zumapro-tegu" + DEVICE="tegu" + FW_BASE="brcmfmac4383-pcie" + WIFI_CHIP="4383a3" + BT_CHIP="BCM4383A3" + MAP=( + "firmware/fw_bcmdhd.bin|brcm/$FW_BASE.$BOARD.bin" + "firmware/bcmdhd.cal_4383_a3|brcm/$FW_BASE.$BOARD.txt" + "firmware/bcmdhd_clm.blob_4383_a3|brcm/$FW_BASE.$BOARD.clm_blob" + "firmware/bcmdhd_txcap.blob_4383_a3|brcm/$FW_BASE.$BOARD.txcap_blob" + "firmware/brcm/BCM.hcd|brcm/BCM.$BOARD.hcd" + "firmware/aoc.bin|aoc-tegu.bin" + "firmware/cs40l26.wmfw|cs40l26.wmfw" + "firmware/cs40l26.bin|cs40l26.bin" + "firmware/cs40l26-svc.bin|cs40l26-svc.bin" + "firmware/cs40l26-dvl.bin|cs40l26-dvl.bin" + "firmware/cs40l26-calib.wmfw|cs40l26-calib.wmfw" + ) ;; + *) die "unknown device $DEVICE_OPT (cheetah, raven or tegu)" ;; esac # The camera data flow (tools/extract-camera-data) exists for cheetah only [[ $DEVICE == cheetah || -z $CAMERA_APEX ]] || die "-c is cheetah's (no camera support for $DEVICE yet)" @@ -227,9 +283,9 @@ if get_file build.prop "$WORK/build.prop"; then fi dest="$OUT/$DEST_REL" -mkdir -p "$dest/brcm" "$dest/cirrus" for entry in "${MAP[@]}"; do from=${entry%%|*} to=${entry#*|} + mkdir -p "$dest/$(dirname "$to")" get_file "$from" "$dest/$to" || die "/vendor/$from is missing from this image" chmod 0644 "$dest/$to" printf ' /vendor/%-28s -> /%s/%s\n' "$from" "$DEST_REL" "$to" @@ -250,53 +306,63 @@ fi # Sanity checks: right chip, text NVRAM, Cirrus file formats. brcm="$dest/brcm" -grep -aq '4389c1-roml' "$brcm/$FW_BASE.$BOARD.bin" || - die "fw_bcmdhd.bin is not a BCM4389C1 PCIe firmware" -grep -aq 'BCM4389C1' "$brcm/BCM.$BOARD.hcd" || - die "BCM.hcd is not a BCM4389C1 Bluetooth patch" +grep -aq "$WIFI_CHIP-roml" "$brcm/$FW_BASE.$BOARD.bin" || + die "fw_bcmdhd.bin is not a $BT_CHIP PCIe firmware" +grep -aq "$BT_CHIP" "$brcm/BCM.$BOARD.hcd" || + die "BCM.hcd is not a $BT_CHIP Bluetooth patch" grep -aq '^NVRAMRev=' "$brcm/$FW_BASE.$BOARD.txt" || die "bcmdhd.cal does not look like a Broadcom text NVRAM" -# The speaker amplifiers' protection firmware, on both phones wmfw_halo() { # WMFW, Halo core (4): what cs_dsp accepts for this part [[ "$(head -c4 "$dest/$1")" == WMFW && "$(od -An -tu1 -j10 -N1 "$dest/$1" | tr -d ' ')" == 4 ]] || die "$1 is not a Halo Core WMFW firmware" } -wmfw_halo "cirrus/cs35l41-dsp1-spk-prot-$DEVICE.wmfw" -grep -aq 'FIRMWARE_HALO_CSPL' "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE.wmfw" || - die "cs35l41-dsp1-spk-prot.wmfw is not the CS35L41 speaker protection firmware" -grep -aq 'CAL_CHECKSUM' "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE.wmfw" || - die "cs35l41-dsp1-spk-prot.wmfw has no calibration controls" -cmp -s "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE-top.bin" "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE-bottom.bin" && - die "the top and bottom speaker tunings are the same file" -for f in top bottom; do - [[ "$(head -c4 "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE-$f.bin")" == WMDR ]] || - die "the $f speaker tuning is not a WMDR coefficient file" -done -# Cheetah's haptics and media deltas -if [[ $DEVICE == cheetah ]]; then +# The speaker amplifiers' protection firmware, on the CS35L41 phones +if [[ $DEVICE == cheetah || $DEVICE == raven ]]; then + wmfw_halo "cirrus/cs35l41-dsp1-spk-prot-$DEVICE.wmfw" + grep -aq 'FIRMWARE_HALO_CSPL' "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE.wmfw" || + die "cs35l41-dsp1-spk-prot.wmfw is not the CS35L41 speaker protection firmware" + grep -aq 'CAL_CHECKSUM' "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE.wmfw" || + die "cs35l41-dsp1-spk-prot.wmfw has no calibration controls" + cmp -s "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE-top.bin" "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE-bottom.bin" && + die "the top and bottom speaker tunings are the same file" + for f in top bottom; do + [[ "$(head -c4 "$dest/cirrus/cs35l41-dsp1-spk-prot-$DEVICE-$f.bin")" == WMDR ]] || + die "the $f speaker tuning is not a WMDR coefficient file" + done +fi +# The CS40L26 haptics (cheetah and tegu) +if [[ $DEVICE == cheetah || $DEVICE == tegu ]]; then for f in cs40l26.wmfw cs40l26-calib.wmfw; do wmfw_halo "$f"; done grep -aq 'FIRMWARE_CS40L26' "$dest/cs40l26.wmfw" || die "cs40l26.wmfw is not a CS40L26 firmware" grep -aq 'BUZZ_EFFECTS2_BUZZ_LEVEL' "$dest/cs40l26.wmfw" || die "cs40l26.wmfw has no buzz generator (cs40l26-vibra needs BUZZGEN)" +fi +# Cheetah's media deltas +if [[ $DEVICE == cheetah ]]; then # The media deltas: comma-separated integers, the first the word count # (vendor mixer_paths.xml "speaker-post"; Google's cs35l41 driver parses them) for f in top bottom; do python3 -I -c 'import sys; w = [int(x) for x in open(sys.argv[1]).read().replace(" ", "").strip().split(",")]; sys.exit(w[0] != len(w))' \ "$dest/cirrus/cs35l41-$DEVICE-$f-media-delta.txt" || die "the $f media delta is not a word list" done +fi +if [[ $DEVICE == cheetah || $DEVICE == tegu ]]; then for f in cs40l26.bin cs40l26-svc.bin cs40l26-dvl.bin; do [[ "$(head -c4 "$dest/$f")" == WMDR ]] || die "$f is not a WMDR coefficient file" done fi ver=$(grep -ao 'Version=[0-9.]* ([^)]*)' "$brcm/$FW_BASE.$BOARD.bin" | head -1) -bt=$(grep -ao 'BCM4389C1 [^[]*' "$brcm/BCM.$BOARD.hcd" | head -1) +bt=$(grep -ao "$BT_CHIP [^[]*" "$brcm/BCM.$BOARD.hcd" | head -1) (cd "$dest" && find . -type f -printf '%P\n' | sort | xargs sha256sum -- > "$OUT/vendor-firmware.sha256") say "Wi-Fi firmware: ${ver:-unknown version}" say "Bluetooth patch: ${bt:-unknown version}" -[[ $DEVICE == cheetah ]] && +[[ $DEVICE == cheetah || $DEVICE == tegu ]] && say "Haptics firmware: cs40l26.wmfw ($(stat -c %s "$dest/cs40l26.wmfw") bytes) and its wavetable" -say "Speaker protection: cs35l41-dsp1-spk-prot-$DEVICE.wmfw and the top and bottom tunings" +[[ $DEVICE == tegu ]] && + say "AoC firmware: aoc-tegu.bin ($(stat -c %s "$dest/aoc-tegu.bin") bytes)" +[[ $DEVICE == cheetah || $DEVICE == raven ]] && + say "Speaker protection: cs35l41-dsp1-spk-prot-$DEVICE.wmfw and the top and bottom tunings" say "Staged in $OUT (checksums in $OUT/vendor-firmware.sha256)" echo "This is Google's proprietary firmware from your own factory image. Do not redistribute it."