aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/rt305x/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/ramips/rt305x/base-files')
-rwxr-xr-xtarget/linux/ramips/rt305x/base-files/etc/board.d/01_leds109
-rwxr-xr-xtarget/linux/ramips/rt305x/base-files/etc/board.d/02_network228
-rw-r--r--target/linux/ramips/rt305x/base-files/lib/preinit/04_handle_checksumming43
-rwxr-xr-xtarget/linux/ramips/rt305x/base-files/lib/upgrade/platform.sh20
4 files changed, 400 insertions, 0 deletions
diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds b/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds
new file mode 100755
index 0000000000..ae813e85d6
--- /dev/null
+++ b/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+. /lib/functions/leds.sh
+. /lib/functions/uci-defaults.sh
+
+set_wifi_led() {
+ ucidef_set_led_netdev "wifi_led" "wifi" "${1}" "${2:-wlan0}"
+}
+
+
+board=$(board_name)
+boardname="${board##*,}"
+
+board_config_update
+
+led_wlan="$(get_dt_led wlan)"
+[ -n "$led_wlan" ] && ucidef_set_led_wlan "wifi_led" "wifi" "$led_wlan" "phy0tpt"
+
+case $board in
+7links,px-4885-4m|\
+7links,px-4885-8m)
+ set_wifi_led "px-4885:orange:wifi"
+ ;;
+airlive,air3gii|\
+aximcom,mr-102n|\
+edimax,3g-6200nl|\
+netgear,wnce2001)
+ set_wifi_led "$boardname:green:wlan"
+ ;;
+alfa-network,w502u|\
+dlink,dir-300-b1|\
+dlink,dir-300-b7|\
+dlink,dir-320-b1|\
+dlink,dir-600-b1|\
+dlink,dir-610-a1|\
+dlink,dir-615-d|\
+dlink,dir-615-h1|\
+dlink,dir-620-a1|\
+engenius,esr-9753|\
+hilink,hlk-rm04|\
+nexx,wt1520-4m|\
+nexx,wt1520-8m|\
+skyline,sl-r7205|\
+tenda,w306r-v2|\
+zyxel,keenetic-start|\
+zyxel,keenetic|\
+zyxel,nbg-419n-v2)
+ set_wifi_led "rt2800pci-phy0::radio"
+ ;;
+allnet,all0256n-4m|\
+allnet,all0256n-8m)
+ ucidef_set_rssimon "wlan0" "200000" "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"
+ ;;
+alphanetworks,asl26555-8m|\
+alphanetworks,asl26555-16m)
+ ucidef_set_led_netdev "eth" "ETH" "asl26555:green:eth" "eth0"
+ set_wifi_led "asl26555:green:wlan"
+ ;;
+asiarf,awapn2403)
+ set_wifi_led "rt2800soc-phy0::radio"
+ ;;
+dlink,dcs-930l-b1)
+ ucidef_set_led_netdev "wifi" "WiFi" "$boardname:blue:wps"
+ ;;
+dlink,dir-620-d1|\
+trendnet,tew-714tru)
+ set_wifi_led "$boardname:green:wifi"
+ ;;
+edimax,3g-6200n|\
+planex,mzk-w300nh2)
+ set_wifi_led "$boardname:amber:wlan"
+ ;;
+fon,fonera-20n)
+ set_wifi_led "$boardname:orange:wifi"
+ ;;
+hauppauge,broadway)
+ set_wifi_led "$boardname:red:wps_active"
+ ;;
+hootoo,ht-tm02)
+ ucidef_set_led_netdev "eth" "Ethernet" "$boardname:green:lan" "eth0"
+ set_wifi_led "$boardname:blue:wlan"
+ ;;
+huawei,hg255d)
+ set_wifi_led "$boardname:green:wlan"
+ ucidef_set_led_netdev "internet" "internet" "$boardname:green:internet" "eth0.2"
+ ;;
+intenso,memory2move)
+ set_wifi_led "$boardname:blue:wifi"
+ ucidef_set_led_netdev "eth" "Ethernet" "$boardname:green:wan" "eth0"
+ ;;
+omnima,miniembplug)
+ set_wifi_led "$boardname:red:wlan"
+ ;;
+vocore,vocore-8m|\
+vocore,vocore-16m)
+ ucidef_set_led_netdev "eth" "ETH" "vocore:orange:eth" "eth0"
+ ;;
+zorlik,zl5900v2)
+ ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" eth0
+ ;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network
new file mode 100755
index 0000000000..326bc8a3df
--- /dev/null
+++ b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network
@@ -0,0 +1,228 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
+
+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=""
+ 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:wan $wanports"
+ else
+ lanports="$port:lan $lanports"
+ fi
+ done
+ ucidef_add_switch "rt305x" $lanports $wanports "6t@eth0"
+}
+
+ramips_setup_interfaces()
+{
+ local board="$1"
+
+ case $board in
+ accton,wr6202|\
+ alfa-network,w502u|\
+ netcore,nw718|\
+ petatel,psr-680w|\
+ skyline,sl-r7205|\
+ upvel,ur-336un)
+ ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+ ;;
+ allnet,all0256n-4m|\
+ allnet,all0256n-8m|\
+ allnet,all5002|\
+ allnet,all5003|\
+ dlink,dcs-930l-b1|\
+ dlink,dcs-930|\
+ hame,mpr-a2|\
+ hauppauge,broadway|\
+ hootoo,ht-tm02|\
+ intenso,memory2move|\
+ netgear,wnce2001|\
+ tenda,3g150b|\
+ tenda,3g300m|\
+ tenda,w150m|\
+ unbranded,a5-v11|\
+ wansview,ncs601w|\
+ zorlik,zl5900v2)
+ ucidef_add_switch "switch0"
+ ucidef_add_switch_attr "switch0" "enable" "false"
+ ucidef_set_interface_lan "eth0"
+ ;;
+ alphanetworks,asl26555-8m|\
+ alphanetworks,asl26555-16m)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
+ ;;
+ argus,atp-52b|\
+ asiarf,awm002-evb-4m|\
+ asiarf,awm002-evb-8m|\
+ jcg,jhr-n805r|\
+ jcg,jhr-n825r|\
+ jcg,jhr-n926r|\
+ planex,mzk-wdpr|\
+ upvel,ur-326n4g)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
+ ;;
+ asiarf,awapn2403)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:wan" "6@eth0"
+ ;;
+ asus,wl-330n|\
+ easyacc,wizard-8800)
+ ucidef_set_interface_lan "eth0.1"
+ ;;
+ aximcom,mr-102n)
+ ucidef_set_interface_lan "eth0.2"
+ ;;
+ belkin,f5d8235-v2|\
+ trendnet,tew-714tru)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
+ ;;
+ buffalo,whr-g300n|\
+ dlink,dir-300-b7|\
+ dlink,dir-320-b1|\
+ dlink,dir-610-a1|\
+ edimax,3g-6200n|\
+ hilink,hlk-rm04|\
+ nixcore,x1-16m|\
+ nixcore,x1-8m|\
+ planex,mzk-w300nh2|\
+ zyxel,keenetic)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
+ ;;
+ dlink,dir-615-h1)
+ ucidef_add_switch "switch0" \
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
+ ;;
+ huawei,d105)
+ ucidef_set_interface_lan "eth0"
+ ;;
+ huawei,hg255d)
+ ucidef_add_switch "switch0" \
+ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
+ ;;
+ nexx,wt1520-4m|\
+ nexx,wt1520-8m)
+ ucidef_add_switch "switch0" \
+ "0:lan" "4:wan" "6@eth0"
+ ;;
+ planex,mzk-dp150n|\
+ vocore,vocore-8m|\
+ vocore,vocore-16m)
+ ucidef_add_switch "switch0" \
+ "0:lan" "4:lan" "6t@eth0"
+ ;;
+ sitecom,wl-351)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
+ ;;
+ sparklan,wcr-150gn)
+ ucidef_add_switch "switch0" \
+ "0:lan" "6t@eth0"
+ ;;
+ trendnet,tew-638apb-v2)
+ ucidef_add_switch "switch0" \
+ "4:lan" "6@eth0"
+ ;;
+ wiznet,wizfi630a)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:wan" "6@eth0"
+ ;;
+ zyxel,keenetic-start)
+ ucidef_add_switch "switch0" \
+ "0:lan:3" "1:lan:2" "2:lan:1" "3:lan:0" "4:wan" "6@eth0"
+ ;;
+ *)
+ RT3X5X=$(grep -E "(RT3.5|RT5350)" /proc/cpuinfo)
+ if [ -n "${RT3X5X}" ]; then
+ ramips_setup_rt3x5x_vlans
+ else
+ ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+ fi
+ ;;
+ esac
+}
+
+ramips_setup_macs()
+{
+ local board="$1"
+ local lan_mac=""
+ local wan_mac=""
+ local label_mac=""
+
+ case $board in
+ 8devices,carambola|\
+ alfa-network,w502u|\
+ arcwireless,freestation5|\
+ netgear,wnce2001)
+ wan_mac=$(mtd_get_mac_binary factory 0x2e)
+ ;;
+ buffalo,whr-g300n|\
+ zyxel,keenetic-start)
+ # This empty case has to be kept for devices without any MAC address adjustments
+ ;;
+ dlink,dir-300-b7|\
+ dlink,dir-320-b1|\
+ dlink,dir-620-a1|\
+ engenius,esr-9753|\
+ hame,mpr-a1|\
+ hauppauge,broadway|\
+ huawei,d105|\
+ hilink,hlk-rm04|\
+ nexaira,bc2|\
+ petatel,psr-680w|\
+ skyline,sl-r7205)
+ lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ;;
+ dlink,dir-615-d|\
+ dlink,dir-615-h1)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+ label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+ ;;
+ poray,m3|\
+ poray,m4-4m|\
+ poray,m4-8m|\
+ poray,x5|\
+ poray,x8)
+ lan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" -2)
+ ;;
+ sparklan,wcr-150gn|\
+ wiznet,wizfi630a)
+ wan_mac=$(mtd_get_mac_binary factory 0x28)
+ ;;
+ tenda,w306r-v2)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 5)
+ ;;
+ *)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+ ;;
+ esac
+
+ [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+ [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+ [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
+}
+
+board_config_update
+board=$(board_name)
+ramips_setup_interfaces $board
+ramips_setup_macs $board
+board_config_flush
+
+exit 0
diff --git a/target/linux/ramips/rt305x/base-files/lib/preinit/04_handle_checksumming b/target/linux/ramips/rt305x/base-files/lib/preinit/04_handle_checksumming
new file mode 100644
index 0000000000..9a2361d057
--- /dev/null
+++ b/target/linux/ramips/rt305x/base-files/lib/preinit/04_handle_checksumming
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Netgear WNCE2001 has does a checksum check on boot and goes into recovery
+# tftp mode when the check fails. Initializing the JFFS2 partition triggers
+# this, so we make sure to zero checksum and size to be checksummed before
+# that happens, so this needs to run very early during boot.
+
+do_checksumming_disable() {
+ . /lib/functions.sh
+
+ local board=$(board_name)
+
+ case "$board" in
+ netgear,wnce2001)
+ echo "Board is WNCE2001, updating checksum partition..."
+ local zeroes=/dev/zero
+ local tmpfile=/tmp/wnce2001_checksum
+ local partname=checksum
+ local mtd=$(find_mtd_part $partname)
+ dd if=$mtd of=$tmpfile bs=80 count=1 2>/dev/null
+ signature=$(dd if=$tmpfile bs=1 skip=24 count=20 2>/dev/null)
+ checksum=$(dd if=$tmpfile bs=1 count=4 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"')
+ if [ "$signature" != "RT3052-AP-WNCE2001-3" ]; then
+ echo "Signature of checksum partition is wrong, bailing."
+ return 0
+ fi
+ if [ "$checksum" != "00000000" ]; then
+ echo "Checksum is set, zeroing."
+ # zero out checksum
+ dd if=$zeroes of=$tmpfile conv=notrunc bs=1 seek=0 count=4 2>/dev/null
+ # zero out bytecount to be checksummed
+ dd if=$zeroes of=$tmpfile conv=notrunc bs=1 seek=60 count=4 2>/dev/null
+ mtd write $tmpfile $partname
+ else
+ echo "Checksum is already zero, nothing to do."
+ fi
+ ;;
+ esac
+
+ return 0
+}
+
+boot_hook_add preinit_main do_checksumming_disable
diff --git a/target/linux/ramips/rt305x/base-files/lib/upgrade/platform.sh b/target/linux/ramips/rt305x/base-files/lib/upgrade/platform.sh
new file mode 100755
index 0000000000..786d57fc70
--- /dev/null
+++ b/target/linux/ramips/rt305x/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+
+PART_NAME=firmware
+REQUIRE_IMAGE_METADATA=1
+
+platform_check_image() {
+ return 0
+}
+
+platform_do_upgrade() {
+ local board=$(board_name)
+
+ case "$board" in
+ *)
+ default_do_upgrade "$1"
+ ;;
+ esac
+}