ramips: do not "local" variables outside of a function
[openwrt/staging/florian.git] / target / linux / ramips / base-files / etc / hotplug.d / firmware / 10-rt2x00-eeprom
index 0cd95a5abd567f157f0f91e4b4c95ec767cd32b0..4c8beac066a60fcf381c0dd594d14d68553814a6 100644 (file)
@@ -21,10 +21,22 @@ rt2x00_eeprom_extract() {
                rt2x00_eeprom_die "failed to extract from $mtd"
 }
 
+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"
+}
+
 FW="/lib/firmware/$FIRMWARE"
 [ -e "$FW" ] && exit 0
 
 . /lib/ramips.sh
+. /lib/functions/system.sh
 
 board=$(ramips_board_name)
 
@@ -45,6 +57,11 @@ case "$FIRMWARE" in
        br-6475nd | rt-n56u | whr-600d | whr-1166d)
                rt2x00_eeprom_extract "factory" 32768 512
                ;;
+       tiny-ac)
+               wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR)
+               rt2x00_eeprom_extract "factory" 0 512
+               rt2x00_eeprom_set_macaddr $wifi_mac
+               ;;
        esac
        ;;
 esac