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>
This commit is contained in:
Mathias Kresin 2016-12-05 09:21:29 +01:00
parent afa3709266
commit ee5a6c1041
1 changed files with 16 additions and 11 deletions

View File

@ -75,19 +75,24 @@ ath9k_ubi_eeprom_extract() {
ath9k_eeprom_extract_raw /dev/$ubi $offset $swap ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
} }
ath9k_patch_firmware_mac() { ath9k_patch_fw_mac_crc() {
local mac=$1 local mac=$1
local mac_offset=$2 local mac_offset=$2
local swap=$3 local chksum_offset=$((mac_offset - 10))
local chksum_offset=$4
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_mac
local xor_fw_mac local xor_fw_mac
local xor_fw_chksum local xor_fw_chksum
[ -z "$mac" -o -z "$mac_offset" ] && return [ -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" ] && { [ -n "$chksum_offset" ] && {
xor_mac=${mac//:/} xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}" xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
@ -120,27 +125,27 @@ case "$FIRMWARE" in
;; ;;
BTHOMEHUBV2B) BTHOMEHUBV2B)
ath9k_eeprom_extract "art" 0 1 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) BTHOMEHUBV3A)
ath9k_eeprom_extract "art-copy" 0 1 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) BTHOMEHUBV5A)
ath9k_ubi_eeprom_extract "caldata" 4096 0 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*) DGN3500*)
ath9k_eeprom_extract "calibration" 61440 0 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) FRITZ3370)
ath9k_eeprom_extract "urlader" 2437 0 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) FRITZ7320|FRITZ7360SL)
ath9k_eeprom_extract "urlader" 2437 0 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) TDW8970|TDW8980)
ath9k_eeprom_extract "boardconfig" 135168 0 ath9k_eeprom_extract "boardconfig" 135168 0