OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #!/bin/sh |
2 | |||
3 | rt2x00_eeprom_die() { |
||
4 | echo "rt2x00 eeprom: " "$*" |
||
5 | exit 1 |
||
6 | } |
||
7 | |||
8 | rt2x00_eeprom_extract() { |
||
9 | local part=$1 |
||
10 | local offset=$2 |
||
11 | local count=$3 |
||
12 | local mtd |
||
13 | |||
14 | mtd=$(find_mtd_part $part) |
||
15 | [ -n "$mtd" ] || \ |
||
16 | rt2x00_eeprom_die "no mtd device found for partition $part" |
||
17 | |||
18 | dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ |
||
19 | rt2x00_eeprom_die "failed to extract from $mtd" |
||
20 | } |
||
21 | |||
22 | jboot_eeprom_extract() { |
||
23 | local part=$1 |
||
24 | local offset=$2 |
||
25 | local mtd |
||
26 | |||
27 | mtd=$(find_mtd_part $part) |
||
28 | [ -n "$mtd" ] || \ |
||
29 | rt2x00_eeprom_die "no mtd device found for partition $part" |
||
30 | |||
31 | jboot_config_read -i $mtd -o $offset -e /lib/firmware/$FIRMWARE 2>/dev/null || \ |
||
32 | rt2x00_eeprom_die "failed to extract from $mtd" |
||
33 | } |
||
34 | |||
35 | rt2x00_eeprom_set_macaddr() { |
||
36 | local macaddr=$1 |
||
37 | |||
38 | [ -n "$macaddr" ] || \ |
||
39 | rt2x00_eeprom_die "invalid wlan mac address" |
||
40 | |||
41 | macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \ |
||
42 | conv=notrunc bs=1 seek=4 count=6 2>/dev/null || \ |
||
43 | rt2x00_eeprom_die "failed to write mac address to eeprom file" |
||
44 | } |
||
45 | |||
46 | FW="/lib/firmware/$FIRMWARE" |
||
47 | [ -e "$FW" ] && exit 0 |
||
48 | |||
49 | . /lib/functions.sh |
||
50 | . /lib/functions/system.sh |
||
51 | |||
52 | board=$(board_name) |
||
53 | |||
54 | case "$FIRMWARE" in |
||
55 | "soc_wmac.eeprom") |
||
56 | case $board in |
||
57 | dlink,dwr-116-a1|\ |
||
3 | office | 58 | dlink,dwr-921-c1) |
1 | office | 59 | wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000) |
60 | wifi_mac=$(macaddr_add "$wan_mac" 1) |
||
61 | jboot_eeprom_extract "config" 0xE000 |
||
62 | rt2x00_eeprom_set_macaddr $wifi_mac |
||
63 | ;; |
||
64 | tiny-ac) |
||
65 | wifi_mac=$(mtd_get_mac_ascii u-boot-env INIC_MAC_ADDR) |
||
66 | rt2x00_eeprom_extract "factory" 0 512 |
||
67 | rt2x00_eeprom_set_macaddr $wifi_mac |
||
68 | ;; |
||
69 | *) |
||
70 | rt2x00_eeprom_die "Please define mtd-eeprom in $board DTS file!" |
||
71 | ;; |
||
72 | esac |
||
73 | ;; |
||
74 | esac |