diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2011-12-05 13:03:54 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2011-12-05 13:03:54 +0000 |
commit | 4cc2b9bb06436a1a57fc3620ea62c4835f9b7d51 (patch) | |
tree | 7c5aa2c06aaeaf9aa475f27f074038b375e774ac /target/linux/ar71xx/base-files | |
parent | 78699c2e51e85d8f56e882d250136f9d8fbdd632 (diff) | |
download | master-31e0f0ae-4cc2b9bb06436a1a57fc3620ea62c4835f9b7d51.tar.gz master-31e0f0ae-4cc2b9bb06436a1a57fc3620ea62c4835f9b7d51.tar.bz2 master-31e0f0ae-4cc2b9bb06436a1a57fc3620ea62c4835f9b7d51.zip |
ar71xx: rewrite WNDR3700/3800 handling
SVN-Revision: 29434
Diffstat (limited to 'target/linux/ar71xx/base-files')
6 files changed, 51 insertions, 159 deletions
diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wndr3700v2/network b/target/linux/ar71xx/base-files/etc/defconfig/wndr3700v2/network deleted file mode 100644 index 69d7dc712b..0000000000 --- a/target/linux/ar71xx/base-files/etc/defconfig/wndr3700v2/network +++ /dev/null @@ -1,69 +0,0 @@ -config interface loopback - option ifname lo - option proto static - option ipaddr 127.0.0.1 - option netmask 255.0.0.0 - -config interface lan - option ifname eth0.1 - option type bridge - option proto static - option ipaddr 192.168.1.1 - option netmask 255.255.255.0 - -config interface wan - option ifname eth1 - option proto dhcp - -config switch - option name rtl8366s - option reset 1 - option enable_vlan 1 - # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms - option blinkrate 2 - -config switch_vlan - option device rtl8366s - option vlan 1 - option ports "0 1 2 3 5t" - -config switch_port - # Port 1 controls the GREEN configuration of LEDs for - # the switch and the section does not correspond to a real - # switch port. - # - # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s; - # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity; - # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber; - # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx); - # 14: Link (master); 15: separate register - - option device rtl8366s - option port 1 - option led 6 - -config switch_port - # Port 2 controls the ORANGE configuration of LEDs for - # the switch and the section does not correspond to a real - # switch port. - # - # See the key above for switch port 1 for the meaning of the - # 'led' setting below. - - option device rtl8366s - option port 2 - option led 9 - -config switch_port - # Port 5 controls the configuration of the WAN LED and the - # section does not correspond to a real switch port. - # - # To toggle the use of green or orange LEDs for the WAN port, - # see the LED setting for wndr3700:green:wan in /etc/config/system. - # - # See the key above for switch port 1 for the meaning of the - # 'led' setting below. - - option device rtl8366s - option port 5 - option led 2 diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wndr3800/network b/target/linux/ar71xx/base-files/etc/defconfig/wndr3800/network deleted file mode 100644 index 69d7dc712b..0000000000 --- a/target/linux/ar71xx/base-files/etc/defconfig/wndr3800/network +++ /dev/null @@ -1,69 +0,0 @@ -config interface loopback - option ifname lo - option proto static - option ipaddr 127.0.0.1 - option netmask 255.0.0.0 - -config interface lan - option ifname eth0.1 - option type bridge - option proto static - option ipaddr 192.168.1.1 - option netmask 255.255.255.0 - -config interface wan - option ifname eth1 - option proto dhcp - -config switch - option name rtl8366s - option reset 1 - option enable_vlan 1 - # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms - option blinkrate 2 - -config switch_vlan - option device rtl8366s - option vlan 1 - option ports "0 1 2 3 5t" - -config switch_port - # Port 1 controls the GREEN configuration of LEDs for - # the switch and the section does not correspond to a real - # switch port. - # - # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s; - # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity; - # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber; - # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx); - # 14: Link (master); 15: separate register - - option device rtl8366s - option port 1 - option led 6 - -config switch_port - # Port 2 controls the ORANGE configuration of LEDs for - # the switch and the section does not correspond to a real - # switch port. - # - # See the key above for switch port 1 for the meaning of the - # 'led' setting below. - - option device rtl8366s - option port 2 - option led 9 - -config switch_port - # Port 5 controls the configuration of the WAN LED and the - # section does not correspond to a real switch port. - # - # To toggle the use of green or orange LEDs for the WAN port, - # see the LED setting for wndr3700:green:wan in /etc/config/system. - # - # See the key above for switch port 1 for the meaning of the - # 'led' setting below. - - option device rtl8366s - option port 5 - option led 2 diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index cb3b85177c..3af66b7e34 100755 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -111,7 +111,7 @@ get_status_led() { wzr-hp-g300nh) status_led="buffalo:green:router" ;; - wndr3700 | wndr3700v2 | wndr3800) + wndr3700) status_led="wndr3700:green:power" ;; wnr2000) diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/leds b/target/linux/ar71xx/base-files/etc/uci-defaults/leds index 0a724221cf..a0779effd8 100755 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/leds +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/leds @@ -123,9 +123,7 @@ wrt160nl) set_led_wlan "wlan" "WLAN" "wrt160nl:blue:wlan" "phy0tpt" ;; -wndr3700 | \ -wndr3700v2 | \ -wndr3800) +wndr3700) set_led_default "wan" "WAN LED (green)" "wndr3700:green:wan" "0" set_led_usbdev "usb" "USB" "wndr3700:green:usb" "1-1" ;; diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 02286e9aab..22e951d143 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -6,6 +6,48 @@ AR71XX_BOARD_NAME= AR71XX_MODEL= +ar71xx_get_mem_total() { + $(awk '/MemTotal:/ {print($2)}' /proc/meminfo) +} + +ar71xx_get_mtd_part_magic() { + local part="$1" + local mtd + + mtd=$(find_mtd_part $part) + [ -z "$mtd" ] && return + + dd if=$mtd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' +} + +wndr3700_board_detect() { + local machine="$1" + local magic + local name + + name="wndr3700" + + magic="$(ar71xx_get_mtd_part_magic firmware)" + case $magic in + "33373030") + machine="NETGEAR WNDR3700" + ;; + "33373031") + local mt + + mt=$(ar71xx_get_mem_total) + if [ "$mt" -lt "65536" ]; then + machine="NETGEAR WNDR3700v2" + else + machine="NETGEAR WNDR3800" + fi + ;; + esac + + AR71XX_BOARD_NAME="$name" + AR71XX_MODEL="$machine" +} + ar71xx_board_detect() { local machine local name @@ -169,14 +211,8 @@ ar71xx_board_detect() { *WP543) name="wp543" ;; - *WNDR3700) - name="wndr3700" - ;; - *WNDR3700v2) - name="wndr3700v2" - ;; - *WNDR3800) - name="wndr3800" + *"WNDR3700/WNDR3800") + wndr3700_board_detect "$machine" ;; *WNR2000) name="wnr2000" diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index cc327e6a1c..1de9077158 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -127,15 +127,11 @@ platform_check_image() { return 0 ;; wndr3700) - [ "$magic_long" != "33373030" ] && { - echo "Invalid image type." - return 1 - } - return 0 - ;; - wndr3700v2|wndr3800) - [ "$magic_long" != "33373031" ] && { - echo "Invalid image type." + local hw_magic + + hw_magic="$(ar71xx_get_mtd_part_magic firmware)" + [ "$magic_long" != "$hw_magic" ] && { + echo "Invalid image, hardware ID mismatch, hw:$hw_magic image:$magic_long." return 1 } return 0 |