[OpenWrt-Devel] [PATCH 2/3] ipq-wifi: select board-2.bin at runtime
Thomas Hebb
tommyhebb at gmail.com
Wed Jan 10 05:15:09 EST 2018
Currently, we solve the problem of different IPQ4019 boards needing
different sets of Wi-Fi calibration data (board-2.bin) by using an
ipq-wifi-* package to overwrite board-2.bin in the filesystem. This
presents a problem when we need the same image to support multiple
boards, as we do for the upcoming Netgear EX6100v2 and EX6150v2
support.
To solve this, re-architect the board-2.bin selection mechanism:
Instead of overwriting board-2.bin, install each version with a name
that indicates the board it's for: for example, board-2-nbg6617.bin.
Add a hotplug script to select and symlink a board-specific file if
present and otherwise fall back to the QCA-provided file, which is
now installed as board-2-generic.bin.
Signed-off-by: Thomas Hebb <tommyhebb at gmail.com>
---
package/firmware/ath10k-firmware/Makefile | 42 +++++++++++++++++++++-
.../files/12-ath10k-dynamic-boarddata | 23 ++++++++++++
package/firmware/ipq-wifi/Makefile | 24 +++++--------
3 files changed, 73 insertions(+), 16 deletions(-)
create mode 100644 package/firmware/ath10k-firmware/files/12-ath10k-dynamic-boarddata
diff --git a/package/firmware/ath10k-firmware/Makefile b/package/firmware/ath10k-firmware/Makefile
index 1c6f4dfb7f..99e0551a25 100644
--- a/package/firmware/ath10k-firmware/Makefile
+++ b/package/firmware/ath10k-firmware/Makefile
@@ -193,6 +193,7 @@ $(Package/ath10k-firmware-default)
TITLE:=ath10k firmware for IPQ/QCA4019 devices
SECTION:=firmware
CATEGORY:=Firmware
+ DEPENDS:=+ath10k-dynamic-boarddata
endef
define Package/ath10k-firmware-qca6174
@@ -221,7 +222,7 @@ define Package/ath10k-firmware-qca4019/install
$(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA4019/hw1.0
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/QCA4019/hw1.0/board-2.bin \
- $(1)/lib/firmware/ath10k/QCA4019/hw1.0/
+ $(1)/lib/firmware/ath10k/QCA4019/hw1.0/board-2-generic.bin
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/QCA4019/hw1.0/3.2.1/firmware-5.bin_10.4-3.2.1-00058 \
$(1)/lib/firmware/ath10k/QCA4019/hw1.0/firmware-5.bin
@@ -341,6 +342,43 @@ define Package/ath10k-firmware-qca9888-ct/install
$(1)/lib/firmware/ath10k/QCA9888/hw2.0/firmware-5.bin
endef
+# We currently only support dynamic selection of board-2.bin for QCA4019.
+# To add support for another chip:
+#
+# 1. Change the relevant ath10k-firmware package to install board-2.bin
+# as board-2-generic.bin.
+# 2. Make that package depend on ath10k-dynamic-boarddata.
+# 3. Add the customized board-2.bin files to the ipq-wifi package, ensuring
+# that they are placed alongside board-2-generic.bin and are named
+# board-2-<board_name>.bin. On boot, the dynamic boarddata script will
+# select and symlink the correct file.
+
+define Package/ath10k-dynamic-boarddata
+ SECTION:=firmware
+ CATEGORY:=Firmware
+ TITLE:=hotplug script to dynamically select ath10k board-2.bin
+endef
+
+define Package/ath10k-dynamic-boarddata/description
+Several IPQ4019 boards require custom Wi-Fi calibration data but reuse BMI
+IDs that are in QCA's stock calibration data. As such, it's not possible to
+store calibration for all of these boards in a single board-2.bin, as the
+ath10k driver expects. This package provides a hotplug script that
+determines the board we're running on and symlinks board-2.bin to the
+appropriate version at runtime.
+
+Note that this package does not provide any board-specific versions of
+board-2.bin. In order for it to be useful, you must also include one or
+more of the ipq-wifi-* packages.
+endef
+
+define Package/ath10k-dynamic-boarddata/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/firmware
+ $(INSTALL_DATA) \
+ ./files/12-ath10k-dynamic-boarddata \
+ $(1)/etc/hotplug.d/firmware/
+endef
+
$(eval $(call BuildPackage,ath10k-firmware-qca9887))
$(eval $(call BuildPackage,ath10k-firmware-qca9888))
$(eval $(call BuildPackage,ath10k-firmware-qca988x))
@@ -354,3 +392,5 @@ $(eval $(call BuildPackage,ath10k-firmware-qca988x-ct))
$(eval $(call BuildPackage,ath10k-firmware-qca99x0-ct))
$(eval $(call BuildPackage,ath10k-firmware-qca9984-ct))
$(eval $(call BuildPackage,ath10k-firmware-qca9888-ct))
+
+$(eval $(call BuildPackage,ath10k-dynamic-boarddata))
diff --git a/package/firmware/ath10k-firmware/files/12-ath10k-dynamic-boarddata b/package/firmware/ath10k-firmware/files/12-ath10k-dynamic-boarddata
new file mode 100644
index 0000000000..f9adedf0fc
--- /dev/null
+++ b/package/firmware/ath10k-firmware/files/12-ath10k-dynamic-boarddata
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+log() {
+ logger -t ath10k-dynamic-boarddata "$@"
+}
+
+dest="/lib/firmware/$FIRMWARE"
+
+[ -e "$dest" ] && exit 0
+echo "$dest" | grep -qx "/lib/firmware/ath10k/.*/board-2.bin" || exit 0
+
+dir="$(dirname "$dest")"
+board="$(board_name)"
+
+if [ -e "$dir/board-2-$board.bin" ] ; then
+ log "Selecting customized board-2.bin for board \"$board\""
+ ln -s "$dir/board-2-$board.bin" "$dest"
+elif [ -e "$dir/board-2-generic.bin" ] ; then
+ log "Selecting generic board-2.bin"
+ ln -s "$dir/board-2-generic.bin" "$dest"
+else
+ log -p user.err "ERROR: No board-2.bin variant present. QCA Wi-Fi will not work."
+fi
diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile
index aec8bf27c2..f2b705e13a 100644
--- a/package/firmware/ipq-wifi/Makefile
+++ b/package/firmware/ipq-wifi/Makefile
@@ -20,35 +20,29 @@ define Package/ipq-wifi-default
SUBMENU:=ath10k IPQ4019 Boarddata
SECTION:=firmware
CATEGORY:=Firmware
- DEPENDS:=@TARGET_ipq806x +ath10k-firmware-qca4019
+ DEPENDS:=@TARGET_ipq806x +ath10k-firmware-qca4019 +ath10k-dynamic-boarddata
TITLE:=Custom Board
endef
define generate-ipq-wifi-package
define Package/ipq-wifi-$(1)
$(call Package/ipq-wifi-default)
- TITLE:=Board for $(3)
- CONFLICTS:=$(PREV_BOARD)
+ TITLE:=Board for $(2)
endef
define Package/ipq-wifi-$(1)/description
-This device custom package board-2.bin overwrites the board-2.bin
-file which is supplied by the ath10k-firmware-qca4019 package.
-
-This is package is only necessary for the $(3).
-Don't install it for any other device!
+Device-specific board-2.bin file for the $(2) that can be selected by
+ath10k-dynamic-boarddata.
endef
- define Package/ipq-wifi-$(1)/install-overlay
+ define Package/ipq-wifi-$(1)/install
$(INSTALL_DIR) $$(1)/lib/firmware/ath10k/QCA4019/hw1.0
- $(INSTALL_DATA) ./$(2) $$(1)/lib/firmware/ath10k/QCA4019/hw1.0/board-2.bin
+ $(INSTALL_DATA) ./board-$(1).bin $$(1)/lib/firmware/ath10k/QCA4019/hw1.0/board-2-$(1).bin
endef
-
- PREV_BOARD+=ipq-wifi-$(1)
endef
-$(eval $(call generate-ipq-wifi-package,rt-ac58u,board-rt-ac58u.bin,ASUS RT-AC58U/RT-ACRH13))
-$(eval $(call generate-ipq-wifi-package,fritz4040,board-fritz4040.bin,AVM FRITZBox 4040))
-$(eval $(call generate-ipq-wifi-package,nbg6617,board-nbg6617.bin,ZyXEL NBG6617))
+$(eval $(call generate-ipq-wifi-package,rt-ac58u,ASUS RT-AC58U/RT-ACRH13))
+$(eval $(call generate-ipq-wifi-package,fritz4040,AVM FRITZBox 4040))
+$(eval $(call generate-ipq-wifi-package,nbg6617,ZyXEL NBG6617))
$(foreach PACKAGE,$(ALLWIFIPACKAGES),$(eval $(call BuildPackage,$(PACKAGE))))
--
2.15.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list