feat: port MT76 firmware load and download script

Add chip::load_firmware(): validates the xow_dongle.bin header, DMAs
the ILM and DLM images in 0x3800-byte chunks over EP 0x04 OUT with
FCE completion polling, then loads the IVB and waits for the firmware
to start. Probe now issues a USB reset first (port of
usb_reset_device), matching xone_dongle_probe.

The chip keeps its firmware across a USB reset on macOS and does not
set the upstream reset-complete bit, so load_firmware falls back to
the running firmware when the chip is still alive. Verified on
hardware: fresh load and re-plug both return success.

Add scripts/download-firmware.sh (port of install/firmware.sh), which
fetches the driver CAB from Windows Update and extracts
firmware/xow_dongle.bin, hash-verified.

Co-Authored-By: qwen3.8-27b@q2_k_xl: ported firmware load and download script
This commit is contained in:
portersky
2026-08-17 16:35:34 +02:00
parent ccc5bc819d
commit 21dc0e09b3
7 changed files with 318 additions and 4 deletions
+48
View File
@@ -0,0 +1,48 @@
#!/bin/sh
# Download and extract the wireless dongle firmware from Windows Update.
# Port of install/firmware.sh from medusalix/xone.
#
# The firmware is subject to Microsoft's Terms of Use:
# https://www.microsoft.com/en-us/legal/terms-of-use
set -eu
cd "$(dirname "$0")/.."
firmware_url='http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab'
firmware_hash='48084d9fa53b9bb04358f3bb127b7495dc8f7bb0b3ca1437bd24ef2b6eabdf66'
echo "The firmware for the wireless dongle is subject to Microsoft's Terms of Use:"
echo 'https://www.microsoft.com/en-us/legal/terms-of-use'
echo
echo 'Press enter to continue!'
read -r _
command -v curl >/dev/null 2>&1 || { echo 'This script requires curl!' >&2; exit 1; }
sha256() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | cut -d' ' -f1
else
shasum -a 256 "$1" | cut -d' ' -f1
fi
}
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT INT HUP TERM
echo "Downloading driver package..."
curl -L --fail -o "$tmpdir/driver.cab" "$firmware_url"
# Extract the firmware image (requires a libarchive-based tar, e.g. macOS).
tar -xf "$tmpdir/driver.cab" -C "$tmpdir"
actual=$(sha256 "$tmpdir/FW_ACC_00U.bin")
if [ "$actual" != "$firmware_hash" ]; then
echo "Firmware hash mismatch: $actual" >&2
exit 1
fi
mkdir -p firmware
mv "$tmpdir/FW_ACC_00U.bin" firmware/xow_dongle.bin
echo "Firmware written to firmware/xow_dongle.bin"