aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/lantiq/base-files/etc/hotplug.d
diff options
context:
space:
mode:
authorMathias Kresin <dev@kresin.me>2016-12-05 09:21:29 +0100
committerMathias Kresin <dev@kresin.me>2016-12-08 19:36:53 +0100
commitee5a6c10410b25adc6d400780953388035135fed (patch)
tree6275e1b710f869dade63e4cebfa985d8a48bbc5c /target/linux/lantiq/base-files/etc/hotplug.d
parentafa37092663d00aa0abf8c61943d9a1b5558b144 (diff)
downloadupstream-ee5a6c10410b25adc6d400780953388035135fed.tar.gz
upstream-ee5a6c10410b25adc6d400780953388035135fed.tar.bz2
upstream-ee5a6c10410b25adc6d400780953388035135fed.zip
lantiq: simplify ath9k eeprom extraction script
Add an extra function to patch the mac and fixup the checksum afterwards. Calculate the checksum position automatically. The offset to the mac address is the same for all checksum protected EEPROMs. No EEPROM requires a byte swapped mac address. The mac byte swap code was required due to an bug in the script that is now fixed. Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'target/linux/lantiq/base-files/etc/hotplug.d')
-rw-r--r--target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom27
1 files changed, 16 insertions, 11 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 28bde59a8a..fa52dd59ec 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
@@ -75,19 +75,24 @@ ath9k_ubi_eeprom_extract() {
ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
}
-ath9k_patch_firmware_mac() {
+ath9k_patch_fw_mac_crc() {
local mac=$1
local mac_offset=$2
- local swap=$3
- local chksum_offset=$4
+ 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
- [ $swap -gt 0 ] && mac="${mac:3:2}:${mac:0:2}:${mac:9:2}:${mac:6:2}:${mac:15:2}:${mac:12:2}"
-
[ -n "$chksum_offset" ] && {
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
@@ -120,27 +125,27 @@ case "$FIRMWARE" in
;;
BTHOMEHUBV2B)
ath9k_eeprom_extract "art" 0 1
- ath9k_patch_firmware_mac "00:00:00:00:00:00" 524 0 514
+ ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 524
;;
BTHOMEHUBV3A)
ath9k_eeprom_extract "art-copy" 0 1
- ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 268 0 258
+ ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 268
;;
BTHOMEHUBV5A)
ath9k_ubi_eeprom_extract "caldata" 4096 0
- ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +2) 268 0 258
+ ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +2) 268
;;
DGN3500*)
ath9k_eeprom_extract "calibration" 61440 0
- ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524 0 514
+ ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524
;;
FRITZ3370)
ath9k_eeprom_extract "urlader" 2437 0
- ath9k_patch_firmware_mac "00:00:00:00:00:00" 2 0
+ ath9k_patch_fw_mac "00:00:00:00:00:00" 2
;;
FRITZ7320|FRITZ7360SL)
ath9k_eeprom_extract "urlader" 2437 0
- ath9k_patch_firmware_mac "00:00:00:00:00:00" 268 0 258
+ ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 268
;;
TDW8970|TDW8980)
ath9k_eeprom_extract "boardconfig" 135168 0