diff options
author | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2019-10-22 21:46:57 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2019-10-27 14:24:22 +0100 |
commit | 0130022baec0a90c6cb039a5cbe9b9c65c01672f (patch) | |
tree | 93815b43aaf2d13863c0beb78e95cf443c29606a /target/linux/ath79/tiny/base-files/etc/board.d/02_network | |
parent | c36ef5970b0342f01f1f3bfc7452b86992c7201b (diff) | |
download | upstream-0130022baec0a90c6cb039a5cbe9b9c65c01672f.tar.gz upstream-0130022baec0a90c6cb039a5cbe9b9c65c01672f.tar.bz2 upstream-0130022baec0a90c6cb039a5cbe9b9c65c01672f.zip |
ath79: 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 (especially helpful for the tiny devices).
The only script remaining in parent base-files is
/etc/hotplug.d/ieee80211/00-wifi-migration, everything else is
moved/split.
Note that this will increase overall code lines, but reduce code
per subtarget.
base-files ipk size reduction:
master (generic) 49135 B
split (generic) 48533 B (- 0.6 kiB)
split (tiny) 43337 B (- 5.7 kiB)
split (nand) 44423 B (- 4.6 kiB)
Tested on TL-WR1043ND v4 (generic) and TL-WR841N v12 (tiny).
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ath79/tiny/base-files/etc/board.d/02_network')
-rwxr-xr-x | target/linux/ath79/tiny/base-files/etc/board.d/02_network | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/target/linux/ath79/tiny/base-files/etc/board.d/02_network b/target/linux/ath79/tiny/base-files/etc/board.d/02_network new file mode 100755 index 0000000000..49fccc0b2e --- /dev/null +++ b/target/linux/ath79/tiny/base-files/etc/board.d/02_network @@ -0,0 +1,96 @@ +#!/bin/sh + +. /lib/functions/system.sh +. /lib/functions/uci-defaults.sh + +ath79_setup_interfaces() +{ + local board="$1" + + case "$board" in + pqi,air-pen|\ + tplink,tl-mr10u|\ + tplink,tl-mr3020-v1|\ + tplink,tl-mr3040-v2|\ + tplink,tl-wa901nd-v2|\ + tplink,tl-wr703n) + ucidef_set_interface_lan "eth0" + ;; + buffalo,whr-g301n) + ucidef_set_interface_wan "eth0" + ucidef_add_switch "switch0" \ + "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" + ;; + tplink,tl-mr3220-v1|\ + tplink,tl-mr3420-v1|\ + tplink,tl-wr841-v7|\ + tplink,tl-wr841-v9|\ + tplink,tl-wr841-v10|\ + tplink,tl-wr841-v11|\ + tplink,tl-wr841-v12|\ + tplink,tl-wr940n-v3|\ + tplink,tl-wr940n-v4|\ + tplink,tl-wr941nd-v6) + ucidef_set_interface_wan "eth1" + ucidef_add_switch "switch0" \ + "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" + ;; + netgear,wnr1000-v2|\ + netgear,wnr2000-v3|\ + netgear,wnr612-v2|\ + on,n150r|\ + tplink,tl-wr740n-v1|\ + tplink,tl-wr740n-v3|\ + tplink,tl-wr741-v1|\ + tplink,tl-wr743nd-v1|\ + tplink,tl-wr841-v5|\ + tplink,tl-wr941-v4) + ucidef_set_interface_wan "eth0" + ucidef_add_switch "switch0" \ + "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" + ;; + tplink,tl-wr941n-v7-cn) + ucidef_add_switch "switch0" \ + "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan" + ;; + tplink,tl-mr3420-v2|\ + tplink,tl-wr740n-v4|\ + tplink,tl-wr741nd-v4|\ + tplink,tl-wr841-v8) + 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-wr941-v2) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" + ;; + *) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ;; + esac +} + +ath79_setup_macs() +{ + local board="$1" + + case "$board" in + tplink,tl-wr941-v2|\ + tplink,tl-wr941n-v7-cn) + base_mac=$(mtd_get_mac_binary u-boot 0x1fc00) + wan_mac=$(macaddr_add "$base_mac" 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) +ath79_setup_interfaces $board +ath79_setup_macs $board +board_config_flush + +exit 0 |