2011-07-03 15:02:01 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
rt2x00_eeprom_die() {
|
|
|
|
echo "rt2x00 eeprom: " "$*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
rt2x00_eeprom_extract() {
|
|
|
|
local part=$1
|
|
|
|
local offset=$2
|
|
|
|
local count=$3
|
|
|
|
local mtd
|
|
|
|
|
|
|
|
mtd=$(find_mtd_part $part)
|
|
|
|
[ -n "$mtd" ] || \
|
|
|
|
rt2x00_eeprom_die "no mtd device found for partition $part"
|
|
|
|
|
2012-05-27 17:09:50 +00:00
|
|
|
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
|
2011-07-03 15:02:01 +00:00
|
|
|
rt2x00_eeprom_die "failed to extract from $mtd"
|
|
|
|
}
|
|
|
|
|
2018-01-20 08:27:03 +00:00
|
|
|
jboot_eeprom_extract() {
|
|
|
|
local part=$1
|
|
|
|
local offset=$2
|
|
|
|
local mtd
|
|
|
|
|
|
|
|
mtd=$(find_mtd_part $part)
|
|
|
|
[ -n "$mtd" ] || \
|
|
|
|
rt2x00_eeprom_die "no mtd device found for partition $part"
|
|
|
|
|
|
|
|
jboot_config_read -i $mtd -o $offset -e /lib/firmware/$FIRMWARE 2>/dev/null || \
|
|
|
|
rt2x00_eeprom_die "failed to extract from $mtd"
|
|
|
|
}
|
|
|
|
|
2015-11-02 10:17:41 +00:00
|
|
|
rt2x00_eeprom_set_macaddr() {
|
|
|
|
local macaddr=$1
|
|
|
|
|
|
|
|
[ -n "$macaddr" ] || \
|
|
|
|
rt2x00_eeprom_die "invalid wlan mac address"
|
|
|
|
|
|
|
|
macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \
|
|
|
|
conv=notrunc bs=1 seek=4 count=6 2>/dev/null || \
|
|
|
|
rt2x00_eeprom_die "failed to write mac address to eeprom file"
|
|
|
|
}
|
|
|
|
|
2013-11-25 08:34:55 +00:00
|
|
|
FW="/lib/firmware/$FIRMWARE"
|
|
|
|
[ -e "$FW" ] && exit 0
|
2011-07-03 15:02:01 +00:00
|
|
|
|
2017-05-12 20:36:07 +00:00
|
|
|
. /lib/functions.sh
|
2015-11-02 10:17:41 +00:00
|
|
|
. /lib/functions/system.sh
|
2012-02-14 17:32:45 +00:00
|
|
|
|
2017-05-12 20:36:07 +00:00
|
|
|
board=$(board_name)
|
2012-02-14 17:32:45 +00:00
|
|
|
|
2011-07-03 15:02:01 +00:00
|
|
|
case "$FIRMWARE" in
|
2012-12-22 16:09:03 +00:00
|
|
|
"soc_wmac.eeprom")
|
2011-07-03 15:02:01 +00:00
|
|
|
case $board in
|
2018-03-10 09:34:38 +00:00
|
|
|
dlink,dwr-116-a1|\
|
2018-04-19 17:34:22 +00:00
|
|
|
dlink,dwr-118-a2|\
|
2018-03-10 09:34:38 +00:00
|
|
|
dlink,dwr-921-c1)
|
2018-01-20 08:27:03 +00:00
|
|
|
wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
|
|
|
|
wifi_mac=$(macaddr_add "$wan_mac" 1)
|
|
|
|
jboot_eeprom_extract "config" 0xE000
|
|
|
|
rt2x00_eeprom_set_macaddr $wifi_mac
|
|
|
|
;;
|
2015-11-02 10:17:51 +00:00
|
|
|
tiny-ac)
|
2016-09-23 22:07:24 +00:00
|
|
|
wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR)
|
2015-11-02 10:17:51 +00:00
|
|
|
rt2x00_eeprom_extract "factory" 0 512
|
|
|
|
rt2x00_eeprom_set_macaddr $wifi_mac
|
|
|
|
;;
|
2016-11-07 21:02:20 +00:00
|
|
|
*)
|
|
|
|
rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!"
|
|
|
|
;;
|
2012-02-14 17:32:45 +00:00
|
|
|
esac
|
|
|
|
;;
|
2011-08-19 15:55:07 +00:00
|
|
|
esac
|