aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/base-files/etc/hotplug.d
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-09-22 11:57:14 +0200
committerDavid Bauer <mail@david-bauer.net>2019-10-14 12:36:02 +0200
commit2c60de0e3f8cbe088fe8e495697cb9e98380710d (patch)
treea632a507208870d4b589dd7ee63d184ba6e2d0f3 /target/linux/ath79/base-files/etc/hotplug.d
parent5b6a80909280cafcb1e28ca120eed6922d68dc5a (diff)
downloadupstream-2c60de0e3f8cbe088fe8e495697cb9e98380710d.tar.gz
upstream-2c60de0e3f8cbe088fe8e495697cb9e98380710d.tar.bz2
upstream-2c60de0e3f8cbe088fe8e495697cb9e98380710d.zip
treewide: move MAC address patch functions to common library
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 <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ath79/base-files/etc/hotplug.d')
-rw-r--r--target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom57
-rw-r--r--target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata31
2 files changed, 11 insertions, 77 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 5ec13efd3f..3240026aec 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
+ ath9k_patch_mac $(mtd_get_mac_text "mac" 0x4)
;;
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
+ ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan24mac")
;;
engenius,ecb1750)
caldata_extract "art" 0x1000 0x440
- ath9k_patch_fw_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env "athaddr") +1) 0x2
+ ath9k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env "athaddr") +1)
;;
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
+ ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env ethaddr)
;;
nec,wg800hp)
caldata_extract "art" 0x1000 0x440
- ath9k_patch_fw_mac $(mtd_get_mac_text board_data 0x680) 0x2
+ ath9k_patch_mac $(mtd_get_mac_text board_data 0x680)
;;
qihoo,c301)
caldata_extract "radiocfg" 0x1000 0x440
- ath9k_patch_fw_mac $(mtd_get_mac_ascii devdata "wlan24mac") 0x2
+ ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan24mac")
;;
*)
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
+ ath9k_patch_mac $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1)
;;
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
+ ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac")
;;
wd,mynet-wifi-rangeextender)
caldata_extract "art" 0x1000 0x1000
- ath9k_patch_fw_mac $(nvram get wl0_hwaddr) "$mac" 0x2
+ ath9k_patch_mac $(nvram get wl0_hwaddr) "$mac"
;;
*)
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
+ ath9k_patch_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
+ ath9k_patch_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 878f6443ab..ebc1fc24d0 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