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
|
|
|
|
|
2012-12-19 16:07:50 +00:00
|
|
|
. /lib/functions.sh
|
2011-07-03 15:02:01 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-02-14 17:32:45 +00:00
|
|
|
. /lib/ramips.sh
|
2015-11-02 10:17:41 +00:00
|
|
|
. /lib/functions/system.sh
|
2012-02-14 17:32:45 +00:00
|
|
|
|
|
|
|
board=$(ramips_board_name)
|
|
|
|
|
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
|
|
|
|
*)
|
2014-07-17 10:55:31 +00:00
|
|
|
rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!"
|
2011-07-03 15:02:01 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2012-02-14 17:32:45 +00:00
|
|
|
|
|
|
|
"rt2x00pci_1_0.eeprom")
|
|
|
|
case $board in
|
2014-06-02 12:42:52 +00:00
|
|
|
cy-swr1100)
|
|
|
|
rt2x00_eeprom_extract "factory" 8192 512
|
|
|
|
;;
|
2015-01-08 20:26:02 +00:00
|
|
|
br-6475nd | rt-n56u | whr-600d | whr-1166d)
|
2013-06-30 21:03:48 +00:00
|
|
|
rt2x00_eeprom_extract "factory" 32768 512
|
2012-02-14 17:32:45 +00:00
|
|
|
;;
|
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
|
|
|
|
;;
|
2012-02-14 17:32:45 +00:00
|
|
|
esac
|
|
|
|
;;
|
2011-08-19 15:55:07 +00:00
|
|
|
esac
|