From b99b9192903f08e1a054e8d38b8345d2f3bcc8ae Mon Sep 17 00:00:00 2001 From: "Sicelo A. Mhlongo" Date: Wed, 12 Feb 2025 14:45:21 +0200 Subject: [PATCH] wl1251-cal: modernize and improve reliability (MR 6202) Alpine now ships compressed firmware, so the old firmware file name is no longer available, causing wl1251-cal to fail. Fix by manually creating the expected uncompressed file. Additionally, wl1251-cal has not been running early enough in most cases, causing the kernel to use default nvs. Fix by blacklisting the driver and probing it after the correct nvs has been extracted and saved. [ci:skip-build]: already built successfully in CI --- device/community/wl1251-cal/APKBUILD | 9 ++++++--- device/community/wl1251-cal/calibrate-wl1251 | 6 +++++- device/community/wl1251-cal/wl1251-blacklist | 3 +++ .../community/wl1251-cal/wl1251-cal-openrc.post-install | 2 +- device/community/wl1251-cal/wl1251-cal.initd | 5 +++-- device/community/wl1251-cal/wl1251-cal.trigger | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 device/community/wl1251-cal/wl1251-blacklist diff --git a/device/community/wl1251-cal/APKBUILD b/device/community/wl1251-cal/APKBUILD index 1d87a4bc7..5f9c203b5 100644 --- a/device/community/wl1251-cal/APKBUILD +++ b/device/community/wl1251-cal/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Dang Huynh pkgname=wl1251-cal pkgver=1.2 -pkgrel=2 +pkgrel=3 pkgdesc="Retrieve wl1251 calibration data from a CAL partition and feed it to the driver" url="https://github.com/maemo-leste/wl1251-cal" arch="armv7" @@ -11,6 +11,7 @@ subpackages="$pkgname-openrc" triggers="$pkgname.trigger=/lib/firmware/ti-connectivity" source="$pkgname-$pkgver.tar.gz::https://github.com/maemo-leste/wl1251-cal/archive/refs/tags/$pkgver.tar.gz wl1251-cal.initd + wl1251-blacklist calibrate-wl1251" options="!check" # No tests @@ -21,6 +22,7 @@ build() { package() { make install DESTDIR="$pkgdir" install -Dm755 "$srcdir/calibrate-wl1251" "$pkgdir/usr/bin/calibrate-wl1251" + install -Dm644 "$srcdir/wl1251-blacklist" "$pkgdir/etc/modprobe.d/wl1251.conf" } openrc() { @@ -31,6 +33,7 @@ openrc() { sha512sums=" 1a402553fc98fa8f2d81d34a548f96be91d13bdcb77ec8e9d8373732b27a6e908895f6044aef8e88dbcd9fa6fa04f0a3d62bed877be91ba6207f68440c3ce758 wl1251-cal-1.2.tar.gz -1793a4d09ce3c4f2af7b7b4e171ed04e4d5e70d3e40f365ef169879d2431bd1f7abe8702a422efb4d86449a2800b53c531af7353d4e4c2563985c97030cbd99b wl1251-cal.initd -0d843727da4d2f3e2fe76ff80c68e67b85fa1e4797ba822d323f3b005df853ec5206c812a9e0caed96aff2bf5f353df79b20f1970c6382d90e02dc664411d0b4 calibrate-wl1251 +39fec86cb13d34a605ad1a76eb3a6ae6e242a01427f477008a3ff066e0b59fb804f0d8379909f81d015aa053ccf9850505dbe3124062ed707a663ae5e2ccd9f1 wl1251-cal.initd +d14fd2816a8d55592907f1cf1f702d86095c8d2581b336460eb7d5bfc6ab8cece37a53c0a181b9f75ef5050bc612ce7443992158d36fc03939b39010cd33de4c wl1251-blacklist +11341461c487b3d797728e5bd0883e659b8440a486d2f0bce008403da517582ba706f6ac89ee4a44217078a5e2d71c3a0b3d79c1189f83a431edc4069eddac10 calibrate-wl1251 " diff --git a/device/community/wl1251-cal/calibrate-wl1251 b/device/community/wl1251-cal/calibrate-wl1251 index 82533a138..336456ceb 100644 --- a/device/community/wl1251-cal/calibrate-wl1251 +++ b/device/community/wl1251-cal/calibrate-wl1251 @@ -5,6 +5,10 @@ if [ -e /in-pmbootstrap ]; then exit 0 fi -echo "Updating wl1251 calibration data.." +# Alpine now ships compressed versions of the firmware. In order for wl1251-cal +# to find the uncompressed file name, create it manually +touch /lib/firmware/ti-connectivity/wl1251-nvs.bin + +echo "Extracting and writing wl1251 calibration data.." wl1251-cal --nvs-loading=/dev/null --nvs-push-data=/lib/firmware/ti-connectivity/wl1251-nvs.bin echo "Done" diff --git a/device/community/wl1251-cal/wl1251-blacklist b/device/community/wl1251-cal/wl1251-blacklist new file mode 100644 index 000000000..c2b6864ef --- /dev/null +++ b/device/community/wl1251-cal/wl1251-blacklist @@ -0,0 +1,3 @@ +# Ensure wl1251 does not load until wl1251-cal has finished running +blacklist wl1251_spi +blacklist wl1251 diff --git a/device/community/wl1251-cal/wl1251-cal-openrc.post-install b/device/community/wl1251-cal/wl1251-cal-openrc.post-install index a919e0f2b..f7abc0cdc 100644 --- a/device/community/wl1251-cal/wl1251-cal-openrc.post-install +++ b/device/community/wl1251-cal/wl1251-cal-openrc.post-install @@ -1,3 +1,3 @@ #!/bin/sh -rc-update add wl1251-cal boot +rc-update add wl1251-cal sysinit diff --git a/device/community/wl1251-cal/wl1251-cal.initd b/device/community/wl1251-cal/wl1251-cal.initd index c385f6521..0f5b781e9 100644 --- a/device/community/wl1251-cal/wl1251-cal.initd +++ b/device/community/wl1251-cal/wl1251-cal.initd @@ -3,12 +3,13 @@ description="Update wl1251 calibration data" depend() { - before modules - after localmount + need localmount } start() { calibrate-wl1251 + # Probe wl1251 once the nvs is ready + modprobe wl1251_spi eend $? } diff --git a/device/community/wl1251-cal/wl1251-cal.trigger b/device/community/wl1251-cal/wl1251-cal.trigger index 65f7cbd5e..2940508ed 100644 --- a/device/community/wl1251-cal/wl1251-cal.trigger +++ b/device/community/wl1251-cal/wl1251-cal.trigger @@ -1,5 +1,5 @@ #!/bin/sh -[ -f /lib/firmware/ti-connectivity/wl1251-nvs.bin ] && calibrate-wl1251 +[ -d /lib/firmware/ti-connectivity ] && calibrate-wl1251 exit 0