From patchwork Wed Jan 10 10:15:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 858318 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R4T5yz1I"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zGrtV0Vc1z9s7s for ; Thu, 11 Jan 2018 01:26:57 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id EB652B80C35; Wed, 10 Jan 2018 15:26:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Wed, 10 Jan 2018 15:26:53 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id A7B87B80C1F for ; Wed, 10 Jan 2018 15:26:51 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. - helo: .mail-qk0-f194.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 10 Jan 2018 15:26:51 +0100 (CET) Received: by mail-qk0-f194.google.com with SMTP id r8so18770022qke.6 for ; Wed, 10 Jan 2018 06:26:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8cGb/G54yuIiXHaT5RU1wZyPg8hZ/lOoavpODV7LQlw=; b=R4T5yz1IpdP4CvEBXj0ixtZMWIc/eKoiwsYzlkvGgZGkstJ8/a/QcYKRbe7anTtKES 3zBImRjMMzDhDhoUe9jRGptlnhQDHvnmootB8ly/kt8RzBiwtI5cS8UdZPoqW88+0BQr Q+Yyodz6tJenKsRtrZ+CroTkONOo1NZV7MZHSpIk+0acZBZDgPH1pmo14HuCn8Z0mZ4y 3tTqNCvyCswWqliyckeWhsXV7OusRqsXrywmnFyZe7TgtpTFZQPd9jbCs2jRVfc3Pb95 qIWOJjHxkw1RFVIKistnN8w0+IL24jC72IGqWC/0CkP817857cfNEQWg2CAGJIbbg10B wfKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8cGb/G54yuIiXHaT5RU1wZyPg8hZ/lOoavpODV7LQlw=; b=q923Yy4W2QeN0wQlX+HkgF5Y28E/3fT9wqdXrr4eah8YlaxuTEd2G/bfF2JfU+MJbd Q7W5BA6uwhUMjTGwjzgrxpGOqd7Az74D/U2trN+fG9XCz9c8NOL2cIu7USI+M+f0O83N 0X0yMXuj+B2P2TOS8Eu9ye95Pwei6f/qZ02JNaBBp+xHCmHfBCn6yssbk6810NKOUEr5 zIH+cFgX5ZU5+aVsYEDxbCJO8lCqMoPEWQuEyHPgwasoR4CuHmU3LrfmD16R5YuvPUBW PkGQHOAcuegBD+fR4A2aj2j3n0dEPtFS/zVrE12fVj6hDT/enEvc956re2zCYwsRBHsX 6IBA== X-Gm-Message-State: AKwxytdrVWf1xsZ7gGKqFHefLK0t3NIKH4j9g7COj0JBrb6F0OnN6U2Y 3ZvmZ7+NA+WcXvFjw4trl7ToJFH9Pdc= X-Google-Smtp-Source: ACJfBouavckDmnQr7DT5kIj+7UxYABQbvIfhJo+XayiLazal+9GTC2sdGxNwZDd4Kes96lxt0/oseQ== X-Received: by 10.55.197.20 with SMTP id p20mr23066497qki.337.1515579317234; Wed, 10 Jan 2018 02:15:17 -0800 (PST) Received: from stingray.lan ([2601:18d:4600:e68c:3252:cbff:fe84:d255]) by smtp.gmail.com with ESMTPSA id u67sm4673826qkd.8.2018.01.10.02.15.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 02:15:16 -0800 (PST) From: Thomas Hebb To: John Crispin , Felix Fietkau Date: Wed, 10 Jan 2018 05:15:09 -0500 Message-Id: X-Mailer: git-send-email 2.15.1 In-Reply-To: References: In-Reply-To: References: Subject: [OpenWrt-Devel] [PATCH 2/3] ipq-wifi: select board-2.bin at runtime X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org, Thomas Hebb MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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 --- 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-.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))))