diff options
Diffstat (limited to 'target/linux/ramips/base-files')
10 files changed, 920 insertions, 0 deletions
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh new file mode 100755 index 000000000..472013025 --- /dev/null +++ b/target/linux/ramips/base-files/etc/diag.sh @@ -0,0 +1,139 @@ +#!/bin/sh +# +# Copyright (C) 2010 OpenWrt.org +# +# + +. /lib/ramips.sh + +status_led="" + +led_set_attr() { + [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2" +} + +status_led_set_timer() { + led_set_attr $status_led "trigger" "timer" + led_set_attr $status_led "delay_on" "$1" + led_set_attr $status_led "delay_off" "$2" +} + +status_led_on() { + led_set_attr $status_led "trigger" "none" + led_set_attr $status_led "brightness" 255 +} + +status_led_off() { + led_set_attr $status_led "trigger" "none" + led_set_attr $status_led "brightness" 0 +} + +get_status_led() { + case $(ramips_board_name) in + 3g-6200n) + status_led="edimax:green:power" + ;; + argus-atp52b) + status_led="argus-atp52b:green:run" + ;; + dir-300-b1 | dir-600-b1 | dir-600-b2 | dir-615-h1 | dir-620-a1) + status_led="d-link:green:status" + ;; + dap-1350) + status_led="d-link:blue:power" + ;; + esr-9753) + status_led="esr-9753:orange:power" + ;; + f5d8235-v2) + status_led="f5d8235v2:blue:router" + ;; + fonera20n) + status_led="fonera20n:green:power" + ;; + all0239-3g|\ + hw550-3g) + status_led="hw550-3g:green:status" + ;; + mofi3500-3gn) + status_led="mofi3500-3gn:green:status" + ;; + nbg-419n) + status_led="nbg-419n:green:power" + ;; + nw718) + status_led="nw718:amber:cpu" + ;; + omni-emb) + status_led="emb:green:status" + ;; + psr-680w) + status_led="psr-680w:red:wan" + ;; + pwh2004) + status_led="pwh2004:green:power" + ;; + rt-n15) + status_led="rt-n15:blue:power" + ;; + rt-n10-plus) + status_led="asus:green:wps" + ;; + rt-n56u | wl-330n | wl-330n3g) + status_led="asus:blue:power" + ;; + sl-r7205) + status_led="sl-r7205:green:status" + ;; + v11st-fe) + status_led="v11st-fe:green:status" + ;; + v22rw-2x2) + status_led="v22rw-2x2:green:security" + ;; + w306r-v20) + status_led="w306r-v20:green:sys" + ;; + w502u) + status_led="alfa:blue:wps" + ;; + wcr-150gn) + status_led="wcr150gn:amber:power" + ;; + whr-g300n) + status_led="whr-g300n:green:router" + ;; + wli-tx4-ag300n) + status_led="buffalo:blue:power" + ;; + wl-351) + status_led="wl-351:amber:power" + ;; + wr512-3gn) + status_led="wr512:green:wps" + ;; + ur-336un) + status_led="ur336:green:wps" + ;; + xdxrn502j) + status_led="xdxrn502j:green:power" + ;; + esac +} + +set_state() { + get_status_led + + case "$1" in + preinit) + insmod leds-gpio + status_led_set_timer 200 200 + ;; + failsafe) + status_led_set_timer 50 50 + ;; + done) + status_led_on + ;; + esac +} diff --git a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom new file mode 100644 index 000000000..bb7f66284 --- /dev/null +++ b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom @@ -0,0 +1,111 @@ +#!/bin/sh + +rt2x00_eeprom_die() { + echo "rt2x00 eeprom: " "$*" + exit 1 +} + +rt2x00_eeprom_extract() { + local part=$1 + local offset=$2 + local count=$3 + local mtd + + . /etc/functions.sh + + mtd=$(find_mtd_part $part) + [ -n "$mtd" ] || \ + rt2x00_eeprom_die "no mtd device found for partition $part" + + dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + rt2x00_eeprom_die "failed to extract from $mtd" +} + +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/ramips.sh + +board=$(ramips_board_name) + +case "$FIRMWARE" in +"RT288X.eeprom" | \ +"RT305X.eeprom" | \ +"RT3883.eeprom") + case $board in + dir-300-b1 | \ + dir-600-b1 | \ + dir-600-b2) + rt2x00_eeprom_extract "devdata" 16384 272 + ;; + + dap-1350) + rt2x00_eeprom_extract "devdata" 0 272 + ;; + + rt-n10-plus | \ + rt-g32-b1) + rt2x00_eeprom_extract "devconf" 0 272 + ;; + + f5d8235-v1 | \ + f5d8235-v2) + rt2x00_eeprom_extract "u-boot" 262144 272 + ;; + + 3g-6200n | \ + all0239-3g | \ + all0256n | \ + all5002 | \ + argus-atp52b | \ + bc2 | \ + carambola | \ + dir-615-h1 | \ + dir-620-a1 | \ + esr-9753 | \ + fonera20n | \ + freestation5 | \ + hw550-3g | \ + mofi3500-3gn | \ + pwh2004 | \ + nbg-419n | \ + nw718 | \ + omni-emb | \ + psr-680w | \ + rt-n15 | \ + rt-n56u | \ + sl-r7205 | \ + v11st-fe | \ + v22rw-2x2 | \ + w306r-v20 | \ + w502u | \ + wcr-150gn | \ + whr-g300n | \ + wl-330n | \ + wl-330n3g | \ + wl-351 | \ + wli-tx4-ag300n | \ + wr512-3gn | \ + wr6202 | \ + ur-336un | \ + xdxrn502j) + rt2x00_eeprom_extract "factory" 0 272 + ;; + + wl341v3) + rt2x00_eeprom_extract "board-nvram" 64880 272 + ;; + + *) + rt2x00_eeprom_die "board $board is not supported yet" + ;; + esac + ;; + +"rt2x00pci_1_0.eeprom") + case $board in + rt-n56u) + rt2x00_eeprom_extract "factory" 32768 272 + ;; + esac + ;; +esac diff --git a/target/linux/ramips/base-files/etc/inittab b/target/linux/ramips/base-files/etc/inittab new file mode 100644 index 000000000..67c36a6a9 --- /dev/null +++ b/target/linux/ramips/base-files/etc/inittab @@ -0,0 +1,4 @@ +::sysinit:/etc/init.d/rcS S boot +::shutdown:/etc/init.d/rcS K shutdown +ttyS0::askfirst:/bin/ash --login +ttyS1::askfirst:/bin/ash --login diff --git a/target/linux/ramips/base-files/etc/uci-defaults/leds b/target/linux/ramips/base-files/etc/uci-defaults/leds new file mode 100755 index 000000000..2fddc011e --- /dev/null +++ b/target/linux/ramips/base-files/etc/uci-defaults/leds @@ -0,0 +1,86 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh +. /lib/ramips.sh + +set_usb_led() { + ucidef_set_led_usbdev "usb" "USB" "$1" "1-1" +} + +set_wifi_led() { + ucidef_set_led_netdev "wifi_led" "wifi" "$1" "wlan0" +} + +board=$(ramips_board_name) + +case $board in + 3g-6200n) + set_wifi_led "edimax:amber:wlan" + set_usb_led "edimax:blue:3g" + ;; + all0256n) + ucidef_set_rssimon "wlan0" "40000" "1" + ucidef_set_led_rssi "rssilow" "RSSILOW" "all0256n:green:rssilow" "wlan0" "1" "40" "0" "6" + ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "all0256n:green:rssimed" "wlan0" "30" "80" "-29" "5" + ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "all0256n:green:rssihigh" "wlan0" "70" "100" "-69" "8" + set_wifi_led "rt2800pci-phy0::radio" + ;; + bc2) + set_usb_led "bc2:blue:usb" + ;; + dir-300-b1|\ + dir-600-b1|\ + dir-600-b2|\ + dir-620-a1) + # ANDed with vlan switch port 4 led state + ucidef_set_led_default "wan" "WAN LED (amber)" "d-link:amber:wan" "1" + set_wifi_led "rt2800pci-phy0::radio" + ;; + dir-615-h1) + ucidef_set_led_default "status" "Status LED (amber)" "d-link:amber:status" "0" + set_wifi_led "rt2800pci-phy0::radio" + ;; + esr-9753) + set_wifi_led "rt2800pci-phy0::radio" + ;; + f5d8235-v1) + set_usb_led "f5d8235-v1:blue:storage" + ;; + f5d8235-v2) + set_usb_led "f5d8235v2:blue:storage" + ;; + fonera20n) + set_usb_led "fonera20n:orange:usb" + set_wifi_led "fonera20n:orange:wifi" + ;; + all0239-3g|\ + hw550-3g) + set_usb_led "hw550-3g:green:usb" + ;; + mofi3500-3gn) + set_usb_led "mofi3500-3gn:green:usb" + ;; + nw718) + set_usb_led "nw718:amber:usb" + ;; + sl-r7205) + set_wifi_led "rt2800pci-phy0::radio" + ;; + v11st-fe) + set_wifi_led "rt2800pci-phy0::radio" + ;; + w306r-v20) + set_wifi_led "rt2800pci-phy0::radio" + ;; + w502u) + set_usb_led "alfa:blue:usb" + set_wifi_led "rt2800pci-phy0::radio" + ;; + wcr-150gn) + set_usb_led "wcr150gn:amber:user" + ;; +esac + +ucidef_commit_leds + +exit 0 diff --git a/target/linux/ramips/base-files/etc/uci-defaults/network b/target/linux/ramips/base-files/etc/uci-defaults/network new file mode 100755 index 000000000..bbb02e862 --- /dev/null +++ b/target/linux/ramips/base-files/etc/uci-defaults/network @@ -0,0 +1,217 @@ +#!/bin/sh + +. /etc/functions.sh +. /lib/ramips.sh +. /lib/functions/uci-defaults.sh + +if [ ! -x /usr/sbin/maccalc ]; then + echo "$0: maccalc not found!" + return +fi + +ramips_setup_rt3x5x_vlans() +{ + if [ ! -x /sbin/swconfig ]; then + # legacy default + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + return + fi + local wanports="" + local lanports="" + swconfig dev rt305x set reset 1 + for port in 5 4 3 2 1 0; do + if [ `swconfig dev rt305x port $port get disable` = "1" ]; then + continue + fi + if [ `swconfig dev rt305x port $port get lan` = "0" ]; then + wanports="$port $wanports" + else + lanports="$port $lanports" + fi + done + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ucidef_add_switch "rt305x" "1" "1" + ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t" + ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t" +} + +ramips_setup_interfaces() +{ + local board="$1" + + ucidef_set_interface_loopback + + case $board in + all0256n | \ + all5002) + ucidef_set_interface_lan "eth0" + ;; + + dir-615-h1 | \ + wl-330n) + ucidef_set_interface_lan "eth0.1" + ;; + + 3g-6200n | \ + argus-atp52b | \ + b2c | \ + nw718 | \ + psr-680w | \ + sl-r7205 | \ + w502u | \ + wr6202) + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ;; + + f5d8235-v1 | \ + f5d8235-v2 | \ + ur-336un) + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ;; + + v11st-fe) + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ucidef_add_switch "switch0" "1" "1" + ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t" + ucidef_add_switch_vlan "switch0" "2" "0 5t" + ;; + + rt-n15 | \ + wl-351) + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ucidef_add_switch "switch0" "1" "1" + ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t" + ucidef_add_switch_vlan "switch0" "2" "4 5t" + ;; + + rt-n56u) + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ucidef_add_switch "switch0" "1" "1" + ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t" + ucidef_add_switch_vlan "switch0" "2" "4 8t" + ;; + + freestation5 | \ + wcr-150gn) + ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1" + ;; + + wli-tx4-ag300n) + ucidef_set_interface_lan "eth0" + ;; + + *) + RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"` + if [ -n "${RT3X5X}" ]; then + ramips_setup_rt3x5x_vlans + else + ucidef_set_interfaces_lan_wan "eth0" "eth1" + fi + ;; + esac +} + +ramips_setup_macs() +{ + local board="$1" + local lan_mac="" + local wan_mac="" + + case $board in + all0256n | \ + all5002 | \ + dir-615-h1) + lan_mac=$(ramips_get_mac_binary factory 40) + ;; + 3g-6200n | \ + argus-atp52b | \ + bc2 | \ + f5d8235-v1 | \ + nw718 | \ + psr-680w | \ + rt-n15 | \ + sl-r7205 | \ + wl-351) + lan_mac=$(ramips_get_mac_binary factory 4) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + w306r-v20) + lan_mac=$(ramips_get_mac_binary factory 4) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 5) + ;; + + fonera20n) + lan_mac=$(ramips_get_mac_binary factory 40) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + dir-300-b1 |\ + dir-300-b2 |\ + dir-600-b1) + lan_mac=$(ramips_get_mac_binary devdata 16388) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + dir-620-a1) + lan_mac=$(ramips_get_mac_binary factory 4) + lan_mac=$(maccalc or "$lan_mac" "02:00:00:00:00:00") + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + esr-9753 | \ + ur-336un) + lan_mac=$(ramips_get_mac_binary devdata 16388) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + nbg-419n | \ + wcr-150gn) + lan_mac=$(ramips_get_mac_binary factory 4) + wan_mac=$(ramips_get_mac_binary factory 40) + ;; + + f5d8235-v2) + lan_mac=$(ramips_get_mac_binary "u-boot" 262148) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + rt-n56u) + lan_mac=$(ramips_get_mac_binary factory 4) + wan_mac=$(ramips_get_mac_binary factory 32772) + ;; + + all0239-3g | \ + carambola | \ + w502u) + lan_mac=$(ramips_get_mac_binary factory 40) + wan_mac=$(ramips_get_mac_binary factory 46) + ;; + + wl341v3) + lan_mac=$(ramips_get_mac_binary board-nvram 65440) + wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1) + ;; + + wli-tx4-ag300n) + lan_mac=$(ramips_get_mac_binary factory 4) + ;; + + esac + + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac +} + +[ -e /etc/config/network ] && exit 0 + +touch /etc/config/network + +board=$(ramips_board_name) + +ramips_setup_interfaces $board +ramips_setup_macs $board + +uci commit network + +exit 0 diff --git a/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh b/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh new file mode 100644 index 000000000..e76418dad --- /dev/null +++ b/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +do_ramips() { + . /lib/ramips.sh +} + +boot_hook_add preinit_main do_ramips diff --git a/target/linux/ramips/base-files/lib/preinit/05_ramips_load-input_drivers b/target/linux/ramips/base-files/lib/preinit/05_ramips_load-input_drivers new file mode 100644 index 000000000..fbd4c83d8 --- /dev/null +++ b/target/linux/ramips/base-files/lib/preinit/05_ramips_load-input_drivers @@ -0,0 +1,12 @@ +# +# Copyright (C) 2011 OpenWrt.org +# + +preinit_ramips_load_input_drivers() { + insmod input-core + insmod input-polldev + insmod gpio_keys_polled + insmod button-hotplug +} + +boot_hook_add preinit_main preinit_ramips_load_input_drivers diff --git a/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac b/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac new file mode 100644 index 000000000..591c549d1 --- /dev/null +++ b/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac @@ -0,0 +1,66 @@ +# +# Copyright (C) 2011 OpenWrt.org +# + +preinit_set_mac_address() { + local mac + + . /lib/ramips.sh + + case $(ramips_board_name) in + 3g-6200n) + mac=$(ramips_get_mac_binary factory 4) + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + bc2 |\ + dir-620-a1 |\ + esr-9753 |\ + freestation5 |\ + nw718 |\ + psr-680w |\ + rt-n56u |\ + sl-r7205) + mac=$(ramips_get_mac_binary factory 4) + mac=$(maccalc or "$mac" "02:00:00:00:00:00") + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + dir-300-b1 |\ + dir-300-b2 |\ + dir-600-b1) + mac=$(ramips_get_mac_binary devdata 16388) + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + dap-1350) + mac=$(ramips_get_mac_binary devdata 46) + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + all0239-3g |\ + all0256n |\ + all5002 |\ + carambola |\ + dir-615-h1 |\ + fonera20n |\ + hw550-3g |\ + nbg-419n |\ + omni-emb |\ + w306r-v20 |\ + w502u |\ + wl-330n |\ + wl-330n3g |\ + wr6202 |\ + xdxrn502j) + mac=$(ramips_get_mac_binary factory 40) + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + wl341v3) + mac=$(ramips_get_mac_binary board-nvram 65440) + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + rt-n10-plus) + mac=$(ramips_get_mac_binary devconf 4) + ifconfig eth0 hw ether $mac 2>/dev/null + ;; + esac +} + +boot_hook_add preinit_main preinit_set_mac_address diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh new file mode 100755 index 000000000..90c28b7ab --- /dev/null +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -0,0 +1,194 @@ +#!/bin/sh +# +# Copyright (C) 2010 OpenWrt.org +# + +ramips_get_mac_binary() +{ + local mtdname="$1" + local seek="$2" + local part + + . /lib/functions.sh + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "ramips_get_mac_binary: partition $mtdname not found!" >&2 + return + fi + + dd bs=1 skip=$seek count=6 if=$part 2>/dev/null | /usr/sbin/maccalc bin2mac +} + +ramips_get_mac_nvram() +{ + local mtdname="$1" + local key="$2" + local part + local mac_dirty + + . /lib/functions.sh + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "ramips_get_mac_nvram: partition $mtdname not found!" >&2 + return + fi + + mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p') + # "canonicalize" mac + /usr/sbin/maccalc add "$mac_dirty" 0 +} + +ramips_board_name() { + local machine + local name + + machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo) + + case "$machine" in + *"8devices Carambola") + name="carambola" + ;; + *"Edimax 3g-6200n") + name="3g-6200n" + ;; + *"Allnet ALL0239-3G") + name="all0239-3g" + ;; + *"Allnet ALL0256N") + name="all0256n" + ;; + *"Allnet ALL5002") + name="all5002" + ;; + *"ARC FreeStation5") + name="freestation5" + ;; + *"Argus ATP-52B") + name="argus-atp52b" + ;; + *"Asus WL-330N") + name="wl-330n" + ;; + *"Asus WL-330N3G") + name="wl-330n3g" + ;; + *"Aztech HW550-3G") + name="hw550-3g" + ;; + *"DIR-300 B1") + name="dir-300-b1" + ;; + *"DIR-600 B1") + name="dir-600-b1" + ;; + *"DIR-600 B2") + name="dir-600-b2" + ;; + *"DIR-620 A1") + name="dir-620-a1" + ;; + *"DIR-615 H1") + name="dir-615-h1" + ;; + *"DAP-1350") + name="dap-1350" + ;; + *"ESR-9753") + name="esr-9753" + ;; + *"F5D8235 v1") + name="f5d8235-v1" + ;; + *"F5D8235 v2") + name="f5d8235-v2" + ;; + *"La Fonera 2.0N") + name="fonera20n" + ;; + *"MoFi Network MOFI3500-3GN") + name="mofi3500-3gn" + ;; + *"NBG-419N") + name="nbg-419n" + ;; + *"NexAira BC2") + name="bc2" + ;; + *"NW718") + name="nw718" + ;; + *"Omnima MiniEMBWiFi") + name="omni-emb" + ;; + *"Petatel PSR-680W"*) + name="psr-680w" + ;; + *"PWH2004") + name="pwh2004" + ;; + *"RT-G32 B1") + name="rt-g32-b1" + ;; + *"RT-N10+") + name="rt-n10-plus" + ;; + *"RT-N15") + name="rt-n15" + ;; + *"RT-N56U") + name="rt-n56u" + ;; + *"Skyline SL-R7205"*) + name="sl-r7205" + ;; + *"Sparklan WCR-150GN") + name="wcr-150gn" + ;; + *"V22RW-2X2") + name="v22rw-2x2" + ;; + *"W502U") + name="w502u" + ;; + *"WHR-G300N") + name="whr-g300n" + ;; + *"Sitecom WL-341 v3") + name="wl341v3" + ;; + *"Sitecom WL-351 v1 002") + name="wl-351" + ;; + *"Tenda W306R V2.0") + name="w306r-v20" + ;; + *"Ralink V11ST-FE") + name="v11st-fe" + ;; + *"WLI-TX4-AG300N") + name="wli-tx4-ag300n" + ;; + *"WZR-AGL300NH") + name="wzr-agl300nh" + ;; + *"WR512-3GN-like router") + name="wr512-3gn" + ;; + *"UR-336UN Wireless N router") + name="ur-336un" + ;; + *"AWB WR6202") + name="wr6202" + ;; + *"XDX RN502J") + name="xdxrn502j" + ;; + *) + name="generic" + ;; + esac + + echo $name +} diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh new file mode 100755 index 000000000..5ebf42a85 --- /dev/null +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -0,0 +1,84 @@ +# +# Copyright (C) 2010 OpenWrt.org +# + +. /lib/ramips.sh + +PART_NAME=firmware +RAMFS_COPY_DATA=/lib/ramips.sh + +platform_check_image() { + local board=$(ramips_board_name) + local magic="$(get_magic_word "$1")" + + [ "$ARGC" -gt 1 ] && return 1 + + case "$board" in + 3g-6200n | \ + all0239-3g | \ + all0256n | \ + all5002 | \ + bc2 | \ + carambola | \ + dir-300-b1 | \ + dir-600-b1 | \ + dir-600-b2 | \ + dir-615-h1 | \ + dir-620-a1 | \ + dap-1350 | \ + esr-9753 | \ + fonera20n | \ + freestation5 | \ + hw550-3g | \ + mofi3500-3gn | \ + nbg-419n | \ + nw718 | \ + omni-emb | \ + psr-680w | \ + rt-g32-b1 | \ + rt-n10-plus | \ + rt-n15 | \ + rt-n56u | \ + sl-r7205 | \ + w306r-v20 |\ + w502u |\ + wr6202 |\ + v22rw-2x2 | \ + wl341v3 | \ + wl-330n | \ + wl-351 | \ + wli-tx4-ag300n | \ + whr-g300n |\ + ur-336un |\ + wr512-3gn) + [ "$magic" != "2705" ] && { + echo "Invalid image type." + return 1 + } + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on $board." + return 1 +} + +platform_do_upgrade() { + local board=$(ramips_board_name) + + case "$board" in + *) + default_do_upgrade "$ARGV" + ;; + esac +} + +disable_watchdog() { + killall watchdog + ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && { + echo 'Could not disable watchdog' + return 1 + } +} + +append sysupgrade_pre_upgrade disable_watchdog |