aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/mt76x8/base-files/etc
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-10-22 12:37:13 +0200
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-11-03 00:26:17 +0100
commit19724e28c81e3ff642f09c49f612cd147c54a697 (patch)
tree278c45d3b1563cee6108e65c3b5856dbab304062 /target/linux/ramips/mt76x8/base-files/etc
parent0975c35b83a632f9662d1944307f87da9db06154 (diff)
downloadupstream-19724e28c81e3ff642f09c49f612cd147c54a697.tar.gz
upstream-19724e28c81e3ff642f09c49f612cd147c54a697.tar.bz2
upstream-19724e28c81e3ff642f09c49f612cd147c54a697.zip
ramips: split base-files into subtargets
While most of the target's contents are split into subtargets, the base-files are maintained for the target as a whole. However, OpenWrt already implements a mechanism that will use (and even prefer) files in the subtargets' directories. This can be exploited to make several scripts subtarget-specific and thus save some space. In certain cases, keeping files in parent (=target) base-files was more convenient, and thus no splitting was performed for those. Note that this will increase overall code lines, but reduce code per subtarget. base-files ipk size reduction: master (mt7621) 60958 B split (mt7620) 46358 B (- 14.3 kiB) split (mt7621) 48759 B (- 11.9 kiB) split (mt76x8) 44948 B (- 15.6 kiB) split (rt288x) 43508 B (- 17.0 kiB) split (rt305x) 45616 B (- 15.0 kiB) split (rt3883) 44176 B (- 16.4 kiB) Run-tested on: GL.iNet GL-MT300N-V2 (mt76x8) D-Link DWR-116 (mt7620) Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ramips/mt76x8/base-files/etc')
-rwxr-xr-xtarget/linux/ramips/mt76x8/base-files/etc/board.d/01_leds138
-rwxr-xr-xtarget/linux/ramips/mt76x8/base-files/etc/board.d/02_network191
2 files changed, 329 insertions, 0 deletions
diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
new file mode 100755
index 0000000000..f397da14a3
--- /dev/null
+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
@@ -0,0 +1,138 @@
+#!/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
+alfa-network,awusfree1)
+ set_wifi_led "$boardname:blue:wlan"
+ ;;
+cudy,wr1000)
+ ucidef_set_led_switch "wan" "wan" "$boardname:blue:wan" "switch0" "0x10"
+ ucidef_set_led_switch "lan1" "lan1" "$boardname:blue:lan1" "switch0" "0x08"
+ ucidef_set_led_switch "lan2" "lan2" "$boardname:blue:lan2" "switch0" "0x04"
+ ;;
+glinet,gl-mt300n-v2)
+ set_wifi_led "$boardname:red:wlan"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x1"
+ ;;
+hilink,hlk-7628n|\
+skylab,skw92a)
+ set_wifi_led "$boardname:green:wlan"
+ ;;
+hiwifi,hc5661a|\
+hiwifi,hc5761a)
+ ucidef_set_led_switch "internet" "internet" "$boardname:blue:internet" "switch0" "0x10"
+ ;;
+mediatek,linkit-smart-7688)
+ ucidef_set_led_wlan "wifi" "wifi" "linkit-smart-7688:orange:wifi" "phy0tpt"
+ ;;
+netgear,r6120)
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x0f"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x10"
+ ucidef_set_led_wlan "wlan2g" "WiFi 2.4GHz" "$boardname:green:wlan2g" "phy0tpt"
+ ;;
+rakwireless,rak633)
+ set_wifi_led "$boardname:blue:wifi"
+ ;;
+tama,w06)
+ ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0"
+ ucidef_set_led_wlan "wlan" "WLAN" "$boardname:green:wlan" "phy0tpt"
+ ;;
+tplink,archer-c20-v4)
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1e"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ucidef_set_led_netdev "wlan2g" "wlan2g" "$boardname:green:wlan2g" "wlan0"
+ ;;
+tplink,archer-c50-v3|\
+tplink,archer-c50-v4)
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1e"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ucidef_set_led_wlan "wlan2g" "wlan2g" "$boardname:green:wlan2g" "phy0tpt"
+ ucidef_set_led_wlan "wlan5g" "wlan5g" "$boardname:green:wlan5g" "phy1tpt"
+ ;;
+tplink,tl-mr3020-v3)
+ set_wifi_led "$boardname:green:wlan"
+ ucidef_set_led_netdev "lan" "LAN" "$boardname:green:lan" "eth0"
+ ;;
+tplink,tl-mr3420-v5|\
+tplink,tl-wr842n-v5)
+ ucidef_set_led_wlan "wlan2g" "wlan2g" "$boardname:green:wlan" "phy0tpt"
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1e"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ;;
+tplink,tl-wa801nd-v5)
+ ucidef_set_led_wlan "wlan" "wlan" "$boardname:green:wlan" "phy0tpt"
+ ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" "eth0"
+ ;;
+tplink,tl-wr840n-v4)
+ ucidef_set_led_wlan "wlan2g" "wlan2g" "$boardname:green:wlan" "phy0tpt"
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1e"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ;;
+tplink,tl-wr841n-v13)
+ ucidef_set_led_wlan "wlan2g" "wlan2g" "$boardname:green:wlan" "phy0tpt"
+ ucidef_set_led_switch "lan1" "lan1" "$boardname:green:lan1" "switch0" "0x2"
+ ucidef_set_led_switch "lan2" "lan2" "$boardname:green:lan2" "switch0" "0x4"
+ ucidef_set_led_switch "lan3" "lan3" "$boardname:green:lan3" "switch0" "0x8"
+ ucidef_set_led_switch "lan4" "lan4" "$boardname:green:lan4" "switch0" "0x10"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ;;
+tplink,tl-wr841n-v14)
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1e"
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ;;
+tplink,tl-wr902ac-v3)
+ ucidef_set_led_wlan "wlan2g" "wlan2g" "$boardname:green:wlan" "phy0tpt"
+ ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x10"
+ ;;
+unielec,u7628-01-16m)
+ ucidef_set_led_switch "lan1" "lan1" "u7628-01:green:lan1" "switch0" "0x2"
+ ucidef_set_led_switch "lan2" "lan2" "u7628-01:green:lan2" "switch0" "0x4"
+ ucidef_set_led_switch "lan3" "lan3" "u7628-01:green:lan3" "switch0" "0x8"
+ ucidef_set_led_switch "lan4" "lan4" "u7628-01:green:lan4" "switch0" "0x10"
+ ucidef_set_led_switch "wan" "wan" "u7628-01:green:wan" "switch0" "0x01"
+ set_wifi_led "u7628-01:green:wlan"
+ ;;
+wavlink,wl-wn570ha1)
+ ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x01"
+ ucidef_set_rssimon "wlan0" "200000" "1"
+ ucidef_set_led_rssi "wifi-low" "wifi-low" "$boardname:green:wifi-low" "wlan0" "1" "49"
+ ucidef_set_led_rssi "wifi-med" "wifi-med" "$boardname:green:wifi-med" "wlan0" "50" "84"
+ ucidef_set_led_rssi "wifi-high" "wifi-high" "$boardname:green:wifi-high" "wlan0" "85" "100"
+ set_wifi_led "$boardname:green:wifi"
+ ;;
+wavlink,wl-wn575a3)
+ ucidef_set_rssimon "wlan1" "200000" "1"
+ ucidef_set_led_rssi "wifi-low" "wifi-low" "$boardname:green:wifi-low" "wlan1" "1" "49"
+ ucidef_set_led_rssi "wifi-med" "wifi-med" "$boardname:green:wifi-med" "wlan1" "50" "84"
+ ucidef_set_led_rssi "wifi-high" "wifi-high" "$boardname:green:wifi-high" "wlan1" "85" "100"
+ ;;
+zbtlink,zbt-we1226)
+ set_wifi_led "$boardname:green:wlan"
+ ucidef_set_led_switch "lan1" "LAN1" "$boardname:green:lan1" "switch0" "0x01"
+ ucidef_set_led_switch "lan2" "LAN2" "$boardname:green:lan2" "switch0" "0x02"
+ ucidef_set_led_switch "wan" "WAN" "$boardname:green:wan" "switch0" "0x10"
+ ;;
+zyxel,keenetic-extra-ii)
+ set_wifi_led "$boardname:green:wifi"
+ ucidef_set_led_switch "internet" "internet" "$boardname:green:internet" "switch0" "0x01"
+ ;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
new file mode 100755
index 0000000000..3bb5d31423
--- /dev/null
+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
@@ -0,0 +1,191 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
+
+ramips_setup_interfaces()
+{
+ local board="$1"
+
+ case $board in
+ alfa-network,awusfree1|\
+ d-team,pbr-d1|\
+ tama,w06|\
+ tplink,tl-mr3020-v3|\
+ tplink,tl-wr802n-v4)
+ ucidef_set_interface_lan "eth0"
+ ;;
+ buffalo,wcr-1166ds)
+ ucidef_add_switch "switch0" \
+ "3:lan" "4:wan" "6@eth0"
+ ;;
+ cudy,wr1000)
+ ucidef_add_switch "switch0" \
+ "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
+ ;;
+ duzun,dm06)
+ ucidef_add_switch "switch0" \
+ "1:lan" "0:wan" "6@eth0"
+ ;;
+ glinet,gl-mt300n-v2)
+ ucidef_add_switch "switch0" \
+ "1:lan" "0:wan" "6@eth0"
+ ;;
+ glinet,vixmini)
+ ucidef_add_switch "switch0" \
+ "0:lan" "6@eth0"
+ ;;
+ hilink,hlk-7628n|\
+ hiwifi,hc5861b|\
+ skylab,skw92a|\
+ tplink,archer-c20-v4|\
+ tplink,archer-c50-v3|\
+ tplink,archer-c50-v4|\
+ tplink,tl-mr3420-v5|\
+ tplink,tl-wr840n-v4|\
+ tplink,tl-wr840n-v5|\
+ tplink,tl-wr841n-v13|\
+ tplink,tl-wr841n-v14|\
+ tplink,tl-wr842n-v5|\
+ unielec,u7628-01-16m|\
+ wrtnode,wrtnode2p|\
+ wrtnode,wrtnode2r|\
+ zyxel,keenetic-extra-ii)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
+ ;;
+ hiwifi,hc5661a|\
+ hiwifi,hc5761a|\
+ mediatek,mt7628an-eval-board|\
+ mercury,mac1200r-v2|\
+ totolink,lr1200|\
+ wavlink,wl-wn570ha1|\
+ wavlink,wl-wn575a3|\
+ xiaomi,miwifi-nano)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
+ ;;
+ iptime,a3)
+ ucidef_add_switch "switch0" \
+ "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
+ ;;
+ iptime,a604m)
+ ucidef_add_switch "switch0" \
+ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
+ ;;
+ mediatek,linkit-smart-7688|\
+ onion,omega2p|\
+ onion,omega2|\
+ tplink,tl-wa801nd-v5|\
+ widora,neo-16m|\
+ widora,neo-32m)
+ ucidef_add_switch "switch0"
+ ucidef_add_switch_attr "switch0" "enable" "false"
+ ucidef_set_interface_lan "eth0"
+ ;;
+ netgear,r6120)
+ ucidef_add_switch "switch0" \
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
+ ;;
+ rakwireless,rak633)
+ ucidef_add_switch "switch0" \
+ "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
+ ;;
+ tplink,tl-wr902ac-v3)
+ ucidef_add_switch "switch0" \
+ "4:lan" "6@eth0"
+ ;;
+ vocore,vocore2|\
+ vocore,vocore2-lite)
+ ucidef_add_switch "switch0" \
+ "0:lan" "2:lan" "6t@eth0"
+ ;;
+ wiznet,wizfi630s)
+ ucidef_add_switch "switch0" \
+ "0:wan" "3:lan" "4:lan" "6@eth0"
+ ;;
+ xiaomi,mir4a-100m)
+ ucidef_add_switch "switch0" \
+ "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
+ ;;
+ zbtlink,zbt-we1226)
+ ucidef_add_switch "switch0" \
+ "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
+ ;;
+ *)
+ ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+ ;;
+ esac
+}
+
+ramips_setup_macs()
+{
+ local board="$1"
+ local lan_mac=""
+ local wan_mac=""
+ local label_mac=""
+
+ case $board in
+ buffalo,wcr-1166ds)
+ local index="$(find_mtd_index "board_data")"
+ wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
+ lan_mac=$wan_mac
+ ;;
+ cudy,wr1000)
+ wan_mac=$(mtd_get_mac_binary factory 0x2e)
+ label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+ ;;
+ glinet,gl-mt300n-v2)
+ # This empty case has to be kept for devices without any MAC address adjustments
+ ;;
+ hilink,hlk-7628n)
+ lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ;;
+ hiwifi,hc5661a|\
+ hiwifi,hc5761a|\
+ hiwifi,hc5861b)
+ lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
+ label_mac=$lan_mac
+ [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ;;
+ iptime,a3|\
+ iptime,a604m)
+ wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
+ ;;
+ mediatek,linkit-smart-7688|\
+ onion,omega2|\
+ onion,omega2p)
+ wan_mac=$(mtd_get_mac_binary factory 0x4)
+ lan_mac=$(mtd_get_mac_binary factory 0x2e)
+ ;;
+ mercury,mac1200r-v2)
+ wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
+ ;;
+ skylab,skw92a|\
+ totolink,lr1200)
+ wan_mac=$(mtd_get_mac_binary factory 0x2e)
+ ;;
+ vocore,vocore2|\
+ vocore,vocore2-lite)
+ label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+ ;;
+ *)
+ 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