ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
new file mode 100755
index 0000000..1464708
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
@@ -0,0 +1,423 @@
+#!/bin/sh
+
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+board=$(board_name)
+
+case "$board" in
+8dev,carambola2)
+	ucidef_set_led_netdev "lan" "LAN" "orange:eth0" "eth0"
+	ucidef_set_led_switch "wan" "WAN" "orange:eth1" "switch0" "0x04"
+	;;
+alfa-network,ap121f|\
+alfa-network,ap121fe|\
+avm,fritz450e|\
+glinet,6408|\
+glinet,6416|\
+glinet,gl-ar300m-lite|\
+glinet,gl-ar300m16|\
+pcs,cap324|\
+tplink,cpe610-v1|\
+tplink,cpe610-v2)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	;;
+alfa-network,n2q)
+	ucidef_set_led_netdev "lan2" "LAN2" "orange:lan2" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "orange:lan1" "switch0" "0x10"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "signal1" "SIGNAL1" "red:signal1" "wlan0" "1" "100"
+	ucidef_set_led_rssi "signal2" "SIGNAL2" "orange:signal2" "wlan0" "33" "100"
+	ucidef_set_led_rssi "signal3" "SIGNAL3" "green:signal3" "wlan0" "66" "100"
+	;;
+alfa-network,n5q)
+	ucidef_set_led_netdev "lan2" "LAN2" "green:lan2" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x10"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "signal1" "SIGNAL1" "red:signal1" "wlan0" "1" "100"
+	ucidef_set_led_rssi "signal2" "SIGNAL2" "orange:signal2" "wlan0" "25" "100"
+	ucidef_set_led_rssi "signal3" "SIGNAL3" "green:signal3" "wlan0" "50" "100"
+	ucidef_set_led_rssi "signal4" "SIGNAL4" "green:signal4" "wlan0" "75" "100"
+	;;
+alfa-network,pi-wifi4)
+	ucidef_set_led_netdev "lan_data" "LAN_DATA" "orange:lan_data" "eth0" "tx rx"
+	ucidef_set_led_netdev "lan_link" "LAN_LINK" "green:lan_link" "eth0" "link"
+	;;
+alfa-network,r36a)
+	ucidef_set_led_netdev "lan" "LAN" "blue:lan" "eth0"
+	ucidef_set_led_switch "wan" "WAN" "blue:wan" "switch0" "0x10"
+	;;
+avm,fritz1750e)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_rssimon "wlan1" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "green:rssi0" "wlan1" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:rssi1" "wlan1" "20" "100"
+	ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "green:rssi2" "wlan1" "40" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssi3" "wlan1" "60" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssi4" "wlan1" "80" "100"
+	;;
+avm,fritz300e)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "green:rssi0" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:rssi1" "wlan0" "20" "100"
+	ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "green:rssi2" "wlan0" "40" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssi3" "wlan0" "60" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssi4" "wlan0" "80" "100"
+	;;
+avm,fritz4020|\
+tplink,archer-c58-v1|\
+tplink,archer-c59-v1|\
+tplink,archer-c59-v2|\
+tplink,archer-c60-v1|\
+tplink,archer-c60-v2|\
+tplink,archer-c60-v3)
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x1e"
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	;;
+avm,fritzdvbc)
+	ucidef_set_rssimon "wlan1" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "green:rssilow" "wlan1" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:rssimediumlow" "wlan1" "20" "100"
+	ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "green:rssimedium" "wlan1" "40" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan1" "60" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan1" "80" "100"
+	;;
+buffalo,wzr-hp-g300nh-rb|\
+buffalo,wzr-hp-g300nh-s)
+        ucidef_set_led_netdev "router" "Router" "green:router" "eth1"
+        ;;
+comfast,cf-e110n-v2)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth1"
+	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x02"
+	ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "red:rssimediumlow" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "76" "100"
+	;;
+comfast,cf-e120a-v3)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth1"
+	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x04"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "red:rssimediumlow" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "76" "100"
+	;;
+comfast,cf-e130n-v2)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "red:rssimediumlow" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "76" "100"
+	;;
+comfast,cf-e313ac)
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x02"
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "red:rssimediumlow" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "76" "100"
+	;;
+comfast,cf-e314n-v2)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth1"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "red:rssimediumlow" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "76" "100"
+	;;
+comfast,cf-e5)
+	ucidef_set_led_switch "lan" "LAN" "blue:lan" "switch0" "0x02"
+	ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "blue:rssi0" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "blue:rssi1" "wlan0" "33" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "blue:rssi2" "wlan0" "66" "100"
+	;;
+comfast,cf-e560ac)
+	ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "blue:lan1" "switch0" "0x02"
+	ucidef_set_led_switch "lan2" "LAN2" "blue:lan2" "switch0" "0x04"
+	ucidef_set_led_switch "lan3" "LAN3" "blue:lan3" "switch0" "0x08"
+	ucidef_set_led_switch "lan4" "LAN4" "blue:lan4" "switch0" "0x10"
+	;;
+comfast,cf-ew72|\
+openmesh,om2p-v2|\
+openmesh,om2p-hs-v1|\
+openmesh,om2p-hs-v2|\
+openmesh,om2p-hs-v3|\
+openmesh,om2p-lc|\
+openmesh,om5p|\
+telco,t1)
+	ucidef_set_led_switch "lan" "LAN" "blue:lan" "switch0" "0x02"
+	ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1"
+	;;
+comfast,cf-wr752ac-v1|\
+enterasys,ws-ap3705i|\
+openmesh,mr900-v1|\
+openmesh,mr900-v2|\
+openmesh,mr1750-v1|\
+openmesh,mr1750-v2)
+	ucidef_set_led_netdev "lan" "LAN" "blue:lan" "eth0"
+	;;
+compex,wpj344-16m|\
+compex,wpj531-16m)
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "sig1" "SIG1" "red:sig1" "wlan0" "85" "100"
+	ucidef_set_led_rssi "sig2" "SIG2" "yellow:sig2" "wlan0" "75" "100"
+	ucidef_set_led_rssi "sig3" "SIG3" "green:sig3" "wlan0" "65" "100"
+	ucidef_set_led_rssi "sig4" "SIG4" "green:sig4" "wlan0" "50" "100"
+	;;
+devolo,magic-2-wifi)
+	ucidef_set_led_netdev "plcw" "dLAN" "white:dlan" "eth0.1" "rx"
+	;;
+dlink,dap-1330-a1|\
+dlink,dap-1365-a1)
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1" "25"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:rssimediumlow" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimediumhigh" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "76" "100"
+	;;
+dlink,dir-859-a1)
+	ucidef_set_led_switch "internet" "WAN" "green:internet" "switch0" "0x20"
+	;;
+engenius,ens202ext-v1|\
+engenius,enstationac-v1)
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan0" "1"  "100"
+	ucidef_set_led_rssi "rssimedium" "RSSIMEDIUM" "amber:rssimedium" "wlan0" "33" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan0" "67" "100"
+	;;
+engenius,ews511ap)
+	ucidef_set_led_netdev "lan1" "LAN1" "blue:lan1" "eth1"
+	ucidef_set_led_netdev "lan2" "LAN2" "blue:lan2" "eth0"
+	;;
+etactica,eg200)
+	ucidef_set_led_netdev "lan" "LAN" "red:eth0" "eth0"
+	ucidef_set_led_oneshot "modbus" "Modbus" "red:modbus" "100" "33"
+	;;
+glinet,gl-mifi|\
+qxwlan,e600g-v2-8m|\
+qxwlan,e600g-v2-16m|\
+qxwlan,e600gac-v2-8m|\
+qxwlan,e600gac-v2-16m|\
+qxwlan,e750a-v4-8m|\
+qxwlan,e750a-v4-16m)
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x02"
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	;;
+glinet,gl-x750)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	;;
+hak5,lan-turtle)
+	ucidef_set_led_netdev "wan" "WAN" "orange:system" "eth1"
+	;;
+joyit,jt-or750i|\
+yuncore,xd3200)
+	ucidef_set_led_default "ath10k" "ath10k-disable" "ath10k-phy0" "0"
+	;;
+meraki,mr12|\
+tplink,cpe210-v2|\
+tplink,cpe210-v3)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "green:link1" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:link2" "wlan0" "30" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:link3" "wlan0" "60" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:link4" "wlan0" "80" "100"
+	;;
+meraki,mr16)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
+	;;
+netgear,wnr2200-8m|\
+netgear,wnr2200-16m)
+	ucidef_set_led_netdev "wan-amber" "WAN (amber)" "amber:wan" "eth0"
+	ucidef_set_led_switch "lan1green" "LAN1 (green)" "green:lan1" "switch0" "0x02" "0x04"
+	ucidef_set_led_switch "lan2green" "LAN2 (green)" "green:lan2" "switch0" "0x04" "0x04"
+	ucidef_set_led_switch "lan3green" "LAN3 (green)" "green:lan3" "switch0" "0x08" "0x04"
+	ucidef_set_led_switch "lan4green" "LAN4 (green)" "green:lan4" "switch0" "0x10" "0x04"
+	ucidef_set_led_switch "lan1amber" "LAN1 (amber)" "amber:lan1" "switch0" "0x02" "0x02"
+	ucidef_set_led_switch "lan2amber" "LAN2 (amber)" "amber:lan2" "switch0" "0x04" "0x02"
+	ucidef_set_led_switch "lan3amber" "LAN3 (amber)" "amber:lan3" "switch0" "0x08" "0x02"
+	ucidef_set_led_switch "lan4amber" "LAN4 (amber)" "amber:lan4" "switch0" "0x10" "0x02"
+	;;
+openmesh,om2p-v4|\
+openmesh,om2p-hs-v4)
+	ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth0"
+	ucidef_set_led_switch "lan" "LAN" "blue:lan" "switch0" "0x02"
+	;;
+pcs,cr3000)
+	ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "blue:lan1" "switch0" "0x04"
+	ucidef_set_led_switch "lan2" "LAN2" "blue:lan2" "switch0" "0x08"
+	ucidef_set_led_switch "lan3" "LAN3" "blue:lan3" "switch0" "0x10"
+	ucidef_set_led_switch "lan4" "LAN4" "blue:lan4" "switch0" "0x02"
+	;;
+qihoo,c301)
+	ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt"
+	;;
+samsung,wam250)
+	ucidef_set_led_netdev "lan" "LAN" "white:lan" "eth0"
+	;;
+tplink,archer-a7-v5|\
+tplink,archer-c7-v4|\
+tplink,archer-c7-v5)
+	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x02"
+	ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x04"
+	ucidef_set_led_switch "lan2" "LAN2" "green:lan2" "switch0" "0x08"
+	ucidef_set_led_switch "lan3" "LAN3" "green:lan3" "switch0" "0x10"
+	ucidef_set_led_switch "lan4" "LAN4" "green:lan4" "switch0" "0x20"
+	;;
+tplink,archer-c2-v3|\
+tplink,tl-wr1043nd-v4|\
+tplink,tl-wr1043n-v5)
+	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x20"
+	ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x10"
+	ucidef_set_led_switch "lan2" "LAN2" "green:lan2" "switch0" "0x08"
+	ucidef_set_led_switch "lan3" "LAN3" "green:lan3" "switch0" "0x04"
+	ucidef_set_led_switch "lan4" "LAN4" "green:lan4" "switch0" "0x02"
+	;;
+tplink,archer-c6-v2|\
+tplink,archer-c6-v2-us)
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x3c"
+	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x02"
+	;;
+tplink,archer-c25-v1|\
+tplink,tl-wr842n-v3)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x10"
+	ucidef_set_led_switch "lan2" "LAN2" "green:lan2" "switch0" "0x08"
+	ucidef_set_led_switch "lan3" "LAN3" "green:lan3" "switch0" "0x04"
+	ucidef_set_led_switch "lan4" "LAN4" "green:lan4" "switch0" "0x02"
+	;;
+tplink,archer-d50-v1)
+	ucidef_set_led_switch "lan" "LAN" "white:lan" "switch0" "0x1c"
+	ucidef_set_led_switch "wan_data" "WAN Data" "white:internet" "switch0" "0x02" "" "tx rx"
+	ucidef_set_led_switch "wan_link" "WAN Link" "white:wan" "switch0" "0x02" "" "link"
+	;;
+tplink,archer-d7-v1|\
+tplink,archer-d7b-v1)
+	ucidef_set_led_switch "lan" "LAN" "white:lan" "switch0" "0x3c"
+	;;
+tplink,cpe210-v1|\
+tplink,cpe220-v2|\
+tplink,cpe220-v3|\
+tplink,cpe510-v1|\
+tplink,wbs210-v1|\
+tplink,wbs210-v2|\
+tplink,wbs510-v1|\
+tplink,wbs510-v2)
+	ucidef_set_led_netdev "lan0" "LAN0" "green:lan0" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x10"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "green:link1" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:link2" "wlan0" "30" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:link3" "wlan0" "60" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:link4" "wlan0" "80" "100"
+	;;
+tplink,cpe510-v2|\
+tplink,cpe510-v3)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "green:link1" "wlan0" "1" "100" "0" "13"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:link2" "wlan0" "26" "100" "-25" "13"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:link3" "wlan0" "51" "100" "-50" "13"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:link4" "wlan0" "76" "100" "-75" "13"
+	;;
+tplink,tl-wr902ac-v1)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_led_netdev "internet" "Internet" "green:internet" "eth0"
+	;;
+tplink,re355-v1|\
+tplink,re450-v1|\
+tplink,re450-v2|\
+tplink,re450-v3)
+	ucidef_set_led_netdev "lan_data" "LAN Data" "green:lan_data" "eth0" "tx rx"
+	ucidef_set_led_netdev "lan_link" "LAN Link" "green:lan_link" "eth0" "link"
+	;;
+tplink,tl-mr6400-v1)
+	ucidef_set_led_switch "lan" "LAN" "white:lan" "switch0" "0x0e"
+	ucidef_set_led_netdev "wan" "WAN" "white:wan" "eth1"
+	ucidef_set_led_netdev "4g" "4G" "white:4g" "usb0"
+	;;
+tplink,tl-wpa8630-v1)
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x3c"
+	;;
+tplink,tl-wr842n-v2)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x04"
+	ucidef_set_led_switch "lan2" "LAN2" "green:lan2" "switch0" "0x08"
+	ucidef_set_led_switch "lan3" "LAN3" "green:lan3" "switch0" "0x10"
+	ucidef_set_led_switch "lan4" "LAN4" "green:lan4" "switch0" "0x02"
+	;;
+trendnet,tew-823dru)
+	ucidef_set_led_netdev "wan" "WAN" "green:planet" "eth0"
+	;;
+ubnt,bullet-ac|\
+ubnt,nanobeam-ac|\
+ubnt,nanobeam-ac-gen2|\
+ubnt,nanostation-ac|\
+ubnt,powerbeam-5ac-gen2)
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "blue:rssi0" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "blue:rssi1" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "blue:rssi2" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "blue:rssi3" "wlan0" "76" "100"
+	;;
+ubnt,bullet-m-ar7240|\
+ubnt,bullet-m-ar7241|\
+ubnt,bullet-m-xw|\
+ubnt,nanobridge-m|\
+ubnt,nanostation-loco-m|\
+ubnt,nanostation-loco-m-xw|\
+ubnt,nanostation-m|\
+ubnt,nanostation-m-xw|\
+ubnt,picostation-m|\
+ubnt,powerbridge-m|\
+ubnt,rocket-m)
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "red:link1" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "orange:link2" "wlan0" "26" "100"
+	ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:link3" "wlan0" "51" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:link4" "wlan0" "76" "100"
+	;;
+wallys,dr531)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x2"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "sig1" "SIG1" "green:sig1" "wlan0" "1" "100"
+	ucidef_set_led_rssi "sig2" "SIG2" "green:sig2" "wlan0" "25" "100"
+	ucidef_set_led_rssi "sig3" "SIG3" "green:sig3" "wlan0" "50" "100"
+	ucidef_set_led_rssi "sig4" "SIG4" "green:sig4" "wlan0" "75" "100"
+	;;
+wd,mynet-wifi-rangeextender)
+	ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
+	ucidef_set_rssimon "wlan0" "200000" "1"
+	ucidef_set_led_rssi "rssilow" "RSSILOW" "blue:rssi-low" "wlan0" "1" "100"
+	ucidef_set_led_rssi "rssimedium" "RSSIMED" "blue:rssi-med" "wlan0" "33" "100"
+	ucidef_set_led_rssi "rssihigh" "RSSIMAX" "blue:rssi-max" "wlan0" "66" "100"
+	;;
+xiaomi,aiot-ac2350)
+	ucidef_set_led_switch "wan" "WAN" "blue:wan" "switch0" "0x02"
+	;;
+yuncore,a770)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x10"
+	;;
+zbtlink,zbt-wd323)
+	ucidef_set_led_switch "lan1" "LAN1" "orange:lan1" "switch0" "0x10"
+	ucidef_set_led_switch "lan2" "LAN2" "orange:lan2" "switch0" "0x08"
+	;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network
new file mode 100755
index 0000000..b01dfa4
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network
@@ -0,0 +1,684 @@
+#!/bin/sh
+
+. /lib/functions/system.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/k2t.sh
+
+ath79_setup_interfaces()
+{
+	local board="$1"
+
+	case "$board" in
+	adtran,bsap1800-v2|\
+	adtran,bsap1840|\
+	allnet,all-wap02860ac|\
+	alfa-network,ap121f|\
+	alfa-network,pi-wifi4|\
+	arduino,yun|\
+	aruba,ap-105|\
+	avm,fritz1750e|\
+	avm,fritz300e|\
+	avm,fritzdvbc|\
+	comfast,cf-wr752ac-v1|\
+	comfast,cf-e130n-v2|\
+	devolo,dvl1200i|\
+	devolo,dvl1750c|\
+	devolo,dvl1750i|\
+	devolo,dvl1750x|\
+	dlink,dap-1330-a1|\
+	dlink,dap-1365-a1|\
+	dlink,dap-2230-a1|\
+	dlink,dap-2660-a1|\
+	dlink,dap-2680-a1|\
+	dlink,dap-3320-a1|\
+	dlink,dir-505|\
+	engenius,eap1200h|\
+	engenius,eap600|\
+	engenius,ecb1200|\
+	engenius,ecb1750|\
+	engenius,ecb600|\
+	enterasys,ws-ap3705i|\
+	glinet,gl-ar300m-lite|\
+	glinet,gl-usb150|\
+	hak5,wifi-pineapple-nano|\
+	meraki,mr16|\
+	netgear,ex6400|\
+	netgear,ex7300|\
+	ocedo,koala|\
+	ocedo,raccoon|\
+	onion,omega|\
+	openmesh,mr600-v1|\
+	openmesh,mr600-v2|\
+	openmesh,mr900-v1|\
+	openmesh,mr900-v2|\
+	openmesh,mr1750-v1|\
+	openmesh,mr1750-v2|\
+	pcs,cap324|\
+	pisen,ts-d084|\
+	pisen,wmb001n|\
+	pisen,wmm003n|\
+	siemens,ws-ap3610|\
+	tplink,cpe210-v2|\
+	tplink,cpe210-v3|\
+	tplink,cpe510-v2|\
+	tplink,cpe510-v3|\
+	tplink,cpe610-v1|\
+	tplink,cpe610-v2|\
+	tplink,eap225-outdoor-v1|\
+	tplink,eap225-v3|\
+	tplink,eap245-v1|\
+	tplink,re350k-v1|\
+	tplink,re355-v1|\
+	tplink,re450-v1|\
+	tplink,re450-v2|\
+	tplink,re450-v3|\
+	tplink,tl-wr902ac-v1|\
+	ubnt,bullet-ac|\
+	ubnt,bullet-m-ar7240|\
+	ubnt,bullet-m-ar7241|\
+	ubnt,bullet-m-xw|\
+	ubnt,lap-120|\
+	ubnt,litebeam-ac-gen2|\
+	ubnt,nanobeam-ac|\
+	ubnt,nanobridge-m|\
+	ubnt,nanostation-ac-loco|\
+	ubnt,nanostation-loco-m|\
+	ubnt,nanostation-loco-m-xw|\
+	ubnt,picostation-m|\
+	ubnt,powerbeam-5ac-500|\
+	ubnt,powerbeam-5ac-gen2|\
+	ubnt,powerbridge-m|\
+	ubnt,rocket-m|\
+	ubnt,unifiac-lite|\
+	ubnt,unifiac-lr|\
+	ubnt,unifiac-mesh|\
+	ubnt,unifi|\
+	wd,mynet-wifi-rangeextender|\
+	winchannel,wb2000)
+		ucidef_set_interface_lan "eth0"
+		;;
+	airtight,c-75)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:wan" "3:lan" "6@eth1"
+		;;
+	alfa-network,ap121fe)
+		ucidef_set_interface_lan "eth0 usb0"
+		;;
+	alfa-network,n2q|\
+	alfa-network,n5q|\
+	devolo,dvl1200e|\
+	devolo,dvl1750e|\
+	engenius,enstationac-v1|\
+	engenius,ews511ap|\
+	ocedo,ursus|\
+	ubnt,unifi-ap-outdoor-plus)
+		ucidef_set_interface_lan "eth0 eth1"
+		;;
+	avm,fritz4020|\
+	pcs,cr3000|\
+	tplink,archer-c58-v1|\
+	tplink,archer-c59-v1|\
+	tplink,archer-c59-v2)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
+		;;
+	belkin,f9j1108-v2|\
+	belkin,f9k1115-v2|\
+	tplink,archer-c5-v1|\
+	tplink,archer-c7-v1|\
+	tplink,archer-c7-v2|\
+	tplink,tl-wdr4900-v2|\
+	tplink,tl-wdr7500-v3)
+		ucidef_add_switch "switch0" \
+			"0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
+		;;
+	buffalo,bhr-4grv|\
+	buffalo,wzr-hp-g450h)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
+		;;
+	buffalo,bhr-4grv2|\
+	trendnet,tew-823dru)
+		ucidef_add_switch "switch0" \
+			"0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
+		;;
+	buffalo,wzr-600dhp|\
+	buffalo,wzr-hp-ag300h|\
+	tplink,archer-c25-v1|\
+	tplink,archer-c60-v1|\
+	tplink,archer-c60-v2|\
+	tplink,archer-c60-v3|\
+	tplink,tl-wdr3500-v1|\
+	tplink,tl-wr842n-v1|\
+	tplink,tl-wr842n-v3|\
+	ubnt,airrouter)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
+		;;
+	buffalo,wzr-hp-g300nh-rb|\
+	buffalo,wzr-hp-g300nh-s|\
+	dlink,dir-825-b1)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
+		;;
+	buffalo,wzr-hp-g302h-a1a0)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
+		;;
+	comfast,cf-e110n-v2|\
+	comfast,cf-e120a-v3|\
+	comfast,cf-e314n-v2|\
+	compex,wpj531-16m|\
+	openmesh,om2p-v4|\
+	openmesh,om2p-hs-v4|\
+	plasmacloud,pa300|\
+	plasmacloud,pa300e|\
+	tplink,cpe210-v1|\
+	tplink,cpe220-v2|\
+	tplink,cpe220-v3|\
+	tplink,cpe510-v1|\
+	tplink,wbs210-v1|\
+	tplink,wbs210-v2|\
+	tplink,wbs510-v1|\
+	tplink,wbs510-v2|\
+	ubnt,nanostation-m|\
+	ubnt,routerstation)
+		ucidef_set_interfaces_lan_wan "eth1" "eth0"
+		;;
+	comfast,cf-e560ac)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
+		;;
+	comfast,cf-wr650ac-v1|\
+	comfast,cf-wr650ac-v2|\
+	zyxel,nbg6616)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
+		;;
+	compex,wpj344-16m|\
+	compex,wpj563)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "3:lan" "2:wan"
+		;;
+	devolo,magic-2-wifi)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:wan" "3:lan" "4:lan"
+		;;
+	dlink,dap-2695-a1)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan" "3:wan" "6@eth1"
+		;;
+	dlink,dap-3662-a1)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:2" "2:lan:1" "6@eth1"
+		;;
+	dlink,dch-g020-a1)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:2" "2:lan:1"
+		;;
+	dlink,dir-825-c1|\
+	dlink,dir-835-a1|\
+	dlink,dir-842-c1|\
+	dlink,dir-842-c2|\
+	dlink,dir-842-c3|\
+	dlink,dir-859-a1|\
+	engenius,epg5000|\
+	sitecom,wlr-7100|\
+	tplink,archer-c2-v3|\
+	tplink,tl-wr1043nd-v4|\
+	tplink,tl-wr1043n-v5)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
+		;;
+	elecom,wrc-1750ghbk2-i|\
+	elecom,wrc-300ghbk2-i|\
+	sitecom,wlr-8100)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
+		;;
+	embeddedwireless,dorin)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:wan" "2:lan:3" "3:lan:2"
+		;;
+	engenius,eap300-v2)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan"
+		;;
+	engenius,ens202ext-v1)
+		ucidef_set_interface_lan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan"
+		;;
+	etactica,eg200)
+		ucidef_set_interface_lan "eth0" "dhcp"
+		;;
+	glinet,gl-ar750)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan"
+		;;
+	iodata,etg3-r|\
+	iodata,wn-ac1167dgr|\
+	iodata,wn-ac1600dgr|\
+	iodata,wn-ac1600dgr2|\
+	iodata,wn-ag300dgr|\
+	pcs,cr5000|\
+	wd,mynet-n750)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
+		;;
+	joyit,jt-or750i)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
+		;;
+	librerouter,librerouter-v1)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "5:wan" "6@eth1" "4:lan"
+		;;
+	meraki,mr12)
+		ucidef_set_interface_lan "eth0"
+		ucidef_add_switch "switch0" \
+			"0@eth1" "1:lan"
+		;;
+	mercury,mw4530r-v1|\
+	tplink,archer-a7-v5|\
+	tplink,archer-c6-v2|\
+	tplink,archer-c6-v2-us|\
+	tplink,archer-c7-v4|\
+	tplink,archer-c7-v5|\
+	tplink,tl-wdr3600-v1|\
+	tplink,tl-wdr4300-v1|\
+	tplink,tl-wdr4300-v1-il|\
+	tplink,tl-wdr4310-v1)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
+		;;
+	nec,wg1200cr|\
+	qxwlan,e1700ac-v2-8m|\
+	qxwlan,e1700ac-v2-16m|\
+	qxwlan,e750g-v8-8m|\
+	qxwlan,e750g-v8-16m|\
+	ubnt,nanobeam-ac-gen2|\
+	ubnt,nanostation-ac|\
+	yuncore,a782|\
+	yuncore,xd3200|\
+	yuncore,xd4200)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan" "3:wan"
+		;;
+	nec,wg800hp|\
+	xiaomi,aiot-ac2350)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
+		;;
+	netgear,wndr3700|\
+	netgear,wndr3700-v2|\
+	netgear,wndr3800|\
+	netgear,wndr3800ch|\
+	netgear,wndrmac-v1|\
+	netgear,wndrmac-v2)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
+		ucidef_add_switch_attr "switch0" "blinkrate" 2
+		ucidef_add_switch_port_attr "switch0" 1 led 6
+		ucidef_add_switch_port_attr "switch0" 2 led 9
+		ucidef_add_switch_port_attr "switch0" 5 led 2
+		;;
+	netgear,wnr2200-8m|\
+	netgear,wnr2200-16m)
+		ucidef_set_interface_wan "eth0"
+		ucidef_add_switch "switch0" \
+			"0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
+		;;
+	phicomm,k2t)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "3:lan:1" "5:lan:2" "4:wan"
+		;;
+	qihoo,c301)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan" "3:lan"
+		;;
+	qxwlan,e558-v2-8m|\
+	qxwlan,e558-v2-16m)
+		ucidef_add_switch "switch0" \
+			"0@eth1" "4:lan" "5:lan" "6@eth0" "3:wan"
+		;;
+	rosinson,wr818)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan" "3:wan"
+		;;
+	teltonika,rut955|\
+	teltonika,rut955-h7v3c0)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
+		;;
+	tplink,archer-d50-v1)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "1:wan"
+		;;
+	tplink,archer-d7-v1|\
+	tplink,archer-d7b-v1)
+		ucidef_add_switch "switch0" \
+			"0@eth1" "3:lan:3" "4:lan:2" "5:lan:1" "6@eth0" "2:wan:4" "1:wan:5"
+		;;
+	tplink,eap225-wall-v2)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
+		;;
+	tplink,eap245-v3)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:1" "5:lan:2"
+		;;
+	tplink,tl-mr6400-v1)
+		ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:1" "2:lan:3" "3:lan:2"
+		;;
+	tplink,tl-wpa8630-v1)
+		# port 5 (internal) is the power-line port
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
+		;;
+	tplink,tl-wr842n-v2)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
+		;;
+	tplink,tl-wr1043nd-v1)
+		ucidef_add_switch "switch0" \
+			"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
+		;;
+	tplink,tl-wr1043nd-v2|\
+	tplink,tl-wr1043nd-v3|\
+	tplink,tl-wr1045nd-v2)
+		ucidef_add_switch "switch0" \
+			"0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
+		;;
+	tplink,tl-wr2543-v1)
+		ucidef_add_switch "switch0" \
+			"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
+		;;
+	ubnt,aircube-ac)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:1" "3:lan:2" "5:lan:3" "4:wan"
+		;;
+	ubnt,aircube-isp)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:1" "3:lan:3" "4:lan:2"
+		;;
+	ubnt,edgeswitch-5xp)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
+		;;
+	ubnt,edgeswitch-8xp)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:lan:5" "5:lan:6" "6:lan:7" "7:lan:8"  "8@eth0"
+		;;
+	ubnt,routerstation-pro)
+		ucidef_set_interface_wan "eth0"
+		ucidef_add_switch "switch0" \
+			"0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
+		;;
+	ubnt,nanostation-m-xw)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "5:lan" "1:wan"
+		;;
+	ubnt,unifiac-mesh-pro|\
+	ubnt,unifiac-pro)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "2:lan:1" "3:lan:2"
+		;;
+	ubnt,unifi-ap-pro)
+		ucidef_add_switch "switch0" \
+			"0@eth0" "1:lan" "2:lan"
+		;;
+	zbtlink,zbt-wd323|\
+	xiaomi,mi-router-4q)
+		ucidef_set_interface_wan "eth1"
+		ucidef_add_switch "switch0" \
+			"0@eth0" "3:lan:1" "4:lan:2"
+		;;
+	*)
+		ucidef_set_interfaces_lan_wan "eth0" "eth1"
+		;;
+	esac
+}
+
+ath79_setup_macs()
+{
+	local board="$1"
+
+	case "$board" in
+	adtran,bsap1800-v2|\
+	adtran,bsap1840)
+		lan_mac=$(mtd_get_mac_binary "Board data" 2)
+		label_mac=$lan_mac
+		;;
+	alfa-network,ap121f|\
+	alfa-network,ap121fe|\
+	alfa-network,n2q|\
+	alfa-network,n5q|\
+	alfa-network,pi-wifi4|\
+	alfa-network,r36a|\
+	engenius,eap300-v2|\
+	engenius,ens202ext-v1)
+		label_mac=$(mtd_get_mac_binary art 0x1002)
+		;;
+	arduino,yun)
+		base_mac=$(mtd_get_mac_binary art 0x1002)
+		lan_mac=$(macaddr_setbit $base_mac 29)
+		[ $lan_mac = $base_mac ] && lan_mac=$(macaddr_unsetbit $base_mac 29)
+		;;
+	avm,fritz1750e|\
+	avm,fritz450e|\
+	avm,fritzdvbc)
+		label_mac=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
+		;;
+	avm,fritz300e)
+		lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
+		label_mac=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
+		;;
+	avm,fritz4020)
+		lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
+		wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
+		;;
+	compex,wpj344-16m|\
+	compex,wpj563)
+		wan_mac=$(mtd_get_mac_binary u-boot 0x2e018)
+		;;
+	devolo,magic-2-wifi)
+		label_mac=$(macaddr_add "$(mtd_get_mac_binary art 0x1002)" 3)
+		;;
+	dlink,dap-1330-a1|\
+	dlink,dap-1365-a1|\
+	dlink,dch-g020-a1)
+		lan_mac=$(mtd_get_mac_text "mp" 0x1)
+		label_mac=$lan_mac
+		;;
+	dlink,dap-2230-a1|\
+	dlink,dap-2660-a1|\
+	dlink,dap-2680-a1|\
+	dlink,dap-3320-a1)
+		lan_mac=$(mtd_get_mac_ascii bdcfg "lanmac")
+		label_mac=$lan_mac
+		;;
+	dlink,dap-2695-a1|\
+	dlink,dap-3662-a1)
+		label_mac=$(mtd_get_mac_ascii bdcfg "wlanmac")
+		;;
+	dlink,dir-825-b1)
+		lan_mac=$(mtd_get_mac_text "caldata" 0xffa0)
+		wan_mac=$(mtd_get_mac_text "caldata" 0xffb4)
+		;;
+	dlink,dir-505)
+		lan_mac=$(mtd_get_mac_text "mac" 0x4)
+		;;
+	dlink,dir-825-c1|\
+	dlink,dir-835-a1)
+		lan_mac=$(mtd_get_mac_text "mac" 0x4)
+		wan_mac=$(mtd_get_mac_text "mac" 0x18)
+		;;
+	dlink,dir-842-c1|\
+	dlink,dir-842-c2|\
+	dlink,dir-842-c3)
+		lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
+		wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
+		label_mac=$lan_mac
+		;;
+	dlink,dir-859-a1|\
+	qihoo,c301|\
+	wd,mynet-n750)
+		lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
+		wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
+		;;
+	elecom,wrc-1750ghbk2-i|\
+	elecom,wrc-300ghbk2-i)
+		wan_mac=$(macaddr_add "$(mtd_get_mac_binary art 0x1002)" -2)
+		;;
+	engenius,ecb1200|\
+	engenius,ecb1750)
+		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		label_mac=$lan_mac
+		;;
+	engenius,epg5000)
+		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+		;;
+	engenius,ews511ap)
+		lan_mac=$(mtd_get_mac_text "u-boot-env" 0xe9)
+		eth1_mac=$(macaddr_add "$lan_mac" 1)
+		ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
+		ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
+		;;
+	enterasys,ws-ap3705i)
+		label_mac=$(mtd_get_mac_ascii u-boot-env0 ethaddr)
+		;;
+	hak5,lan-turtle|\
+	hak5,packet-squirrel)
+		label_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
+		;;
+	iodata,etg3-r)
+		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		wan_mac=$(macaddr_add "$lan_mac" -1)
+		label_mac=$wan_mac
+		;;
+	iodata,wn-ac1167dgr|\
+	iodata,wn-ac1600dgr|\
+	iodata,wn-ac1600dgr2|\
+	iodata,wn-ag300dgr)
+		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+		label_mac=$wan_mac
+		;;
+	jjplus,ja76pf2)
+		wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n alias/ethaddr)
+		lan_mac=$(macaddr_add "$wan_mac" 1)
+		;;
+	mercury,mw4530r-v1|\
+	tplink,tl-wdr3600-v1|\
+	tplink,tl-wdr4300-v1|\
+	tplink,tl-wdr4300-v1-il)
+		base_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
+		wan_mac=$(macaddr_add "$base_mac" 1)
+		;;
+	nec,wg1200cr)
+		lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
+		wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
+		label_mac=$wan_mac
+		;;
+	nec,wg800hp)
+		lan_mac=$(mtd_get_mac_text board_data 0x280)
+		wan_mac=$(mtd_get_mac_text board_data 0x480)
+		label_mac=$wan_mac
+		;;
+	netgear,wndr3700|\
+	netgear,wndr3700-v2|\
+	netgear,wndr3800|\
+	netgear,wndrmac-v1|\
+	netgear,wndrmac-v2)
+		lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0x0)")
+		;;
+	phicomm,k2t)
+		lan_mac=$(k2t_get_mac "lan_mac")
+		wan_mac=$(k2t_get_mac "wan_mac")
+		;;
+	rosinson,wr818)
+		wan_mac=$(mtd_get_mac_binary factory 0x0)
+		lan_mac=$(macaddr_setbit_la "$wan_mac")
+		;;
+	sitecom,wlr-7100|\
+	sitecom,wlr-8100)
+		lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+		label_mac=$lan_mac
+		;;
+	tplink,archer-a7-v5|\
+	tplink,archer-c7-v4|\
+	tplink,archer-c7-v5|\
+	tplink,tl-wr1043nd-v4|\
+	tplink,tl-wr1043n-v5)
+		base_mac=$(mtd_get_mac_binary info 0x8)
+		wan_mac=$(macaddr_add "$base_mac" 1)
+		;;
+	trendnet,tew-823dru)
+		lan_mac=$(mtd_get_mac_text mac 0x4)
+		wan_mac=$(mtd_get_mac_text mac 0x18)
+		label_mac=$wan_mac
+		;;
+	ubnt,airrouter|\
+	ubnt,bullet-m-ar7240|\
+	ubnt,bullet-m-ar7241|\
+	ubnt,nanobridge-m|\
+	ubnt,nanostation-loco-m|\
+	ubnt,nanostation-m|\
+	ubnt,picostation-m|\
+	ubnt,powerbridge-m|\
+	ubnt,rocket-m|\
+	ubnt,unifi)
+		label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+		;;
+	ubnt,litebeam-ac-gen2|\
+	ubnt,nanobeam-ac-gen2|\
+	ubnt,powerbeam-5ac-500|\
+	ubnt,powerbeam-5ac-gen2)
+		label_mac=$(mtd_get_mac_binary art 0x5006)
+		;;
+	ubnt,routerstation|\
+	ubnt,routerstation-pro)
+		wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
+		lan_mac=$(macaddr_add "$wan_mac" 1)
+		;;
+	wd,mynet-wifi-rangeextender)
+		lan_mac=$(nvram get et0macaddr)
+		;;
+	xiaomi,aiot-ac2350)
+		lan_mac=$(mtd_get_mac_binary art 0x1002)
+		;;
+	zyxel,nbg6616)
+		label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		;;
+	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)
+ath79_setup_interfaces $board
+ath79_setup_macs $board
+board_config_flush
+
+exit 0
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/03_gpio_switches b/target/linux/ath79/generic/base-files/etc/board.d/03_gpio_switches
new file mode 100755
index 0000000..b3e0d0d
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/board.d/03_gpio_switches
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# Copyright (C) 2018 OpenWrt.org
+#
+
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+board=$(board_name)
+
+case "$board" in
+adtran,bsap1800-v2|\
+adtran,bsap1840)
+	ucidef_add_gpio_switch "wifi1_ext_a" "5GHz External Antenna A" "489" "1"
+	ucidef_add_gpio_switch "wifi1_int_a" "5GHz Internal Antenna A" "493"
+	ucidef_add_gpio_switch "wifi1_ext_b" "5GHz External Antenna B" "494" "1"
+	ucidef_add_gpio_switch "wifi1_int_b" "5GHz Internal Antenna B" "495"
+	ucidef_add_gpio_switch "wifi1_ext_c" "5GHz External Antenna C" "496" "1"
+	ucidef_add_gpio_switch "wifi1_int_c" "5GHz Internal Antenna C" "497"
+	ucidef_add_gpio_switch "wifi0_ext_a" "2.4GHz External Antenna A" "505" "1"
+	ucidef_add_gpio_switch "wifi0_int_a" "2.4GHz Internal Antenna A" "506"
+	ucidef_add_gpio_switch "wifi0_ext_b" "2.4GHz External Antenna B" "507" "1"
+	ucidef_add_gpio_switch "wifi0_int_b" "2.4GHz Internal Antenna B" "508"
+	ucidef_add_gpio_switch "wifi0_ext_c" "2.4GHz External Antenna C" "509" "1"
+	ucidef_add_gpio_switch "wifi0_int_c" "2.4GHz Internal Antenna C" "510"
+	;;
+comfast,cf-e5|\
+telco,t1)
+	ucidef_add_gpio_switch "lte_power" "LTE Power" "14" "1"
+	ucidef_add_gpio_switch "lte_wakeup" "LTE Wakeup" "11" "1"
+	ucidef_add_gpio_switch "lte_poweroff" "LTE Poweroff" "1" "1"
+	ucidef_add_gpio_switch "lte_reset" "LTE Reset" "12" "1"
+	;;
+devolo,magic-2-wifi)
+	ucidef_add_gpio_switch "plc_pairing" "PLC pairing" "11" "1"
+	ucidef_add_gpio_switch "plc_enable" "PLC enable" "13" "1"
+	;;
+dlink,dir-825-c1|\
+dlink,dir-835-a1)
+	ucidef_add_gpio_switch "wan_led_auto" "WAN LED Auto" "20" "0"
+	;;
+librerouter,librerouter-v1)
+	ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "1" "0"
+	;;
+teltonika,rut955)
+	ucidef_add_gpio_switch "sim_sel" "SIM select" "503" "1"
+	ucidef_add_gpio_switch "DOUT1" "DOUT1 (OC)" "504" "0"
+	ucidef_add_gpio_switch "DOUT2" "DOUT2 (Relay)" "505" "0"
+	ucidef_add_gpio_switch "modem_vbus" "Modem enable" "506" "1"
+	ucidef_add_gpio_switch "modem_rst" "Modem reset" "507" "0"
+	ucidef_add_gpio_switch "DOUT3" "DOUT3" "508" "0"
+	;;
+teltonika,rut955-h7v3c0)
+	ucidef_add_gpio_switch "sim_sel" "SIM select" "503" "1"
+	ucidef_add_gpio_switch "DOUT1" "DOUT1 (OC)" "504" "0"
+	ucidef_add_gpio_switch "DOUT2" "DOUT2 (Relay)" "505" "0"
+	ucidef_add_gpio_switch "modem_vbus" "Modem enable" "508" "1"
+	ucidef_add_gpio_switch "modem_rst" "Modem reset" "509" "0"
+	;;
+
+tplink,archer-c25-v1)
+	ucidef_add_gpio_switch "led_control" "LED control" "21" "0"
+	ucidef_add_gpio_switch "led_reset" "LED reset" "19" "1"
+	;;
+tplink,cpe210-v1|\
+tplink,cpe220-v2|\
+tplink,cpe220-v3|\
+tplink,cpe510-v1|\
+tplink,wbs210-v1|\
+tplink,wbs210-v2|\
+tplink,wbs510-v1|\
+tplink,wbs510-v2)
+	ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "20"
+	;;
+ubnt,aircube-ac|\
+ubnt,aircube-isp)
+	ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "11"
+	;;
+ubnt,nanobeam-ac-gen2|\
+ubnt,nanostation-ac)
+	ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "3"
+	;;
+ubnt,nanostation-m)
+	ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "8"
+	;;
+ubnt,nanostation-m-xw)
+	ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "2"
+	;;
+zbtlink,zbt-wd323)
+	ucidef_add_gpio_switch "io0" "IO#0" "0"
+	ucidef_add_gpio_switch "io1" "IO#1" "1"
+	ucidef_add_gpio_switch "io2" "IO#2" "2"
+	ucidef_add_gpio_switch "io14" "IO#14" "14"
+	;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
new file mode 100644
index 0000000..08d9e01
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -0,0 +1,192 @@
+#!/bin/sh
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+
+. /lib/functions/caldata.sh
+
+board=$(board_name)
+
+case "$FIRMWARE" in
+"ath9k-eeprom-ahb-18100000.wmac.bin")
+	case $board in
+	8dev,lima)
+		caldata_extract "art" 0x1000 0x800
+		;;
+	avm,fritz1750e|\
+	avm,fritz4020|\
+	avm,fritz450e|\
+	avm,fritzdvbc)
+		caldata_extract_reverse "urlader" 0x1541 0x440
+		;;
+	dlink,dap-2695-a1)
+		caldata_extract "art" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii bdcfg "wlanmac")
+		;;
+	dlink,dir-505|\
+	dlink,dir-825-c1|\
+	dlink,dir-835-a1)
+		caldata_extract "art" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_text "mac" 0x4)
+		;;
+	dlink,dir-842-c1|\
+	dlink,dir-842-c2|\
+	dlink,dir-842-c3|\
+	dlink,dir-859-a1|\
+	nec,wg1200cr|\
+	wd,mynet-n750)
+		caldata_extract "art" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan24mac")
+		;;
+	engenius,ecb1200|\
+	engenius,ecb1750)
+		caldata_extract "art" 0x1000 0x440
+		ath9k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env athaddr) +1)
+		;;
+	engenius,epg5000|\
+	iodata,wn-ac1167dgr|\
+	iodata,wn-ac1600dgr|\
+	iodata,wn-ac1600dgr2|\
+	iodata,wn-ag300dgr|\
+	sitecom,wlr-7100|\
+	sitecom,wlr-8100)
+		caldata_extract "art" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env ethaddr)
+		;;
+	enterasys,ws-ap3705i)
+		caldata_extract "calibrate" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env0 RADIOADDR1)
+		;;
+	nec,wg800hp)
+		caldata_extract "art" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_text board_data 0x680)
+		;;
+	qihoo,c301)
+		caldata_extract "radiocfg" 0x1000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan24mac")
+		;;
+	*)
+		caldata_die "board $board is not supported yet"
+		;;
+	esac
+	;;
+"ath9k-eeprom-pci-0000:00:00.0.bin")
+	case $board in
+	avm,fritz300e)
+		caldata_extract_reverse "urloader" 0x1541 0x440
+		;;
+	buffalo,wzr-hp-g302h-a1a0|\
+	ubnt,unifi-ap-outdoor-plus)
+		caldata_extract "art" 0x1000 0xeb8
+		;;
+	buffalo,wzr-hp-g450h|\
+	ubnt,unifi)
+		caldata_extract "art" 0x1000 0x440
+		;;
+	dlink,dir-825-c1|\
+	dlink,dir-835-a1)
+		caldata_extract "art" 0x5000 0x440
+		ath9k_patch_mac $(macaddr_add $(mtd_get_mac_text "mac" 0x18) 1)
+		;;
+	engenius,eap600|\
+	engenius,ecb600|\
+	mercury,mw4530r-v1|\
+	ocedo,raccoon|\
+	tplink,tl-wdr3500-v1|\
+	tplink,tl-wdr3600-v1|\
+	tplink,tl-wdr4300-v1|\
+	tplink,tl-wdr4300-v1-il|\
+	tplink,tl-wdr4310-v1|\
+	tplink,tl-wdr4900-v2|\
+	ubnt,unifi-ap-pro|\
+	winchannel,wb2000)
+		caldata_extract "art" 0x5000 0x440
+		;;
+	enterasys,ws-ap3705i)
+		caldata_extract "calibrate" 0x5000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env0 RADIOADDR0)
+		;;
+	meraki,mr12)
+		caldata_extract "art" 0x11000 0xeb8
+		;;
+	netgear,wnr2200-8m|\
+	netgear,wnr2200-16m|\
+	pcs,cap324|\
+	tplink,tl-wr2543-v1|\
+	tplink,tl-wr842n-v1|\
+	ubnt,airrouter|\
+	ubnt,bullet-m-ar7240|\
+	ubnt,bullet-m-ar7241|\
+	ubnt,nanobridge-m|\
+	ubnt,nanostation-loco-m|\
+	ubnt,nanostation-m|\
+	ubnt,picostation-m|\
+	ubnt,powerbridge-m|\
+	ubnt,rocket-m)
+		caldata_extract "art" 0x1000 0x1000
+		;;
+	openmesh,mr600-v1|\
+	openmesh,mr600-v2)
+		caldata_extract "ART" 0x5000 0x440
+		;;
+	wd,mynet-n750)
+		caldata_extract "art" 0x5000 0x440
+		ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac")
+		;;
+	wd,mynet-wifi-rangeextender)
+		caldata_extract "art" 0x1000 0x1000
+		ath9k_patch_mac $(nvram get wl0_hwaddr)
+		;;
+	*)
+		caldata_die "board $board is not supported yet"
+		;;
+	esac
+	;;
+"ath9k-eeprom-pci-0000:00:11.0.bin")
+	case $board in
+	buffalo,wzr-600dhp|\
+	buffalo,wzr-hp-ag300h|\
+	netgear,wndr3700|\
+	netgear,wndr3700-v2|\
+	netgear,wndr3800|\
+	netgear,wndr3800ch|\
+	netgear,wndrmac-v1|\
+	netgear,wndrmac-v2)
+		caldata_extract "art" 0x1000 0xeb8
+		;;
+	dlink,dir-825-b1)
+		caldata_extract "caldata" 0x1000 0xeb8
+		ath9k_patch_mac_crc $(mtd_get_mac_text "caldata" 0xffa0) 0x20c
+		;;
+	meraki,mr16)
+		caldata_extract "art" 0x11000 0xeb8
+		;;
+	*)
+		caldata_die "board $board is not supported yet"
+		;;
+	esac
+	;;
+"ath9k-eeprom-pci-0000:00:12.0.bin")
+	case $board in
+	buffalo,wzr-600dhp|\
+	buffalo,wzr-hp-ag300h|\
+	netgear,wndr3700|\
+	netgear,wndr3700-v2|\
+	netgear,wndr3800|\
+	netgear,wndr3800ch|\
+	netgear,wndrmac-v1|\
+	netgear,wndrmac-v2)
+		caldata_extract "art" 0x5000 0xeb8
+		;;
+	dlink,dir-825-b1)
+		caldata_extract "caldata" 0x5000 0xeb8
+		ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 0xffb4) 1) 0x20c
+		;;
+	meraki,mr16)
+		caldata_extract "art" 0x15000 0xeb8
+		;;
+	*)
+		caldata_die "board $board is not supported yet"
+		;;
+	esac
+	;;
+esac
diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
new file mode 100644
index 0000000..c7dbaaf
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -0,0 +1,257 @@
+#!/bin/sh
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+
+. /lib/functions/caldata.sh
+. /lib/functions/k2t.sh
+
+board=$(board_name)
+
+case "$FIRMWARE" in
+"ath10k/cal-pci-0000:00:00.0.bin")
+	case $board in
+	allnet,all-wap02860ac|\
+	engenius,eap1200h|\
+	engenius,enstationac-v1|\
+	glinet,gl-x750)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2)
+		;;
+	avm,fritz1750e|\
+	avm,fritzdvbc)
+		caldata_extract "urlader" 0x198a 0x844
+		;;
+	comfast,cf-wr650ac-v1|\
+	comfast,cf-wr650ac-v2|\
+	devolo,magic-2-wifi|\
+	joyit,jt-or750i|\
+	qxwlan,e1700ac-v2-8m|\
+	qxwlan,e1700ac-v2-16m|\
+	qxwlan,e600gac-v2-8m|\
+	qxwlan,e600gac-v2-16m|\
+	ubnt,aircube-ac|\
+	ubnt,bullet-ac|\
+	ubnt,unifiac-lite|\
+	ubnt,unifiac-lr|\
+	ubnt,unifiac-mesh|\
+	ubnt,unifiac-mesh-pro|\
+	ubnt,lap-120|\
+	ubnt,litebeam-ac-gen2|\
+	ubnt,nanobeam-ac|\
+	ubnt,nanobeam-ac-gen2|\
+	ubnt,nanostation-ac|\
+	ubnt,nanostation-ac-loco|\
+	ubnt,powerbeam-5ac-500|\
+	ubnt,powerbeam-5ac-gen2|\
+	ubnt,unifiac-pro|\
+	yuncore,a770|\
+	yuncore,xd3200)
+		caldata_extract "art" 0x5000 0x844
+		;;
+	devolo,dvl1200e|\
+	devolo,dvl1200i|\
+	devolo,dvl1750c|\
+	devolo,dvl1750e|\
+	devolo,dvl1750i|\
+	devolo,dvl1750x)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) -1)
+		;;
+	dlink,dap-2660-a1|\
+	dlink,dap-2695-a1|\
+	dlink,dap-3662-a1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
+		;;
+	dlink,dir-859-a1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac")
+		;;
+	elecom,wrc-1750ghbk2-i)
+		caldata_extract "art" 0x5000 0x844
+		;;
+	engenius,ecb1200|\
+	engenius,ecb1750)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr)
+		;;
+	engenius,epg5000|\
+	iodata,wn-ac1167dgr|\
+	iodata,wn-ac1600dgr2|\
+	sitecom,wlr-7100|\
+	zyxel,nbg6616)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
+		;;
+	engenius,ews511ap)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
+		;;
+	glinet,gl-ar750)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1)
+		;;
+	nec,wg800hp)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(mtd_get_mac_text board_data 0x880)
+		;;
+	ocedo,koala|\
+	ocedo,ursus)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(mtd_get_mac_binary art 0xc)
+		;;
+	openmesh,mr1750-v1|\
+	openmesh,mr1750-v2|\
+	openmesh,om5p-ac-v2)
+		caldata_extract "ART" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
+		;;
+	qihoo,c301)
+		caldata_extract "radiocfg" 0x5000 0x844
+		ath10k_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
+		;;
+	tplink,archer-a7-v5|\
+	tplink,archer-c2-v3|\
+	tplink,archer-c7-v4|\
+	tplink,archer-c7-v5|\
+	tplink,archer-c25-v1|\
+	tplink,tl-wr902ac-v1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) -1)
+		;;
+	tplink,archer-c5-v1|\
+	tplink,archer-c7-v2|\
+	tplink,tl-wdr7500-v3)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x1fc00) -1)
+		;;
+	tplink,archer-d50-v1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary romfile 0xf100) +2)
+		;;
+	tplink,archer-d7-v1|\
+	tplink,archer-d7b-v1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary romfs 0xf100) +2)
+		;;
+	tplink,eap245-v1|\
+	tplink,re450-v2|\
+	tplink,re450-v3)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1)
+		;;
+	tplink,re350k-v1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +2)
+		;;
+	tplink,re355-v1|\
+	tplink,re450-v1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
+		;;
+	tplink,tl-wpa8630-v1)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x0fc00) +1)
+		;;
+	esac
+	;;
+"ath10k/cal-pci-0000:01:00.0.bin")
+	case $board in
+	sitecom,wlr-8100)
+		caldata_extract "art" 0x5000 0x844
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
+		;;
+	esac
+	;;
+"ath10k/pre-cal-pci-0000:00:00.0.bin")
+	case $board in
+	comfast,cf-e313ac)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(mtd_get_mac_binary art 0x6)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
+		;;
+	comfast,cf-e560ac|\
+	comfast,cf-ew72|\
+	comfast,cf-wr752ac-v1)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
+		;;
+	dlink,dap-2680-a1)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	dlink,dir-842-c1|\
+	dlink,dir-842-c2|\
+	dlink,dir-842-c3)
+		caldata_extract "art" 0x5000 0x2f20
+		caldata_valid "202f" || caldata_extract "reserved" 0x15000 0x2f20
+		ath10k_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	nec,wg1200cr)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	netgear,ex6400|\
+	netgear,ex7300)
+		caldata_extract "caldata" 0x5000 0x2f20
+		ath10k_patch_mac $(mtd_get_mac_binary caldata 0xc)
+		;;
+	phicomm,k2t)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(k2t_get_mac "5g_mac")
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	tplink,archer-c58-v1|\
+	tplink,archer-c59-v1|\
+	tplink,archer-c59-v2|\
+	tplink,archer-c60-v1|\
+	tplink,archer-c60-v2|\
+	tplink,archer-c60-v3|\
+	tplink,archer-c6-v2|\
+	tplink,archer-c6-v2-us)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) -1)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	tplink,eap225-outdoor-v1|\
+	tplink,eap225-v3|\
+	tplink,eap225-wall-v2)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1)
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	tplink,eap245-v3)
+		caldata_extract "art" 0x5000 0x2f20
+		ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1)
+		;;
+	xiaomi,aiot-ac2350)
+		caldata_extract "art" 0x5000 0x2f20
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9984/hw1.0/board.bin
+		;;
+	yuncore,a782|\
+	yuncore,xd4200)
+		caldata_extract "art" 0x5000 0x2f20
+		ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
+			/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
+		;;
+	esac
+	;;
+*)
+	exit 1
+	;;
+esac
diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
new file mode 100644
index 0000000..ac8b59c
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -0,0 +1,68 @@
+#!/bin/ash
+
+[ "$ACTION" = "add" ] || exit 0
+
+PHYNBR=${DEVPATH##*/phy}
+
+[ -n $PHYNBR ] || exit 0
+
+. /lib/functions.sh
+. /lib/functions/system.sh
+. /lib/functions/k2t.sh
+
+board=$(board_name)
+
+case "$board" in
+	adtran,bsap1800-v2|\
+	adtran,bsap1840)
+		macaddr_add "$(mtd_get_mac_binary 'Board data' 2)" $(($PHYNBR * 8 + 1)) > /sys${DEVPATH}/macaddress
+		;;
+	dlink,dap-1330-a1|\
+	dlink,dap-1365-a1|\
+	dlink,dch-g020-a1)
+		mtd_get_mac_text "mp" 0x13 > /sys${DEVPATH}/macaddress
+		;;
+	dlink,dap-2230-a1|\
+	dlink,dap-3320-a1)
+		mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
+		;;
+	dlink,dap-2660-a1|\
+	dlink,dap-2680-a1|\
+	dlink,dap-3662-a1)
+		[ "$PHYNBR" -eq 1 ] && \
+			mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
+		;;
+	iodata,wn-ac1600dgr)
+		# There is no eeprom data for 5 GHz wlan in "art" partition
+		# which would allow to patch the macaddress
+		[ "$PHYNBR" -eq 0 ] && \
+			macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
+		;;
+	iodata,wn-ag300dgr)
+		# There is no eeprom data for 5 GHz wlan in "art" partition
+		# which would allow to patch the macaddress
+		[ "$PHYNBR" -eq 1 ] && \
+			macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
+		;;
+	phicomm,k2t)
+		# The K2T factory firmware does use LAN mac address as the 2.4G wifi mac address
+		[ "$PHYNBR" -eq 1 ] && \
+			k2t_get_mac "lan_mac" > /sys${DEVPATH}/macaddress
+		;;
+	siemens,ws-ap3610)
+		mtd_get_mac_ascii cfg1 RADIOADDR${PHYNBR} > /sys${DEVPATH}/macaddress
+		;;
+	trendnet,tew-823dru)
+		# set the 2.4G interface mac address to LAN MAC
+		[ "$PHYNBR" -eq 1 ] && \
+			mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
+		# set the 5G interface mac address to WAN MAC + 1
+		[ "$PHYNBR" -eq 0 ] && \
+			macaddr_add "$(mtd_get_mac_text mac 0x18)" 1 > /sys${DEVPATH}/macaddress
+		;;
+	zyxel,nbg6616)
+		# Set mac address for 2.4g device
+		[ "$PHYNBR" -eq 1 ] && \
+			mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress
+		;;
+esac
diff --git a/target/linux/ath79/generic/base-files/etc/init.d/bootcount b/target/linux/ath79/generic/base-files/etc/init.d/bootcount
new file mode 100755
index 0000000..7807559
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/init.d/bootcount
@@ -0,0 +1,16 @@
+#!/bin/sh /etc/rc.common
+
+START=99
+
+boot() {
+	case $(board_name) in
+	adtran,bsap1800-v2|\
+	adtran,bsap1840)
+		fconfig -s -w -d $(find_mtd_part "RedBoot config") -n boot_cntb -x 0
+		;;
+	qihoo,c301)
+		local n=$(fw_printenv activeregion | cut -d = -f 2)
+		fw_setenv "image${n}trynum" 0
+		;;
+	esac
+}
diff --git a/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration b/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration
new file mode 100644
index 0000000..e9b0fad
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration
@@ -0,0 +1,73 @@
+. /lib/functions.sh
+. /lib/functions/migrations.sh
+
+board=$(board_name)
+
+case "$board" in
+dlink,dap-1330-a1)
+	migrate_leds "red:power=red:status" \
+		"red:wifi=red:rssilow" \
+		"green:wifi=green:rssimediumlow" \
+		"green:signal1=green:rssimediumhigh" \
+		"green:signal2=green:rssihigh"
+	;;
+engenius,epg5000)
+	migrate_leds ":wlan-2g=:wlan2g" ":wlan-5g=:wlan5g"
+	;;
+glinet,gl-mifi)
+	migrate_leds ":net=:3g4g"
+	;;
+meraki,mr12)
+	migrate_leds ":wifi=:link" ":wan=:lan"
+	;;
+openmesh,mr600-v1)
+	migrate_leds ":wlan58=:wifi5g"
+	;;
+openmesh,mr600-v2)
+	migrate_leds ":wlan24=:wifi2g" ":wlan58=:wifi5g"
+	;;
+openmesh,mr900-v1|\
+openmesh,mr900-v2|\
+openmesh,mr1750-v1|\
+openmesh,mr1750-v2)
+	migrate_leds ":wlan24=:wifi2g" ":wlan58=:wifi5g" ":wan=:lan"
+	;;
+pcs,cap324)
+	migrate_leds "lan:amber=amber:lan" "lan:green=green:lan"
+	;;
+qxwlan,e558-v2-16m|\
+qxwlan,e558-v2-8m)
+	migrate_leds ":qss=:sig2"
+	;;
+qxwlan,e600g-v2-16m|\
+qxwlan,e600g-v2-8m)
+	migrate_leds "blue:wan=blue:wlan"
+	;;
+qxwlan,e600gac-v2-16m|\
+qxwlan,e600gac-v2-8m)
+	migrate_leds "orange:wan=orange:wlan2g" "green:system=blue:system"
+	;;
+qxwlan,e750a-v4-16m|\
+qxwlan,e750a-v4-8m|\
+qxwlan,e750g-v8-16m|\
+qxwlan,e750g-v8-8m)
+	migrate_leds ":ds10=:sig1" ":ds20=:sig2"
+	;;
+mercury,mw4530r-v1|\
+tplink,archer-c7-v2|\
+tplink,tl-wdr3600-v1|\
+tplink,tl-wdr4300-v1|\
+tplink,tl-wdr4300-v1-il|\
+tplink,tl-wdr4310-v1)
+	migrate_leds "blue:=green:"
+	;;
+tplink,tl-wpa8630-v1)
+	migrate_leds ':wlan$=:wifi2g' ':wlan5$=:wifi5g'
+	;;
+esac
+
+remove_devicename_leds
+
+migrations_apply system
+
+exit 0
diff --git a/target/linux/ath79/generic/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/ath79/generic/base-files/etc/uci-defaults/05_fix-compat-version
new file mode 100644
index 0000000..a6b7fa3
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/uci-defaults/05_fix-compat-version
@@ -0,0 +1,11 @@
+. /lib/functions.sh
+
+case "$(board_name)" in
+	meraki,mr12|\
+	meraki,mr16)
+		uci set system.@system[0].compat_version="2.0"
+		uci commit system
+		;;
+esac
+
+exit 0
diff --git a/target/linux/ath79/generic/base-files/etc/uci-defaults/09_fix-checksum b/target/linux/ath79/generic/base-files/etc/uci-defaults/09_fix-checksum
new file mode 100644
index 0000000..92048fd
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/etc/uci-defaults/09_fix-checksum
@@ -0,0 +1,27 @@
+. /lib/functions.sh
+
+fix_seama_header() {
+	local kernel_size=$(sed -n 's/mtd[0-9]*: \([0-9a-f]*\).*"kernel".*/\1/p' /proc/mtd)
+	[ "$kernel_size" ] && mtd -c 0x$kernel_size fixseama firmware
+}
+
+fixwrgg() {
+	local kernel_size=$(sed -n 's/mtd[0-9]*: \([0-9a-f]*\).*"kernel".*/\1/p' /proc/mtd)
+	[ "$kernel_size" ] && mtd -c 0x$kernel_size fixwrgg firmware
+}
+
+board=$(board_name)
+
+case "$board" in
+dlink,dap-2230-a1|\
+dlink,dap-2660-a1|\
+dlink,dap-2680-a1|\
+dlink,dap-2695-a1|\
+dlink,dap-3320-a1|\
+dlink,dap-3662-a1)
+	fixwrgg
+	;;
+qihoo,c301)
+	fix_seama_header
+	;;
+esac
diff --git a/target/linux/ath79/generic/base-files/lib/functions/k2t.sh b/target/linux/ath79/generic/base-files/lib/functions/k2t.sh
new file mode 100644
index 0000000..f16734f
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/functions/k2t.sh
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2018 Weijie Gao <hackpascal@gmail.com>
+#
+# Helper function to extract mac addresses from mtd part for Phicomm K2T
+#
+
+. /lib/functions.sh
+. /lib/functions/system.sh
+. /usr/share/libubox/jshn.sh
+
+k2t_config_load() {
+	local mtd_blk=$(find_mtd_part config)
+
+	if [ -z "$mtd_blk" ]; then
+		echo "k2t_config_load: no mtd part named config" >&2
+		exit 1
+	fi
+
+	local json_size=$(dd if=$mtd_blk bs=1 count=8 2>/dev/null)
+
+	json_size="0x$json_size"
+	json_size=$((json_size))
+
+	if [ "$?" -ne 0 ]; then
+		echo "k2t_config_load: invalid json data size" >&2
+		exit 2
+	fi
+
+	if [ "$json_size" -eq 0 ]; then
+		echo "k2t_config_load: empty json data" >&2
+		exit 3
+	fi
+
+	local json_data=$(dd if=$mtd_blk bs=1 skip=8 count=$json_size 2>/dev/null)
+
+	json_load "$json_data"
+}
+
+k2t_get_mac() {
+	local old_ns
+
+	json_set_namespace "k2t" old_ns
+
+	if k2t_config_load; then
+		json_select "this_dev_info"
+		json_get_var val "$1"
+		json_select ..
+	fi
+
+	json_set_namespace old_ns
+
+	echo $val
+}
+
diff --git a/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh b/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh
new file mode 100644
index 0000000..c2c7913
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh
@@ -0,0 +1,29 @@
+. /lib/functions.sh
+
+preinit_set_mac_address() {
+	case $(board_name) in
+	avm,fritz1750e|\
+	avm,fritz450e|\
+	avm,fritzdvbc)
+		ip link set dev eth0 address $(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
+		;;
+	dlink,dap-2695-a1|\
+	dlink,dap-3662-a1)
+		ip link set dev eth0 address $(mtd_get_mac_ascii bdcfg "lanmac")
+		ip link set dev eth1 address $(mtd_get_mac_ascii bdcfg "wanmac")
+		;;
+	enterasys,ws-ap3705i)
+		ip link set dev eth0 address $(mtd_get_mac_ascii u-boot-env0 ethaddr)
+		;;
+	siemens,ws-ap3610)
+		ip link set dev eth0 address $(mtd_get_mac_ascii cfg1 ethaddr)
+		;;
+	zyxel,nbg6616)
+		ethaddr=$(mtd_get_mac_ascii u-boot-env ethaddr)
+		ip link set dev eth0 address $(macaddr_add $ethaddr 2)
+		ip link set dev eth1 address $(macaddr_add $ethaddr 3)
+		;;
+	esac
+}
+
+boot_hook_add preinit_main preinit_set_mac_address
diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/dualboot_datachk.sh b/target/linux/ath79/generic/base-files/lib/upgrade/dualboot_datachk.sh
new file mode 100644
index 0000000..002f5f9
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/upgrade/dualboot_datachk.sh
@@ -0,0 +1,105 @@
+# The U-Boot loader with the datachk patchset for dualbooting requires image
+# sizes and checksums to be provided in the U-Boot environment.
+# The devices come with 2 main partitions - while one is active
+# sysupgrade will flash the other. The boot order is changed to boot the
+# newly flashed partition. If the new partition can't be booted due to
+# upgrade failures the previously used partition is loaded.
+
+platform_do_upgrade_dualboot_datachk() {
+	local tar_file="$1"
+	local restore_backup
+	local primary_kernel_mtd
+
+	local setenv_script="/tmp/fw_env_upgrade"
+
+	local inactive_mtd="$(find_mtd_index $PART_NAME)"
+	local inactive_offset="$(cat /sys/class/mtd/mtd${inactive_mtd}/offset)"
+	local total_size="$(cat /sys/class/mtd/mtd${inactive_mtd}/size)"
+	local flash_start_mem=0x9f000000
+
+	# detect to which flash region the new image is written to.
+	#
+	# 1. check what is the mtd index for the first flash region on this
+	#    device
+	# 2. check if the target partition ("inactive") has the mtd index of
+	#    the first flash region
+	#
+	#    - when it is: the new bootseq will be 1,2 and the first region is
+	#      modified
+	#    - when it isnt: bootseq will be 2,1 and the second region is
+	#      modified
+	#
+	# The detection has to be done via the hardcoded mtd partition because
+	# the current boot might be done with the fallback region. Let us
+	# assume that the current bootseq is 1,2. The bootloader detected that
+	# the image in flash region 1 is corrupt and thus switches to flash
+	# region 2. The bootseq in the u-boot-env is now still the same and
+	# the sysupgrade code can now only rely on the actual mtd indexes and
+	# not the bootseq variable to detect the currently booted flash
+	# region/image.
+	#
+	# In the above example, an implementation which uses bootseq ("1,2") to
+	# detect the currently booted image would assume that region 1 is booted
+	# and then overwrite the variables for the wrong flash region (aka the
+	# one which isn't modified). This could result in a device which doesn't
+	# boot anymore to Linux until it was reflashed with ap51-flash.
+	local next_boot_part="1"
+	case "$(board_name)" in
+	plasmacloud,pa300|\
+	plasmacloud,pa300e)
+		primary_kernel_mtd=3
+		;;
+	*)
+		echo "failed to detect primary kernel mtd partition for board"
+		return 1
+		;;
+	esac
+	[ "$inactive_mtd" = "$primary_kernel_mtd" ] || next_boot_part="2"
+
+	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
+	board_dir=${board_dir%/}
+
+	local kernel_length=$(tar xf $tar_file ${board_dir}/kernel -O | wc -c)
+	local rootfs_length=$(tar xf $tar_file ${board_dir}/root -O | wc -c)
+	# rootfs without EOF marker
+	rootfs_length=$((rootfs_length-4))
+
+	local kernel_md5=$(tar xf $tar_file ${board_dir}/kernel -O | md5sum); kernel_md5="${kernel_md5%% *}"
+	# md5 checksum of rootfs with EOF marker
+	local rootfs_md5=$(tar xf $tar_file ${board_dir}/root -O | dd bs=1 count=$rootfs_length | md5sum); rootfs_md5="${rootfs_md5%% *}"
+
+	#
+	# add tar support to get_image() to use default_do_upgrade() instead?
+	#
+
+	# take care of restoring a saved config
+	[ -n "$UPGRADE_BACKUP" ] && restore_backup="${MTD_CONFIG_ARGS} -j ${UPGRADE_BACKUP}"
+
+	mtd -q erase inactive
+	tar xf $tar_file ${board_dir}/root -O | mtd -n -p $kernel_length $restore_backup write - $PART_NAME
+	tar xf $tar_file ${board_dir}/kernel -O | mtd -n write - $PART_NAME
+
+	# prepare new u-boot env
+	if [ "$next_boot_part" = "1" ]; then
+		echo "bootseq 1,2" > $setenv_script
+	else
+		echo "bootseq 2,1" > $setenv_script
+	fi
+
+	printf "kernel_size_%i %i\n" $next_boot_part $((kernel_length / 1024)) >> $setenv_script
+	printf "vmlinux_start_addr 0x%08x\n" $((flash_start_mem + inactive_offset)) >> $setenv_script
+	printf "vmlinux_size 0x%08x\n" ${kernel_length} >> $setenv_script
+	printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script
+
+	printf "rootfs_size_%i %i\n" $next_boot_part $(((total_size-kernel_length) / 1024)) >> $setenv_script
+	printf "rootfs_start_addr 0x%08x\n" $((flash_start_mem+inactive_offset+kernel_length)) >> $setenv_script
+	printf "rootfs_size 0x%08x\n" ${rootfs_length} >> $setenv_script
+	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script
+
+	# store u-boot env changes
+	mkdir -p /var/lock
+	fw_setenv -s $setenv_script || {
+		echo "failed to update U-Boot environment"
+		return 1
+	}
+}
diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh b/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh
new file mode 100644
index 0000000..de84233
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh
@@ -0,0 +1,64 @@
+# U-Boot with the datachk patchset requires image sizes, offsets,
+# and checksums to be provided in the U-Boot environment.
+# This script is based on the dualboot version for devices that come with 2 OS partitions.
+# For Senao boards with a "failsafe" partition image, the process is almost the same.
+# Instead of booting a secondary instalation on checksum failure,
+# the failsafe image is booted instead.
+# These boards also use the OKLI lzma kernel loader and mtd-concat
+# So the kernel check is for the loader, the rootfs check is for kernel + rootfs
+
+platform_do_upgrade_failsafe_datachk() {
+	local setenv_script="/tmp/fw_env_upgrade"
+
+	local flash_base=0x9f000000
+
+	local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel})
+	local rootfs_mtd=$(find_mtd_index ${ROOTFS_PART:-rootfs})
+
+	local kernel_offset=$(cat /sys/class/mtd/mtd${kernel_mtd}/offset)
+	local rootfs_offset=$(cat /sys/class/mtd/mtd${rootfs_mtd}/offset)
+
+	if [ -n "$IMAGE_LIST" ]; then
+		KERNEL_FILE=$($IMAGE_LIST | grep $KERNEL_FILE)
+		ROOTFS_FILE=$($IMAGE_LIST | grep $ROOTFS_FILE)
+	fi
+
+	local kernel_size=$($IMAGE_CMD $KERNEL_FILE | wc -c)
+	local rootfs_size=$($IMAGE_CMD $ROOTFS_FILE | wc -c)
+
+	# rootfs without JFFS2
+	local rootfs_blocks=$((rootfs_size / 4096))
+	rootfs_size=$((rootfs_blocks * 4096))
+
+	local kernel_md5=$($IMAGE_CMD $KERNEL_FILE | md5sum | cut -d ' ' -f1)
+	local rootfs_md5=$($IMAGE_CMD $ROOTFS_FILE | dd bs=4k count=$rootfs_blocks iflag=fullblock | md5sum | cut -d ' ' -f1)
+
+	# prepare new u-boot-env vars
+	printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script
+	printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script
+	printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script
+
+	printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $setenv_script
+	printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script
+	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script
+
+	# store u-boot-env
+	mkdir -p /var/lock
+	fw_setenv -s $setenv_script || {
+		echo 'failed to update U-Boot environment'
+		exit 1
+	}
+
+	# sysupgrade
+	sleep 2
+	sync
+	echo 3 > /proc/sys/vm/drop_caches
+	$IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel}
+	sleep 2
+	sync
+	if [ -n "$UPGRADE_BACKUP" ]; then
+		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs}
+	else
+		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs}
+	fi
+}
diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/openmesh.sh b/target/linux/ath79/generic/base-files/lib/upgrade/openmesh.sh
new file mode 100644
index 0000000..fdb57db
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/upgrade/openmesh.sh
@@ -0,0 +1,114 @@
+# The U-Boot loader of the OpenMesh devices requires image sizes and
+# checksums to be provided in the U-Boot environment.
+# The OpenMesh devices come with 2 main partitions - while one is active
+# sysupgrade will flash the other. The boot order is changed to boot the
+# newly flashed partition. If the new partition can't be booted due to
+# upgrade failures the previously used partition is loaded.
+
+cfg_value_get()
+{
+	local cfg=$1 cfg_opt
+	local section=$2 our_section=0
+	local param=$3 our_param=
+
+	for cfg_opt in $cfg; do
+		[ "$cfg_opt" = "[$section]" ] && our_section=1 && continue
+		[ "$our_section" = "1" ] || continue
+
+		our_param=${cfg_opt%%=*}
+		[ "$param" = "$our_param" ] && echo ${cfg_opt##*=} && break
+	done
+}
+
+platform_do_upgrade_openmesh()
+{
+	local img_path="$1"
+	local restore_backup
+
+	local setenv_script="/tmp/fw_env_upgrade"
+
+	local inactive_mtd="$(find_mtd_index $PART_NAME)"
+	local inactive_offset="$(cat /sys/class/mtd/mtd${inactive_mtd}/offset)"
+	local total_size="$(cat /sys/class/mtd/mtd${inactive_mtd}/size)"
+	local total_kbs=$((total_size / 1024))
+	local flash_start_mem=0x9f000000
+	local data_offset=$((64 * 1024))
+
+	# detect to which flash region the new image is written to.
+	#
+	# 1. check what is the mtd index for the first flash region on this
+	#    device
+	# 2. check if the target partition ("inactive") has the mtd index of
+	#    the first flash region
+	#
+	#    - when it is: the new bootseq will be 1,2 and the first region is
+	#      modified
+	#    - when it isn't: bootseq will be 2,1 and the second region is
+	#      modified
+	#
+	# The detection has to be done via the hardcoded mtd partition because
+	# the current boot might be done with the fallback region. Let us
+	# assume that the current bootseq is 1,2. The bootloader detected that
+	# the image in flash region 1 is corrupt and thus switches to flash
+	# region 2. The bootseq in the u-boot-env is now still the same and
+	# the sysupgrade code can now only rely on the actual mtd indexes and
+	# not the bootseq variable to detect the currently booted flash
+	# region/image.
+	#
+	# In the above example, an implementation which uses bootseq ("1,2") to
+	# detect the currently booted image would assume that region 1 is booted
+	# and then overwrite the variables for the wrong flash region (aka the
+	# one which isn't modified). This could result in a device which doesn't
+	# boot anymore to Linux until it was reflashed with ap51-flash.
+	local next_boot_part="1"
+	local primary_kernel_mtd="3"
+	[ "$inactive_mtd" = "$primary_kernel_mtd" ] || next_boot_part="2"
+
+	local cfg_size=$(dd if="$img_path" bs=8 skip=70 count=1 iflag=skip_bytes 2>/dev/null)
+	local cfg_length=$((0x$cfg_size))
+	local cfg_content=$(dd if="$img_path" bs=$cfg_length skip=$data_offset count=1 iflag=skip_bytes 2>/dev/null)
+
+	local kernel_size=$(dd if="$img_path" bs=8 skip=142 count=1 iflag=skip_bytes 2>/dev/null)
+	local kernel_length=$((0x$kernel_size))
+	local kernel_kbs=$((kernel_length / 1024))
+	local kernel_md5=$(cfg_value_get "$cfg_content" "vmlinux" "md5sum")
+
+	local rootfs_size=$(dd if="$img_path" bs=8 skip=214 count=1 iflag=skip_bytes 2>/dev/null)
+	local rootfs_length=$((0x$rootfs_size))
+	local rootfs_md5=$(cfg_value_get "$cfg_content" "rootfs" "md5sum")
+	local rootfs_checksize=$(cfg_value_get "$cfg_content" "rootfs" "checksize")
+
+	# take care of restoring a saved config
+	[ -n "$UPGRADE_BACKUP" ] && restore_backup="${MTD_CONFIG_ARGS} -j ${UPGRADE_BACKUP}"
+
+	# write image parts
+	mtd -q erase inactive
+	dd if="$img_path" bs=1 skip=$((data_offset + cfg_length + kernel_length)) count=$rootfs_length 2>&- | \
+		mtd -n -p $kernel_length $restore_backup write - $PART_NAME
+	dd if="$img_path" bs=1024 skip=$((data_offset + cfg_length)) count=$kernel_kbs iflag=skip_bytes 2>&- | \
+		mtd -n write - $PART_NAME
+
+	# prepare new u-boot env
+	if [ "$next_boot_part" = "1" ]; then
+		echo "bootseq 1,2" > $setenv_script
+	else
+		echo "bootseq 2,1" > $setenv_script
+	fi
+
+	printf "kernel_size_%i %i\n" $next_boot_part $kernel_kbs >> $setenv_script
+	printf "vmlinux_start_addr 0x%08x\n" $((flash_start_mem + inactive_offset)) >> $setenv_script
+	printf "vmlinux_size 0x%08x\n" ${kernel_length} >> $setenv_script
+	printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script
+
+	printf "rootfs_size_%i %i\n" $next_boot_part $((total_kbs - kernel_kbs)) >> $setenv_script
+	printf "rootfs_start_addr 0x%08x\n" $((flash_start_mem+inactive_offset+kernel_length)) >> $setenv_script
+	printf "rootfs_size %s\n" $rootfs_checksize >> $setenv_script
+	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script
+
+	# store u-boot env changes
+	mkdir -p /var/lock
+	fw_setenv -s $setenv_script || {
+		echo "failed to update U-Boot environment"
+		return 1
+	}
+}
diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
new file mode 100644
index 0000000..1240ef5
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,99 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+PART_NAME=firmware
+REQUIRE_IMAGE_METADATA=1
+
+RAMFS_COPY_BIN='fw_printenv fw_setenv'
+RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
+
+redboot_fis_do_upgrade() {
+	local append
+	local sysup_file="$1"
+	local kern_part="$2"
+	local magic=$(get_magic_word "$sysup_file")
+
+	if [ "$magic" = "4349" ]; then
+		local kern_length=0x$(dd if="$sysup_file" bs=2 skip=1 count=4 2>/dev/null)
+
+		[ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
+		dd if="$sysup_file" bs=64k skip=1 2>/dev/null | \
+			mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs
+
+	elif [ "$magic" = "7379" ]; then
+		local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$')
+		local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c)
+
+		[ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
+		tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \
+			mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs
+
+	else
+		echo "Unknown image, aborting!"
+		return 1
+	fi
+}
+
+platform_check_image() {
+	return 0
+}
+
+platform_do_upgrade() {
+	local board=$(board_name)
+
+	case "$board" in
+	adtran,bsap1800-v2|\
+	adtran,bsap1840)
+		redboot_fis_do_upgrade "$1" vmlinux_2
+		;;
+	allnet,all-wap02860ac|\
+	engenius,eap1200h|\
+	engenius,eap300-v2|\
+	engenius,eap600|\
+	engenius,ecb600|\
+	engenius,ens202ext-v1|\
+	engenius,enstationac-v1)
+		IMAGE_LIST="tar tzf $1"
+		IMAGE_CMD="tar xzOf $1"
+		KERNEL_PART="loader"
+		ROOTFS_PART="fwconcat0"
+		KERNEL_FILE="uImage-lzma.bin"
+		ROOTFS_FILE="root.squashfs"
+		platform_do_upgrade_failsafe_datachk "$1"
+		;;
+	jjplus,ja76pf2)
+		redboot_fis_do_upgrade "$1" linux
+		;;
+	openmesh,mr600-v1|\
+	openmesh,mr600-v2|\
+	openmesh,mr900-v1|\
+	openmesh,mr900-v2|\
+	openmesh,mr1750-v1|\
+	openmesh,mr1750-v2|\
+	openmesh,om2p-v2|\
+	openmesh,om2p-v4|\
+	openmesh,om2p-hs-v1|\
+	openmesh,om2p-hs-v2|\
+	openmesh,om2p-hs-v3|\
+	openmesh,om2p-hs-v4|\
+	openmesh,om2p-lc|\
+	openmesh,om5p|\
+	openmesh,om5p-ac-v2)
+		PART_NAME="inactive"
+		platform_do_upgrade_openmesh "$1"
+		;;
+	plasmacloud,pa300|\
+	plasmacloud,pa300e)
+		PART_NAME="inactive"
+		platform_do_upgrade_dualboot_datachk "$1"
+		;;
+	ubnt,routerstation|\
+	ubnt,routerstation-pro)
+		redboot_fis_do_upgrade "$1" kernel
+		;;
+	*)
+		default_do_upgrade "$1"
+		;;
+	esac
+}
diff --git a/target/linux/ath79/generic/config-default b/target/linux/ath79/generic/config-default
new file mode 100644
index 0000000..d9a52af
--- /dev/null
+++ b/target/linux/ath79/generic/config-default
@@ -0,0 +1,28 @@
+CONFIG_BCM_NET_PHYLIB=y
+CONFIG_BROADCOM_PHY=y
+CONFIG_GPIO_PCA953X=y
+CONFIG_GPIO_PCA953X_IRQ=y
+CONFIG_GPIO_WATCHDOG=y
+CONFIG_GPIO_WATCHDOG_ARCH_INITCALL=y
+CONFIG_I2C=y
+CONFIG_I2C_ALGOBIT=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_GPIO=y
+CONFIG_INTEL_XWAY_PHY=y
+CONFIG_IP17XX_PHY=y
+CONFIG_LEDS_RESET=y
+CONFIG_MARVELL_PHY=y
+CONFIG_MICREL_PHY=y
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-3
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_SPLIT_EVA_FW=y
+CONFIG_PHY_AR7100_USB=y
+CONFIG_PHY_AR7200_USB=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_RTL8366RB_PHY=y
+CONFIG_RTL8366S_PHY=y
+CONFIG_RTL8366_SMI=y
+CONFIG_RTL8367_PHY=y
+CONFIG_VITESSE_PHY=y
+CONFIG_WATCHDOG_CORE=y
diff --git a/target/linux/ath79/generic/target.mk b/target/linux/ath79/generic/target.mk
new file mode 100644
index 0000000..4e53c89
--- /dev/null
+++ b/target/linux/ath79/generic/target.mk
@@ -0,0 +1,7 @@
+BOARDNAME:=Generic
+
+DEFAULT_PACKAGES += wpad-basic-wolfssl
+
+define Target/Description
+	Build firmware images for generic Atheros AR71xx/AR913x/AR934x based boards.
+endef