From 4b81c1fd570c61ca7bafa5baf750e7364bd8117f Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 7 Nov 2019 22:29:21 +0100 Subject: [PATCH 1/8] base-files: remove shebang from uci-defaults files uci-defaults are sourced and non-executable, so they do not require a shebang. While at it, apply consistent naming scheme. Signed-off-by: Adrian Schmutzler --- package/base-files/Makefile | 2 +- package/base-files/files/etc/uci-defaults/10_migrate-shadow | 2 -- .../base-files/files/etc/uci-defaults/12_network-generate-ula | 2 -- .../etc/uci-defaults/{13_fix_group_user => 13_fix-group-user} | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) rename package/base-files/files/etc/uci-defaults/{13_fix_group_user => 13_fix-group-user} (94%) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 5c121ace24..b35d00cf94 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=207 +PKG_RELEASE:=208 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/uci-defaults/10_migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow index a354844fe4..481444f35e 100644 --- a/package/base-files/files/etc/uci-defaults/10_migrate-shadow +++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -1,5 +1,3 @@ -#!/bin/sh - ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)" diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula index 8871427c60..19d7ed7f2e 100644 --- a/package/base-files/files/etc/uci-defaults/12_network-generate-ula +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -1,5 +1,3 @@ -#!/bin/sh - [ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0 r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"') diff --git a/package/base-files/files/etc/uci-defaults/13_fix_group_user b/package/base-files/files/etc/uci-defaults/13_fix-group-user similarity index 94% rename from package/base-files/files/etc/uci-defaults/13_fix_group_user rename to package/base-files/files/etc/uci-defaults/13_fix-group-user index e6dae2419f..bf9febdfe4 100644 --- a/package/base-files/files/etc/uci-defaults/13_fix_group_user +++ b/package/base-files/files/etc/uci-defaults/13_fix-group-user @@ -1,5 +1,3 @@ -#!/bin/sh - . /lib/functions.sh for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do From f4c3cfc620db16484fd85570c8215abc3b36dc82 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 11 Nov 2019 00:18:45 +0100 Subject: [PATCH 2/8] ramips: read label MAC address from flash instead of using phy0/phy1 This replaces all uses of $(cat /sys/class/ieee80211/phyX/macaddress) by retrieval from the proper flash locations. This will make 02_network independent of WiFi setup again. Signed-off-by: Adrian Schmutzler --- .../linux/ramips/mt7620/base-files/etc/board.d/02_network | 6 +++--- .../linux/ramips/mt7621/base-files/etc/board.d/02_network | 8 ++++---- .../linux/ramips/mt76x8/base-files/etc/board.d/02_network | 4 ++-- .../linux/ramips/rt305x/base-files/etc/board.d/02_network | 7 +++++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index dfca48e123..1b51f17485 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -288,7 +288,7 @@ ramips_setup_macs() glinet,gl-mt300n|\ glinet,gl-mt750) wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; hiwifi,hc5661|\ hiwifi,hc5761|\ @@ -312,11 +312,11 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR) ;; zbtlink,zbt-we1026-5g-16m) - label_mac=$(cat /sys/class/ieee80211/phy1/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; zbtlink,zbt-we1026-h-32m) wan_mac=$(mtd_get_mac_binary factory 0x2e) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; zyxel,keenetic-omni|\ zyxel,keenetic-omni-ii|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index ae03dc71b1..0de3804cdb 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -188,7 +188,7 @@ ramips_setup_macs() asus,rt-ac65p|\ asus,rt-ac85p) wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; buffalo,wsr-1166dhp) local index="$(find_mtd_index "board_data")" @@ -198,7 +198,7 @@ ramips_setup_macs() dlink,dir-860l-b1) lan_mac=$(mtd_get_mac_ascii factory lanmac) wan_mac=$(mtd_get_mac_ascii factory wanmac) - label_mac=$(cat /sys/class/ieee80211/phy1/macaddress) + label_mac=$(mtd_get_mac_binary radio 0x4) ;; edimax,rg21s) lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) @@ -241,12 +241,12 @@ ramips_setup_macs() ;; zbtlink,zbt-we1326) wan_mac=$(mtd_get_mac_binary factory 0xe006) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; zbtlink,zbt-wg3526-16m|\ zbtlink,zbt-wg3526-32m) wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; esac diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index 63861c2089..87ce447612 100755 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -134,7 +134,7 @@ ramips_setup_macs() ;; cudy,wr1000) wan_mac=$(mtd_get_mac_binary factory 0x2e) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x8) ;; duzun,dm06|\ mediatek,mt7628an-eval-board|\ @@ -192,7 +192,7 @@ ramips_setup_macs() ;; vocore,vocore2|\ vocore,vocore2-lite) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x8) ;; esac diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network index 5c110b375e..de71dd6202 100755 --- a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network @@ -242,10 +242,13 @@ ramips_setup_macs() lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)") wan_mac=$(macaddr_add "$lan_mac" 1) ;; - dlink,dir-615-d|\ + dlink,dir-615-d) + wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) + label_mac=$(mtd_get_mac_binary devdata 0x4004) + ;; dlink,dir-615-h1) wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary factory 0x4) ;; poray,m3|\ poray,m4-4m|\ From d421a8b9448968de0e3265f5beb469c210a909ab Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 11 Nov 2019 00:22:33 +0100 Subject: [PATCH 3/8] ath79: read label MAC address from flash instead of using phy0/phy1 This replaces all uses of $(cat /sys/class/ieee80211/phyX/macaddress) by retrieval from the proper flash locations. This will make 02_network independent of WiFi setup again. For future reference: The MAC addresses of the FRITZ!WLAN Repeater 300E can be extracted from the urlader key value store: maca *:6B macb *:6C macwlan *:6D macdsl *:6E and be set by e.g. addr=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)")) Signed-off-by: Adrian Schmutzler --- target/linux/ath79/generic/base-files/etc/board.d/02_network | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 34f6e31047..3a896b55b0 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -292,11 +292,11 @@ ath79_setup_macs() ubnt,nanostation-m|\ ubnt,rocket-m|\ ubnt,unifi) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + label_mac=$(mtd_get_mac_binary art 0x1002) ;; avm,fritz300e) lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)")) - label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + 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)")) From a021268032fb64afdce7bafa91c7c7bf44fa6ff2 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Wed, 13 Nov 2019 15:05:29 +0100 Subject: [PATCH 4/8] ar71xx: fix MAC addresses for Archer C5 v1, C7 v1/v2, WDR4900 v2 As discussed in 1d18a14a90c7 ("ath79: really fix TP-Link Archer C7 v2 MAC address"), stock firmware MAC address assignment is actually as follows: wlan0 (5GHz) : -1 wlan1 (2.4GHz) : 0 eth1 (LAN) : 0 eth0 (WAN) : 1 This has never been fixed for ar71xx, so let's do it now. Note that with WDR4900 v2 even both wlan0 and wlan1 where assigned to basemac-1 before ... Fixes: FS#408 Signed-off-by: Adrian Schmutzler --- .../ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata | 2 +- target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 2ba8de4783..5170fa518f 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -143,7 +143,7 @@ case "$FIRMWARE" in archer-c5|\ archer-c7) ath10kcal_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1) ;; nbg6616|\ nbg6716) diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c index 287252780d..923ed28b4a 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c @@ -212,8 +212,7 @@ static void __init common_setup(bool pcie_slot) ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c7_leds_gpio), archer_c7_leds_gpio); - ath79_init_mac(tmpmac, mac, -1); - ath79_register_wmac(art + ARCHER_C7_WMAC_CALDATA_OFFSET, tmpmac); + ath79_register_wmac(art + ARCHER_C7_WMAC_CALDATA_OFFSET, mac); if (pcie_slot) { ath79_register_pci(); From 7231c1edd99217c6baa8d7d5d841d75ad9de26f1 Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Wed, 13 Nov 2019 23:22:54 +0900 Subject: [PATCH 5/8] ramips: fix MAC address setup for Samsung CY-SWR1100 Ethernet MAC address setup has been broken since c3e420f28cf1. Restore original setting. Fixes: c3e420f28cf1 ("ramips: Add support for D-Link DCH-M225") Signed-off-by: Sungbo Eo --- target/linux/ramips/rt3883/base-files/etc/board.d/02_network | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ramips/rt3883/base-files/etc/board.d/02_network b/target/linux/ramips/rt3883/base-files/etc/board.d/02_network index 27c15eecac..2ef0e319bb 100755 --- a/target/linux/ramips/rt3883/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt3883/base-files/etc/board.d/02_network @@ -70,7 +70,8 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_binary devdata 0x7) ;; samsung,cy-swr1100) - lan_mac=$(mtd_get_mac_ascii factory lanmac) + lan_mac=$(mtd_get_mac_ascii nvram lanmac) + wan_mac=$(mtd_get_mac_ascii nvram wanmac) ;; sitecom,wlr-6000) wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x8004)" 2) From aabdf6991cce55a76540c91ff3b5177afd8dce99 Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Wed, 13 Nov 2019 23:29:21 +0900 Subject: [PATCH 6/8] ramips: improve Samsung CY-SWR1100 support This patch does the following: - rename "devdata" flash partition and make it read-only - switch from gpio-keys-polled to gpio-keys - add missing power LED - set correct PCI ID to compatible string in wifi node - remove ralink,5ghz property in wifi node - provide label MAC address Rename devdata partition to devconf as indicated in the stock firmware partition table: 00030000-00040000: "devdata" 00040000-00050000: "devconf" Power LED can be controlled by SoC GPIO. Add it in the dts leds node. RT3092L supports only bgn mode, so it is unnecessary to disable 5GHz band. Signed-off-by: Sungbo Eo --- .../linux/ramips/dts/rt3662_samsung_cy-swr1100.dts | 14 +++++++++----- .../rt3883/base-files/etc/board.d/02_network | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts b/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts index a25d9d02c1..7bab768fe4 100644 --- a/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts +++ b/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts @@ -49,8 +49,9 @@ }; partition@40000 { - label = "devdata"; + label = "devconf"; reg = <0x40000 0x10000>; + read-only; }; partition@50000 { @@ -69,8 +70,7 @@ }; keys { - compatible = "gpio-keys-polled"; - poll-interval = <100>; + compatible = "gpio-keys"; reset { label = "reset"; @@ -99,6 +99,11 @@ trigger-sources = <&ohci_port1>, <&ehci_port1>; linux,default-trigger = "usbport"; }; + + power { + label = "cy-swr1100:blue:power"; + gpios = <&gpio1 2 GPIO_ACTIVE_LOW>; + }; }; }; @@ -130,9 +135,8 @@ status = "okay"; wifi@0,0 { - compatible = "pci0,0"; + compatible = "pci1814,3091"; reg = <0x10000 0 0 0 0>; - ralink,5ghz = <0>; ralink,mtd-eeprom = <&factory 0x2000>; }; }; diff --git a/target/linux/ramips/rt3883/base-files/etc/board.d/02_network b/target/linux/ramips/rt3883/base-files/etc/board.d/02_network index 2ef0e319bb..873c72cea3 100755 --- a/target/linux/ramips/rt3883/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt3883/base-files/etc/board.d/02_network @@ -72,6 +72,7 @@ ramips_setup_macs() samsung,cy-swr1100) lan_mac=$(mtd_get_mac_ascii nvram lanmac) wan_mac=$(mtd_get_mac_ascii nvram wanmac) + label_mac=$wan_mac ;; sitecom,wlr-6000) wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x8004)" 2) From fe6a04a8fe85755f080971280aa6a2b34f79718c Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Wed, 13 Nov 2019 23:47:14 +0900 Subject: [PATCH 7/8] ramips: change status LED of Samsung CY-SWR1100 Use power LED for status indication and free WPS LED for other uses. Signed-off-by: Sungbo Eo --- target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts b/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts index 7bab768fe4..0d98a43e0b 100644 --- a/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts +++ b/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts @@ -10,8 +10,10 @@ model = "Samsung CY-SWR1100"; aliases { - led-boot = &led_wps; - led-failsafe = &led_wps; + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; }; nor-flash@1c000000 { @@ -88,7 +90,7 @@ leds { compatible = "gpio-leds"; - led_wps: wps { + wps { label = "cy-swr1100:blue:wps"; gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; }; @@ -100,7 +102,7 @@ linux,default-trigger = "usbport"; }; - power { + led_power: power { label = "cy-swr1100:blue:power"; gpios = <&gpio1 2 GPIO_ACTIVE_LOW>; }; From 261c746631d2bf311a6b62a6d3bacce6fde90976 Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Wed, 13 Nov 2019 23:23:17 +0900 Subject: [PATCH 8/8] ramips: add usb-ledtrig-usbport to DEVICE_PACKAGES of CY-SWR1100 CY-SWR1100 has a USB LED but kmod-usb-ledtrig-usbport is missing in default images. This commit adds it. Signed-off-by: Sungbo Eo [changed commit title] Signed-off-by: Adrian Schmutzler --- target/linux/ramips/image/rt3883.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ramips/image/rt3883.mk b/target/linux/ramips/image/rt3883.mk index 8fc778c864..0279bcd2d3 100644 --- a/target/linux/ramips/image/rt3883.mk +++ b/target/linux/ramips/image/rt3883.mk @@ -89,7 +89,7 @@ define Device/samsung_cy-swr1100 SEAMA_SIGNATURE := wrgnd10_samsung_ss815 DEVICE_VENDOR := Samsung DEVICE_MODEL := CY-SWR1100 - DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 swconfig + DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport swconfig SUPPORTED_DEVICES += cy-swr1100 endef TARGET_DEVICES += samsung_cy-swr1100