mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 22:23:27 +00:00
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>
This commit is contained in:
parent
5b6a809092
commit
2c60de0e3f
@ -73,3 +73,62 @@ caldata_valid() {
|
|||||||
return $?
|
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_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"
|
||||||
|
}
|
||||||
|
|
||||||
|
ath9k_patch_mac() {
|
||||||
|
local mac=$1
|
||||||
|
|
||||||
|
caldata_patch_mac "$mac" 0x2
|
||||||
|
}
|
||||||
|
|
||||||
|
ath9k_patch_mac_crc() {
|
||||||
|
local mac=$1
|
||||||
|
local mac_offset=$2
|
||||||
|
local chksum_offset=$((mac_offset - 10))
|
||||||
|
|
||||||
|
caldata_patch_mac "$mac" "$mac_offset" "$chksum_offset"
|
||||||
|
}
|
||||||
|
|
||||||
|
ath10kcal_patch_mac() {
|
||||||
|
local mac=$1
|
||||||
|
|
||||||
|
caldata_patch_mac "$mac" 0x6
|
||||||
|
}
|
||||||
|
|
||||||
|
ath10kcal_patch_mac_crc() {
|
||||||
|
local mac=$1
|
||||||
|
|
||||||
|
caldata_patch_mac "$mac" 0x6 0x2
|
||||||
|
}
|
||||||
|
@ -4,14 +4,6 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /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)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
@ -24,7 +16,7 @@ case "$FIRMWARE" in
|
|||||||
caldata_extract_ubi "caldata" 0x5000 0x1000
|
caldata_extract_ubi "caldata" 0x5000 0x1000
|
||||||
else
|
else
|
||||||
caldata_extract "wifi_data" 0x5000 0x1000
|
caldata_extract "wifi_data" 0x5000 0x1000
|
||||||
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0xc)
|
ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0xc)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -42,7 +34,7 @@ case "$FIRMWARE" in
|
|||||||
caldata_extract_ubi "caldata" 0x1000 0x1000
|
caldata_extract_ubi "caldata" 0x1000 0x1000
|
||||||
else
|
else
|
||||||
caldata_extract "wifi_data" 0x1000 0x1000
|
caldata_extract "wifi_data" 0x1000 0x1000
|
||||||
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0x0)
|
ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0x0)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -4,41 +4,6 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /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)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
@ -50,7 +15,7 @@ case "$FIRMWARE" in
|
|||||||
dlink,dir-825-c1|\
|
dlink,dir-825-c1|\
|
||||||
dlink,dir-835-a1)
|
dlink,dir-835-a1)
|
||||||
caldata_extract "art" 0x1000 0x440
|
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-c1|\
|
||||||
dlink,dir-842-c2|\
|
dlink,dir-842-c2|\
|
||||||
@ -59,11 +24,11 @@ case "$FIRMWARE" in
|
|||||||
nec,wg1200cr|\
|
nec,wg1200cr|\
|
||||||
wd,mynet-n750)
|
wd,mynet-n750)
|
||||||
caldata_extract "art" 0x1000 0x440
|
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)
|
engenius,ecb1750)
|
||||||
caldata_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
|
ath9k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env "athaddr") +1)
|
||||||
;;
|
;;
|
||||||
engenius,epg5000|\
|
engenius,epg5000|\
|
||||||
iodata,wn-ac1167dgr|\
|
iodata,wn-ac1167dgr|\
|
||||||
@ -71,15 +36,15 @@ case "$FIRMWARE" in
|
|||||||
iodata,wn-ac1600dgr2|\
|
iodata,wn-ac1600dgr2|\
|
||||||
iodata,wn-ag300dgr)
|
iodata,wn-ag300dgr)
|
||||||
caldata_extract "art" 0x1000 0x440
|
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)
|
nec,wg800hp)
|
||||||
caldata_extract "art" 0x1000 0x440
|
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)
|
qihoo,c301)
|
||||||
caldata_extract "radiocfg" 0x1000 0x440
|
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"
|
caldata_die "board $board is not supported yet"
|
||||||
@ -103,7 +68,7 @@ case "$FIRMWARE" in
|
|||||||
dlink,dir-825-c1|\
|
dlink,dir-825-c1|\
|
||||||
dlink,dir-835-a1)
|
dlink,dir-835-a1)
|
||||||
caldata_extract "art" 0x5000 0x440
|
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|\
|
ocedo,raccoon|\
|
||||||
tplink,tl-wdr3500-v1|\
|
tplink,tl-wdr3500-v1|\
|
||||||
@ -139,11 +104,11 @@ case "$FIRMWARE" in
|
|||||||
;;
|
;;
|
||||||
wd,mynet-n750)
|
wd,mynet-n750)
|
||||||
caldata_extract "art" 0x5000 0x440
|
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)
|
wd,mynet-wifi-rangeextender)
|
||||||
caldata_extract "art" 0x1000 0x1000
|
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"
|
caldata_die "board $board is not supported yet"
|
||||||
@ -161,7 +126,7 @@ case "$FIRMWARE" in
|
|||||||
;;
|
;;
|
||||||
dlink,dir-825-b1)
|
dlink,dir-825-b1)
|
||||||
caldata_extract "caldata" 0x1000 0xeb8
|
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"
|
caldata_die "board $board is not supported yet"
|
||||||
@ -179,7 +144,7 @@ case "$FIRMWARE" in
|
|||||||
;;
|
;;
|
||||||
dlink,dir-825-b1)
|
dlink,dir-825-b1)
|
||||||
caldata_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_patch_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 0xffb4) 1) 0x20c
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
caldata_die "board $board is not supported yet"
|
caldata_die "board $board is not supported yet"
|
||||||
|
@ -5,37 +5,6 @@
|
|||||||
. /lib/functions/caldata.sh
|
. /lib/functions/caldata.sh
|
||||||
. /lib/functions/k2t.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)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
|
@ -4,31 +4,6 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /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)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
|
@ -4,31 +4,6 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /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)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
|
@ -5,20 +5,13 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /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
|
case "$FIRMWARE" in
|
||||||
"ath10k/cal-pci-0000:02:00.0.bin")
|
"ath10k/cal-pci-0000:02:00.0.bin")
|
||||||
board=$(board_name)
|
board=$(board_name)
|
||||||
case $board in
|
case $board in
|
||||||
bt,homehub-v5a)
|
bt,homehub-v5a)
|
||||||
caldata_extract_ubi "caldata" 0x5000 0x844
|
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"
|
caldata_die "board $board is not supported yet"
|
||||||
|
@ -52,41 +52,6 @@ ath9k_ubi_eeprom_extract() {
|
|||||||
ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
|
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
|
case "$FIRMWARE" in
|
||||||
"ath9k-eeprom-pci-0000:00:0e.0.bin" | \
|
"ath9k-eeprom-pci-0000:00:0e.0.bin" | \
|
||||||
"ath9k-eeprom-pci-0000:01:00.0.bin" | \
|
"ath9k-eeprom-pci-0000:01:00.0.bin" | \
|
||||||
@ -102,19 +67,19 @@ case "$FIRMWARE" in
|
|||||||
;;
|
;;
|
||||||
bt,homehub-v2b)
|
bt,homehub-v2b)
|
||||||
ath9k_eeprom_extract "art" 0x0 1
|
ath9k_eeprom_extract "art" 0x0 1
|
||||||
ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 0x20c
|
ath9k_patch_mac_crc "00:00:00:00:00:00" 0x20c
|
||||||
;;
|
;;
|
||||||
bt,homehub-v3a)
|
bt,homehub-v3a)
|
||||||
ath9k_eeprom_extract "art-copy" 0x0 1
|
ath9k_eeprom_extract "art-copy" 0x0 1
|
||||||
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c
|
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c
|
||||||
;;
|
;;
|
||||||
bt,homehub-v5a)
|
bt,homehub-v5a)
|
||||||
ath9k_ubi_eeprom_extract "caldata" 0x1000 0
|
ath9k_ubi_eeprom_extract "caldata" 0x1000 0
|
||||||
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c
|
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c
|
||||||
;;
|
;;
|
||||||
netgear,dgn3500|netgear,dgn3500b)
|
netgear,dgn3500|netgear,dgn3500b)
|
||||||
ath9k_eeprom_extract "calibration" 0xf000 0
|
ath9k_eeprom_extract "calibration" 0xf000 0
|
||||||
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c
|
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c
|
||||||
;;
|
;;
|
||||||
avm,fritz3370-rev2-hynix|\
|
avm,fritz3370-rev2-hynix|\
|
||||||
avm,fritz3370-rev2-micron|\
|
avm,fritz3370-rev2-micron|\
|
||||||
|
@ -4,17 +4,6 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /lib/functions/caldata.sh
|
||||||
|
|
||||||
tpl_set_wireless_mac()
|
|
||||||
{
|
|
||||||
local offset=$1
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
board=$(board_name)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
@ -22,7 +11,7 @@ case "$FIRMWARE" in
|
|||||||
case $board in
|
case $board in
|
||||||
tplink,tl-wdr4900-v1)
|
tplink,tl-wdr4900-v1)
|
||||||
caldata_extract "caldata" 0x1000 0x800
|
caldata_extract "caldata" 0x1000 0x800
|
||||||
tpl_set_wireless_mac 0
|
ath9k_patch_mac $(mtd_get_mac_binary u-boot 0x4fc00)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
caldata_die "board $board is not supported yet"
|
caldata_die "board $board is not supported yet"
|
||||||
@ -34,7 +23,7 @@ case "$FIRMWARE" in
|
|||||||
case $board in
|
case $board in
|
||||||
tplink,tl-wdr4900-v1)
|
tplink,tl-wdr4900-v1)
|
||||||
caldata_extract "caldata" 0x5000 0x800
|
caldata_extract "caldata" 0x5000 0x800
|
||||||
tpl_set_wireless_mac -1
|
ath9k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x4fc00) -1)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
caldata_die "board $board is not supported yet"
|
caldata_die "board $board is not supported yet"
|
||||||
|
@ -17,17 +17,6 @@ jboot_eeprom_extract() {
|
|||||||
caldata_die "failed to extract from $mtd"
|
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)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
@ -43,12 +32,12 @@ case "$FIRMWARE" in
|
|||||||
wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
|
wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
|
||||||
wifi_mac=$(macaddr_add "$wan_mac" 1)
|
wifi_mac=$(macaddr_add "$wan_mac" 1)
|
||||||
jboot_eeprom_extract "config" 0xE000
|
jboot_eeprom_extract "config" 0xE000
|
||||||
rt2x00_eeprom_set_macaddr $wifi_mac
|
caldata_patch_mac $wifi_mac 0x4
|
||||||
;;
|
;;
|
||||||
dovado,tiny-ac)
|
dovado,tiny-ac)
|
||||||
wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR)
|
wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR)
|
||||||
caldata_extract "factory" 0x0 0x200
|
caldata_extract "factory" 0x0 0x200
|
||||||
rt2x00_eeprom_set_macaddr $wifi_mac
|
caldata_patch_mac $wifi_mac 0x4
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
caldata_die "Please define mtd-eeprom in $board DTS file!"
|
caldata_die "Please define mtd-eeprom in $board DTS file!"
|
||||||
|
Loading…
Reference in New Issue
Block a user