mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-28 09:39:00 +00:00
5b6a809092
This moves the almost identical calibration data extraction functions present multiple times in several targets to a single library file /lib/functions/caldata.sh. Functions are renamed with more generic names to merge different variants that only differ in their names. Most of the targets used find_mtd_chardev, while some used find_mtd_part inside the extraction code. To merge them, the more abundant version with find_mtd_chardev is used in the common code. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> [rebase on latest master; add mpc85xx] Signed-off-by: David Bauer <mail@david-bauer.net>
45 lines
757 B
Bash
45 lines
757 B
Bash
#!/bin/sh
|
|
|
|
[ -e /lib/firmware/$FIRMWARE ] && exit 0
|
|
|
|
. /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)
|
|
|
|
case "$FIRMWARE" in
|
|
"pci_wmac0.eeprom")
|
|
case $board in
|
|
tplink,tl-wdr4900-v1)
|
|
caldata_extract "caldata" 0x1000 0x800
|
|
tpl_set_wireless_mac 0
|
|
;;
|
|
*)
|
|
caldata_die "board $board is not supported yet"
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
"pci_wmac1.eeprom")
|
|
case $board in
|
|
tplink,tl-wdr4900-v1)
|
|
caldata_extract "caldata" 0x5000 0x800
|
|
tpl_set_wireless_mac -1
|
|
;;
|
|
*)
|
|
caldata_die "board $board is not supported yet"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|