Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/omamobile-device-husky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Not in this package: the boot-success marker, the charger, cameras, and the slot

## Firmware the phone needs

Nothing here is in the package. Wi-Fi needs four files from Google's firmware for the BCM4398 D0, which `tools/extract-vendor-firmware -d husky -s SKU` takes from the owner's own factory image or OTA `vendor.img`. They're installed under `/usr/lib/firmware/updates/brcm`, with the board-suffixed names brcmfmac loads first:
Nothing here is in the package. `tools/extract-vendor-firmware -d husky -s SKU` also stages the Bluetooth patch (`brcm/BCM.google,zuma-husky.hcd`, stock's `BCM.hcd`) and the five CS40L26 haptics files (`cs40l26.wmfw`, `cs40l26.bin` and the three tuning files) from the same image. Wi-Fi needs four files from Google's firmware for the BCM4398 D0, which `tools/extract-vendor-firmware -d husky -s SKU` takes from the owner's own factory image or OTA `vendor.img`. They're installed under `/usr/lib/firmware/updates/brcm`, with the board-suffixed names brcmfmac loads first:

- `brcmfmac4398d0-pcie.google,zuma-husky.bin`: the firmware;
- `.txt`: the NVRAM for the phone's region, which `-s` picks from the hardware SKU (`grep hardware.sku /proc/bootconfig`);
Expand Down
15 changes: 12 additions & 3 deletions tests/extract-vendor-firmware
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ make_vendor() {
printf 'NVRAMRev=%s\n' "$g" > "$v/firmware/bcmdhd.cal_USI_G5SN_9957_V17"
echo "clm $g" > "$v/firmware/bcmdhd_clm.blob_4398_d0"
echo "txcap $g" > "$v/firmware/bcmdhd_txcap.blob_4398_d0"
echo "fictional G5SN_V17_HK3 REL $g" > "$v/firmware/brcm/BCM.hcd"
halo "FIRMWARE_CS40L26 BUZZ_EFFECTS2_BUZZ_LEVEL $g" > "$v/firmware/cs40l26.wmfw"
halo "calib $g" > "$v/firmware/cs40l26-calib.wmfw"
for f in cs40l26.bin cs40l26-svc.bin cs40l26-dvl.bin; do echo "WMDR $f $g" > "$v/firmware/$f"; done
return
fi
printf 'fictional 4389c1-roml Version=1.0.1 (%s)\n' "$g" > "$v/firmware/fw_bcmdhd.bin"
Expand Down Expand Up @@ -204,15 +208,20 @@ o=$t/husky-reuse n=$failed
seed "$o"
if run "$t/husky" "$t/ext4.img" -d husky -o "$o"; then
[[ ! -e $o/usr/share/omamobile/sensors ]] || fail "husky: an earlier device's sensor registry is dropped"
[[ $(listed "$o" | tr '\n' ' ') == "brcm/brcmfmac4398d0-pcie.google,zuma-husky.bin brcm/brcmfmac4398d0-pcie.google,zuma-husky.clm_blob brcm/brcmfmac4398d0-pcie.google,zuma-husky.txcap_blob brcm/brcmfmac4398d0-pcie.google,zuma-husky.txt " ]] ||
fail "husky: the checksum list names husky's four files only"
[[ $(find "$o/$FW" -type f | wc -l) == 4 ]] || fail "husky: no cheetah firmware stays"
[[ $(listed "$o" | tr '\n' ' ') == "brcm/BCM.google,zuma-husky.hcd brcm/brcmfmac4398d0-pcie.google,zuma-husky.bin brcm/brcmfmac4398d0-pcie.google,zuma-husky.clm_blob brcm/brcmfmac4398d0-pcie.google,zuma-husky.txcap_blob brcm/brcmfmac4398d0-pcie.google,zuma-husky.txt cs40l26-calib.wmfw cs40l26-dvl.bin cs40l26-svc.bin cs40l26.bin cs40l26.wmfw " ]] ||
fail "husky: the checksum list names husky's ten files only"
[[ $(find "$o/$FW" -type f | wc -l) == 10 ]] || fail "husky: no cheetah firmware stays"
grep -qF 'Bluetooth patch: G5SN_V17_HK3 REL gen3' "$t/log" || fail "husky: the Bluetooth patch's release is reported"
pass_since "$n" "husky: a run over a cheetah generation leaves only husky's files"
else
cat "$t/log"; fail "husky: a run over a cheetah generation succeeds"
fi

# --- Failed runs leave the previous generation ----------------------------------
# husky's BCM.hcd names the module and board, not the chip: another phone's
# patch (here the 7 Pro's) is refused
rm -rf "$t/husky-otherbt"; cp -r "$t/husky" "$t/husky-otherbt"; echo "BCM4389C1 fictional" > "$t/husky-otherbt/firmware/brcm/BCM.hcd"
refuses "husky: another chip's Bluetooth patch" "BCM.hcd is not a" "$t/husky-otherbt" "$t/ext4.img" -d husky
rm -rf "$t/v2-missing"; cp -r "$t/v2" "$t/v2-missing"; rm "$t/v2-missing/firmware/aoc.bin"
refuses "a missing ext4 file with an older copy in OUT" "/vendor/firmware/aoc.bin is missing" "$t/v2-missing" "$t/ext4.img"
refuses "a missing EROFS file with an older copy in OUT" "/vendor/firmware/aoc.bin is missing" "$t/v2-missing" "$t/erofs.img"
Expand Down
41 changes: 29 additions & 12 deletions tools/extract-vendor-firmware
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# 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. The Pixel 7 (panther), the Pixel 6 Pro
# (raven), the Pixel 9a (tegu) and the Pixel 8 Pro (husky, Wi-Fi only) are
# options (-d).
# (raven), the Pixel 9a (tegu) and the Pixel 8 Pro (husky: Wi-Fi, Bluetooth
# and haptics) are options (-d).
#
# 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
Expand Down Expand Up @@ -66,12 +66,15 @@
# is in another format, device/tegu/AUDIO-PLAN.md). The modem's and GNSS's
# files are tools/extract-vendor-chroot's.
#
# The Pixel 8 Pro (-d husky; <board> is "google,zuma-husky"), Wi-Fi only:
# The Pixel 8 Pro (-d husky; <board> is "google,zuma-husky"): Wi-Fi, Bluetooth
# and haptics:
#
# vendor/firmware/fw_bcmdhd.bin_4398_d0 -> brcm/brcmfmac4398d0-pcie.<board>.bin (brcmfmac)
# vendor/firmware/bcmdhd.cal_<region> -> brcm/brcmfmac4398d0-pcie.<board>.txt (NVRAM)
# vendor/firmware/bcmdhd_clm.blob_4398_d0 -> brcm/brcmfmac4398d0-pcie.<board>.clm_blob (regulatory)
# vendor/firmware/bcmdhd_txcap.blob_4398_d0 -> brcm/brcmfmac4398d0-pcie.<board>.txcap_blob (TX capabilities)
# vendor/firmware/brcm/BCM.hcd -> brcm/BCM.<board>.hcd (btbcm)
# vendor/firmware/cs40l26*.{wmfw,bin} -> the same five files as cheetah's
#
# The radio is a BCM4398 D0. Stock picks the CLM and TX capability files by
# chip revision (_4398_d0), but the NVRAM by the phone's hardware SKU
Expand All @@ -81,8 +84,15 @@
# (bcmdhd.cal_USI_G5SN_9957_V17, the same bytes as _ROW). The regions differ
# only in their energy-detect thresholds. Read the SKU with
# `grep hardware.sku /proc/bootconfig` on the phone, or
# `adb shell getprop ro.boot.hardware.sku` on Android. Bluetooth and the
# other files wait for drivers (device/husky/ROADMAP.md). An OTA's vendor.img
# `adb shell getprop ro.boot.hardware.sku` on Android. The Bluetooth patch
# is stock's BCM.hcd, the file btbcm asks for under the board name (kernel
# #199 was tested with it); the vendor partition's BCM_174.hcd (a BCM4398 B0
# patch), BCM_181.hcd and BTFW_B.hcd are not copied. This BCM.hcd names the
# module and the board ("G5SN_V17_HK3 REL ..."), not the chip, so that is
# what the sanity check looks for. The haptics chip is a CS40L26, as on the
# 7 Pro and the 9a (kernel #200); stock's cs40l26-dbc.bin has no user in
# cs40l26-vibra and is not copied. The AoC's and the speaker amplifiers'
# files wait for their drivers (device/husky/ROADMAP.md). An OTA's vendor.img
# (from its payload.bin) works as SOURCE as well as a factory image.
#
# Output is a tree rooted at /, under usr/lib/firmware/updates (searched before
Expand Down Expand Up @@ -227,13 +237,14 @@ case $DEVICE_OPT in
"firmware/cs40l26-calib.wmfw|cs40l26-calib.wmfw"
) ;;
husky)
# Pixel 8 Pro: Wi-Fi (BCM4398 D0) only, with the NVRAM for the SKU's
# region (the header).
# Pixel 8 Pro: Wi-Fi (BCM4398 D0) with the NVRAM for the SKU's region,
# Bluetooth and the haptics files (the header). BT_CHIP is the module and
# board string husky's BCM.hcd carries in place of a chip name.
BOARD="google,zuma-husky"
DEVICE="husky"
FW_BASE="brcmfmac4398d0-pcie"
WIFI_CHIP="4398d0"
BT_CHIP=""
BT_CHIP="G5SN_V[0-9]*_HK3"
# Google's SKU table (dhd_custom_google.c); husky's vendor has NVRAMs for
# MMW, ROW and NA only, so the others take the module's default, as on stock
case $SKU in
Expand All @@ -247,6 +258,12 @@ case $DEVICE_OPT in
"firmware/$nvram|brcm/$FW_BASE.$BOARD.txt"
"firmware/bcmdhd_clm.blob_4398_d0|brcm/$FW_BASE.$BOARD.clm_blob"
"firmware/bcmdhd_txcap.blob_4398_d0|brcm/$FW_BASE.$BOARD.txcap_blob"
"firmware/brcm/BCM.hcd|brcm/BCM.$BOARD.hcd"
"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, panther, raven, tegu or husky)" ;;
esac
Expand Down Expand Up @@ -457,8 +474,8 @@ if [[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == raven ]]; then
die "the $f speaker tuning is not a WMDR coefficient file"
done
fi
# The CS40L26 haptics (the gs201 phones and tegu)
if [[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == tegu ]]; then
# The CS40L26 haptics (the gs201 phones, tegu and husky)
if [[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == tegu || $DEVICE == husky ]]; 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"
Expand All @@ -474,7 +491,7 @@ if [[ $DEVICE == cheetah || $DEVICE == panther ]]; then
"$dest/cirrus/cs35l41-$DEVICE-$f-media-delta.txt" || die "the $f media delta is not a word list"
done
fi
if [[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == tegu ]]; then
if [[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == tegu || $DEVICE == husky ]]; 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
Expand All @@ -495,7 +512,7 @@ if [[ $DEVICE == husky ]]; then
[[ -n $SKU ]] || say "No -s SKU: stock's default NVRAM; pass the phone's SKU for its region's"
fi
[[ -z $BT_CHIP ]] || say "Bluetooth patch: ${bt:-unknown version}"
[[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == tegu ]] &&
[[ $DEVICE == cheetah || $DEVICE == panther || $DEVICE == tegu || $DEVICE == husky ]] &&
say "Haptics firmware: cs40l26.wmfw ($(stat -c %s "$dest/cs40l26.wmfw") bytes) and its wavetable"
[[ $DEVICE == tegu ]] &&
say "AoC firmware: aoc-tegu.bin ($(stat -c %s "$dest/aoc-tegu.bin") bytes)"
Expand Down