From 4ea31d69c1910a19403c37b409c2bb840d7680eb Mon Sep 17 00:00:00 2001 From: lotherk Date: Sun, 8 Nov 2026 15:17:42 +0000 Subject: [PATCH] mobile: hotdogb modem, WLAN, charger and fuel gauge - kernel/patches 0014-0016: ath10k keeps the WCN powered from probe (qcom,keep-powered); the modem with its firmware from the phone's partition, WLAN, rmtfs outside the TZ region; charger and the bq27411 fuel gauge. - firmware-partitions maps the modem partition too; /usr/lib/firmware/qcom/sm8150/partitions links there for tqftpserv. - wlan-board and ath10k-board: the phone's own WLAN board data from persist, as board-2.bin under /run, before ath10k loads. - qcom_pd_mapper in stage 1, so the modem's WLAN domain starts. - base/void: rmtfs, tqftpserv (services), linux-firmware-network. Measured: wlan0 up, a scan finds 12 networks, Bluetooth alongside, the charger charges, the gauge reads 4.433 V / 100 %. Open: the display white in some boots, and one sysrq reboot that ended switched off (devices/hotdogb/AGENTS.md). Co-Authored-By: Claude Opus 5.5 --- mobile/base/void/base.conf | 2 +- mobile/base/void/packages | 8 ++ mobile/devices/hotdogb/AGENTS.md | 40 +++++++++ ...-optionally-keep-the-WCN-powered-fro.patch | 90 +++++++++++++++++++ ...m8150-oneplus-hotdogb-modem-and-WLAN.patch | 86 ++++++++++++++++++ ...m8150-oneplus-hotdogb-charger-batter.patch | 75 ++++++++++++++++ .../core-services/01-firmware-partitions.sh | 2 + .../rootfs/etc/makronix/firmware-partitions | 1 + .../etc/modules-load.d/qcom-pd-mapper.conf | 7 ++ .../usr/lib/firmware/qcom/sm8150/partitions | 1 + .../rootfs/usr/libexec/makronix/ath10k-board | 47 ++++++++++ .../rootfs/usr/libexec/makronix/wlan-board | 29 ++++++ 12 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 mobile/kernel/patches/0014-wifi-ath10k-snoc-optionally-keep-the-WCN-powered-fro.patch create mode 100644 mobile/kernel/patches/0015-arm64-dts-qcom-sm8150-oneplus-hotdogb-modem-and-WLAN.patch create mode 100644 mobile/kernel/patches/0016-arm64-dts-qcom-sm8150-oneplus-hotdogb-charger-batter.patch create mode 100644 mobile/soc/sm8150/rootfs/etc/modules-load.d/qcom-pd-mapper.conf create mode 120000 mobile/soc/sm8150/rootfs/usr/lib/firmware/qcom/sm8150/partitions create mode 100755 mobile/soc/sm8150/rootfs/usr/libexec/makronix/ath10k-board create mode 100755 mobile/soc/sm8150/rootfs/usr/libexec/makronix/wlan-board diff --git a/mobile/base/void/base.conf b/mobile/base/void/base.conf index 2f61b355eb..bbd3ab6615 100644 --- a/mobile/base/void/base.conf +++ b/mobile/base/void/base.conf @@ -16,4 +16,4 @@ VOID_ROOTFS_SHA256=01a30f17ae06d4d5b322cd579ca971bc479e02cc284ec1e5a4255bea6bac3 VOID_REPO=https://repo-default.voidlinux.org/current/aarch64 # runit services to enable -VOID_SERVICES="dbus elogind NetworkManager sshd chronyd bluetoothd" +VOID_SERVICES="dbus elogind NetworkManager sshd chronyd bluetoothd rmtfs tqftpserv" diff --git a/mobile/base/void/packages b/mobile/base/void/packages index 38168b1f9b..f5c589be0c 100644 --- a/mobile/base/void/packages +++ b/mobile/base/void/packages @@ -23,6 +23,14 @@ chrony dnsmasq # Bluetooth: the stack for the kernel's hci (WCN3998 on hotdogb) bluez +# the modem's userspace on Qualcomm phones: its file systems from the EFS +# partitions (rmtfs, read-only: Void's -r keeps writes in memory) and its +# files over QRTR (tqftpserv: wlanmdsp.mbn for WLAN); the PD mapper is the +# kernel's (qcom_pd_mapper) +rmtfs +tqftpserv +# WLAN firmware for the host side (ath10k WCN3990 firmware-5.bin, board-2.bin) +linux-firmware-network # graphics stack: the kernel's DRM needs Mesa's userspace mesa-dri libinput diff --git a/mobile/devices/hotdogb/AGENTS.md b/mobile/devices/hotdogb/AGENTS.md index 7f58a79190..87cac58f77 100644 --- a/mobile/devices/hotdogb/AGENTS.md +++ b/mobile/devices/hotdogb/AGENTS.md @@ -266,6 +266,46 @@ a reboot, bluez 5.86 scans 14 devices. Seen once per boot, harmless: `Frame reassembly failed (-84)` during the baud-rate switch. For WLAN, later: `persist` holds the board data `bdwlan.bin`. +## Measured 2026-11-08: modem, WLAN, charger, fuel gauge + +- Modem (`kernel/patches/0015`): firmware from the phone's own `modem_` + (vfat `image/modem.mdt`, `/etc/makronix/firmware-partitions`), started by + rmtfs (`-r -P -s`: read-only, writes stay in memory, `storage.c`); the EFS + partitions (`modemst1/2`, `fsg`, `fsc`) and `persist` are backed up in + `~/src/nura/hotdogb-backup` (`SHA256SUMS.efs`). rmtfs at the dtsi's + 0x89b00000 was refused (`Assign memory protection call failed -22`): it + lies in the stock map's `removed_regions` (0x86200000-0x8b700000, the + stock DT `twrp-3.7.0_12-1-hotdogb.img` dtb.08 + `dtbo_a.img` entry 3); + tz_mem now covers it, rmtfs moved to 0xf2900000 with guard pages. +- The WLAN domain of the modem starts only when the PD mapper answers: + `qcom_pd_mapper` is loaded in stage 1 (`modules-load.d`) -- loaded by + udev in stage 2 it came too late, and no WLAN service ever appeared. +- WLAN: the firmware (WLAN.HL.3.0) crashed the modem twice per start + (`WCSS_WLAN1_GDSCR.PWR_ON`, then `CCPM: PLL lock failed`). Two causes: + the WCN had no power before ath10k's QMI handshake + (`kernel/patches/0014`, `qcom,keep-powered`, as stock's icnss), and the + generic board data linux-firmware gives a chip without board id (0xff). + The phone's own, `persist/bdwlan.bin` (none of the modem partition's + `bdwlan.*`), wrapped by `ath10k-board` into + `/run/makronix-firmware/ath10k/WCN3990/hw1.0/board-2.bin` (`wlan-board`, + stage 1): `wifi fw ready`, no crash, `wlan0`, a scan finds 12 networks on + 2.4 and 5 GHz, Bluetooth alongside. +- `vreg_l11c_3p3` stays at 3.0 V: with stock's 3.104 V minimum the display + was white once, at 3.0 V normal -- but the display was white again later + at 3.0 V, so this is not settled (below). +- Charger and gauge (`kernel/patches/0016`): before, the PMIC took about + 110 mA from USB (ADC `usbin_i`); now `pm8150b-charger` charges with a + 450 mA limit (the port offers USB default current), and the bq27411 at + i2c8 0x55 reads 4.433 V, 100 %, 32.9 C. + +Open, since the modem and WLAN run (2026-11-08): +- The display came up **white** in some boots, directly at boot; the log + of a white boot is the same as of a good one (autorefresh stopped, + handoff, `fb0`). Not explained. +- Once the phone did not come back from `sysrq b` and was off (Konrad + switched it on: `startupmode=dc_charger`). The battery was not empty: + 100 % twenty minutes later. Not explained. + Open: the DSI `Invalid response cmd 0x00` on the first read after the takeover (the panel driver's retry reads cleanly, as with the ACK error); OTG host mode; netconsole misses the first seconds of a boot since the ACM diff --git a/mobile/kernel/patches/0014-wifi-ath10k-snoc-optionally-keep-the-WCN-powered-fro.patch b/mobile/kernel/patches/0014-wifi-ath10k-snoc-optionally-keep-the-WCN-powered-fro.patch new file mode 100644 index 0000000000..1987757266 --- /dev/null +++ b/mobile/kernel/patches/0014-wifi-ath10k-snoc-optionally-keep-the-WCN-powered-fro.patch @@ -0,0 +1,90 @@ +From d4af8bcc45bd5bbd817a387ec281e94a7d1a9343 Mon Sep 17 00:00:00 2001 +From: lotherk +Date: Sun, 8 Nov 2026 15:04:25 +0000 +Subject: [PATCH 14/15] wifi: ath10k: snoc: optionally keep the WCN powered + from probe + +On sm8150 the WLAN firmware (WLAN.HL.3.0, on the modem) touches the WCN +as soon as the modem starts its WLAN domain, before the QMI handshake +brings ath10k to hif_power_up. With the supplies off it crashed the modem +("MAXIMUM POLL COUNT REACHED FOR WCSS_WLAN1_GDSCR.PWR_ON"). The +downstream icnss driver powers the WCN at probe and keeps it so. + +With qcom,keep-powered in the DT, take one power reference (pwrseq, +regulators, clocks) in probe and drop it in remove; hif_power_up/down add +and drop theirs on top. +--- + drivers/net/wireless/ath/ath10k/snoc.c | 27 +++++++++++++++++++++++++- + drivers/net/wireless/ath/ath10k/snoc.h | 1 + + 2 files changed, 27 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c +index f72f236fb..539c0e0cc 100644 +--- a/drivers/net/wireless/ath/ath10k/snoc.c ++++ b/drivers/net/wireless/ath/ath10k/snoc.c +@@ -1852,10 +1852,29 @@ static int ath10k_snoc_probe(struct platform_device *pdev) + goto err_free_irq; + } + ++ /* ++ * Some firmware (WLAN.HL.3.0 on sm8150) touches the WCN as soon as ++ * the modem starts its WLAN domain, before the QMI handshake brings ++ * us to hif_power_up: without its supplies and reference clock it ++ * crashes the modem ("WCSS_WLAN1_GDSCR.PWR_ON", "CCPM: PLL lock ++ * failed"). The downstream icnss driver powers the WCN at probe and ++ * keeps it so; with qcom,keep-powered, hold one power reference from ++ * probe to remove. hif_power_up/down then only add and drop theirs. ++ */ ++ ar_snoc->keep_powered = of_property_read_bool(dev->of_node, ++ "qcom,keep-powered"); ++ if (ar_snoc->keep_powered) { ++ ret = ath10k_hw_power_on(ar); ++ if (ret) { ++ ath10k_err(ar, "failed to power on: %d\n", ret); ++ goto err_fw_deinit; ++ } ++ } ++ + ret = ath10k_qmi_init(ar, msa_size); + if (ret) { + ath10k_warn(ar, "failed to register wlfw qmi client: %d\n", ret); +- goto err_fw_deinit; ++ goto err_power_off; + } + + ret = ath10k_modem_init(ar); +@@ -1869,6 +1888,10 @@ static int ath10k_snoc_probe(struct platform_device *pdev) + err_qmi_deinit: + ath10k_qmi_deinit(ar); + ++err_power_off: ++ if (ar_snoc->keep_powered) ++ ath10k_hw_power_off(ar); ++ + err_fw_deinit: + ath10k_fw_deinit(ar); + +@@ -1893,6 +1916,8 @@ static int ath10k_snoc_free_resources(struct ath10k *ar) + set_bit(ATH10K_SNOC_FLAG_UNREGISTERING, &ar_snoc->flags); + + ath10k_core_unregister(ar); ++ if (ar_snoc->keep_powered) ++ ath10k_hw_power_off(ar); + ath10k_fw_deinit(ar); + ath10k_snoc_free_irq(ar); + ath10k_snoc_release_resource(ar); +diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h +index 1ecae3468..1fbaf2b03 100644 +--- a/drivers/net/wireless/ath/ath10k/snoc.h ++++ b/drivers/net/wireless/ath/ath10k/snoc.h +@@ -84,6 +84,7 @@ struct ath10k_snoc { + struct notifier_block nb; + void *notifier; + unsigned long flags; ++ bool keep_powered; + bool xo_cal_supported; + u32 xo_cal_data; + DECLARE_BITMAP(pending_ce_irqs, CE_COUNT_MAX); +-- +2.53.0 + diff --git a/mobile/kernel/patches/0015-arm64-dts-qcom-sm8150-oneplus-hotdogb-modem-and-WLAN.patch b/mobile/kernel/patches/0015-arm64-dts-qcom-sm8150-oneplus-hotdogb-modem-and-WLAN.patch new file mode 100644 index 0000000000..46b36b7c26 --- /dev/null +++ b/mobile/kernel/patches/0015-arm64-dts-qcom-sm8150-oneplus-hotdogb-modem-and-WLAN.patch @@ -0,0 +1,86 @@ +From 1718c80ab35bb71d74e9e958ed8532d333e38605 Mon Sep 17 00:00:00 2001 +From: lotherk +Date: Sun, 8 Nov 2026 15:04:25 +0000 +Subject: [PATCH 15/15] arm64: dts: qcom: sm8150-oneplus-hotdogb: modem and + WLAN + +- The modem (mpss), with its firmware from the phone's own modem partition + (qcom/sm8150/partitions/modem/modem.mdt, provided at run time). +- WLAN (WCN3998) with the supplies of the stock icnss node and + qcom,keep-powered. +- tz_mem as large as the stock memory map's removed_regions (to + 0x8b700000): the rmtfs region the dtsi placed at 0x89b00000 lay inside + it, and the hypervisor refused to assign it (-22). rmtfs moves to the + OnePlus common dtsi's 0xf2901000, with guard pages. +- vreg_l11c_3p3 stays at the common dtsi's 3.0 V minimum: at stock's + 3.104 V (icnss ch0) the display came up white, measured on hotdogb. +--- + .../boot/dts/qcom/sm8150-oneplus-hotdogb.dts | 40 +++++++++++++++++-- + 1 file changed, 37 insertions(+), 3 deletions(-) + +diff --git a/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts b/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts +index 995646d87..89d6b53b9 100644 +--- a/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts ++++ b/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts +@@ -113,8 +113,14 @@ touchscreen@48 { + }; + }; + ++/* ++ * The modem: needed for WLAN, whose firmware (wlanmdsp.mbn) runs on it. ++ * Its firmware is the phone's own, from the modem partition at run time ++ * (/etc/makronix/firmware-partitions: qcom/sm8150/partitions/modem). ++ */ + &remoteproc_mpss { +- status = "disabled"; ++ firmware-name = "qcom/sm8150/partitions/modem/modem.mdt"; ++ status = "okay"; + }; + + &remoteproc_adsp { +@@ -125,12 +131,40 @@ &remoteproc_cdsp { + status = "disabled"; + }; + ++/* WCN3998 WLAN; the supplies of the stock icnss node (L1A, L7A, L2C, L11C) */ + &wifi { +- status = "disabled"; /* enable once WCN3990 firmware is in place */ ++ vdd-0.8-cx-mx-supply = <&vreg_l1a_0p75>; ++ vdd-1.8-xo-supply = <&vreg_l7a_1p8>; ++ vdd-1.3-rfa-supply = <&vreg_l2c_1p3>; ++ vdd-3.3-ch0-supply = <&vreg_l11c_3p3>; ++ /* ++ * The WLAN firmware on the modem wakes the WCN as its domain starts, ++ * before ath10k's QMI handshake: powered from probe on, as stock's ++ * icnss (drivers/net/wireless/ath/ath10k/snoc.c, kernel/patches). ++ */ ++ qcom,keep-powered; ++ status = "okay"; + }; + ++/* ++ * The stock memory map (the phone's DTB with its DTBO, project 18865) ++ * reserves 0x86200000-0x8b700000 for TZ ("removed_regions"); the dtsi's ++ * tz_mem ends at 0x89b00000, and an rmtfs region placed there was refused ++ * by the hypervisor ("Assign memory protection call failed -22"). ++ */ ++&tz_mem { ++ reg = <0x0 0x86200000 0x0 0x5500000>; ++}; ++ ++/* ++ * rmtfs is allocated dynamically downstream; its address reaches the modem ++ * through the rmtfs daemon. The OnePlus 7's address (the common dtsi), ++ * with a guard page on each side against XPU violations, as the sdm845 ++ * OnePlus phones. ++ */ + &rmtfs_mem { +- reg = <0x0 0x89b00000 0x0 0x200000>; ++ reg = <0x0 0xf2900000 0x0 0x202000>; ++ qcom,use-guard-pages; + }; + + &adsp_mem { +-- +2.53.0 + diff --git a/mobile/kernel/patches/0016-arm64-dts-qcom-sm8150-oneplus-hotdogb-charger-batter.patch b/mobile/kernel/patches/0016-arm64-dts-qcom-sm8150-oneplus-hotdogb-charger-batter.patch new file mode 100644 index 0000000000..7758b66f17 --- /dev/null +++ b/mobile/kernel/patches/0016-arm64-dts-qcom-sm8150-oneplus-hotdogb-charger-batter.patch @@ -0,0 +1,75 @@ +From 6c04bd02faabb041e302532cead5afbd6841a82e Mon Sep 17 00:00:00 2001 +From: lotherk +Date: Sun, 8 Nov 2026 15:17:22 +0000 +Subject: [PATCH] arm64: dts: qcom: sm8150-oneplus-hotdogb: charger, battery + and fuel gauge + +- The pm8150b charger (qcom_smbx) with the 7T's battery (stock DT with its + DTBO, project 18865: 3800 mAh, full at 4.4 V). Without it the PMIC kept + its minimal input current, about 110 mA from USB. +- The fuel gauge on i2c8 at 0x55 (stock: oplus,bq27541-battery, whose + driver picks the chip at run time): read as a bq27541 the values were + nonsense (3075 %, -259 C), as a bq27411 they are plausible (4.433 V, + 100 %, 32.9 C, design 3755 mAh while charging). +--- + .../boot/dts/qcom/sm8150-oneplus-hotdogb.dts | 37 +++++++++++++++++++ + 1 file changed, 37 insertions(+) + +diff --git a/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts b/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts +index 89d6b53b9..48fa25656 100644 +--- a/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts ++++ b/arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts +@@ -29,6 +29,17 @@ / { + oplus,dtsi_no = <19801>; + oplus,pcb_range = <0 55>; + ++ /* ++ * The 7T's battery, from the stock DT with its DTBO (project 18865): ++ * qcom,batt_capacity_mah 3800, qcom,vbatt_full_thr 4400 mV. ++ */ ++ battery: battery { ++ compatible = "simple-battery"; ++ charge-full-design-microamp-hours = <3800000>; ++ voltage-min-design-microvolt = <3400000>; ++ voltage-max-design-microvolt = <4400000>; ++ }; ++ + aliases { + serial0 = &uart2; + serial1 = &uart13; +@@ -237,6 +248,32 @@ &usb_1_dwc3_hs { + remote-endpoint = <&pm8150b_hs_in>; + }; + ++/* ++ * The charger: without it the PMIC kept its minimal input current limit, ++ * the phone took about 110 mA from USB, less than it uses, and ran its ++ * battery empty and switched off (2026-11-08). ++ */ ++&pm8150b_charger { ++ monitored-battery = <&battery>; ++ status = "okay"; ++}; ++ ++/* ++ * The fuel gauge: a TI bq27541 on i2c8 at 0x55, 400 kHz (stock: ++ * qupv3_se8_i2c, oplus,bq27541-battery), which Android reads the charge ++ * from. bq27xxx only reads it (no DT_UPDATES_NVM in the config). ++ */ ++&i2c8 { ++ clock-frequency = <400000>; ++ status = "okay"; ++ ++ fuel-gauge@55 { ++ compatible = "ti,bq27411"; ++ reg = <0x55>; ++ monitored-battery = <&battery>; ++ }; ++}; ++ + &pm8150b_vbus { + regulator-min-microamp = <500000>; + regulator-max-microamp = <1500000>; +-- +2.53.0 + diff --git a/mobile/soc/sm8150/rootfs-void/etc/runit/core-services/01-firmware-partitions.sh b/mobile/soc/sm8150/rootfs-void/etc/runit/core-services/01-firmware-partitions.sh index 08ee80a599..4d283d5f09 100644 --- a/mobile/soc/sm8150/rootfs-void/etc/runit/core-services/01-firmware-partitions.sh +++ b/mobile/soc/sm8150/rootfs-void/etc/runit/core-services/01-firmware-partitions.sh @@ -6,4 +6,6 @@ if [ -z "$VIRTUALIZATION" ] && [ -x /usr/libexec/makronix/firmware-partitions ]; then /usr/libexec/makronix/firmware-partitions || msg_warn "firmware-partitions: not every partition is there" + /usr/libexec/makronix/wlan-board || + msg_warn "wlan-board: no board data from persist" fi diff --git a/mobile/soc/sm8150/rootfs/etc/makronix/firmware-partitions b/mobile/soc/sm8150/rootfs/etc/makronix/firmware-partitions index 8b306b1ae1..e0c8975edd 100644 --- a/mobile/soc/sm8150/rootfs/etc/makronix/firmware-partitions +++ b/mobile/soc/sm8150/rootfs/etc/makronix/firmware-partitions @@ -5,3 +5,4 @@ # # bluetooth image qca +modem image qcom/sm8150/partitions/modem diff --git a/mobile/soc/sm8150/rootfs/etc/modules-load.d/qcom-pd-mapper.conf b/mobile/soc/sm8150/rootfs/etc/modules-load.d/qcom-pd-mapper.conf new file mode 100644 index 0000000000..d514b1e6db --- /dev/null +++ b/mobile/soc/sm8150/rootfs/etc/modules-load.d/qcom-pd-mapper.conf @@ -0,0 +1,7 @@ +# The protection domain mapper the modem (and the DSPs) ask before they +# start a domain such as wlan_pd. remoteproc announces it as an auxiliary +# device when the modem starts, from rmtfs in stage 2 -- often before udevd +# runs again and could load the module, so the domain never started (no +# WLAN QMI service, 2026-11-08). Loaded in stage 1 (02-kmods), it binds +# whenever the device appears. +qcom_pd_mapper diff --git a/mobile/soc/sm8150/rootfs/usr/lib/firmware/qcom/sm8150/partitions b/mobile/soc/sm8150/rootfs/usr/lib/firmware/qcom/sm8150/partitions new file mode 120000 index 0000000000..fa92fbf044 --- /dev/null +++ b/mobile/soc/sm8150/rootfs/usr/lib/firmware/qcom/sm8150/partitions @@ -0,0 +1 @@ +/run/makronix-firmware/qcom/sm8150/partitions \ No newline at end of file diff --git a/mobile/soc/sm8150/rootfs/usr/libexec/makronix/ath10k-board b/mobile/soc/sm8150/rootfs/usr/libexec/makronix/ath10k-board new file mode 100755 index 0000000000..f6a793f300 --- /dev/null +++ b/mobile/soc/sm8150/rootfs/usr/libexec/makronix/ath10k-board @@ -0,0 +1,47 @@ +#!/bin/sh +# +# ath10k-board BDF OUT NAME... -- write an ath10k board-2.bin (OUT) that +# holds the board data file BDF under each board NAME, e.g. +# "bus=snoc,qmi-board-id=ff,qmi-chip-id=30224". +# +# Why: the WCN399x of a phone has no board id programmed (qmi board_id +# 0xff), so ath10k takes the generic "bus=snoc,qmi-board-id=ff" entry of +# linux-firmware's board-2.bin -- the board data of another board, with +# which the WLAN firmware on hotdogb crashed ("CCPM: PLL lock failed"). The +# phone's own board data (its persist partition) stays on the phone; this +# file, under /run/makronix-firmware, is found before linux-firmware's. +# +# The format is ath10k's (drivers/net/wireless/ath/ath10k/hw.h, +# core.c ath10k_core_fetch_board_data_api_n): the magic +# "QCA-ATH10K-BOARD\0" padded to 4 bytes, then one ATH10K_BD_IE_BOARD (0) +# per name holding ATH10K_BD_IE_BOARD_NAME (0) and ATH10K_BD_IE_BOARD_DATA +# (1); every IE is id and length (little-endian 32 bit), its data padded +# to 4 bytes. + +[ $# -ge 3 ] || { echo "usage: ath10k-board BDF OUT NAME..." >&2; exit 2; } +bdf=$1 out=$2 +shift 2 +[ -s "$bdf" ] || { echo "ath10k-board: no $bdf" >&2; exit 1; } + +le32() { # le32 N: N as 4 bytes, little-endian + printf "\\$(printf %03o $(($1 & 255)))\\$(printf %03o $((($1 >> 8) & 255)))" + printf "\\$(printf %03o $((($1 >> 16) & 255)))\\$(printf %03o $((($1 >> 24) & 255)))" +} +pad() { # pad N: the zero bytes that bring N to a multiple of 4 + _p=$(( (4 - $1 % 4) % 4 )) + while [ "$_p" -gt 0 ]; do printf '\000'; _p=$((_p - 1)); done +} +pad4() { echo $(( ($1 + 3) / 4 * 4 )); } + +dlen=$(wc -c < "$bdf" | tr -d ' ') +tmp=$out.tmp +{ + printf 'QCA-ATH10K-BOARD\000'; pad 17 + for name in "$@"; do + nlen=${#name} + le32 0 + le32 $((8 + $(pad4 "$nlen") + 8 + $(pad4 "$dlen"))) + le32 0; le32 "$nlen"; printf '%s' "$name"; pad "$nlen" + le32 1; le32 "$dlen"; cat "$bdf"; pad "$dlen" + done +} > "$tmp" && mv "$tmp" "$out" diff --git a/mobile/soc/sm8150/rootfs/usr/libexec/makronix/wlan-board b/mobile/soc/sm8150/rootfs/usr/libexec/makronix/wlan-board new file mode 100755 index 0000000000..96d2806564 --- /dev/null +++ b/mobile/soc/sm8150/rootfs/usr/libexec/makronix/wlan-board @@ -0,0 +1,29 @@ +#!/bin/sh +# +# wlan-board -- the phone's own WLAN board data for ath10k, before the +# driver loads (stage 1, after firmware-partitions): the persist partition's +# bdwlan.bin (the board data the vendor's software uses; it matches none of +# the generic bdwlan.* files in the modem partition), wrapped by +# ath10k-board into /run/makronix-firmware/ath10k/WCN3990/hw1.0/board-2.bin +# under the names ath10k asks for when the chip has no board id (0xff). +# persist is ext4 and mounted read-only without journal replay (noload): it +# is the vendor's and must not change. Nothing to do on a phone without it. + +PERSIST=/run/makronix-partitions/persist +OUT=/run/makronix-firmware/ath10k/WCN3990/hw1.0 + +dev= +for u in /sys/class/block/*/uevent; do + grep -qx PARTNAME=persist "$u" && { d=${u%/uevent}; dev=/dev/${d##*/}; break; } +done +[ -n "$dev" ] || exit 0 + +mkdir -p "$PERSIST" +grep -q " $PERSIST " /proc/mounts || + mount -t ext4 -o ro,noload,nosuid,nodev,noexec "$dev" "$PERSIST" || exit 1 +[ -s "$PERSIST/bdwlan.bin" ] || exit 0 + +mkdir -p "$OUT" +/usr/libexec/makronix/ath10k-board "$PERSIST/bdwlan.bin" "$OUT/board-2.bin" \ + "bus=snoc,qmi-board-id=ff,qmi-chip-id=30224" "bus=snoc,qmi-board-id=ff" && + echo "wlan-board: $OUT/board-2.bin from $dev (persist) bdwlan.bin" > /dev/kmsg