From patchwork Sun Sep 22 09:57:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="M4xtjyWh"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjbf34rjz9s7T for ; Sun, 22 Sep 2019 19:59:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YCarKY2h7+3vfj7xJKLbqO899sTN5p0UdJoMDDBX1R8=; b=M4xtjyWhE7fD6c88WefQcgQVIO GXsiBbc1hmp+Q06lf+a6hzP0mkpglNGVQFz4aets+u8N8UyzIiqOaMIsP/hu1rFXZAlG1CgKdTNKQ 7JLIBpVZuyxIjvu21nQiNgunzGEzuuSwh1Np6hBBhKGPFY/kO1m6pfSTV8xxyg2E7YCeo/5uUDdE0 IRCXXwx1hjIrEJpSwpr6ArusQSQcBNaLmkMMaEAGtz7t+ZmIPCtStVU0xuqWoQlXG0NQx0yBVDmoX NsAF532z2ye2tJi7xD3d1mmeWGJVtsOguPxuG0TNPz+G10J3s/tXsIaWwZoAzo8RFCOOCGqSOhwCk FPdc68uA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iByeH-0004Wm-Ks; Sun, 22 Sep 2019 09:59:21 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycU-0003VJ-S3 for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:34 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mft3h-1hjGVn39Ef-00gFrq for ; Sun, 22 Sep 2019 11:57:22 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:11 +0200 Message-Id: <20190922095717.1714-2-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:IiaRbyCpgNLa5l4bzUxCbcMJwW0rrCw4iQKTGRknaJI0UEm4gXn mx4PueZrkucIPzczdp+I83m/N+h0b92LuBdqU5s6B2DcD3uI24irDv2b7uxPl/SzYzJOkis ZFOZHVg/Ny3fGAjThU08tv9AiZmENhx+Kqw4KWfT80OPd9/lim/3KblWKaJK/iZrUTmue5+ 7pB5noup+asW/bfSuFSDg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:mQ0irrmj1a8=:YDHjbCPAr0b2DY0IboJtAj +gjHrqslQbpxqseKDQlZGKsimTOmEhOtabFsVCPLAyM7eGSzvjFFfpUGL84dAELAja3mmYRML VWkA/m1rANNtUdF7Vm3PUQkCD4Z8Fe9RuW9jAmJRzPF3+zt6vqhTlIBg/mxLFeHjv0YNLwhgq d7J3HiJByY3aFIscQHLDI07dA3J2K9YAlw4FwEmbOqhdm9Yh15I9LD/bf/fzdti1AbaSWFpBQ ebZv8Z849bw7aXWTWMsB3RmU0UCmPT1f2mM73hMX76HW9spqFifrihQB6VZtMKEPEmols7nbO WFJ7L6AI8WZk+Li+xWh7VMH5ThpiQwrRJ7KpehvfUV4HfccJtxyv7P9vXXAz0IQM8Qfs9VyqX 60J+paOgEmcENxyjf4r3loWKYovnT3sugAYoNs6olLuMWz9+GuTCP6f9Niz11wbmjh0ADqtbo iDajNFl3Z8Rx6mrATaqVpNVAnj+WUypPFBcGBuJRdY7862ik5pdvQQkE9MqNpzU2IzSex0els erTPPzORRqQ8vS+/5HkiIprEe1RMmDWtqaqprXhPMMQVcCPKBjnap1P5t2HLfE0TAU40QSIrl ckLDh3pj21G7DKjBgX8sLPwRUafmhBtcrxCsb+qb2gd1fcY/iMgHH+5OvRk0u7tFMLbkD+46e SxnIyONqhasp9j9wBIgOKYfxjCaCk9rTyaBdNJ6GsT1tvXCPNROTqNGj7r1zJ4NMRzALDbsdp RlhnHxCSPfCkdLHnXr6xzk47QlqEpcSPNnVfEsltcNC+os84ghKJqYxGYTpyAr7m1z6ZbZBTD WzjXNI8F5zdaTZDdg8921yCsSv4kqA1aNIVPsKNS/UjqG2ZQvLOwAyDtpde0mn94doyAnKJNx d3olVTEm6SAPLK+jizzh7QzWBh220Y1OzSJfs9VRY= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025731_336790_D61FE799 X-CRM114-Status: GOOD ( 10.42 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.133 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH v2 1/7] treewide: fix hex2dec conversion for MAC address checksum offset X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org If chksum_offset is converted by $(($...)) at the beginning, the check [ -n "$chksum_offset" ] will always return true, as the conversion yields "0" for an empty argument, and [ -n "0" ] is true. With this patch, the variable is not converted before the check, but only when it's used in dd. No conversion is done for use in hexdump, as this can deal with hex value offsets. Fixes: b133e466b08e ("treewide: convert WiFi caldata size and offset to hexadecimal") Signed-off-by: Adrian Schmutzler --- This is also sent as separate patch, as it is a fix, while this patchset is an enhancement. Since this patchset however depends on the fix, it was included here, as this is easier as describing the dependency. --- .../ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom | 4 ++-- .../lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 25d82a5f0d..7911d0aa1e 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -60,7 +60,7 @@ xor() { ath9k_patch_fw_mac() { local mac=$1 local mac_offset=$(($2)) - local chksum_offset=$(($3)) + local chksum_offset=$3 local xor_mac local xor_fw_mac local xor_fw_chksum @@ -78,7 +78,7 @@ ath9k_patch_fw_mac() { xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 + dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$(($chksum_offset)) count=2 } macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1 diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 82f6885221..6f133c82a7 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -103,7 +103,7 @@ ath9k_patch_fw_mac_crc() { ath9k_patch_fw_mac() { local mac=$1 local mac_offset=$(($2)) - local chksum_offset=$(($3)) + local chksum_offset=$3 local xor_mac local xor_fw_mac local xor_fw_chksum @@ -121,7 +121,7 @@ ath9k_patch_fw_mac() { xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 + dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$(($chksum_offset)) count=2 } macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6 From patchwork Sun Sep 22 09:57:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165732 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E0VccBXq"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjZP2q7Pz9s7T for ; Sun, 22 Sep 2019 19:58:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qmMQ7G7cOCXCwLPLfBQy7yjygfF22fLnHvjwp0E0P2Q=; b=E0VccBXqroSBXaYW0yslLYXnMp MjWmNaLoq9TL4HCHnhsirkP+CThbGIY+0Ff8qUasmKes5V7+uzj1bWM9PyAYqBoRK5ILHjpFhnvCh nboZZkJ5VdFQWJNttOdkRYME1ZFWNeHOSPlffIb8N9kwnjYK+2jo1figs0b4rT354opbBcApHYNnu wtutNT8oL/SdF3XuHgULPCP8BPostz10WhJ+ImTUN8NFocEyjLGaN8lAN75cs1AMRy6jn1aZVUYhU 6v5jhXliAsEjeA+oSGYS53fa4bCfi5qeRTILiPAdj2YJHbn04F27zqNcDGlzNQWhhP1bbcRWycEzR B8AGnjBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iByd2-0003fb-4s; Sun, 22 Sep 2019 09:58:04 +0000 Received: from mout.kundenserver.de ([212.227.126.134]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycV-0003VU-3M for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:33 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MC0HF-1iLdfj3jEj-00CPDO for ; Sun, 22 Sep 2019 11:57:22 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:12 +0200 Message-Id: <20190922095717.1714-3-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:XoNNFvJXXgtQbFs+tqf4CUPh1nqJuIBqZYepqXGX7HfGg5G1to3 0zppKnOCNodim7UvjixdWcf29LGitAMW6IMgWu4rNzm6MNZo5nC6j7xYc1pmltRoYqGUbic Zy5P68muzu21q8NoweLaEOrSu4ChPyP7vaHdVULB/pu3JLXte+OjY8rYwYFI2Dv7gIPxaa3 HzaNj9FlHqf7Gs39Bj0MQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:wXuK20J2OrM=:ziz9je7m6rFDw25eLZaqxx 69+7lEsxw6uWxYsG1AYZDck6Jtnn4GBEWfmtIBZCNSda+Sk6vkcJn5CJ/SM60cEJI9rOXabcu ouZrX0szCtFPqIzc/bFlSKGUD6L9545dSkr+Wequrma1bu3vKPm7NU6C0cUSXidhSqciJoJrV zDcBUsoZM21Dpqb1LrAjxkAo7xk6wulXZo+aSPuNoWB4IKMQMO/7RM8tG554M3EUPnvfZRn16 E++mzR9yibojL9TXNqRo9cgH9ZkxMni8RdCrm68TsaC7kdyPvLlTWVL9rmFfrCyetUjMn0Yuq f5wY8msNvU+KJWNFnt0QnBA4vKbOGkcmqyJgUnsa4fTS5/OQZeaVISrokVTYx+TTVPWmmfTUg flTElPBKfpn3flV2etprBiv0l1BI+Tj4a3CUt3lmiec9sugq7EDe0eSTFFdtyEmtyxBBTxknt xZCO3Mw8p4KS1HSFotXMkBBwn+ahRqieyxHTz7gVABMjSutR79UgjNCL+ale/d1C88gpDnqUF wUjsXydFeCQViOXZRljNznY8fvcathbDi3U9/EksX22xtAO15aFyC2y0HSTn7J/5MUdD54yBE NjkzH23wJBf9c6rsta6czcfNwK6bm4mTiTCGadawMLjBdT8VwoXW3uSvPGh16PBSfbsGVu9xm 9VsfbRILn5VFJ5Uq6fmoaAdFwXCnAb5xvV2meFZjdQ/eejTor94xAKewpMmFEXL2LH5OOs/vy eHhgfVTLto95ilt7eEXnaTi3AM63myfwCVVZ3Vdy4mVn5QtJy42SiVSNgoMAUAVpLtVhVYoXL c8QhN13ydL6RIrE/NPiB2wrCd1rXvR/kUx6tY1/kedqLj4co52jMKB6rnW2kOosJA7QpYW3eu EQvDgOyrDG2MoP4FYOlh8AZVHqA8iIKV4wc3wHTD4= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025731_434188_3EF941DA X-CRM114-Status: UNSURE ( 7.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.134 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH v2 2/7] base-files: move xor() from caldata extraction to functions.sh X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The xor() function is defined in each of the caldata extraction scripts for several targets. Move it to functions.sh to reduce duplicate code. Signed-off-by: Adrian Schmutzler --- v2: rebase --- package/base-files/files/lib/functions.sh | 16 ++++++++++++++++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 15 --------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 18 +----------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 17 +---------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 17 +---------------- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 16 ---------------- 6 files changed, 19 insertions(+), 80 deletions(-) diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 860fc04510..81176431d1 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -17,6 +17,22 @@ NO_EXPORT=1 LOAD_STATE=1 LIST_SEP=" " +# xor multiple hex values of the same length +xor() { + local val + local ret="0x$1" + local retlen=${#1} + + shift + while [ -n "$1" ]; do + val="0x$1" + ret=$((ret ^ val)) + shift + done + + printf "%0${retlen}x" "$ret" +} + append() { local var="$1" local value="$2" diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 7911d0aa1e..0cdd783315 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -42,21 +42,6 @@ ath9k_eeprom_extract_reverse() { printf "%b" "$caldata" > /lib/firmware/$FIRMWARE } -xor() { - local val - local ret="0x$1" - local retlen=${#1} - - shift - while [ -n "$1" ]; do - val="0x$1" - ret=$((ret ^ val)) - shift - done - - printf "%0${retlen}x" "$ret" -} - ath9k_patch_fw_mac() { local mac=$1 local mac_offset=$(($2)) diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 446b729a2b..d34146121a 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,23 +1,8 @@ #!/bin/sh +. /lib/functions.sh . /lib/functions/k2t.sh -# xor multiple hex values of the same length -xor() { - local val - local ret="0x$1" - local retlen=${#1} - - shift - while [ -n "$1" ]; do - val="0x$1" - ret=$((ret ^ val)) - shift - done - - printf "%0${retlen}x" "$ret" -} - ath10kcal_die() { echo "ath10cal: " "$*" exit 1 @@ -79,7 +64,6 @@ ath10kcal_patch_mac_crc() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh . /lib/functions/system.sh board=$(board_name) diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index be57646128..dfb0a0cf76 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,20 +1,6 @@ #!/bin/sh -# xor multiple hex values of the same length -xor() { - local val - local ret="0x$1" - local retlen=${#1} - - shift - while [ -n "$1" ]; do - val="0x$1" - ret=$((ret ^ val)) - shift - done - - printf "%0${retlen}x" "$ret" -} +. /lib/functions.sh ath10kcal_die() { echo "ath10cal: " "$*" @@ -88,7 +74,6 @@ ath10kcal_is_caldata_valid() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh . /lib/functions/system.sh board=$(board_name) diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index bdc36070f2..c0fb1db16d 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,20 +1,6 @@ #!/bin/sh -# xor multiple hex values of the same length -xor() { - local val - local ret="0x$1" - local retlen=${#1} - - shift - while [ -n "$1" ]; do - val="0x$1" - ret=$((ret ^ val)) - shift - done - - printf "%0${retlen}x" "$ret" -} +. /lib/functions.sh ath10kcal_die() { echo "ath10cal: " "$*" @@ -71,7 +57,6 @@ ath10kcal_patch_mac_crc() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh . /lib/functions/system.sh board=$(board_name) diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 6f133c82a7..2c4a5a1799 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -7,22 +7,6 @@ . /lib/functions/system.sh . /lib/upgrade/nand.sh -# xor multiple hex values of the same length -xor() { - local val - local ret="0x$1" - local retlen=${#1} - - shift - while [ -n "$1" ]; do - val="0x$1" - ret=$((ret ^ val)) - shift - done - - printf "%0${retlen}x" "$ret" -} - ath9k_eeprom_die() { echo "ath9k eeprom: $*" exit 1 From patchwork Sun Sep 22 09:57:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165738 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dkaMjU1u"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjd54Wqcz9s7T for ; Sun, 22 Sep 2019 20:00:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uikaevGC2UU5SOk5lbW87wgNJLcCIWy9jA4bivkEhEU=; b=dkaMjU1uzsypPULO4n96auHYna SZQZzKksNJ5JdBIQHYMj00JMTL7qltIK0dVupsE6f/eMU+KSBUe3dXVbWTGDaejm2/Bxcbka0jcJj PuBltMLqO7J1/y+AtcIGP2Z9hQowjPkFN9x2tspzspQs7GA+sj10evkWHGCDMPvwLd5bOhq9/fUCL ikiyY7NWGQHfxpOqkZoLb2YLSGc6z10/pT2Ej8Z2srGeCT1Gh5yS6SSv+kA2S+ybKyzFoE5VZML9h QnwhIY4Hh063sSZOH9I016khMCIo7i/p2Ly6vyroKQ3IoA4U2seEs4GL9+4V9ob2P/tk1RD1haWqB KEnCi+lQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iByfN-0006cT-5n; Sun, 22 Sep 2019 10:00:29 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycU-0003VK-S2 for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:36 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTw02-1ibnF308Ty-00R2Bp for ; Sun, 22 Sep 2019 11:57:23 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:13 +0200 Message-Id: <20190922095717.1714-4-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:tDwxwFV0uopI9cooBRjOw1qsRAX/yvYPIRVVZuKGZ7MeWNunYh5 oNidgbIBhVJml0YUa3Ptbj5a8wT+T7DnFD8wgnGOCzwFljONdN11ISzuPnTHr00/cEMYyvU aveA6eU1HKTcHAu+XUrj9lg9ImfkqOONpn3yXgKFbU1B1fb1NwHu3QC5kS2O9b6XiWXnwHq 4p4VzzmomaEkBoJ9oE9Gg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Fp2YcitVosg=:/lwMqjY4s5ZKfhV8LKOAEl WUHaTy9tSWqkTcFHVMPJQUO+QpVALZnb4Vp9i7uJBXEEV9wqvQzKXtc5qudz/T4obpFTAT/jG 00jqMXu1MvX1ocn9DsnxLdf1pugsrxF4Dcyk+Erw4knzbn9hKcBADU2SYQvmEJB2F0NhXDJAX mjf1mwrBsH2JxjnvfPDFAOWqagm4EReF2P9Z8FQ58SK91fkZb1xFb4BXToLUCnvXV8WDGmyVt 41FFGSOmr7jpUdVryHpSecuuwagQ6rZFYPW8tTE0T6UD8YV5YO1ZNtWhgM1gsc0syVmbaSxhO gNAt0cAcST2Qgsph0PR5mhP+bhKHe8jWzmkogXyY9hnshQDrdxdokwDDFiZTyliTe+OHtiCKO UYmC4BtVueBFt6Y74SQ8oKJejNg64F6tfP4+KrtpgVl8qbY17hPYtqWHAgSa2pLSxyHRIwLWT asE3Lxxed/3W2vnEAv8ACelC6+kCr5tFC0JMfHEGsKDD4lVnNHHdU/zxM1aIzsRmasiZiUjVj +4YIvirFH2ptFpqBzboHqYc/7K3jtjBX1PnjvmGyg2k07w7886cQ+xKRV/CmteGQjH3TQ0x44 r+BwVzRorR0WMe33WzlPXQLGQfYizMSswnuGVrx+QU7UqVbPESR9dznjT7XBI5CETkZlJOzQ3 YdOKnWrGtjIu4O2LVE2d05tTvkwM7ByDLm7D3qbvxJ8L0tDE8xtnUL/0aOPmmqKzGFbLbAAI2 kIrVJ8u8xiCzDbYiGlUEMAZ/0pCKufxjUSdQ+WU9p/KVK4i6NpKfQ5Rsq2H5pE19lX/js4eNs TcVlldXhPdyJR7KREFTlhA4p+SUAEANlrHLSeq0zfSfn5R0ZrcP3PdrvIKwq9MUNwohUhkohh pkHau7olCXtMlufBl41KeRBedDV45f1Mvlc+ib4jU= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025731_355190_85204066 X-CRM114-Status: GOOD ( 15.46 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.133 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH v2 3/7] treewide: move calibration data extraction function to library X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This moves the almost identical calibration data extraction functions present multiple times in several targets to a single library file /lib/functions/caldata.sh. Functions are renamed with more generic names to merge different variants that only differ in their names. Most of the targets used find_mtd_chardev, while some used find_mtd_part inside the extraction code. To merge them, the more abundant version with find_mtd_chardev is used in the common code. Signed-off-by: Adrian Schmutzler --- Open questions: 1. I tested find_mtd_chardev and find_mtd_part on mpc85xx, both gave the same result (one uses /dev/mtd*, the other one uses /dev/mtdblock*). Is there any difference or advantage of one over the other in this use-case? 2. For mpc85xx, there is a chained command with "dd if=... | dd of..." used for caldata extraction. I'm a bit surprised about the use of $count and $offset there and would be glad if someone had a look. v2: rebased --- .../base-files/files/lib/functions/caldata.sh | 75 +++++++++++++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 49 ++------- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 90 +++++----------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 84 +++++---------- .../etc/hotplug.d/firmware/10-rt2x00-eeprom | 27 +---- .../etc/hotplug.d/firmware/11-ath10k-caldata | 101 +++++------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 62 +++-------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 28 +---- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 36 ++----- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 24 ++--- .../etc/hotplug.d/firmware/10-rt2x00-eeprom | 37 ++----- 11 files changed, 207 insertions(+), 406 deletions(-) create mode 100644 package/base-files/files/lib/functions/caldata.sh diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh new file mode 100644 index 0000000000..f2a306675f --- /dev/null +++ b/package/base-files/files/lib/functions/caldata.sh @@ -0,0 +1,75 @@ +# Copyright (C) 2019 OpenWrt.org + +. /lib/functions.sh +. /lib/functions/system.sh + +caldata_die() { + echo "caldata: " "$*" + exit 1 +} + +caldata_extract() { + local part=$1 + local offset=$(($2)) + local count=$(($3)) + local mtd + + mtd=$(find_mtd_chardev $part) + [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part" + + dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ + caldata_die "failed to extract calibration data from $mtd" +} + +caldata_extract_ubi() { + local part=$1 + local offset=$(($2)) + local count=$(($3)) + local ubidev + local ubi + + . /lib/upgrade/nand.sh + + ubidev=$(nand_find_ubi $CI_UBIPART) + ubi=$(nand_find_volume $ubidev $part) + [ -n "$ubi" ] || caldata_die "no UBI volume found for $part" + + dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ + caldata_die "failed to extract calibration data from $ubi" +} + +caldata_extract_reverse() { + local part=$1 + local offset=$2 + local count=$(($3)) + local mtd + local reversed + local caldata + + mtd=$(find_mtd_chardev "$part") + reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd) + + for byte in $reversed; do + caldata="\x${byte}${caldata}" + done + + printf "%b" "$caldata" > /lib/firmware/$FIRMWARE +} + +caldata_from_file() { + local source=$1 + local offset=$(($2)) + local count=$(($3)) + + dd if=$source of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ + caldata_die "failed to extract calibration data from $source" +} + +caldata_valid() { + local expected="$1" + + magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE) + [[ "$magic" == "$expected" ]] + return $? +} + diff --git a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 272c084c99..07100b1856 100644 --- a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -2,42 +2,7 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh - -ath9k_eeprom_die() { - echo "ath9k eeprom: " "$*" - exit 1 -} - -ath9k_eeprom_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath9k_eeprom_die "no mtd device found for partition $part" - - dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath9k_eeprom_die "failed to extract from $mtd" -} - -ath9k_ubi_eeprom_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local ubidev=$(nand_find_ubi $CI_UBIPART) - local ubi - - ubi=$(nand_find_volume $ubidev $part) - [ -n "$ubi" ] || \ - ath9k_eeprom_die "no UBI volume found for $part" - - dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath9k_eeprom_die "failed to extract from $ubi" -} +. /lib/functions/caldata.sh ath9k_patch_firmware_mac() { local mac=$1 @@ -56,14 +21,14 @@ case "$FIRMWARE" in . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 0x5000 0x1000 + caldata_extract_ubi "caldata" 0x5000 0x1000 else - ath9k_eeprom_extract "wifi_data" 0x5000 0x1000 + caldata_extract "wifi_data" 0x5000 0x1000 ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0xc) fi ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; @@ -74,14 +39,14 @@ case "$FIRMWARE" in . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 0x1000 0x1000 + caldata_extract_ubi "caldata" 0x1000 0x1000 else - ath9k_eeprom_extract "wifi_data" 0x1000 0x1000 + caldata_extract "wifi_data" 0x1000 0x1000 ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0x0) fi ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 0cdd783315..5ec13efd3f 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -2,45 +2,7 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh - -ath9k_eeprom_die() { - echo "ath9k eeprom: " "$*" - exit 1 -} - -ath9k_eeprom_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath9k_eeprom_die "no mtd device found for partition $part" - - dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath9k_eeprom_die "failed to extract from $mtd" -} - -ath9k_eeprom_extract_reverse() { - local part=$1 - local offset=$2 - local count=$(($3)) - local mtd - local reversed - local caldata - - mtd=$(find_mtd_chardev "$part") - reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd) - - for byte in $reversed; do - caldata="\x${byte}${caldata}" - done - - printf "%b" "$caldata" > /lib/firmware/$FIRMWARE -} +. /lib/functions/caldata.sh ath9k_patch_fw_mac() { local mac=$1 @@ -83,11 +45,11 @@ case "$FIRMWARE" in "ath9k-eeprom-ahb-18100000.wmac.bin") case $board in avm,fritz4020) - ath9k_eeprom_extract_reverse "urlader" 0x1541 0x440 + caldata_extract_reverse "urlader" 0x1541 0x440 ;; dlink,dir-825-c1|\ dlink,dir-835-a1) - ath9k_eeprom_extract "art" 0x1000 0x440 + caldata_extract "art" 0x1000 0x440 ath9k_patch_fw_mac $(mtd_get_mac_text "mac" 0x4) 0x2 ;; dlink,dir-842-c1|\ @@ -96,11 +58,11 @@ case "$FIRMWARE" in dlink,dir-859-a1|\ nec,wg1200cr|\ wd,mynet-n750) - ath9k_eeprom_extract "art" 0x1000 0x440 + caldata_extract "art" 0x1000 0x440 ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2 ;; engenius,ecb1750) - ath9k_eeprom_extract "art" 0x1000 0x440 + caldata_extract "art" 0x1000 0x440 ath9k_patch_fw_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env "athaddr") +1) 0x2 ;; engenius,epg5000|\ @@ -108,39 +70,39 @@ case "$FIRMWARE" in iodata,wn-ac1600dgr|\ iodata,wn-ac1600dgr2|\ iodata,wn-ag300dgr) - ath9k_eeprom_extract "art" 0x1000 0x440 + caldata_extract "art" 0x1000 0x440 ath9k_patch_fw_mac $(mtd_get_mac_ascii u-boot-env ethaddr) 0x2 ;; nec,wg800hp) - ath9k_eeprom_extract "art" 0x1000 0x440 + caldata_extract "art" 0x1000 0x440 ath9k_patch_fw_mac $(mtd_get_mac_text board_data 0x680) 0x2 ;; qihoo,c301) - ath9k_eeprom_extract "radiocfg" 0x1000 0x440 + caldata_extract "radiocfg" 0x1000 0x440 ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; "ath9k-eeprom-pci-0000:00:00.0.bin") case $board in avm,fritz300e) - ath9k_eeprom_extract_reverse "urloader" 0x1541 0x440 + caldata_extract_reverse "urloader" 0x1541 0x440 ;; buffalo,whr-g301n|\ buffalo,wzr-hp-g302h-a1a0|\ tplink,tl-wr841-v5|\ tplink,tl-wr941-v4) - ath9k_eeprom_extract "art" 0x1000 0xeb8 + caldata_extract "art" 0x1000 0xeb8 ;; buffalo,wzr-hp-g450h) - ath9k_eeprom_extract "art" 0x1000 0x440 + caldata_extract "art" 0x1000 0x440 ;; dlink,dir-825-c1|\ dlink,dir-835-a1) - ath9k_eeprom_extract "art" 0x5000 0x440 + caldata_extract "art" 0x5000 0x440 ath9k_patch_fw_mac $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1) 0x2 ;; ocedo,raccoon|\ @@ -149,7 +111,7 @@ case "$FIRMWARE" in tplink,tl-wdr4300-v1|\ tplink,tl-wdr4900-v2|\ winchannel,wb2000) - ath9k_eeprom_extract "art" 0x5000 0x440 + caldata_extract "art" 0x5000 0x440 ;; netgear,wnr612-v2|\ on,n150r|\ @@ -167,24 +129,24 @@ case "$FIRMWARE" in ubnt,bullet-m|\ ubnt,nano-m|\ ubnt,rocket-m) - ath9k_eeprom_extract "art" 0x1000 0x1000 + caldata_extract "art" 0x1000 0x1000 ;; pqi,air-pen) - ath9k_eeprom_extract "art" 0x1000 0x7d2 + caldata_extract "art" 0x1000 0x7d2 ;; ubnt,unifi) - ath9k_eeprom_extract "art" 0x1000 0x800 + caldata_extract "art" 0x1000 0x800 ;; wd,mynet-n750) - ath9k_eeprom_extract "art" 0x5000 0x440 + caldata_extract "art" 0x5000 0x440 ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan5mac") 0x2 ;; wd,mynet-wifi-rangeextender) - ath9k_eeprom_extract "art" 0x1000 0x1000 + caldata_extract "art" 0x1000 0x1000 ath9k_patch_fw_mac $(nvram get wl0_hwaddr) "$mac" 0x2 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; @@ -195,14 +157,14 @@ case "$FIRMWARE" in netgear,wndr3700v2|\ netgear,wndr3800|\ netgear,wndr3800ch) - ath9k_eeprom_extract "art" 0x1000 0xeb8 + caldata_extract "art" 0x1000 0xeb8 ;; dlink,dir-825-b1) - ath9k_eeprom_extract "caldata" 0x1000 0xeb8 + caldata_extract "caldata" 0x1000 0xeb8 ath9k_patch_fw_mac_crc $(mtd_get_mac_text "caldata" 0xffa0) 0x20c ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; @@ -213,14 +175,14 @@ case "$FIRMWARE" in netgear,wndr3700v2|\ netgear,wndr3800|\ netgear,wndr3800ch) - ath9k_eeprom_extract "art" 0x5000 0xeb8 + caldata_extract "art" 0x5000 0xeb8 ;; dlink,dir-825-b1) - ath9k_eeprom_extract "caldata" 0x5000 0xeb8 + caldata_extract "caldata" 0x5000 0xeb8 ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 0xffb4) 1) 0x20c ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index d34146121a..30857e9c71 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,35 +1,9 @@ #!/bin/sh -. /lib/functions.sh -. /lib/functions/k2t.sh - -ath10kcal_die() { - echo "ath10cal: " "$*" - exit 1 -} - -ath10kcal_from_file() { - local source=$1 - local offset=$(($2)) - local count=$(($3)) - - dd if=$source of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath10kcal_die "failed to extract calibration data from $source" -} - -ath10kcal_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath10kcal_die "no mtd device found for partition $part" +[ -e /lib/firmware/$FIRMWARE ] && exit 0 - dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath10kcal_die "failed to extract calibration data from $mtd" -} +. /lib/functions/caldata.sh +. /lib/functions/k2t.sh ath10kcal_patch_mac() { local mac=$1 @@ -62,10 +36,6 @@ ath10kcal_patch_mac_crc() { } } -[ -e /lib/firmware/$FIRMWARE ] && exit 0 - -. /lib/functions/system.sh - board=$(board_name) case "$FIRMWARE" in @@ -74,7 +44,7 @@ case "$FIRMWARE" in comfast,cf-wr650ac-v1|\ comfast,cf-wr650ac-v2|\ yuncore,a770) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ;; devolo,dvl1200e|\ devolo,dvl1200i|\ @@ -82,54 +52,54 @@ case "$FIRMWARE" in devolo,dvl1750e|\ devolo,dvl1750i|\ devolo,dvl1750x) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x0) -1) ;; dlink,dir-859-a1) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac") ;; elecom,wrc-1750ghbk2-i) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ;; engenius,ecb1750) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr) ;; engenius,epg5000|\ iodata,wn-ac1167dgr|\ iodata,wn-ac1600dgr2) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) ;; engenius,ews511ap) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; glinet,gl-ar750|\ glinet,gl-ar750s) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) ;; glinet,gl-x750) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2) ;; nec,wg800hp) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac_crc $(mtd_get_mac_text board_data 0x880) ;; ocedo,koala|\ ocedo,ursus) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(mtd_get_mac_binary art 0xc) ;; openmesh,om5p-ac-v2) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; qihoo,c301) - ath10kcal_extract "radiocfg" 0x5000 0x844 + caldata_extract "radiocfg" 0x5000 0x844 ath10kcal_patch_mac_crc $(mtd_get_mac_ascii devdata wlan5mac) ;; tplink,archer-a7-v5|\ @@ -137,29 +107,29 @@ case "$FIRMWARE" in tplink,archer-c7-v4|\ tplink,archer-c7-v5|\ tplink,archer-c25-v1) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) -1) ;; tplink,archer-c5-v1|\ tplink,archer-c7-v2) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x1fc00) -1) ;; tplink,archer-d50-v1) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary romfile 0xf100) +2) ;; tplink,re350k-v1) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary config 0x10008) +2) ;; tplink,re355-v1|\ tplink,re450-v1) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; tplink,re450-v2) - ath10kcal_extract "art" 0x5000 0x844 + caldata_extract "art" 0x5000 0x844 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1) ;; ubnt,unifiac-lite|\ @@ -170,7 +140,7 @@ case "$FIRMWARE" in ubnt,nanostation-ac|\ ubnt,nanostation-ac-loco|\ ubnt,unifiac-pro) - ath10kcal_extract "EEPROM" 0x5000 0x844 + caldata_extract "EEPROM" 0x5000 0x844 ;; esac ;; @@ -180,18 +150,18 @@ case "$FIRMWARE" in dlink,dir-842-c2|\ dlink,dir-842-c3|\ nec,wg1200cr) - ath10kcal_extract "art" 0x5000 0x2f20 + caldata_extract "art" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_ascii devdata wlan5mac) ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; netgear,ex6400|\ netgear,ex7300) - ath10kcal_extract "caldata" 0x5000 0x2f20 + caldata_extract "caldata" 0x5000 0x2f20 ath10kcal_patch_mac $(mtd_get_mac_binary caldata 0xc) ;; phicomm,k2t) - ath10kcal_extract "art" 0x5000 0x2f20 + caldata_extract "art" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(k2t_get_mac "5g_mac") ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin @@ -202,7 +172,7 @@ case "$FIRMWARE" in tplink,archer-c60-v1|\ tplink,archer-c60-v2|\ tplink,archer-c6-v2) - ath10kcal_extract "art" 0x5000 0x2f20 + caldata_extract "art" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary mac 0x8) -1) ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin diff --git a/target/linux/brcm63xx/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom b/target/linux/brcm63xx/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom index 305d5feda5..2400eb998a 100644 --- a/target/linux/brcm63xx/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom +++ b/target/linux/brcm63xx/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom @@ -1,28 +1,9 @@ #!/bin/sh # Based on gabors ralink wisoc implementation. -rt2x00_eeprom_die() { - echo "rt2x00 eeprom: " "$*" - exit 1 -} - -rt2x00_eeprom_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_part $part) - [ -n "$mtd" ] || \ - rt2x00_eeprom_die "no mtd device found for partition $part" - - dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count || \ - rt2x00_eeprom_die "failed to extract from $mtd" -} - [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh +. /lib/functions/caldata.sh board=$(board_name) @@ -30,14 +11,14 @@ case "$FIRMWARE" in "rt2x00.eeprom" ) case $board in hg556a_c) - rt2x00_eeprom_extract "cal_data" 0x1fe00 0x200 + caldata_extract "cal_data" 0x1fe00 0x200 ;; hg622 |\ hg655b) - rt2x00_eeprom_extract "cal_data" 0x0 0x200 + caldata_extract "cal_data" 0x0 0x200 ;; *) - rt2x00_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index dfb0a0cf76..61597ea669 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,43 +1,8 @@ #!/bin/sh -. /lib/functions.sh - -ath10kcal_die() { - echo "ath10cal: " "$*" - exit 1 -} - -ath10kcal_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath10kcal_die "no mtd device found for partition $part" - - dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath10kcal_die "failed to extract calibration data from $mtd" -} - -ath10kcal_ubi_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local ubidev - local ubi - - . /lib/upgrade/nand.sh - - ubidev=$(nand_find_ubi $CI_UBIPART) - ubi=$(nand_find_volume $ubidev $part) - [ -n "$ubi" ] || \ - ath10kcal_die "no UBI volume found for $part" +[ -e /lib/firmware/$FIRMWARE ] && exit 0 - dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath10kcal_die "failed to extract from $ubi" -} +. /lib/functions/caldata.sh ath10kcal_patch_mac_crc() { local mac=$1 @@ -64,26 +29,14 @@ ath10kcal_patch_mac_crc() { dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 } -ath10kcal_is_caldata_valid() { - local expected="$1" - - magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE) - [[ "$magic" == "$expected" ]] - return $? -} - -[ -e /lib/firmware/$FIRMWARE ] && exit 0 - -. /lib/functions/system.sh - board=$(board_name) case "$FIRMWARE" in "ath10k/cal-pci-0000:01:00.0.bin") case "$board" in meraki,mr33) - ath10kcal_ubi_extract "ART" 0x9000 0x844 - ath10kcal_is_caldata_valid "4408" || ath10kcal_extract "ART" 0x9000 0x844 + caldata_extract_ubi "ART" 0x9000 0x844 + caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +1) ;; esac @@ -91,7 +44,7 @@ case "$FIRMWARE" in "ath10k/pre-cal-pci-0000:01:00.0.bin") case "$board" in asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 0x9000 0x2f20 + caldata_extract_ubi "Factory" 0x9000 0x2f20 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; @@ -104,12 +57,12 @@ case "$FIRMWARE" in /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") ;; linksys,ea8300) - ath10kcal_extract "ART" 0x9000 0x2f20 + caldata_extract "ART" 0x9000 0x2f20 # OEM assigns 4 sequential MACs ath10kcal_patch_mac_crc $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4)) ;; openmesh,a62) - ath10kcal_extract "0:ART" 0x9000 0x2f20 + caldata_extract "0:ART" 0x9000 0x2f20 ;; esac ;; @@ -120,14 +73,14 @@ case "$FIRMWARE" in glinet,gl-b1300 |\ linksys,ea6350v3 |\ qcom,ap-dk01.1-c1) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ;; asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 0x1000 0x2f20 + caldata_extract_ubi "Factory" 0x1000 0x2f20 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - ath10kcal_ubi_extract "Factory" 0x1000 0x2f20 + caldata_extract_ubi "Factory" 0x1000 0x2f20 ;; avm,fritzbox-4040) /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config") @@ -147,29 +100,29 @@ case "$FIRMWARE" in openmesh,a62 |\ qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) - ath10kcal_extract "0:ART" 0x1000 0x2f20 + caldata_extract "0:ART" 0x1000 0x2f20 ;; engenius,ens620ext) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +2) ;; linksys,ea8300) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2) ;; meraki,mr33) - ath10kcal_ubi_extract "ART" 0x1000 0x2f20 - ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract_ubi "ART" 0x1000 0x2f20 + caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +2) ;; netgear,ex6100v2 |\ netgear,ex6150v2) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0x0) ;; zyxel,nbg6617 |\ zyxel,wre6606) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; esac @@ -181,14 +134,14 @@ case "$FIRMWARE" in glinet,gl-b1300 |\ linksys,ea6350v3 |\ qcom,ap-dk01.1-c1) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ;; asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 0x5000 0x2f20 + caldata_extract_ubi "Factory" 0x5000 0x2f20 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - ath10kcal_ubi_extract "Factory" 0x5000 0x2f20 + caldata_extract_ubi "Factory" 0x5000 0x2f20 ;; avm,fritzbox-4040) /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config") @@ -208,29 +161,29 @@ case "$FIRMWARE" in openmesh,a62 |\ qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) - ath10kcal_extract "0:ART" 0x5000 0x2f20 + caldata_extract "0:ART" 0x5000 0x2f20 ;; engenius,ens620ext) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +3) ;; linksys,ea8300) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3) ;; meraki,mr33) - ath10kcal_ubi_extract "ART" 0x5000 0x2f20 - ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract_ubi "ART" 0x5000 0x2f20 + caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +3) ;; netgear,ex6100v2 |\ netgear,ex6150v2) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0xc) ;; zyxel,nbg6617 |\ zyxel,wre6606) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; esac diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index c0fb1db16d..12b76ec33f 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,34 +1,8 @@ #!/bin/sh -. /lib/functions.sh - -ath10kcal_die() { - echo "ath10cal: " "$*" - exit 1 -} - -ath10kcal_from_file() { - local source=$1 - local offset=$(($2)) - local count=$(($3)) - - dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ - ath10kcal_die "failed to extract calibration data from $source" -} - -ath10kcal_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath10kcal_die "no mtd device found for partition $part" +[ -e /lib/firmware/$FIRMWARE ] && exit 0 - dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ - ath10kcal_die "failed to extract calibration data from $mtd" -} +. /lib/functions/caldata.sh ath10kcal_patch_mac_crc() { local mac=$1 @@ -55,43 +29,39 @@ ath10kcal_patch_mac_crc() { dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 } -[ -e /lib/firmware/$FIRMWARE ] && exit 0 - -. /lib/functions/system.sh - board=$(board_name) case "$FIRMWARE" in "ath10k/pre-cal-pci-0000:01:00.0.bin") case $board in buffalo,wxr-2533dhp) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 0x1e) ;; linksys,ea8500) - ath10kcal_extract "art" 0x1000 0x2f20 + caldata_extract "art" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1) ;; nec,wg2600hp) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 0xc) +1) ;; netgear,d7800 |\ netgear,r7500v2 |\ netgear,r7800) - ath10kcal_extract "art" 0x1000 0x2f20 + caldata_extract "art" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x6) +1) ;; tplink,c2600) - ath10kcal_extract "radio" 0x1000 0x2f20 + caldata_extract "radio" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1) ;; tplink,vr2600v) - ath10kcal_extract "ART" 0x1000 0x2f20 + caldata_extract "ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1) ;; zyxel,nbg6817) - ath10kcal_extract "0:ART" 0x1000 0x2f20 + caldata_extract "0:ART" 0x1000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1) ;; esac @@ -99,33 +69,33 @@ case "$FIRMWARE" in "ath10k/pre-cal-pci-0001:01:00.0.bin") case $board in buffalo,wxr-2533dhp) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 0x18) ;; linksys,ea8500) - ath10kcal_extract "art" 0x5000 0x2f20 + caldata_extract "art" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2) ;; nec,wg2600hp) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary PRODUCTDATA 0xc) ;; netgear,d7800 |\ netgear,r7500v2 |\ netgear,r7800) - ath10kcal_extract "art" 0x5000 0x2f20 + caldata_extract "art" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x6) +2) ;; tplink,c2600) - ath10kcal_extract "radio" 0x5000 0x2f20 + caldata_extract "radio" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0x8) ;; tplink,vr2600v) - ath10kcal_extract "ART" 0x5000 0x2f20 + caldata_extract "ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0x0) ;; zyxel,nbg6817) - ath10kcal_extract "0:ART" 0x5000 0x2f20 + caldata_extract "0:ART" 0x5000 0x2f20 ath10kcal_patch_mac_crc $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) ;; esac diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 6d7682a7f3..5b03fb0e01 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -3,29 +3,7 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh -. /lib/upgrade/nand.sh - -ath10k_caldata_die() { - echo "ath10k caldata: " "$*" - exit 1 -} - -ath10k_caldata_extract_ubi() { - local part=$1 - local offset=$2 - local count=$3 - local ubidev=$(nand_find_ubi $CI_UBIPART) - local ubi - - ubi=$(nand_find_volume $ubidev $part) - [ -n "$ubi" ] || \ - ath10k_caldata_die "no UBI volume found for $part" - - dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ - ath10k_caldata_die "failed to extract from $ubi" -} +. /lib/functions/caldata.sh ath10k_caldata_set_macaddr() { local macaddr=$1 @@ -39,11 +17,11 @@ case "$FIRMWARE" in board=$(board_name) case $board in bt,homehub-v5a) - ath10k_caldata_extract_ubi "caldata" 20480 2116 + caldata_extract_ubi "caldata" 0x5000 0x844 ath10k_caldata_set_macaddr $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3) ;; *) - ath10k_caldata_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 2c4a5a1799..20160cb32b 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -3,15 +3,9 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh +. /lib/functions/caldata.sh . /lib/upgrade/nand.sh -ath9k_eeprom_die() { - echo "ath9k eeprom: $*" - exit 1 -} - ath9k_eeprom_extract_raw() { local source=$1 local offset=$(($2)) @@ -28,25 +22,7 @@ ath9k_eeprom_extract_raw() { fi dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset count=$size $conv 2>/dev/null || \ - ath9k_eeprom_die "failed to extract from $mtd" -} - -ath9k_eeprom_extract_reverse() { - local part=$1 - local offset=$2 - local count=$(($3)) - local mtd - local reversed - local caldata - - mtd=$(find_mtd_chardev "$part") - reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd) - - for byte in $reversed; do - caldata="\x${byte}${caldata}" - done - - printf "%b" "$caldata" > /lib/firmware/$FIRMWARE + caldata_die "failed to extract from $mtd" } ath9k_eeprom_extract() { @@ -57,7 +33,7 @@ ath9k_eeprom_extract() { mtd=$(find_mtd_chardev $part) [ -n "$mtd" ] || \ - ath9k_eeprom_die "no mtd device found for partition $part" + caldata_die "no mtd device found for partition $part" ath9k_eeprom_extract_raw $mtd $offset $swap } @@ -71,7 +47,7 @@ ath9k_ubi_eeprom_extract() { ubi=$(nand_find_volume $ubidev $part) [ -n "$ubi" ] || \ - ath9k_eeprom_die "no UBI volume found for $part" + caldata_die "no UBI volume found for $part" ath9k_eeprom_extract_raw /dev/$ubi $offset $swap } @@ -143,7 +119,7 @@ case "$FIRMWARE" in avm,fritz3370-rev2-hynix|\ avm,fritz3370-rev2-micron|\ avm,fritz7362sl) - ath9k_eeprom_extract_reverse "urlader" 0x1541 0x440 + caldata_extract_reverse "urlader" 0x1541 0x440 ;; avm,fritz7312|avm,fritz7320|avm,fritz7360sl) ath9k_eeprom_extract "urlader" 0x985 0 @@ -155,7 +131,7 @@ case "$FIRMWARE" in ath9k_eeprom_extract "boardconfig" 0x21000 0 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index dc66226d7b..168f10e0f6 100644 --- a/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -1,11 +1,8 @@ #!/bin/sh -FW_FILE="/lib/firmware/$FIRMWARE" +[ -e /lib/firmware/$FIRMWARE ] && exit 0 -ath9k_eeprom_die() { - echo "ath9k eeprom: " "$*" >&2 - exit 1 -} +. /lib/functions/caldata.sh ath9k_eeprom_extract() { local part=$1 @@ -15,10 +12,10 @@ ath9k_eeprom_extract() { mtd=$(find_mtd_chardev $part) [ -n "$mtd" ] || \ - ath9k_eeprom_die "no mtd device found for partition $part" + caldata_die "no mtd device found for partition $part" - dd if=$mtd bs=$offset skip=1 count=1 2>/dev/null | dd of=$FW_FILE bs=$count count=1 2>/dev/null || \ - ath9k_eeprom_die "failed to extract from $mtd" + dd if=$mtd bs=$offset skip=1 count=1 2>/dev/null | dd of=/lib/firmware/$FIRMWARE bs=$count count=1 2>/dev/null || \ + caldata_die "failed to extract from $mtd" } tpl_set_wireless_mac() @@ -29,14 +26,9 @@ tpl_set_wireless_mac() mac=$(mtd_get_mac_binary u-boot 0x4fc00) mac=$(macaddr_add $mac $offset) - macaddr_2bin $mac | dd bs=1 count=6 seek=2 conv=notrunc of=$FW_FILE 2>/dev/null + macaddr_2bin $mac | dd bs=1 count=6 seek=2 conv=notrunc of=/lib/firmware/$FIRMWARE 2>/dev/null } -[ -e $FW_FILE ] && exit 0 - -. /lib/functions.sh -. /lib/functions/system.sh - board=$(board_name) case "$FIRMWARE" in @@ -47,7 +39,7 @@ case "$FIRMWARE" in tpl_set_wireless_mac 0 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; @@ -59,7 +51,7 @@ case "$FIRMWARE" in tpl_set_wireless_mac -1 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom index 7b98936ec3..ec70d86dac 100644 --- a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom +++ b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom @@ -1,23 +1,8 @@ #!/bin/sh -rt2x00_eeprom_die() { - echo "rt2x00 eeprom: " "$*" - exit 1 -} - -rt2x00_eeprom_extract() { - local part=$1 - local offset=$(($2)) - local count=$(($3)) - local mtd - - mtd=$(find_mtd_part $part) - [ -n "$mtd" ] || \ - rt2x00_eeprom_die "no mtd device found for partition $part" +[ -e /lib/firmware/$FIRMWARE ] && exit 0 - dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - rt2x00_eeprom_die "failed to extract from $mtd" -} +. /lib/functions/caldata.sh jboot_eeprom_extract() { local part=$1 @@ -26,29 +11,23 @@ jboot_eeprom_extract() { mtd=$(find_mtd_part $part) [ -n "$mtd" ] || \ - rt2x00_eeprom_die "no mtd device found for partition $part" + caldata_die "no mtd device found for partition $part" jboot_config_read -i $mtd -o $offset -e /lib/firmware/$FIRMWARE 2>/dev/null || \ - rt2x00_eeprom_die "failed to extract from $mtd" + caldata_die "failed to extract from $mtd" } rt2x00_eeprom_set_macaddr() { local macaddr=$1 [ -n "$macaddr" ] || \ - rt2x00_eeprom_die "invalid wlan mac address" + caldata_die "invalid wlan mac address" macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \ conv=notrunc oflag=seek_bytes bs=6 seek=4 count=1 2>/dev/null || \ - rt2x00_eeprom_die "failed to write mac address to eeprom file" + caldata_die "failed to write mac address to eeprom file" } -FW="/lib/firmware/$FIRMWARE" -[ -e "$FW" ] && exit 0 - -. /lib/functions.sh -. /lib/functions/system.sh - board=$(board_name) case "$FIRMWARE" in @@ -68,11 +47,11 @@ case "$FIRMWARE" in ;; dovado,tiny-ac) wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR) - rt2x00_eeprom_extract "factory" 0x0 0x200 + caldata_extract "factory" 0x0 0x200 rt2x00_eeprom_set_macaddr $wifi_mac ;; *) - rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!" + caldata_die "Please define mtd-eeprom in $board DTS file!" ;; esac ;; From patchwork Sun Sep 22 09:57:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165736 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bhfx8g4g"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjc70qTQz9s7T for ; Sun, 22 Sep 2019 19:59:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XZ8vZtCsUlPQ3X9ZV4dU32smO5m4YnsAJMUiSP+V7cE=; b=bhfx8g4gxeSXUVDfLdgF7VgasJ gM7sPiis9mgBSIQdAPeJq1R2l31PwOfyOR/VqeIJ5Fi3fOp7JqFvxauprGchZuQe7mDeC6RVP+Zyf IZKNbzLd3IPdwmkzDQ48s2352yp/iMzufAFmj62UqrGEl3c3d9e+68svFawjj9IfMpxrUYEdt4CHb eWDXJ7pYghWBYktp9345ZkAoJz4rxrs49ISf8UYM+3olvZj9qkR2buSj4dJE+ny/HZKrmLM/ic+kV FzauYcpfzUjsvzspfiHEbsKIq9AQEq/61zn4mfCQXSeWR9jIzUw/Ws4C3thJ1w8HVfp0tIYZK1d3O RqaFU80g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iByeW-0004ll-W1; Sun, 22 Sep 2019 09:59:37 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycV-0003VN-3L for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:35 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MKuGD-1iUKqs0zcb-00LJAI for ; Sun, 22 Sep 2019 11:57:23 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:14 +0200 Message-Id: <20190922095717.1714-5-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Titl+W70yqsVZZYeQ88EqPX0pcv+ZXMxY0OoaQ9d6DxfvJNGX6E oZ/0N93RmodmAGa+3rxk9XN6raA066M5v9CDXElaa+fBG8BvrMBRyQYf3xxbZd9foR0nta+ mkMGvsL2RJVrRqJw/K6RknGvKSWRyCHBqCCAMfmYumfbpAWck3x0rGqluGcYH01Bl76v2R8 eUpPwd+96rzLzlSr3qU2w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:dPPj4gdH7YI=:vNTuv8SLOd4B1trX0X8PqR oQVX/civpbq8nG+Q0jTCv3SLI/79rkY5/aCB1JOnMBOPuUGnsZeJarGZbbVc5xqOzKS46bRel gLkIZ5D5uWzDHE2r/wmnrwWhwTIWWTUbx9wVjPNqgk1ub+rkfmqG0GPWxyzZ41rSTBK+Du3HH ZkYF5phS53RZZK50n0N5M+1LrVFcJx6fUMOxzP9ODFIE07H2DfZlFzB+jZEwruGW7K9PRKUtb jwQ07fbkUz6MeQvBQhac0JLRMtjLt5qPZNBoW7Gv7krGGqijQAdT5O5+pxBsDBCvScqJVvTxD qH2OKTPUg7CHGTX8MwTZD24uOLoW0FAt3p9L+nBEK6UpuFtrmn/ZhQKEth7JSAOLVfZypryt0 GpLaJmOqMBdZMptEHPyeF02pszsm+KQyf9CB3W0nYMU4ixFecr0buYRDWuigFP8s1VJCXHVAb GgQ/HYUmaAHCiWETZKiy+N13wDwQqbI+luXI2W4fNY6/gLWk9l3vqx9daN1URPz7QoEC5Fi+W pFbRuISu8we73Zv1e3iLeLnQlAL/eTCkfMfCw4MygUKuJzEFWAuuGzycHXnao8HwBeEjxW8n0 Jyl4jD6zudfL5o8s7TucOhbnjEtyqkp8aeYczjee+h8xNnOUubb2swp6P+zCGsyH8lRZ9es+d JiokfGVfiyEGX3bEIqjIC63D+2i+gTT02jx8s6NeCHjlewwSAt1VAy75bUQ2ERY8PIzm5aZFP 1kKKW/e6fIrlg5qszRsDXQK+WhIZ9c2iCKAQvLfJvEGI6DLpw6OaJlR1DwHYPIxGqGDftk3+9 +n098U2LSfdTbq09QANcrQGggcdeB8jiFacN3oN0fZs7G0cj/RRojGFUUFWe1+mAJxu3WgaHe pdKaVnay9luwQX4rBT8VoGTwz8iASvYYw5ajR+hMo= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025731_459426_FC75148A X-CRM114-Status: GOOD ( 10.63 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.131 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH v2 4/7] treewide: move MAC address patch functions to common library X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This unifies MAC address patch functions and moves them to a common script. While those were implemented differently for different targets, they all seem to do the same. The number of different variants is significantly reduced by this patch. Signed-off-by: Adrian Schmutzler --- v2: rebased, put chksum calculation into separate function --- .../base-files/files/lib/functions/caldata.sh | 53 +++++++++++++++++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 12 +--- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 57 ++++--------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 31 ---------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 25 -------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 25 -------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 9 +-- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 43 ++------------ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 3 +- .../etc/hotplug.d/firmware/10-rt2x00-eeprom | 15 +---- 10 files changed, 74 insertions(+), 199 deletions(-) diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh index f2a306675f..db7aed5b4f 100644 --- a/package/base-files/files/lib/functions/caldata.sh +++ b/package/base-files/files/lib/functions/caldata.sh @@ -73,3 +73,56 @@ caldata_valid() { return $? } +caldata_patch_chksum() { + local mac=$1 + local mac_offset=$(($2)) + local chksum_offset=$(($3)) + local xor_mac + local xor_fw_mac + local xor_fw_chksum + + xor_mac=${mac//:/} + xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" + + xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) + xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}" + + xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) + xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) + + printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ + dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 +} + +caldata_patch_fw_mac() { + local mac=$1 + local mac_offset=$(($2)) + local chksum_offset=$3 + + [ -z "$mac" -o -z "$mac_offset" ] && return + + [ -n "$chksum_offset" ] && caldata_patch_chksum "$mac" "$mac_offset" "$chksum_offset" + + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1 || \ + caldata_die "failed to write MAC address to eeprom file" +} + +caldata_patch_fw_mac_crc() { + local mac=$1 + local mac_offset=$2 + local chksum_offset=$((mac_offset - 10)) + + caldata_patch_fw_mac "$mac" "$mac_offset" "$chksum_offset" +} + +ath10kcal_patch_mac() { + local mac=$1 + + caldata_patch_fw_mac "$mac" 0x6 +} + +ath10kcal_patch_mac_crc() { + local mac=$1 + + caldata_patch_fw_mac "$mac" 0x6 0x2 +} diff --git a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 07100b1856..a03c3436cb 100644 --- a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -4,14 +4,6 @@ . /lib/functions/caldata.sh -ath9k_patch_firmware_mac() { - local mac=$1 - - [ -z "$mac" ] && return - - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6 -} - board=$(board_name) case "$FIRMWARE" in @@ -24,7 +16,7 @@ case "$FIRMWARE" in caldata_extract_ubi "caldata" 0x5000 0x1000 else caldata_extract "wifi_data" 0x5000 0x1000 - ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0xc) + caldata_patch_fw_mac $(mtd_get_mac_binary wifi_data 0xc) 0x2 fi ;; *) @@ -42,7 +34,7 @@ case "$FIRMWARE" in caldata_extract_ubi "caldata" 0x1000 0x1000 else caldata_extract "wifi_data" 0x1000 0x1000 - ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0x0) + caldata_patch_fw_mac $(mtd_get_mac_binary wifi_data 0x0) 0x2 fi ;; *) diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 5ec13efd3f..5f53538229 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -4,41 +4,6 @@ . /lib/functions/caldata.sh -ath9k_patch_fw_mac() { - local mac=$1 - local mac_offset=$(($2)) - local chksum_offset=$3 - local xor_mac - local xor_fw_mac - local xor_fw_chksum - - [ -z "$mac" -o -z "$mac_offset" ] && return - - [ -n "$chksum_offset" ] && { - xor_mac=${mac//:/} - xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" - - xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}" - - xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) - - printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$(($chksum_offset)) count=2 - } - - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1 -} - -ath9k_patch_fw_mac_crc() { - local mac=$1 - local mac_offset=$2 - local chksum_offset=$((mac_offset - 10)) - - ath9k_patch_fw_mac "${mac}" "${mac_offset}" "${chksum_offset}" -} - board=$(board_name) case "$FIRMWARE" in @@ -50,7 +15,7 @@ case "$FIRMWARE" in dlink,dir-825-c1|\ dlink,dir-835-a1) caldata_extract "art" 0x1000 0x440 - ath9k_patch_fw_mac $(mtd_get_mac_text "mac" 0x4) 0x2 + caldata_patch_fw_mac $(mtd_get_mac_text "mac" 0x4) 0x2 ;; dlink,dir-842-c1|\ dlink,dir-842-c2|\ @@ -59,11 +24,11 @@ case "$FIRMWARE" in nec,wg1200cr|\ wd,mynet-n750) caldata_extract "art" 0x1000 0x440 - ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2 + caldata_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2 ;; engenius,ecb1750) caldata_extract "art" 0x1000 0x440 - ath9k_patch_fw_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env "athaddr") +1) 0x2 + caldata_patch_fw_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env "athaddr") +1) 0x2 ;; engenius,epg5000|\ iodata,wn-ac1167dgr|\ @@ -71,15 +36,15 @@ case "$FIRMWARE" in iodata,wn-ac1600dgr2|\ iodata,wn-ag300dgr) caldata_extract "art" 0x1000 0x440 - ath9k_patch_fw_mac $(mtd_get_mac_ascii u-boot-env ethaddr) 0x2 + caldata_patch_fw_mac $(mtd_get_mac_ascii u-boot-env ethaddr) 0x2 ;; nec,wg800hp) caldata_extract "art" 0x1000 0x440 - ath9k_patch_fw_mac $(mtd_get_mac_text board_data 0x680) 0x2 + caldata_patch_fw_mac $(mtd_get_mac_text board_data 0x680) 0x2 ;; qihoo,c301) caldata_extract "radiocfg" 0x1000 0x440 - ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2 + caldata_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2 ;; *) caldata_die "board $board is not supported yet" @@ -103,7 +68,7 @@ case "$FIRMWARE" in dlink,dir-825-c1|\ dlink,dir-835-a1) caldata_extract "art" 0x5000 0x440 - ath9k_patch_fw_mac $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1) 0x2 + caldata_patch_fw_mac $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1) 0x2 ;; ocedo,raccoon|\ tplink,tl-wdr3500-v1|\ @@ -139,11 +104,11 @@ case "$FIRMWARE" in ;; wd,mynet-n750) caldata_extract "art" 0x5000 0x440 - ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan5mac") 0x2 + caldata_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan5mac") 0x2 ;; wd,mynet-wifi-rangeextender) caldata_extract "art" 0x1000 0x1000 - ath9k_patch_fw_mac $(nvram get wl0_hwaddr) "$mac" 0x2 + caldata_patch_fw_mac $(nvram get wl0_hwaddr) "$mac" 0x2 ;; *) caldata_die "board $board is not supported yet" @@ -161,7 +126,7 @@ case "$FIRMWARE" in ;; dlink,dir-825-b1) caldata_extract "caldata" 0x1000 0xeb8 - ath9k_patch_fw_mac_crc $(mtd_get_mac_text "caldata" 0xffa0) 0x20c + caldata_patch_fw_mac_crc $(mtd_get_mac_text "caldata" 0xffa0) 0x20c ;; *) caldata_die "board $board is not supported yet" @@ -179,7 +144,7 @@ case "$FIRMWARE" in ;; dlink,dir-825-b1) caldata_extract "caldata" 0x5000 0xeb8 - ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 0xffb4) 1) 0x20c + caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 0xffb4) 1) 0x20c ;; *) caldata_die "board $board is not supported yet" diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 30857e9c71..3175d5a1f8 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -5,37 +5,6 @@ . /lib/functions/caldata.sh . /lib/functions/k2t.sh -ath10kcal_patch_mac() { - local mac=$1 - - [ -z "$mac" ] && return - - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=6 count=1 -} - -ath10kcal_patch_mac_crc() { - local mac=$1 - local mac_offset=6 - local chksum_offset=2 - local xor_mac - local xor_fw_mac - local xor_fw_chksum - - xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}" - - ath10kcal_patch_mac "$mac" && { - xor_mac=${mac//:/} - xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" - - xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) - - printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 - } -} - board=$(board_name) case "$FIRMWARE" in diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 61597ea669..898e0bb074 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -4,31 +4,6 @@ . /lib/functions/caldata.sh -ath10kcal_patch_mac_crc() { - local mac=$1 - local mac_offset=6 - local chksum_offset=2 - local xor_mac - local xor_fw_mac - local xor_fw_chksum - - [ -z "$mac" ] && return - - xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}" - - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6 - - xor_mac=${mac//:/} - xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" - - xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) - - printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 -} - board=$(board_name) case "$FIRMWARE" in diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 12b76ec33f..f8a4c98542 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -4,31 +4,6 @@ . /lib/functions/caldata.sh -ath10kcal_patch_mac_crc() { - local mac=$1 - local mac_offset=6 - local chksum_offset=2 - local xor_mac - local xor_fw_mac - local xor_fw_chksum - - [ -z "$mac" ] && return - - xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}" - - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6 - - xor_mac=${mac//:/} - xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" - - xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) - - printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2 -} - board=$(board_name) case "$FIRMWARE" in diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 5b03fb0e01..244635c6db 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -5,20 +5,13 @@ . /lib/functions/caldata.sh -ath10k_caldata_set_macaddr() { - local macaddr=$1 - - macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \ - conv=notrunc bs=1 seek=6 count=6 -} - case "$FIRMWARE" in "ath10k/cal-pci-0000:02:00.0.bin") board=$(board_name) case $board in bt,homehub-v5a) caldata_extract_ubi "caldata" 0x5000 0x844 - ath10k_caldata_set_macaddr $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3) + ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3) ;; *) caldata_die "board $board is not supported yet" diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 20160cb32b..b5dba670b1 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -52,41 +52,6 @@ ath9k_ubi_eeprom_extract() { ath9k_eeprom_extract_raw /dev/$ubi $offset $swap } -ath9k_patch_fw_mac_crc() { - local mac=$1 - local mac_offset=$2 - local chksum_offset=$((mac_offset - 10)) - - ath9k_patch_fw_mac "${mac}" "${mac_offset}" "${chksum_offset}" -} - -ath9k_patch_fw_mac() { - local mac=$1 - local mac_offset=$(($2)) - local chksum_offset=$3 - local xor_mac - local xor_fw_mac - local xor_fw_chksum - - [ -z "$mac" -o -z "$mac_offset" ] && return - - [ -n "$chksum_offset" ] && { - xor_mac=${mac//:/} - xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" - - xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}" - - xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE) - xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac) - - printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \ - dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$(($chksum_offset)) count=2 - } - - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6 -} - case "$FIRMWARE" in "ath9k-eeprom-pci-0000:00:0e.0.bin" | \ "ath9k-eeprom-pci-0000:01:00.0.bin" | \ @@ -102,19 +67,19 @@ case "$FIRMWARE" in ;; bt,homehub-v2b) ath9k_eeprom_extract "art" 0x0 1 - ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 0x20c + caldata_patch_fw_mac_crc "00:00:00:00:00:00" 0x20c ;; bt,homehub-v3a) ath9k_eeprom_extract "art-copy" 0x0 1 - ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c + caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c ;; bt,homehub-v5a) ath9k_ubi_eeprom_extract "caldata" 0x1000 0 - ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c + caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c ;; netgear,dgn3500|netgear,dgn3500b) ath9k_eeprom_extract "calibration" 0xf000 0 - ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c + caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c ;; avm,fritz3370-rev2-hynix|\ avm,fritz3370-rev2-micron|\ diff --git a/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 168f10e0f6..3b9d9130f9 100644 --- a/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -24,9 +24,8 @@ tpl_set_wireless_mac() local mac mac=$(mtd_get_mac_binary u-boot 0x4fc00) - mac=$(macaddr_add $mac $offset) - macaddr_2bin $mac | dd bs=1 count=6 seek=2 conv=notrunc of=/lib/firmware/$FIRMWARE 2>/dev/null + caldata_patch_fw_mac $(macaddr_add $mac $offset) 0x2 } board=$(board_name) diff --git a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom index ec70d86dac..52d81a29c4 100644 --- a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom +++ b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom @@ -17,17 +17,6 @@ jboot_eeprom_extract() { caldata_die "failed to extract from $mtd" } -rt2x00_eeprom_set_macaddr() { - local macaddr=$1 - - [ -n "$macaddr" ] || \ - caldata_die "invalid wlan mac address" - - macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \ - conv=notrunc oflag=seek_bytes bs=6 seek=4 count=1 2>/dev/null || \ - caldata_die "failed to write mac address to eeprom file" -} - board=$(board_name) case "$FIRMWARE" in @@ -43,12 +32,12 @@ case "$FIRMWARE" in wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000) wifi_mac=$(macaddr_add "$wan_mac" 1) jboot_eeprom_extract "config" 0xE000 - rt2x00_eeprom_set_macaddr $wifi_mac + caldata_patch_fw_mac $wifi_mac 0x4 ;; dovado,tiny-ac) wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR) caldata_extract "factory" 0x0 0x200 - rt2x00_eeprom_set_macaddr $wifi_mac + caldata_patch_fw_mac $wifi_mac 0x4 ;; *) caldata_die "Please define mtd-eeprom in $board DTS file!" From patchwork Sun Sep 22 09:57:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165737 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Y3d9z2sq"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjcB5mRPz9s7T for ; Sun, 22 Sep 2019 19:59:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=97Q4jZJZtGRKB/l/lyTJUzoFON5IbhKHcQ8aNiNCqgg=; b=Y3d9z2sqvfQ6J1HiGsJNiRjYsq /dkPgKrawNU1Ti6y8IueRJoP0BSmOYg0TIoDSNTaMmtQndYhxiTO4mHWD6eTxviMJS7GnSbMscgeP +hzi2mI0znwN8SrqYDKE2086Qhi02qgqfVp/cOUFnHhhCJveUGX+nJ0HAC6hPxYvvaOJKYu62Rqdk hke91aAUqeB430/LZ+qvzyrEemptBscwZDOC9Wr0bAY4We0P3H3u4JHU+GobJmK1tMA+tEjM2QlIJ nm6GWueiURWtpULHsOKd1FcmlfAnt8TtaB9PQZNp7nxQjB5yTA5WGBduYdiN0VbA7x6JGaY2jMhqC 5Zb1K8jw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iByem-00050a-JU; Sun, 22 Sep 2019 09:59:52 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycW-0003VI-2Z for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:36 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MkEdF-1hngMc1cbZ-00kdZW for ; Sun, 22 Sep 2019 11:57:23 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:15 +0200 Message-Id: <20190922095717.1714-6-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:f6el3Jb/EUNxzYfcpJy3uaWBeDTiC4PVAX3CqrtlyNGtA/XTnke U8dWqV/FpmmxdyMEgJI4VI2qD83ez0pKIiIk0d9rPMWB4V8gk9/n/dsCmr0q7Je4yHhWKRT YzepDG7pVemz/bJtLiKF0zTON+LM8jWGxcetqy7KBCQ9z8TDv19mM5u4iTRyC4SAsc/RdVm aEEKb2zeurq47FAvpjo9Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:qBUTYRlU2HA=:HHh7yT7/ZO5eRagWOW46I/ O5hCDf/DDMIXgP1hT9S9vE+PTI9rplqUsXacroyBnwPoaiv2o1v379iI7IrWeN2+iQwBBCpq6 xPCPoKAyjhv7TgpO7xN++WNOxrNg45/svAY9ziaGgI2MCf3f/pCKYiIJmyZSYL6KBARY7sZS2 c96eb7iI88VMIJ0B28OkdTLCnYXkWBCDMezZ1O6b/oRmj5SdAACQdQW7EN9HfQTQoiky3IknV 82oOAsnUqRHDyhcZ4NQOdnuTXd2u7p60+O16OuJCr63FDz5O4IkvMlMpFu2QLR+jkBIxcfLah j/D/LqxdEvtqCypaobcriYuvKyv61uZiSi+EKzJQweXP/v3J2Vn004X8b5XWOCBVbU7cCoEUX QgQQOOvbJbPKe4Yxl0/PHL2ClunRiEtutZFi478nLv3ev24dn2NHn8zeIyBwJvxFV0jNUIO/w i/hqxu7DLfB1G3yvAy8qzu+LdW/xwoEkXU/XBaPi1EvtvPnBfW0KxZ6+v+N/C7DMHJTbIxn2H Z+afBSLMl+hiH19Xx01zl77yPE6rSMlt81BY+i+khIDI9jbIh/4XlqNRDYF9QlDovLw98sh/B xy7b6reBIUJwy+sQbkZJ6qrDmIfnwi1uC8TijI6ao8pXbwtV0COf8aCRcASBKmPkSiPHI0osZ wbkCnx8dVWiaJ8HlzD1vwn02rGcyF2hZ6Les6W7W6zOVaKukxm/EdC98A8RIlaTucwJpJF1lp os/1106+ThMQSc9BtIEiomrIvmyniJnT4YrYm8CBjlst/gvwMZ2Fkq0P6/SKQw2eS5boKbIU/ OsfXeBoBevmrhxCVDPxnh3HvlY6W2ytldsnotG2LgzTNu9eo7RkjxGAUetNMSYg92wzzEdwYv F7EqEGrwQNz8BCSOXwuOZTT1SBQq+xlo5xVgEV950= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025732_443817_5B0735FB X-CRM114-Status: UNSURE ( 7.80 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.187 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.187 listed in wl.mailspike.net] Subject: [OpenWrt-Devel] [PATCH v2 5/7] ath79: set checksum when patching MAC address on ath10k X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Several devices use ath10kcal_patch_mac, although all ath10k eeproms have a checksum field and should use ath10kcal_patch_mac_crc. This might be because the field is not evaluated by the firmware at the moment. Nevertheless, this patch will use ath10kcal_patch_mac_crc for all devices so the correct checksum is in place. Signed-off-by: Adrian Schmutzler --- v2: New patch --- .../etc/hotplug.d/firmware/11-ath10k-caldata | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 3175d5a1f8..802ef4039e 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -26,33 +26,33 @@ case "$FIRMWARE" in ;; dlink,dir-859-a1) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac") + ath10kcal_patch_mac_crc $(mtd_get_mac_ascii devdata "wlan5mac") ;; elecom,wrc-1750ghbk2-i) caldata_extract "art" 0x5000 0x844 ;; engenius,ecb1750) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr) + ath10kcal_patch_mac_crc $(mtd_get_mac_ascii u-boot-env athaddr) ;; engenius,epg5000|\ iodata,wn-ac1167dgr|\ iodata,wn-ac1600dgr2) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) ;; engenius,ews511ap) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; glinet,gl-ar750|\ glinet,gl-ar750s) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) ;; glinet,gl-x750) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x0) +2) ;; nec,wg800hp) caldata_extract "art" 0x5000 0x844 @@ -61,11 +61,11 @@ case "$FIRMWARE" in ocedo,koala|\ ocedo,ursus) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(mtd_get_mac_binary art 0xc) + ath10kcal_patch_mac_crc $(mtd_get_mac_binary art 0xc) ;; openmesh,om5p-ac-v2) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; qihoo,c301) caldata_extract "radiocfg" 0x5000 0x844 @@ -77,29 +77,29 @@ case "$FIRMWARE" in tplink,archer-c7-v5|\ tplink,archer-c25-v1) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) -1) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary info 0x8) -1) ;; tplink,archer-c5-v1|\ tplink,archer-c7-v2) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x1fc00) -1) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary u-boot 0x1fc00) -1) ;; tplink,archer-d50-v1) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary romfile 0xf100) +2) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary romfile 0xf100) +2) ;; tplink,re350k-v1) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary config 0x10008) +2) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary config 0x10008) +2) ;; tplink,re355-v1|\ tplink,re450-v1) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2) + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; tplink,re450-v2) caldata_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary info 0x8) +1) ;; ubnt,unifiac-lite|\ ubnt,unifiac-mesh|\ @@ -127,7 +127,7 @@ case "$FIRMWARE" in netgear,ex6400|\ netgear,ex7300) caldata_extract "caldata" 0x5000 0x2f20 - ath10kcal_patch_mac $(mtd_get_mac_binary caldata 0xc) + ath10kcal_patch_mac_crc $(mtd_get_mac_binary caldata 0xc) ;; phicomm,k2t) caldata_extract "art" 0x5000 0x2f20 From patchwork Sun Sep 22 09:57:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165731 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V9I0kaLQ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjYl6x8Wz9s7T for ; Sun, 22 Sep 2019 19:57:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tMOChKSR1c+PeTWxHTPPLQGU7r7p2/H8QogCsDBzmmI=; b=V9I0kaLQ6gTsUix8qjAxvZyMiD hkbjSUqItkKUwFVW4JKJnwYhln5uV8Coj4FU7zmC/BHAHL7mcKeUk4+lj82dKDZcWd93k7zLJQ1GF DydOmS8uyDEMdCTlZCUQuOHTCqJvsl0VdL5X929Rp8XY1fMGMyLDoUqUnfvZSZd5BT0hPXZlQ92rt 0EYgSkLCiSDV+t3vGVciJesE6ht2CsZhIP39Us1K5b3Qz7nsPOnBjByYCVH7iHO1nZmqns4Z4lyzH ofzZ44U8wsa7OKto1smnpi0zBHyUdB8ViukfoHoeM8FRq4BA3If27lLhPBm7RZvUNKcZ5dhP1AoWQ PaEVWV0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycZ-0003Xk-Ky; Sun, 22 Sep 2019 09:57:35 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycV-0003VM-3K for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:33 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mth79-1huj7M2EVb-00vBwm for ; Sun, 22 Sep 2019 11:57:23 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:16 +0200 Message-Id: <20190922095717.1714-7-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:rdBYftOsmOrrdaHSIR9YdmO4vlCCSIqwoCooWbyYAgs0mOzySEU qRu9LmufKOvAIJNd6oVGks/rjxHjPNnMrVK6L2jtIvM6xqIfrG0zAv57a3Y/N/HytdkqLpQ xu9sUou0BVtt6FDVNBijaJQXXK9Dcpae4Qs2BXTg1JisvTBU20M7GSYGuyPnukEzOyeg2h1 X//25kB0z9hetzty/Karw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:zpNFNK5f8pY=:M2zmQfHAdTlNBaoQvXkV2q Wdk5nQ5tTpZpZis0jwKGAuQGnETs3TL267Mh5PlRhTI9KqSEg53ih7EynG1lLJACM4Fj/NaWY PlfCV9Bfdrz0W4Et9Qn/8x2UITczz/QdqKXdoiyZJRB5BQ6MAMipJtFT4wYufET8651UrAB5M /rFlr6YSXtfA6Ra1QEv/KQl5J/Qb9qnrgShh402hz0TwZOzqHbI29mh5vymGKuQOg5MWuKNWv XTVmTaiKM3Y/FQV+33FEdJgf97LbNG1Y9w293qC8LOjIBOLIWzea+LyE5bjxAO48WpG8xII7x Ghf2Lf/nFfqStMbbkI7ZhAFtaenDMAZ3KdHL9axJH2pJykWKj/V8qgWtv6UtJvmR2XnDj29Sd 96+lX7h5TbzjCjijgI14VBI5a9TRE+L4NXTNcrHsDWi3OeVEDhTM43e5nojuF10ELSzV9vpdM Nk+hJUzBMmzC8qwqWROuAky+f8c7IfkNhgYFjpvCe0ZiFF+d5y6TgL+k0BMzrvrkfGiNBs6tj R5SS/khKLNnKUXnKwcgqGl+mLuxLnGKbQKmyRZsrok9mfYhkXSv5w2R/hgxWlCFgBg7YM79uY JS5uW9bpyrnFwTYxbZrwwDIS6mWhwD1WK/KXO9xdppEMiVU37twK9qup+Zq0un7ZEcUT3Y5dg ljkPsJIcOkmv9irOPR6rlYo7h72QmhF4tm31Y7Uq85zDet8R/OeJivdiVaI0KEW149IhXMGsY 2Ul2l5tj6lABwT3tMdgx+v2wGdOiJJnQol3WKWNqp8IHOevFXex9ONQdA1xTP/tp5t6avwqle PEefxguD+GTq2zxNWEpVRozSwih415sr7cSq0VsWIdcFvTuvOskUtde03x7L/wTSupI9yfe9N DuBBW+DvsGDqDb5DyBuB+Ga7oQBRD/jFm7TuUiojk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025731_433052_C7AD02A9 X-CRM114-Status: GOOD ( 10.13 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.133 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH v2 6/7] lantiq: set checksum when patching MAC address on ath10k X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org One lantiq device uses ath10kcal_patch_mac, although all ath10k eeproms have a checksum field and should use ath10kcal_patch_mac_crc. This might be because the field is not evaluated by the firmware at the moment. Nevertheless, this patch will use ath10kcal_patch_mac_crc for all devices so the correct checksum is in place. Signed-off-by: Adrian Schmutzler --- v2: New patch --- .../lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 244635c6db..dbfd201193 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -11,7 +11,7 @@ case "$FIRMWARE" in case $board in bt,homehub-v5a) caldata_extract_ubi "caldata" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3) + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3) ;; *) caldata_die "board $board is not supported yet" From patchwork Sun Sep 22 09:57:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1165733 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="N/OjZRzj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46bjZh3DwJz9s7T for ; Sun, 22 Sep 2019 19:58:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=idFjjBAOhF5IOg7uMgNlim2HrCojmCtkvVThnDUuKj0=; b=N/OjZRzj0i71514u3T7N3vAvXu JWeXT4IiikBkx4squZmPLqF/o7MC1iYflxwymJoG1uqyPC0xinZ871L2F4REFpF3DsJbo23LNBhbR sOPmgax0BwCdlCjiWub1VaQnssw6v9O0nArhNUaBgasGyWIHFT7CaznWXJeugpOAidkoHv+vP4Mlu fQRKh0Tlhp3TrE9Tk2kC09IFPjwCzam/nb2gIe1jnzsPCvEXCdoM/30p+Pipsl3lLl8zIHsc/jfws k/aH+Qv8Uj4p0l6ZSGKZhkurIKVS6LaUq7bCNRlDULZjuXe7tue4rJO4T6R4Bp3h1K2UPx4IrGUo8 7Ze1fjxg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBydV-000410-PD; Sun, 22 Sep 2019 09:58:33 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBycU-0003VP-Po for openwrt-devel@lists.openwrt.org; Sun, 22 Sep 2019 09:57:34 +0000 Received: from buildfff.adridolf.com ([188.192.136.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MHmuE-1iNZkT2o22-00Eqzp for ; Sun, 22 Sep 2019 11:57:23 +0200 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Sun, 22 Sep 2019 11:57:17 +0200 Message-Id: <20190922095717.1714-8-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922095717.1714-1-freifunk@adrianschmutzler.de> References: <20190922095717.1714-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:FHtgX/EXxyKXL2wLxQ5h5tfc3pi1vxEzStBO3Ytd8Q0ax0gCBdm v9EtzgMEq0LEyBMjubuYbLpuMOHe9dAqlmgaqwJFtGXV8VVfW9bal/SS6DVVDIP3HtF6GTc p5hH5y3NEEz5g1Igpxm68xBLdxPWuJaxI/svcRmDyx0IWOHEXB05hW5arJ8aVvVMwURy4eS aImrw/BMmBIoAsMTDz1xA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:fpoYrpNtwSI=:sPQ1EKbqzNZhTSktgs670J tndbQ0Vn/KjWj/lPXjhhcvb+f5UEDKYBkEh6eCcr0Qu1KbT3VU1X6h3tIsjocOOuij7oP3k4g Mlyw3g70w44vlsSL10qaANbnGtacoE9wU8XvVM0y6XfPLqGDsygL7xGjOaM6eZCODlM+J99fL IADagAXyihArxH3OGyma7t+EfqFweTIyufOo9GZVpyJWIV2dFk4mHfek9qzHEwCu8HDkSLTYT iUXVckC0/rLIM4MOu5qeNyEJj4N2hJvxokEHCOfSVZYDvwtfhDYfAiTSyL8BLvHmcxrW8D4i5 S1y41tgvSqkV7CungoSUXc2/FdUHRV1c6kJGPdbatoXPMS9DH22b3R1oB97DcmUHIZeMqxSfy B201Sicmyl8Fayt3tbG6XHSjvRn/nv7TTwWq/aSBuzSlSUsrOCJshsN8EYcR6YBsOHAly22Zo S5Zzmm00CAp8v9lWJPPR/LrCwH0g0vTU32kxeHxYZ+xxEP2OFVxTfG+WTLvwhSS5wihOVRfa3 SDEckL/RyfWXvIuWM3t56IvlBKdzsZcYHOXdtQIJYquxKmXx8+ugyAy1fED/xd/YqrF+75DSL lV97ZK9IpxCteb6vmFdDHYe/iR+H1p1FlOoFNCO1o3O6IdJhXpbMcvjxFp/3z8JQ6yutsLSk5 soHxKaoYLDi1MWZr4JNfwoNFEKCega7LZx5jTTd5yxOQT5dgxTOgY9Jy8Hlsn9NOi+/5Uj1o9 cJnQTjMToYLShpQfK0mom9d3l6ZshOFrfZfKZXs7yh2h3EPMwDvcnqyv0dq7TK7PnmD2Th4pV WrY/VyppWY9flWLn8BuVBihKEbfmv2GG0eKbNhzBZWPu9O5TSqdZkUEZQQ3JpN6uDJJuWnNQP F0fSNNDA6NVndFzuCnTKdZO6euDfP+BVx5rRwsjGk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190922_025731_322020_C8BDBF0F X-CRM114-Status: GOOD ( 11.70 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.135 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v2 7/7] lantiq: modify ath9k caldata extraction to reuse caldata.sh X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org In lantiq, ath9k caldata extraction is implemented to work in two alternate "modes", the standard one and another one with swapped byte pairs. This rearranges the functions so "standard" use is based on the caldata.sh library, while only a single local function is required for the special case. Note that while the parameter for switching between normal and swab is removed, the size of the caldata is added to the function calls to stay consistent. Signed-off-by: Adrian Schmutzler --- v2: - Added this patch (previously separate [5/5] lantiq: modify ath9k caldata extraction to reuse caldata.sh) - Made size in caldata_extract_swap a parameter to match other functions --- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 62 +++++-------------- 1 file changed, 15 insertions(+), 47 deletions(-) diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index b5dba670b1..f3627c40ca 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -1,55 +1,23 @@ #!/bin/sh -# Based on ar71xx 10-ath9k-eeprom [ -e /lib/firmware/$FIRMWARE ] && exit 0 . /lib/functions/caldata.sh -. /lib/upgrade/nand.sh -ath9k_eeprom_extract_raw() { - local source=$1 - local offset=$(($2)) - local swap=$3 - local size=4096 - local bs=1 - local conv= - - if [ $swap -gt 0 ]; then - bs=2 - conv="conv=swab" - size=$((size / bs)) - offset=$((offset / bs)) - fi - - dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset count=$size $conv 2>/dev/null || \ - caldata_die "failed to extract from $mtd" -} - -ath9k_eeprom_extract() { +caldata_extract_swap() { local part=$1 local offset=$2 - local swap=$3 + local count=$3 local mtd mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - caldata_die "no mtd device found for partition $part" - - ath9k_eeprom_extract_raw $mtd $offset $swap -} - -ath9k_ubi_eeprom_extract() { - local part=$1 - local offset=$2 - local swap=$3 - local ubidev=$(nand_find_ubi $CI_UBIPART) - local ubi + [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part" - ubi=$(nand_find_volume $ubidev $part) - [ -n "$ubi" ] || \ - caldata_die "no UBI volume found for $part" + offset=$(($offset / 2)) + count=$(($count / 2)) - ath9k_eeprom_extract_raw /dev/$ubi $offset $swap + dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab 2>/dev/null || \ + caldata_die "failed to extract calibration data from $mtd" } case "$FIRMWARE" in @@ -60,25 +28,25 @@ case "$FIRMWARE" in case "$board" in arcadyan,arv7518pw) - ath9k_eeprom_extract "boardconfig" 0x400 1 + caldata_extract_swap "boardconfig" 0x400 0x1000 ;; arcadyan,arv8539pw22) - ath9k_eeprom_extract "art" 0x400 1 + caldata_extract_swap "art" 0x400 0x1000 ;; bt,homehub-v2b) - ath9k_eeprom_extract "art" 0x0 1 + caldata_extract_swap "art" 0x0 0x1000 caldata_patch_fw_mac_crc "00:00:00:00:00:00" 0x20c ;; bt,homehub-v3a) - ath9k_eeprom_extract "art-copy" 0x0 1 + caldata_extract_swap "art-copy" 0x0 0x1000 caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c ;; bt,homehub-v5a) - ath9k_ubi_eeprom_extract "caldata" 0x1000 0 + caldata_extract_ubi "caldata" 0x1000 0x1000 caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c ;; netgear,dgn3500|netgear,dgn3500b) - ath9k_eeprom_extract "calibration" 0xf000 0 + caldata_extract "calibration" 0xf000 0x1000 caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c ;; avm,fritz3370-rev2-hynix|\ @@ -87,13 +55,13 @@ case "$FIRMWARE" in caldata_extract_reverse "urlader" 0x1541 0x440 ;; avm,fritz7312|avm,fritz7320|avm,fritz7360sl) - ath9k_eeprom_extract "urlader" 0x985 0 + caldata_extract "urlader" 0x985 0x1000 ;; avm,fritz7412) /usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 4096 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader") ;; tplink,tdw8970|tplink,tdw8980) - ath9k_eeprom_extract "boardconfig" 0x21000 0 + caldata_extract "boardconfig" 0x21000 0x1000 ;; *) caldata_die "board $board is not supported yet"