From 0130022baec0a90c6cb039a5cbe9b9c65c01672f Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Tue, 22 Oct 2019 21:46:57 +0200 Subject: 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 --- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 144 ++++++++++++++++++ .../etc/hotplug.d/firmware/11-ath10k-caldata | 167 +++++++++++++++++++++ .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 45 ++++++ 3 files changed, 356 insertions(+) create mode 100644 target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom create mode 100644 target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata create mode 100644 target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac (limited to 'target/linux/ath79/generic/base-files/etc/hotplug.d') 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 0000000000..f1bc6c3c22 --- /dev/null +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -0,0 +1,144 @@ +#!/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 + avm,fritz4020) + caldata_extract_reverse "urlader" 0x1541 0x440 + ;; + 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,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) + caldata_extract "art" 0x1000 0x440 + ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env ethaddr) + ;; + 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") + ;; + zyxel,nbg6716) + caldata_extract "art" 0x1000 0x440 + ath9k_patch_mac $(mtd_get_mac_ascii u-boot-env ethaddr) + ;; + *) + 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) + caldata_extract "art" 0x1000 0xeb8 + ;; + buffalo,wzr-hp-g450h) + 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) + ;; + ocedo,raccoon|\ + tplink,tl-wdr3500-v1|\ + tplink,tl-wdr3600-v1|\ + tplink,tl-wdr4300-v1|\ + tplink,tl-wdr4900-v2|\ + winchannel,wb2000) + caldata_extract "art" 0x5000 0x440 + ;; + pcs,cap324|\ + tplink,tl-wr2543-v1|\ + tplink,tl-wr842n-v1|\ + ubnt,airrouter|\ + ubnt,bullet-m|\ + ubnt,nano-m|\ + ubnt,rocket-m) + caldata_extract "art" 0x1000 0x1000 + ;; + ubnt,unifi) + caldata_extract "art" 0x1000 0x800 + ;; + 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-hp-ag300h|\ + netgear,wndr3700|\ + netgear,wndr3700v2|\ + netgear,wndr3800|\ + netgear,wndr3800ch) + 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 + ;; + *) + caldata_die "board $board is not supported yet" + ;; + esac + ;; +"ath9k-eeprom-pci-0000:00:12.0.bin") + case $board in + buffalo,wzr-hp-ag300h|\ + netgear,wndr3700|\ + netgear,wndr3700v2|\ + netgear,wndr3800|\ + netgear,wndr3800ch) + 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 + ;; + *) + 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 0000000000..91e813f121 --- /dev/null +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -0,0 +1,167 @@ +#!/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 + comfast,cf-wr650ac-v1|\ + comfast,cf-wr650ac-v2|\ + yuncore,a770) + 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,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,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) + 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|\ + glinet,gl-ar750s) + caldata_extract "art" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) + ;; + glinet,gl-x750) + caldata_extract "art" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2) + ;; + 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,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) + 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) + 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,re350k-v1) + caldata_extract "art" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary config 0x10008) +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,re450-v2) + caldata_extract "art" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1) + ;; + ubnt,unifiac-lite|\ + ubnt,unifiac-lr|\ + ubnt,unifiac-mesh|\ + ubnt,unifiac-mesh-pro|\ + ubnt,lap-120|\ + ubnt,nanobeam-ac|\ + ubnt,nanostation-ac|\ + ubnt,nanostation-ac-loco|\ + ubnt,unifiac-pro) + caldata_extract "EEPROM" 0x5000 0x844 + ;; + zyxel,nbg6716) + caldata_extract "art" 0x5000 0x844 + ath10kcal_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 + ;; + dlink,dir-842-c1|\ + dlink,dir-842-c2|\ + dlink,dir-842-c3|\ + 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-c6-v2) + caldata_extract "art" 0x5000 0x2f20 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary mac 0x8) -1) + 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 0000000000..8c8b7932bc --- /dev/null +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -0,0 +1,45 @@ +#!/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 + ;; + 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 + ;; + 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 + ;; +esac -- cgit v1.2.3