aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/base-files/etc
diff options
context:
space:
mode:
authorblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-05 10:12:53 +0000
committerblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-05 10:12:53 +0000
commit5c105d9f3fd086aff195d3849dcf847d6b0bd927 (patch)
tree1229a11f725bfa58aa7c57a76898553bb5f6654a /target/linux/ramips/base-files/etc
downloadopenwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.tar.gz
openwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.zip
branch Attitude Adjustment
git-svn-id: svn://svn.openwrt.org/openwrt/branches/attitude_adjustment@33625 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ramips/base-files/etc')
-rwxr-xr-xtarget/linux/ramips/base-files/etc/diag.sh139
-rw-r--r--target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom111
-rw-r--r--target/linux/ramips/base-files/etc/inittab4
-rwxr-xr-xtarget/linux/ramips/base-files/etc/uci-defaults/leds86
-rwxr-xr-xtarget/linux/ramips/base-files/etc/uci-defaults/network217
5 files changed, 557 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