From patchwork Fri Mar 1 14:40: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: 1050230 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="ZmcA9vil"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sY80gCWz9s2R for ; Sat, 2 Mar 2019 01:41:00 +1100 (AEDT) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject: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=hqCMuLbvpLv23kxhF7ghZd9O8XKjJ5syxPdYx3ZvSPk=; b=ZmcA9vilNHeqB4uljTNdE8kM7F NY81XkB3WOx98CfaGGvPUnDOiltA8yOrvXqPu+ep1Qnh0BHeBy1ykBpiQun/dR/QqHqWgMIrX2uSG kM4zxSJxYElVQ5/b+pg7Nr4JOwx0jNb8IkI0H4blzCpfWmn91AuFb5XqcDcBCnRpl690k4EYm8Pka ji77CZ96o6klFEOiHb5XLy3qwddF/WuBq5Hub8fqXgNvPgr0eYgPH3iZgsHU2a9ztnwrLpeW2kcIo GEwOKVixuHuqfzoTM357Tgw819Q/H7b6IP+pYvcYkHTnIOtHkZjEGNu5LfMeLJSzMB/oUCxtxRK73 wh1i6I2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjLH-0006Fc-UP; Fri, 01 Mar 2019 14:40:51 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKx-0005pS-Pr for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:35 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLiPA-1gi3vX2fdw-00Hj7Q for ; Fri, 01 Mar 2019 15:40:27 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:17 +0100 Message-Id: <20190301144022.1984-2-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:QbUTQD0J8i0gkscD0+SQD3+4mvCc7CXI2fFacgK6hfl+Mp/unBT aFi2MqwrHWYoDc2KGRXDlQL6ovWj0cqlFX72gvnlqy7+mIG+t5Wc2BJaLELMcedcIm9NHQz aR8f/Fpr3YclNTYDL7SYve3t2CXIfcIz2gpQD+V7+QZxBUkeD9HlfK+4sftqzvskAu/UM1k I5Rh9YI2AsYwIOk8awg0g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:1hrPW26tmXY=:FmppkhUAmt576/ho/G67oW 5aVCy60kaXnnhgrJ03epqasP8wflTauxZEj8D99GN38QchdwOs3tEW+rUdDWlUujVt94o3k8U p5KQe294iXcC8tnz+TrndfYmVY35mjmvGDAl0bLAVGx4NEAwhqasywBNW1oOVZNfDSr9idZUM EPn0tExzYBG+Au0GJy5OTAqu4s3aWiIqiGn5kyDM0eUWuLJ4HctRMDXnjLKlR5+JN/I4K8AZN uiQO6pAwiB/n9axYMqLQbK7OEvgi1FJ0G7WUR6xr6lqvb3BjOoBSRFwuLnzY7KTfwLT+YtQ6z 82OhePCbX86pN4+1dwMMyinI+pMmxZxu41ut/t9nA5P3x+zJwipGmocT6SlU/vhsRRrMITfHw YvhKeAeK0LPhBRwZepPue1cnNID9Dazy7GROHPsbmawrII867aLO/p4mvA9k7btFegg+zp8ri MbM1mTLm3Rx8//I6UvP+5hsEnd+wQXoDKqXEVFuiFqgmnZcY2LJzp73umWvbDj5Z/dS1nrmrL 7LKEBPeQlmBJBnZIOT5XzIUsuEApD7rfBKv3DKHRlAN9nU8kpb1NdHJTozsaV5dW/5351ZUSF i+IcxenfxVBFGNjQBVGIL661XW86y28lFP6EpEwJeAKRI/xWNcZ7OIcIBik4P6AJlA90m/gw1 s3uHQhui694a5HqEmhHl/hLgWiXj3d7yyaIU2EchtGOi+cR1AQQFXwsUP5rJ0sN5+F5J0lbxY fsTN8rQ+dIBBMS1m3sRGp6koggHmI39607x16EJaQfcmDI1QW5drmugvKEY= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_141217_EE85845B X-CRM114-Status: GOOD ( 13.28 ) 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] Subject: [OpenWrt-Devel] [PATCH v4 1/6] ath79: Speed up caldata/eeprom handling X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Reading and writing to and from flash storage is slowed down enormously by some functions which use a block size of 1. This patch reworks the extraction scripts to be much faster and efficient by reading and writing in possibly one big block. This is based on the initial commit a69e101 for ipq40xx by Christian Lamparter . Speed comparison @ UBNT AC-Mesh (just manually) results in a time reduction by three orders of magnitude (99.9 %). > time dd if=/dev/mtd6 of=/lib/firmware/test-slow bs=1 count=4096 skip=4096 4096+0 records in 4096+0 records out real 0m 16.84s user 0m 0.07s sys 0m 13.54s > time dd if=/dev/mtd6 of=/lib/firmware/test-fast bs=4096 count=1 skip=4096 iflag=skip_bytes 1+0 records in 1+0 records out real 0m 0.02s user 0m 0.00s sys 0m 0.02s Signed-off-by: Adrian Schmutzler Tested-by: Rosen Penev --- This depends on the patch "ath79: speed up ath9k-eeprom extraction" from Dmitry Tunin. Changed in v3: - Rebased on the patch from Dmitry Tunin - Changed position of iflag/oflag to be consistent with Dmitry Changed in v4: - Rebased --- .../linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom | 2 +- .../linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata | 6 +++--- 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 84e4d07b35..d8b292f4da 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 @@ -81,7 +81,7 @@ ath9k_patch_fw_mac() { 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 + 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() { 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 096064b7ce..f8e385be68 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 @@ -28,7 +28,7 @@ ath10kcal_from_file() { local offset=$2 local count=$3 - dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + 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" } @@ -42,7 +42,7 @@ ath10kcal_extract() { [ -n "$mtd" ] || \ ath10kcal_die "no mtd device found for partition $part" - dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + 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" } @@ -51,7 +51,7 @@ ath10kcal_patch_mac() { [ -z "$mac" ] && return - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6 + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=6 count=1 } ath10kcal_patch_mac_crc() { From patchwork Fri Mar 1 14:40:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050228 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="lLHJedhI"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sY33y5Jz9s4V for ; Sat, 2 Mar 2019 01:40:55 +1100 (AEDT) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject: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=Icxz+ogaBi9DklhhSvYSOmTqsy8sWeUxZM7Fh1Qpoec=; b=lLHJedhI/UsVtOYflusu5F7Gp0 gqQYALn7hGIStCuWhnC6n2u57UppOa3/wR1cqiApiBQZeVOQ9yA/4AfxIB1HF9L/7gODbwiMrffbn MxWwZFFii6EDZmqorVByqa9xZhkrOHUyxzEzbGiCazlDSNmsJ8pvuiVnfGmTHu3JV14adGRGic3qD FptyTOZlRDveNfKrW9K3FjaCPZIJyfIHqdymyteZGZvR3xEiTw4GqDDNigSk4SpXaij8ZO9ux7e9u ZCMuYPFHiUdObJAXnPgjug04KmI83+54ShN8VBLXiLITOMyHRiasCLEE+gIR5YIVnjcExL2xJBazr PfsHavlQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjL7-0005yj-Ix; Fri, 01 Mar 2019 14:40:41 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKx-0005pT-Ot for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:33 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLRI3-1giLAu3EsF-00IY4B for ; Fri, 01 Mar 2019 15:40:27 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:18 +0100 Message-Id: <20190301144022.1984-3-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:lUMqmB6iq08JzqguiYz9hYzKmZVtUkTZnOXngxNIzlZtesqO/5+ l42yDi4dY8lhuBeV66sdnjGOAQ1aNDOyEtiqT+eUPQ4RUgH0L1ChdnaQLb3PF2x8P/pvZsW jy/jfzGoK+OU+IkenJHl08cJmqwj33uhsAbxtb/aj/vK+ifSDnIeM5cDyFMhAXHJ6d92cdI kMrCHXH5r8TtIjTGK/Slg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ZF5VfbJfkmk=:6gvrxrb47gaZzelEkasXli /1S7/D+zOWpH2pw/zgqNXfv2Hs31r8m2KeVovAiySMDo50nUfPmdskp1gNbcKUrEJPTqRUYeq gpyP4aOs3V+OU4d9IYqmq/QJTZvdur4rkCaJ7beR9+3o/XWSG7sRF4qsNvNc1Fni3FNkxL7u6 y0vM0tbou/EXf8gnmTL/wdO7LLHMFYXxCrSjA3AXOA3zVjS4eHoZTq2ejT1L/+Foer30Y2Nlq GQJfN8HhtpP38HYYrwZhIzxzKzjT3hABP18CjukYeXpjZI93tcHQhJXY/sHKfUkPkECIya+mX jgQ4/uNut0mv5YmmmYKcdyhnBeT6cTaotjY/mrPgrzZTfqeAYKUJpyFP0jplEjtzYOE9Ztasv vrYZIJ6q3zykzU2B5AQY4VnAWsBZ/VCi3dZHGnyTiTej/lLBZOuteODOUGRtamvTEW5AuKS9t ffQ1wb8VBekvk/CYjR6J8pEM3LQuE+/3brYgwSXTtECf2WALvIVrUlv6OkqcyEUzoeIS8BM6b Ki+AE0oS4KT9GW6Q2AgOVdB+eq387Q7IZKALwo1iGK0hZPUq8NuRer9+y6RSf36FfI4hNaVKI RwD3UQXu0etKXJOk4epX9C1xDCI1RktgSxRCnLqEacOxQUsE6zjTTENTdt7DkT/Dom8RBTvnG Q3ufonX/3KntQRQcULEmKSjqR2StU9Z8SuqEMIXP3IZSAYVX+OtIuQJA7rmBfhTln12TebrCi tUYYNyZer/iASm9mQyMLjP14lap5gdbv7WUzdfqyxIjRlv1ndhBkqcqiEtA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_117746_918307CB X-CRM114-Status: GOOD ( 11.97 ) 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] Subject: [OpenWrt-Devel] [PATCH v4 2/6] ar71xx: Speed up caldata/eeprom handling X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Reading and writing to and from flash storage is slowed down enormously by some functions which use a block size of 1. This patch reworks the extraction scripts to be much faster and efficient by reading and writing in possibly one big block. This is based on the initial commit a69e101 for ipq40xx by Christian Lamparter . Speed comparison @ TP-Link TL-WDR4300 (just manually) results in a time reduction by three orders of magnitude (99.9 %). > time dd if=/dev/mtd3 of=/lib/firmware/test-slow bs=1 count=4096 skip=4096 4096+0 records in 4096+0 records out real 0m 15.85s user 0m 0.06s sys 0m 13.28s > time dd if=/dev/mtd3 of=/lib/firmware/test-fast bs=4096 count=1 skip=4096 iflag=skip_bytes 1+0 records in 1+0 records out real 0m 0.02s user 0m 0.00s sys 0m 0.02s Signed-off-by: Adrian Schmutzler --- Changed in v3: - Changed position of iflag/oflag to be consistent with ath79 Changed in v4: - Rebased --- .../linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom | 6 +++--- .../ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 94bce7d335..208d5f6bff 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -20,7 +20,7 @@ ath9k_eeprom_extract() { [ -n "$mtd" ] || \ ath9k_eeprom_die "no mtd device found for partition $part" - dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + 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" } @@ -35,7 +35,7 @@ ath9k_ubi_eeprom_extract() { [ -n "$ubi" ] || \ ath9k_eeprom_die "no UBI volume found for $part" - dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + 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" } @@ -62,7 +62,7 @@ ath9k_patch_firmware_mac() { [ -z "$mac" ] && return - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6 + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=2 count=1 } board=$(board_name) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 3450819630..cd5c1c2bcb 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -10,7 +10,7 @@ ath10kcal_from_file() { local offset=$2 local count=$3 - dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + 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" } @@ -30,7 +30,7 @@ ath10kcal_extract() { [ "$count" = "$cal_size" ] || \ ath10kcal_die "no calibration data found in $part" - dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + 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" } @@ -39,7 +39,7 @@ ath10kcal_patch_mac() { [ -z "$mac" ] && return - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6 + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=6 count=1 } [ -e /lib/firmware/$FIRMWARE ] && exit 0 From patchwork Fri Mar 1 14:40:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050232 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="ZwXecOA3"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sYd2z8mz9s4V for ; Sat, 2 Mar 2019 01:41:25 +1100 (AEDT) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject: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=vz1qmWJZNTTc1gHijA2RAzOn7/T3DB3o196uSGhQGPc=; b=ZwXecOA30eq0/M/E1RNP+x82yb NYyM20B31kcG4/J7i3MQxzGjxMXEGPz4ItfHRhzEyJfzHKVx7CW8aDLCL8/IpzcamP2zhVkRRTEG3 pP9KjsgPjdE1RwD16a57zRcgOdl1g+NB0vRNdyyAVYaFC/uHZFVV5jX5Zvy6AocFIMZUT3qVguPXE h4AnDy3QrDx45zOyvsdwTx4rljjT03vtZVdE1aL1t968RxTsDBcJYz/xCbWwSSU04dZmjYtVhfvCB EdW7gx+urBPVvNdCLYE9fRTBl4oI17vWAdXqhrJ2yq1yaqhm/ovEEijpIynJPTp6KQShxvoSDyLXr LcUrnW6A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjLd-0006np-PD; Fri, 01 Mar 2019 14:41:13 +0000 Received: from mout.kundenserver.de ([212.227.126.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKy-0005pY-B7 for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:35 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MXXhv-1gU6683ryx-00Z03b for ; Fri, 01 Mar 2019 15:40:28 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:19 +0100 Message-Id: <20190301144022.1984-4-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:3RC5GO0JY24k9jYT031n92pj8Ybkw8UGNeykkLIE7P7YGlB971O f56CCoZs7gt0Qdgc6PFBT/KrS/PVtS+vXi6zCqSSBvJEoD13JeaEOxkYIDsV9apQNGsekdz sSL3GGKfYB2/0thkyjNjd0J0o65j439Y7t5qWoM+D2Lg/00oeGRVX2pwbcWR6rYSVKFmhla aFlflBDOn/cg5cwtZfh8A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:G+786nlVUg4=:bPIVZbskUau4XIP/6uhPOu Yqygptur+JDDArjya4zb/OyS0l/uV/4EbSLdQekf7re6TRS2kMx4zSy5b/YSbU8Fo/TdzsHno 5wHdNQIYsTcCxyDK5Q0MAfeX2Ym7Ho41W2hx4Z4EeQiK88weysxIWlVqmhipGZwXODjPU5V0u 7g0U+/Jgl5IteovkqbVDdwhllVtMy1t2kBa+1YM9raCwk+ZVvXpGYPZt8SBoqrSl/eZNSkxKl Lergjyq2F5u974sAKDgqnh5BwVlyFBjZxUDCSZOHe/u/8vDWQvIuJ6G2cIdv6h7F5AJTZGrYK h5E6rBuYjC/EVTUEhZyO0hOEWauPF0681fH9WHNEHaJ/q3/VtepicUREdmGZdORIbeOc8bdqj cJidYcBb2N8mXg871Yp5CUzTEeUPnVTlSmpvetrzLKReTY/hyvnJXuyFZeiJlvdnNXIOrBmeZ eUItC9uNc+L2ROQledcVtZ/4elCnC55CPj0bOh1kx052Ic2amqJu1WhxTkPKgXfkHX8XnVNHI AIbTe3y5+DOcGTy6qnFVtCdGyJCaw0aVF97jhgiy4Qxlh2KWlNutij4UhqwiwZdzSAwPcxMVF fRF8EOgf4MW4ksGsggTM62KHhpNMPOrW+pqWqSYBY7PrFLvjju36ormc6ROkZdJjN5BI2FT5I ELmOOzU+e9f0FA8X53VrAkkfX8/GgPc+OH8R/v+Xh5ZJDiNcrpM4HiDl4vAM6E1KUnecn7pph 35KcwHhNOUsAuHAPUH7uffXrU7GOfPWdo/DBWgKdv3d9Ig8tJQYXCt0NZ/0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_680202_9E5120D1 X-CRM114-Status: UNSURE ( 9.41 ) 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.134 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v4 3/6] ar71xx: Speed up mtd extraction in ar71xx.sh X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Although the amount of data read here is smaller than for the caldata, there still might be some speed gain compared to reading bytewise. And there is no harm... Signed-off-by: Adrian Schmutzler --- Changed in v3: - Changed position of iflag to be consistent Changed in v4: - Rebased --- target/linux/ar71xx/base-files/lib/ar71xx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 95fa247f4b..f0f6f0398b 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -16,7 +16,7 @@ ar71xx_get_mtd_offset_size_format() { dev=$(find_mtd_part $mtd) [ -z "$dev" ] && return - dd if=$dev bs=1 skip=$offset count=$size 2>/dev/null | hexdump -v -e "1/1 \"$format\"" + dd if=$dev iflag=skip_bytes bs=$size skip=$offset count=1 2>/dev/null | hexdump -v -e "1/1 \"$format\"" } ar71xx_get_mtd_part_magic() { @@ -390,7 +390,7 @@ tplink_pharos_v2_get_model_string() { part=$(find_mtd_part 'product-info') [ -z "$part" ] && return 1 - dd if=$part bs=1 skip=4360 count=64 2>/dev/null | tr -d '\r\0' | head -n 1 + dd if=$part iflag=skip_bytes bs=64 skip=4360 count=1 2>/dev/null | tr -d '\r\0' | head -n 1 } ar71xx_board_detect() { From patchwork Fri Mar 1 14:40:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050234 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="US6am7Vw"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sYw0vNLz9s2R for ; Sat, 2 Mar 2019 01:41:40 +1100 (AEDT) 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=ZjLPwA5VO4RswIgbTKEv96CCu3cxR3TfriL+d1s5pOY=; b=US6am7VwFL3nGA7MK/hXUpJg/X tmUWvH0QAe6EtP76oPlFD38KiJV7lio2/6wkBebhKmPNBKVVbngU90sniIchS94SwB1iDvRjI3Bvu ImnBfCFD5ua0eZzpmKoHRk2QjzxXvLSCYdh2msjaOQ3Rn4/1OrYk2XUqR8oCdAeUXxzFULOKCt0Ns seTKy9ZruAxiCE/KqV60o4RQzJ856h3LkIWUA6IzQQTbG/0+01dmbsAxMGsk8sOqhlI9qhuyhL1JO OQH3hr0GMgKzlbTpm9WzQu9tiY2J8+/TlfacBkhjy45akRs1dxK36T8vuS+FTJ7rCo/N/QA/NFmKr 7qdJIh1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjLw-0007Hc-S4; Fri, 01 Mar 2019 14:41:32 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKx-0005pV-Rj for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:38 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N6bPS-1h3hti0IZy-0183pG for ; Fri, 01 Mar 2019 15:40:28 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:20 +0100 Message-Id: <20190301144022.1984-5-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Jt6HttbK/CL3jDgY4cPKS0Si3p+ccfXUzO7+YRBT1/yUDebDR1e 6+ylcjx4F/K2r7+TYuZMvEjhORGJuTTbgWJu3BJouWp1SWabbVVkrN5F/v3lXl26j2wkrqO Jd7QvFOm8TsdFpRRLAcH7mJ5+ik2TUZpO1RRX87qpqED1TePz6gU0xQJ1uRByowDWZnYnIM jQqw26S2/368sXTOz8DXg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ojZfmoo4PcE=:6/EyLUsrZqSHagqhECzpid IHFisM/Rx/rmfxgU1SVjzErve93IO/9JyKpAnPH/WP6XR5KbESUswnOxm8amUYQG/v0XeLksS HCxzAILGttJpVPuv2k9TbjvbO5ySi38fdJ6XHwnKcYIH50A5fyiGALl0I3RWZ85yv3wwrhtgt krq6JMb9O2QTRYYkq/vOzkRK3sj2T/FvH1fL7APJ/Wl16cxs65aUyyBvJONWBI4HHFg+8BI7h xKtwsnJ5hrB78wIKcqpD9iaLixh28sTOizFYaoW7T1OVp/me5r4jn4MwcfFouSzYR7Lod6OHT EGFi8v0AjlXdz5BzlRSDryNmDHlN9upMO5JoOkACNW+Fuu9xLVqNrsrN4ZTTmJ2dirENevJMW +8O6SpZLjREdI+KcE1wZvyCW3ilK3w/8spXubYE/mpVjntKfBmFNG7gLzSA4uWM80+L+iQGi6 zBlhaOgaaslWd0HtsjVC1k9PTiGDQKaiqbaOhcw211dMuzmbauYlXzcdtlwQDPsIMA4xEXLIP 0HgGE7MMRjnGN62KvDO68SzI/Mr4FR34s2PUYbh89cc+wFx5KN5OBaPlTrhwb+aM7aOrz2+tI vVs7cE57KBksB7/03H7QPLWnStng3YiJOmdcUI6SKZVzkp/sB5o9X/FoN+dAYTkSoDJmss4GC /vCL1x9ZGl1D0Ae8YlNHozT7yvfkoqBTR8SDvpiF8tw2cN/a8nM0pSHppcsEKbgFHPZNEnQaX QWlb23Fe+VVxgQUhbW5etq8a7u9Cselo9EsgI8lc4D3OndGVupFzXXP5moL+yktQJcSmhJdYI pJVdm4Q X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_362673_64EF7448 X-CRM114-Status: GOOD ( 14.08 ) 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.135 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.135 listed in wl.mailspike.net] Subject: [OpenWrt-Devel] [PATCH v4 4/6] ar71xx/ath79: Merge eeprom/caldata extraction into eeprom.sh X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 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 eeprom/caldata extraction is the same across different targets and also uses similar functions compared to each other. This patch is based on the proposed unification by Petr Štetiar. While this only covers ath79/ar71xx, others target supposedly will be merged easily. Signed-off-by: Adrian Schmutzler --- New in v3: Merged from the migration patches in my alternate patchset, which is obsoleted now. Changed in v4: - Rebased --- package/base-files/files/lib/functions/eeprom.sh | 88 ++++++++++++++++++++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 97 +++++----------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 78 +++++------------ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 84 +++++-------------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 60 ++++--------- 5 files changed, 171 insertions(+), 236 deletions(-) create mode 100644 package/base-files/files/lib/functions/eeprom.sh diff --git a/package/base-files/files/lib/functions/eeprom.sh b/package/base-files/files/lib/functions/eeprom.sh new file mode 100644 index 0000000000..80df3bb359 --- /dev/null +++ b/package/base-files/files/lib/functions/eeprom.sh @@ -0,0 +1,88 @@ +. /lib/functions.sh +. /lib/functions/system.sh + +eeprom_die() { + echo "eeprom: " "$*" + exit 1 +} + +ath10kcal_die() { + echo "ath10cal: " "$*" + exit 1 +} + +mtd_eeprom_extract() { + local part=$1 + local offset=$2 + local count=$3 + local mtd + + mtd=$(find_mtd_chardev $part) + [ -n "$mtd" ] || \ + 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 || \ + eeprom_die "failed to extract from $mtd" +} + +mtd_eeprom_extract_check() { + local part=$1 + local offset=$2 + local count=$3 + local mtd cal_size + + mtd=$(find_mtd_chardev $part) + [ -n "$mtd" ] || \ + eeprom_die "no mtd device found for partition $part" + + # Check that the calibration data size in header equals the desired size + cal_size=$(dd if=$mtd bs=2 count=1 skip=$(( $offset / 2 )) conv=swab 2>/dev/null | hexdump -ve '1/2 "%d"') + + [ "$count" = "$cal_size" ] || \ + eeprom_die "no calibration data found in $part" + + dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ + eeprom_die "failed to extract from $mtd" +} + +mtd_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 +} + +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" ] || \ + 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 || \ + eeprom_die "failed to extract from $ubi" +} + +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" +} diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 208d5f6bff..6b94b19ee7 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -2,60 +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" -} - -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/eeprom.sh ath9k_patch_firmware_mac() { local mac=$1 @@ -72,48 +19,48 @@ case "$FIRMWARE" in case $board in c-55|\ c-60) - ath9k_eeprom_extract "art" 4096 2048 + mtd_eeprom_extract "art" 4096 2048 ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +1) ;; fritz4020|\ fritz450e) - ath9k_eeprom_extract_reverse "urlader" 5441 1088 + mtd_eeprom_extract_reverse "urlader" 5441 1088 ;; mr18) . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 4096 2048 + ubi_eeprom_extract "caldata" 4096 2048 else - ath9k_eeprom_extract "odm-caldata" 4096 2048 + mtd_eeprom_extract "odm-caldata" 4096 2048 fi ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +1) ;; r6100 | \ wndr3700v4 | \ wndr4300) - ath9k_eeprom_extract "caldata" 4096 2048 + mtd_eeprom_extract "caldata" 4096 2048 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0) ;; rambutan) - ath9k_eeprom_extract "art" 4096 2048 + mtd_eeprom_extract "art" 4096 2048 ;; wlr8100) - ath9k_eeprom_extract "art" 4096 2048 + mtd_eeprom_extract "art" 4096 2048 ath9k_patch_firmware_mac $(mtd_get_mac_ascii u-boot-env "ethaddr") ;; z1) . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 4096 2048 + ubi_eeprom_extract "caldata" 4096 2048 else - ath9k_eeprom_extract "origcaldata" 4096 2048 + mtd_eeprom_extract "origcaldata" 4096 2048 fi ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2) ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_die "board $board is not supported yet" ;; esac ;; @@ -121,39 +68,39 @@ case "$FIRMWARE" in "pci_wmac0.eeprom") case $board in c-55) - ath9k_eeprom_extract "art" 20480 2048 + mtd_eeprom_extract "art" 20480 2048 ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +2) ;; fritz300e) - ath9k_eeprom_extract_reverse "urloader" 5441 1088 + mtd_eeprom_extract_reverse "urloader" 5441 1088 ;; mr18) . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 20480 2048 + ubi_eeprom_extract "caldata" 20480 2048 else - ath9k_eeprom_extract "odm-caldata" 20480 2048 + mtd_eeprom_extract "odm-caldata" 20480 2048 fi ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2) ;; wndr3700v4 | \ wndr4300) - ath9k_eeprom_extract "caldata" 20480 2048 + mtd_eeprom_extract "caldata" 20480 2048 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12) ;; z1) . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 86016 4096 + ubi_eeprom_extract "caldata" 86016 4096 else - ath9k_eeprom_extract "origcaldata" 86016 4096 + mtd_eeprom_extract "origcaldata" 86016 4096 fi ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3) ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_die "board $board is not supported yet" ;; esac ;; @@ -164,14 +111,14 @@ case "$FIRMWARE" in . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 36864 2048 + ubi_eeprom_extract "caldata" 36864 2048 else - ath9k_eeprom_extract "odm-caldata" 36864 2048 + mtd_eeprom_extract "odm-caldata" 36864 2048 fi ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3) ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index cd5c1c2bcb..37223686fb 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,38 +1,6 @@ #!/bin/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 cal_size - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath10kcal_die "no mtd device found for partition $part" - - # Check that the calibration data size in header equals the desired size - cal_size=$(dd if=$mtd bs=2 count=1 skip=$(( $offset / 2 )) conv=swab 2>/dev/null | hexdump -ve '1/2 "%d"') - - [ "$count" = "$cal_size" ] || \ - ath10kcal_die "no calibration data found in $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" -} +. /lib/functions/eeprom.sh ath10kcal_patch_mac() { local mac=$1 @@ -57,17 +25,17 @@ case "$FIRMWARE" in mr1750|\ mr1750v2|\ om5p-acv2) - ath10kcal_extract "ART" 20480 2116 + mtd_eeprom_extract_check "ART" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; archer-c25-v1|\ tl-wdr6500-v2) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) ;; archer-c7-v4|\ archer-c7-v5) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; cf-e355ac-v1|\ @@ -81,42 +49,42 @@ case "$FIRMWARE" in oolite-v5.2-dev|\ sr3200|\ xd3200) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ;; dap-2695-a1) - ath10kcal_extract "radiocfg" 20480 2116 + mtd_eeprom_extract_check "radiocfg" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a) ;; dir-869-a1|\ qihoo-c301) - ath10kcal_extract "radiocfg" 20480 2116 + mtd_eeprom_extract_check "radiocfg" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac) ;; dw33d) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_binary art 18) ;; epg5000|\ esr1750) - ath10kcal_extract "caldata" 20480 2116 + mtd_eeprom_extract_check "caldata" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; gl-ar750s|\ gl-ar750|\ tl-wpa8630) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; koala) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 12) +0) ;; mc-mac1200r) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1) ;; r6100) - ath10kcal_extract "caldata" 20480 2116 + mtd_eeprom_extract_check "caldata" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +2) ;; rb-952ui-5ac2nd|\ @@ -126,15 +94,15 @@ case "$FIRMWARE" in re355|\ re450|\ tl-wr902ac-v1) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; unifiac-lite|\ unifiac-pro) - ath10kcal_extract "EEPROM" 20480 2116 + mtd_eeprom_extract_check "EEPROM" 20480 2116 ;; wi2a-ac200i) - ath10kcal_extract "ART" 20480 2116 + mtd_eeprom_extract_check "ART" 20480 2116 ;; esac ;; @@ -142,16 +110,16 @@ case "$FIRMWARE" in case $board in archer-c5|\ archer-c7) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) ;; nbg6616|\ nbg6716) - ath10kcal_extract "RFdata" 20480 2116 + mtd_eeprom_extract_check "RFdata" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) ;; om5p-ac) - ath10kcal_extract "ART" 20480 2116 + mtd_eeprom_extract_check "ART" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; rb-911g-5hpacd|\ @@ -160,7 +128,7 @@ case "$FIRMWARE" in ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116 ;; wlr8100) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract_check "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) ;; esac @@ -173,18 +141,18 @@ case "$FIRMWARE" in archer-c60-v1|\ cf-e355ac-v2|\ cf-e375ac) - ath10kcal_extract "art" 20480 12064 + mtd_eeprom_extract_check "art" 20480 12064 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; archer-c60-v2) - ath10kcal_extract "art" 20480 12064 + mtd_eeprom_extract_check "art" 20480 12064 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; cf-e385ac) - ath10kcal_extract "art" 20480 12064 + mtd_eeprom_extract_check "art" 20480 12064 ;; 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 d8b292f4da..685bab4b05 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/eeprom.sh xor() { local val @@ -98,50 +60,50 @@ case "$FIRMWARE" in "ath9k-eeprom-ahb-18100000.wmac.bin") case $board in avm,fritz4020) - ath9k_eeprom_extract_reverse "urlader" 5441 1088 + mtd_eeprom_extract_reverse "urlader" 5441 1088 ;; dlink,dir-825-c1|\ dlink,dir-835-a1) - ath9k_eeprom_extract "art" 4096 1088 + mtd_eeprom_extract "art" 4096 1088 ath9k_patch_fw_mac_crc $(mtd_get_mac_text "mac" 4) 2 ;; dlink,dir-859-a1) - ath9k_eeprom_extract "art" 4096 1088 + mtd_eeprom_extract "art" 4096 1088 ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 2 ;; iodata,wn-ac1167dgr|\ iodata,wn-ac1600dgr|\ iodata,wn-ac1600dgr2|\ iodata,wn-ag300dgr) - ath9k_eeprom_extract "art" 4096 1088 + mtd_eeprom_extract "art" 4096 1088 ath9k_patch_fw_mac $(mtd_get_mac_ascii u-boot-env ethaddr) 2 ;; nec,wg800hp) - ath9k_eeprom_extract "art" 4096 1088 + mtd_eeprom_extract "art" 4096 1088 ath9k_patch_fw_mac $(mtd_get_mac_text board_data 1664) 2 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_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" 5441 1088 + mtd_eeprom_extract_reverse "urloader" 5441 1088 ;; buffalo,whr-g301n|\ buffalo,wzr-hp-g302h-a1a0|\ tplink,tl-wr841-v5|\ tplink,tl-wr941-v4) - ath9k_eeprom_extract "art" 4096 3768 + mtd_eeprom_extract "art" 4096 3768 ;; buffalo,wzr-hp-g450h) - ath9k_eeprom_extract "ART" 4096 1088 + mtd_eeprom_extract "ART" 4096 1088 ;; dlink,dir-825-c1|\ dlink,dir-835-a1) - ath9k_eeprom_extract "art" 20480 1088 + mtd_eeprom_extract "art" 20480 1088 ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "mac" 24) 1) 2 ;; ocedo,raccoon|\ @@ -149,7 +111,7 @@ case "$FIRMWARE" in tplink,tl-wdr4300|\ tplink,tl-wdr4900-v2|\ winchannel,wb2000) - ath9k_eeprom_extract "art" 20480 1088 + mtd_eeprom_extract "art" 20480 1088 ;; netgear,wnr612-v2|\ on,n150r|\ @@ -167,20 +129,20 @@ case "$FIRMWARE" in ubnt,bullet-m|\ ubnt,nano-m|\ ubnt,rocket-m) - ath9k_eeprom_extract "art" 4096 4096 + mtd_eeprom_extract "art" 4096 4096 ;; pqi,air-pen) - ath9k_eeprom_extract "art" 4096 2002 + mtd_eeprom_extract "art" 4096 2002 ;; ubnt,unifi) - ath9k_eeprom_extract "art" 4096 2048 + mtd_eeprom_extract "art" 4096 2048 ;; wd,mynet-wifi-rangeextender) - ath9k_eeprom_extract "art" 4096 4096 + mtd_eeprom_extract "art" 4096 4096 ath9k_patch_fw_mac_crc $(nvram get wl0_hwaddr) "$mac" 2 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_die "board $board is not supported yet" ;; esac ;; @@ -190,14 +152,14 @@ case "$FIRMWARE" in netgear,wndr3700|\ netgear,wndr3700v2|\ netgear,wndr3800) - ath9k_eeprom_extract "art" 4096 3768 + mtd_eeprom_extract "art" 4096 3768 ;; dlink,dir-825-b1) - ath9k_eeprom_extract "caldata" 4096 3768 + mtd_eeprom_extract "caldata" 4096 3768 ath9k_patch_fw_mac_crc $(mtd_get_mac_text "caldata" 65440) 524 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_die "board $board is not supported yet" ;; esac ;; @@ -207,14 +169,14 @@ case "$FIRMWARE" in netgear,wndr3700|\ netgear,wndr3700v2|\ netgear,wndr3800) - ath9k_eeprom_extract "art" 20480 3768 + mtd_eeprom_extract "art" 20480 3768 ;; dlink,dir-825-b1) - ath9k_eeprom_extract "caldata" 20480 3768 + mtd_eeprom_extract "caldata" 20480 3768 ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 65460) 1) 524 ;; *) - ath9k_eeprom_die "board $board is not supported yet" + eeprom_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 f8e385be68..52f9582e10 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,6 +1,7 @@ #!/bin/sh . /lib/functions/k2t.sh +. /lib/functions/eeprom.sh # xor multiple hex values of the same length xor() { @@ -18,34 +19,6 @@ xor() { printf "%0${retlen}x" "$ret" } -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" - - 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_patch_mac() { local mac=$1 @@ -79,9 +52,6 @@ ath10kcal_patch_mac_crc() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh - board=$(board_name) case "$FIRMWARE" in @@ -92,53 +62,53 @@ case "$FIRMWARE" in devolo,dvl1750c|\ devolo,dvl1750e|\ devolo,dvl1750i) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0) -1) ;; dlink,dir-859-a1) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac") ;; elecom,wrc-1750ghbk2-i) - ath10kcal_extract "ART" 20480 2116 + mtd_eeprom_extract "ART" 20480 2116 ;; engenius,ews511ap|\ glinet,gl-ar750s|\ glinet,gl-x750|\ tplink,re450-v2) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; iodata,wn-ac1167dgr|\ iodata,wn-ac1600dgr2) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) ;; nec,wg800hp) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac_crc $(mtd_get_mac_text board_data 2176) ;; ocedo,koala) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_binary art 12) ;; openmesh,om5p-ac-v2) - ath10kcal_extract "ART" 20480 2116 + mtd_eeprom_extract "ART" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; tplink,archer-c2-v3) - ath10kcal_extract "ART" 20480 2116 + mtd_eeprom_extract "ART" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; tplink,archer-c5-v1|\ tplink,archer-c7-v2) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1) ;; tplink,archer-a7-v5|\ tplink,archer-c7-v4|\ tplink,archer-c7-v5) - ath10kcal_extract "art" 20480 2116 + mtd_eeprom_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; ubnt,unifiac-lite|\ @@ -148,14 +118,14 @@ case "$FIRMWARE" in ubnt,nanostation-ac|\ ubnt,nanostation-ac-loco|\ ubnt,unifiac-pro) - ath10kcal_extract "EEPROM" 20480 2116 + mtd_eeprom_extract "EEPROM" 20480 2116 ;; esac ;; "ath10k/pre-cal-pci-0000:00:00.0.bin") case $board in phicomm,k2t) - ath10kcal_extract "art" 20480 12064 + mtd_eeprom_extract "art" 20480 12064 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 @@ -163,7 +133,7 @@ case "$FIRMWARE" in tplink,archer-c58-v1|\ tplink,archer-c59-v1|\ tplink,archer-c6-v2) - ath10kcal_extract "art" 20480 12064 + mtd_eeprom_extract "art" 20480 12064 ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary mac 8) -1) ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin From patchwork Fri Mar 1 14:40:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050231 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="IJX+aDur"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sYT1TQWz9s4V for ; Sat, 2 Mar 2019 01:41:17 +1100 (AEDT) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject: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=REwGdF6sE5fPqKGJxTiaShx/klesoLG9lmepLllm1c0=; b=IJX+aDurYFo8GPODGbL2AfFG8V ibig+49gQ+ushanXFPrxLWEz2IHtIk0CSntMPUw1nZ7j8oN5sAUsbs7WMk//JAL4IQt6fOb9tpOOt JXTTC1viKc8begu69iiuSpC6vy85SN1uE+WoiHCFknTx8I/e2HzRFBPEtjGNP/jXpnmM5uWgzldFo /3b+Xyjpjeg4P0ijpEoP1E2+htNVZGe4kyyVGaEZbHkRTh0yGNbKqlX7VN2YVr+OWFUXBtY8Rf5YF 0FW+3rfQ5q9gogdAzaTyj4rV1CiaQGnImM+O8AHI819OZtQi+vae2Ea3epymaXtaT+z/vlxqdy0pB sjVnG0Ww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjLT-0006XQ-FP; Fri, 01 Mar 2019 14:41:03 +0000 Received: from mout.kundenserver.de ([212.227.126.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKy-0005pW-BO for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:35 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MoOIi-1hJj9A146y-00okWO for ; Fri, 01 Mar 2019 15:40:28 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:21 +0100 Message-Id: <20190301144022.1984-6-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:pmArQH0lgFzl/cIV+rktQ8zW9DK9Z6PCBgXsCmjdvYluZ8NBV6O tKuJ/vd291i+htT71o2DDU4TxyZiWIPFAilw9Jza8+ATFVoTpDrVF9YfsBBfIegx465d7fr qoD/8PNK4TWge6KBPdejeNJ3IsFFs1IATXeOcgkZgligXAwaSwPqkt27w+ds3KgiQGo4MSB BDpXaoONrXbm5Mz0cG/aQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:oAi0mMRMVQc=:IaKUYna9ZAzD6aZY3YCOL6 CnOoCt9XoRO6xtoLgXqU3lXlcdqbQfI8EKdvy3S3BfjtuY0OCFpvF9ItVFH/L8uNEkBzNQd9a Xjj4+rygelOJ6myodrUpWn/wGQmYlvNPofrwbCbZXOeFkHVCi+pnZok81h3QcZ5Qkq7+kmhhv CZuTgmkTlmi+gTtyBdD5/zq0q+XO44VbicohFJz/33QYZy0W7D6ZRHQ8RIpprbXzDzjY6WmDz Y23pxpnky8bpncEHJTmjbNB/w/MFAsUWOCaCxP7tSTTX+3JF7J2nD7hyLSqg+YGp7Cyc35Vz+ AND6oh+CD2ovle1QgOEmCtbPdcrR08TLoBRd3m4/Go68BopD1tnXhU/+GHgeAaK24T5Hc1jPb QSy6BAOug9YQdz47jxuL2TqvPlKrtFq1pYI83BJVL3VWv+GmGVunOoFFqy0JJaBhBtjrKCiim 1MQ1JE4JdwKZdhRzrRsfpqNP7N37PWser/zDqQ3wwik51GuZyX1pdCW1qiRjeESe5r/MZVuqA tgvANW+VDBkQya8q63XwAuEZXIG5eVWwNV/CeIXEOv+dCKu3UdEkwUE/VpAkga5UD0iM/AagN PGSepDQUqr0g7cR2DX0bNBwkT9BL/f1j0H1fdhATeKhneKRDS8oSnvI6qwtmxs75CVf5/K6qU WfxUKlOAJWu4dQ14MR1423Xdb4ZXuRpjA88VR73nSUmvJImALbUwYKQJwN7harZu1v6IrmvP1 OhCao3/FvPg6m8DSUv3LPgOUgAuavSF1QFdUGGzpssDp0LChhjSpvsk6M10= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_689812_75D072C5 X-CRM114-Status: GOOD ( 10.40 ) 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.134 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v4 5/6] ipq40xx: Make use of common eeprom.sh library for caldata X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This merges the ath10k-caldata extraction into the common eeprom.sh. Signed-off-by: Adrian Schmutzler --- New in v3: Moved over from alternate patchset Changed in v4: - Rebased --- package/base-files/files/lib/functions/eeprom.sh | 5 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 82 ++++++---------------- 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/package/base-files/files/lib/functions/eeprom.sh b/package/base-files/files/lib/functions/eeprom.sh index 80df3bb359..48c7fd362d 100644 --- a/package/base-files/files/lib/functions/eeprom.sh +++ b/package/base-files/files/lib/functions/eeprom.sh @@ -67,9 +67,12 @@ ubi_eeprom_extract() { local part=$1 local offset=$2 local count=$3 - local ubidev=$(nand_find_ubi $CI_UBIPART) + local ubidev local ubi + . /lib/upgrade/nand.sh + + ubidev=$(nand_find_ubi $CI_UBIPART) ubi=$(nand_find_volume $ubidev $part) [ -n "$ubi" ] || \ eeprom_die "no UBI volume found for $part" 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 1264d2ef36..75e8f1a237 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,5 +1,7 @@ #!/bin/sh +. /lib/functions/eeprom.sh + # xor multiple hex values of the same length xor() { local val @@ -16,43 +18,6 @@ xor() { printf "%0${retlen}x" "$ret" } -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" - - 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" -} - ath10kcal_patch_mac_crc() { local mac=$1 local mac_offset=6 @@ -88,9 +53,6 @@ ath10kcal_is_caldata_valid() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh - board=$(board_name) @@ -98,8 +60,8 @@ case "$FIRMWARE" in "ath10k/cal-pci-0000:01:00.0.bin") case "$board" in meraki,mr33) - ath10kcal_ubi_extract "ART" 36864 2116 - ath10kcal_is_caldata_valid "4408" || ath10kcal_extract "ART" 36864 2116 + ubi_eeprom_extract "ART" 36864 2116 + ath10kcal_is_caldata_valid "4408" || mtd_eeprom_extract "ART" 36864 2116 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +1) ;; esac @@ -107,12 +69,12 @@ case "$FIRMWARE" in "ath10k/pre-cal-pci-0000:01:00.0.bin") case "$board" in asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 36864 12064 + ubi_eeprom_extract "Factory" 36864 12064 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; openmesh,a62) - ath10kcal_extract "0:ART" 36864 12064 + mtd_eeprom_extract "0:ART" 36864 12064 ;; esac ;; @@ -123,14 +85,14 @@ case "$FIRMWARE" in glinet,gl-b1300 |\ linksys,ea6350v3 |\ qcom,ap-dk01.1-c1) - ath10kcal_extract "ART" 4096 12064 + mtd_eeprom_extract "ART" 4096 12064 ;; asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 4096 12064 + ubi_eeprom_extract "Factory" 4096 12064 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - ath10kcal_ubi_extract "Factory" 4096 12064 + ubi_eeprom_extract "Factory" 4096 12064 ;; 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") @@ -145,21 +107,21 @@ case "$FIRMWARE" in openmesh,a62 |\ qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) - ath10kcal_extract "0:ART" 4096 12064 + mtd_eeprom_extract "0:ART" 4096 12064 ;; meraki,mr33) - ath10kcal_ubi_extract "ART" 4096 12064 - ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 4096 12064 + ubi_eeprom_extract "ART" 4096 12064 + ath10kcal_is_caldata_valid "202f" || mtd_eeprom_extract "ART" 4096 12064 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +2) ;; netgear,ex6100v2 |\ netgear,ex6150v2) - ath10kcal_extract "ART" 4096 12064 + mtd_eeprom_extract "ART" 4096 12064 ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0) ;; zyxel,nbg6617 |\ zyxel,wre6606) - ath10kcal_extract "ART" 4096 12064 + mtd_eeprom_extract "ART" 4096 12064 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; esac @@ -171,14 +133,14 @@ case "$FIRMWARE" in glinet,gl-b1300 |\ linksys,ea6350v3 |\ qcom,ap-dk01.1-c1) - ath10kcal_extract "ART" 20480 12064 + mtd_eeprom_extract "ART" 20480 12064 ;; asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 20480 12064 + ubi_eeprom_extract "Factory" 20480 12064 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - ath10kcal_ubi_extract "Factory" 20480 12064 + ubi_eeprom_extract "Factory" 20480 12064 ;; 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") @@ -193,21 +155,21 @@ case "$FIRMWARE" in openmesh,a62 |\ qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) - ath10kcal_extract "0:ART" 20480 12064 + mtd_eeprom_extract "0:ART" 20480 12064 ;; meraki,mr33) - ath10kcal_ubi_extract "ART" 20480 12064 - ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 20480 12064 + ubi_eeprom_extract "ART" 20480 12064 + ath10kcal_is_caldata_valid "202f" || mtd_eeprom_extract "ART" 20480 12064 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +3) ;; netgear,ex6100v2 |\ netgear,ex6150v2) - ath10kcal_extract "ART" 20480 12064 + mtd_eeprom_extract "ART" 20480 12064 ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 12) ;; zyxel,nbg6617 |\ zyxel,wre6606) - ath10kcal_extract "ART" 20480 12064 + mtd_eeprom_extract "ART" 20480 12064 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; esac From patchwork Fri Mar 1 14:40:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050233 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="Km++nndu"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449sYl5BQ8z9s2R for ; Sat, 2 Mar 2019 01:41:31 +1100 (AEDT) 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=A8rvF1PY4qNXoZrsrDRta0Oy0R6KvQL5KI3Y67LUTWg=; b=Km++nnduOlVy5ej1NDx+a7Tzyv I9i24n6E+febF0bzeq6dTaX+GxFv/Q03VuHjhnkZlMs5UZvgDviIgFmgFMJGeY0zSxMQm5fHuZdQJ f3cI5e+9UHUGl4ykW1dZYkKTsR+AEBMFKlCfbaD9j9bfpJwaFSjGf0vOAoJzQ55W2Bj6plzIBMb93 5jBccBvvL7htyP8olABe5pdUp4wlL6GBYIF+QLWtMu/a3yhllAcoPbFwUD3UX2CnXH+0sqb/Uma7p OfPqdOiOkIVdb/CKmkDAjHCeWQzOl1Oakvi7bczicvKbVT1djIv9S8mrIaZQs/6ys7oKcujyRwvV/ fSM4Qq1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjLm-00071s-I5; Fri, 01 Mar 2019 14:41:22 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKy-0005pZ-Pt for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:35 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MvavG-1hJ2uA1h4g-00shlW for ; Fri, 01 Mar 2019 15:40:28 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:22 +0100 Message-Id: <20190301144022.1984-7-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/IX9z3+cvRf116yeuDWhSKuNvXLqn3SWoXL52N8QVdP9U2obPm+ NjreEi8GwCzWAZbVLQ46UOlq3LgjHfJHf1+wU5wX/Mdy/DknUEvjawlnZeHr+eg5J9c+7nR 6IqnYH0bb0O3Syx7bCo12uUQx/EUE97X8l/AEKDLKJQD+saW0OXLA7Q4oZFHUACpQCugnuo 9QlBq3vrEDUuGRM/b5/fQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:GNUEeMlnFUE=:TWw2a8KyjSzGv3DdswXtGt j4p14ZeuKBRUK5Lel+WK8+/U2pba6Juq3XY0cHYI3j/nXkwWj0X7ePuGMsOHpNkgPWVhc0AxZ ox+pUNmXlJkcKqpgvMjTr391DOXEo5JsoiTdZ3xA9Pp4WuZSx/rtA7LLvdlySrl4NzGAaXc3Z +a/F0f+eLvGYabuXXbZKV912xPWvayGYzndzXSn+SWAMkJKglLT8PhcrB+0ZU7SfeDluZatiK ti/QhNXnx6Ag+265KBi8wZzOboVBOrq4z0DOJNap90Mnq7ELkzwAiFApx5TJ+MT/xFshJokIq q+yxJswnFv/684wpGmMdr65hh4F17rS3o9WgTxEdebl8glpD1wPUXdMTDgKnbtbeJrp95TWAU 702spTttrfQPHbsL18vijRXF7nt8a8emPIMsrR6kYOjjD2JSNzZG/n700qdIHezTat4iKqqmL LC3LZ/GOblVcp1oyoco81lLV2w56WW34W2RVrO+RudYo909oDFmTXanRIELhuVrAB7MV7HJWm suMQDMEM81Yfev9VjDRpWtUWV+a8uRs57KIxL0UKZDIgLw/5hCdAWg+3XYG5SRzUWuOrBKRWO B6uhF/8zfT9/gQaHyImOUl33jKZ5TEqOH7BZau8KnKYf9kGxKQuwIsfjiv8v3PHc07nQ8j3ix lvojpfbMZMhVcklR4vn0EWuLW/m926nzazkTqrLAqaEV8mlM2BM+jDnNcROsfgymsF3otrroN ziJgpkfZRh/Vn77CbByTvfF8li+odZqT56lR5ja0sRy1QH0CO1msrLqyruOIp+32pthdMgeGT PtuyK9C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064033_139429_BF2B177A X-CRM114-Status: GOOD ( 11.26 ) 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] Subject: [OpenWrt-Devel] [PATCH v4 6/6] ramips: Merge ath9k-eeprom extraction to common eeprom.sh X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 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 uses the common eeprom extraction functions in eeprom.sh. As a by-product, this will bring the speed enhancement through blockwise reading to the ramips target. This patch is based on the proposed unification by Petr Štetiar. Signed-off-by: Adrian Schmutzler --- New in v3: This is cut out from Petr's initial unification proposal, as I do not own a ramips device to test. Changed in v4: - Rebased --- .../etc/hotplug.d/firmware/10-rt2x00-eeprom | 32 +++++----------------- 1 file changed, 7 insertions(+), 25 deletions(-) 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 13a4687251..60b0e68bff 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,24 +1,5 @@ #!/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" - - dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ - rt2x00_eeprom_die "failed to extract from $mtd" -} - jboot_eeprom_extract() { local part=$1 local offset=$2 @@ -26,21 +7,21 @@ jboot_eeprom_extract() { mtd=$(find_mtd_part $part) [ -n "$mtd" ] || \ - rt2x00_eeprom_die "no mtd device found for partition $part" + eeprom_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" + eeprom_die "failed to extract from $mtd" } rt2x00_eeprom_set_macaddr() { local macaddr=$1 [ -n "$macaddr" ] || \ - rt2x00_eeprom_die "invalid wlan mac address" + eeprom_die "invalid wlan mac address" macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \ conv=notrunc bs=1 seek=4 count=6 2>/dev/null || \ - rt2x00_eeprom_die "failed to write mac address to eeprom file" + eeprom_die "failed to write mac address to eeprom file" } FW="/lib/firmware/$FIRMWARE" @@ -48,6 +29,7 @@ FW="/lib/firmware/$FIRMWARE" . /lib/functions.sh . /lib/functions/system.sh +. /lib/functions/eeprom.sh board=$(board_name) @@ -67,11 +49,11 @@ case "$FIRMWARE" in ;; tiny-ac) wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR) - rt2x00_eeprom_extract "factory" 0 512 + mtd_eeprom_extract "factory" 0 512 rt2x00_eeprom_set_macaddr $wifi_mac ;; *) - rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!" + eeprom_die "Please define mtd-eeprom in $board DTS file!" ;; esac ;;