From 4176100b0690db3a53cb6fcfe70dbf9e7d59347e Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 7 Nov 2019 17:03:50 +0100 Subject: [PATCH 01/10] ath79: replace generic button node names In several DTS files, button nodes are just named buttonX or xxx_button. This replaces the names with more specific names matching the majority of key definitions. While at it, fix name of keys node in one case. Signed-off-by: Adrian Schmutzler --- target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts | 2 +- target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts | 4 ++-- target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts | 4 ++-- target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts | 6 +++--- target/linux/ath79/dts/qca9531_comfast_cf-e5.dts | 2 +- target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi | 6 +++--- target/linux/ath79/dts/qca9531_glinet_gl-x750.dts | 2 +- target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi | 2 +- target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi | 2 +- .../linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts | 2 +- target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts | 2 +- target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts | 2 +- target/linux/ath79/dts/qca9561_avm_fritz4020.dts | 4 ++-- target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts | 4 ++-- target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi | 6 +++--- target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi | 4 ++-- target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi | 2 +- target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi | 4 ++-- 18 files changed, 30 insertions(+), 30 deletions(-) diff --git a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts index e3971d1e95..71769ef9f7 100644 --- a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts +++ b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts @@ -32,7 +32,7 @@ debounce-interval = <60>; }; - button_usb { + usb { label = "usb"; linux,code = ; gpios = <&gpio 7 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts b/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts index 3728b682c8..846e517de8 100644 --- a/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts +++ b/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts @@ -27,14 +27,14 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; debounce-interval = <60>; }; - button1 { + qss { label = "qss"; linux,code = ; gpios = <&gpio 7 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts b/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts index 80677fa894..1be4d6183a 100644 --- a/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts +++ b/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts @@ -21,14 +21,14 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; debounce-interval = <60>; }; - button1 { + qss { label = "qss"; linux,code = ; gpios = <&gpio 7 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts b/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts index 9b222904e1..3cd5c130c8 100644 --- a/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts +++ b/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts @@ -49,14 +49,14 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; debounce-interval = <60>; }; - button1 { + sw1 { label = "sw1"; linux,input-type = ; linux,code = ; @@ -64,7 +64,7 @@ debounce-interval = <60>; }; - button2 { + sw2 { label = "sw2"; linux,input-type = ; linux,code = ; diff --git a/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts b/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts index fb32923213..74a3554bcb 100644 --- a/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts +++ b/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts @@ -17,7 +17,7 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 17 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi index 67a3331ab3..78961bf71b 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi @@ -20,19 +20,19 @@ pinctrl-names = "default"; pinctrl-0 = <&jtag_disable_pins>; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; }; - button1 { + right { label = "button right"; linux,code = ; gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; }; - button3 { + left { label = "button left"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts b/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts index ae4553a207..c845b5465a 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts +++ b/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts @@ -16,7 +16,7 @@ pinctrl-names = "default"; pinctrl-0 = <&jtag_disable_pins>; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi b/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi index 8f0a86334e..50d34c7c90 100644 --- a/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi +++ b/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi @@ -46,7 +46,7 @@ keys { compatible = "gpio-keys"; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 17 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi b/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi index 5f7498a06e..39fae74b83 100644 --- a/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi +++ b/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi @@ -14,7 +14,7 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 19 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts b/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts index 8d3d5c58a6..5c01126bc4 100644 --- a/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts +++ b/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts @@ -42,7 +42,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { diff --git a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts index 7d7433d44e..83e76e463e 100644 --- a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts +++ b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts @@ -44,7 +44,7 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts b/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts index d81d9c54f5..5a896d52bc 100644 --- a/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts +++ b/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts @@ -76,7 +76,7 @@ debounce-interval = <60>; }; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_avm_fritz4020.dts b/target/linux/ath79/dts/qca9561_avm_fritz4020.dts index 2bb135eaff..6412252590 100644 --- a/target/linux/ath79/dts/qca9561_avm_fritz4020.dts +++ b/target/linux/ath79/dts/qca9561_avm_fritz4020.dts @@ -86,13 +86,13 @@ keys { compatible = "gpio-keys"; - wps_button { + wps { label = "WPS button"; linux,code = ; gpios = <&gpio 2 GPIO_ACTIVE_LOW>; }; - wlan_button { + wlan { label = "WLAN button"; linux,code = ; gpios = <&gpio 21 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts b/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts index 351e37519d..f894fc8672 100644 --- a/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts +++ b/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts @@ -45,13 +45,13 @@ keys { compatible = "gpio-keys"; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 22 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi b/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi index 26cc9ec2e8..00cd413bd2 100644 --- a/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi +++ b/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi @@ -85,19 +85,19 @@ keys { compatible = "gpio-keys"; - wps_button { + wps { label = "WPS button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; }; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 2 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 21 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi b/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi index 21a470961f..719a9d065a 100644 --- a/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi +++ b/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi @@ -22,13 +22,13 @@ keys { compatible = "gpio-keys"; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 21 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi b/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi index 028c1747d2..f04304ee4c 100644 --- a/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi +++ b/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi @@ -37,7 +37,7 @@ debounce-interval = <60>; }; - button_wps { + wps { label = "wps"; gpios = <&gpio 5 GPIO_ACTIVE_LOW>; linux,code = ; diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi b/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi index 21c16be36d..c6bb8a2417 100644 --- a/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi @@ -18,13 +18,13 @@ keys { compatible = "gpio-keys"; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 2 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; From a9219457730f81b842bfc3520f60cbc625f66e1e Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 7 Nov 2019 17:07:01 +0100 Subject: [PATCH 02/10] ramips: rename keys node formerly named button For some devices, the keys node is named "button". Change name to match the rest of the target. Signed-off-by: Adrian Schmutzler --- target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts | 2 +- target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts | 2 +- target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts index 58da88a862..757e487bcb 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts @@ -35,7 +35,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts index 5044890d6c..29ac019899 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts @@ -54,7 +54,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts index f36a920b6b..9482889b8a 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts @@ -60,7 +60,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { From a6fbdd3a7837ea93d65115a62001ab96d5ff0b67 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 4 Nov 2019 20:44:41 +0100 Subject: [PATCH 03/10] base-files: don't store label MAC address in uci system config If set, label MAC address is available from one of two sources, device tree or board.json. So far, the function get_mac_label was meant for retrieving the address, while an option in uci system config was specified only for case 2 (board.json). The uci config option has several drawbacks: - it is only used for a fraction of devices (those not in DT) - label MAC address is a device property, while config implies user interaction - label_macaddr option will only be set if /etc/config/system does not exist (i.e. only for new installations) Thus, this patch changes the behavior of get_mac_label: Instead of writing the value in board.json to uci system config and reading from this location afterwards, get_mac_label now extracts data from board.json directly. The uci config option won't be used anymore. In addition, two utility functions for extraction only from DT or from board.json are introduced. Since this is only changing the access to the label MAC address, it won't interfere with the addresses stored in the code base so far. Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/config_generate | 5 --- .../base-files/files/lib/functions/system.sh | 35 +++++++++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 0b26afe57f..3ca035ca8b 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -260,11 +260,6 @@ generate_static_system() { uci -q set "system.@system[-1].hostname=$hostname" fi - local label_macaddr - if json_get_var label_macaddr label_macaddr; then - uci -q set "system.@system[-1].label_macaddr=$label_macaddr" - fi - if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index cb0508fe9c..be7efe4e2e 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -1,5 +1,7 @@ # Copyright (C) 2006-2013 OpenWrt.org +. /usr/share/libubox/jshn.sh + get_mac_binary() { local path="$1" local offset="$2" @@ -12,14 +14,41 @@ get_mac_binary() { hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null } -get_mac_label() { +get_mac_label_dt() { local basepath="/proc/device-tree" local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)" local macaddr - [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) + [ -n "$macdevice" ] || return + + macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null) - [ -n "$macaddr" ] || macaddr=$(uci -q get system.@system[0].label_macaddr) + + echo $macaddr +} + +get_mac_label_json() { + local cfg="/etc/board.json" + local macaddr + + [ -s "$cfg" ] || return + + json_init + json_load "$(cat $cfg)" + if json_is_a system object; then + json_select system + json_get_var macaddr label_macaddr + json_select .. + fi + + echo $macaddr +} + +get_mac_label() { + local macaddr=$(get_mac_label_dt) + + [ -n "$macaddr" ] || macaddr=$(get_mac_label_json) + echo $macaddr } From 6170c46b477d4953f91b99e805a276de444913cf Mon Sep 17 00:00:00 2001 From: Rosy Song Date: Mon, 4 Nov 2019 20:44:41 +0100 Subject: [PATCH 04/10] base-files: rename hostname with EUI of mac address If a label MAC address is provided for device, system will rename the hostname with OpenWrt_{eui mac address}. This helps to distinguish between different devices. Since it's no good idea to nest json_* functions, this code does not use get_mac_label directly, but only get_mac_label_dt as external resource. Signed-off-by: Rosy Song [merged with commit introducing macaddr_geteui, rebased on updated label MAC address storage, extended commit message] Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/config_generate | 16 +++++++++++++++- package/base-files/files/lib/functions/system.sh | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 3ca035ca8b..b473eba9e9 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -3,6 +3,7 @@ CFG=/etc/board.json . /usr/share/libubox/jshn.sh +. /lib/functions/system.sh [ -s $CFG ] || /bin/board_detect || exit 1 [ -s /etc/config/network -a -s /etc/config/system ] && exit 0 @@ -253,9 +254,22 @@ generate_static_system() { add_list system.ntp.server='3.openwrt.pool.ntp.org' EOF + local label_macaddr=$(get_mac_label_dt) + local hostname + + if json_is_a system object; then + json_select system + [ -n "$label_macaddr" ] || json_get_var label_macaddr label_macaddr + json_select .. + fi + + if [ -n "$label_macaddr" ]; then + hostname="OpenWrt-$(macaddr_geteui $label_macaddr)" + uci -q set "system.@system[-1].hostname=$hostname" + fi + if json_is_a system object; then json_select system - local hostname if json_get_var hostname hostname; then uci -q set "system.@system[-1].hostname=$hostname" fi diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index be7efe4e2e..c4dc3cc3a9 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -144,6 +144,13 @@ macaddr_add() { echo $oui:$nic } +macaddr_geteui() { + local mac=$1 + local sep=$2 + + echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2} +} + macaddr_setbit_la() { local mac=$1 From 22b8a6263d72bb1911c5841ef90ebdf452b53905 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 7 Nov 2019 18:16:46 +0100 Subject: [PATCH 05/10] Revert "base-files: rename hostname with EUI of mac address" This reverts commit 6170c46b477d4953f91b99e805a276de444913cf. There has been demand for further evaluation of the impact of a changed hostname, so this is reverted for now. The default hostname will be "OpenWrt" again after this commit. The macaddr_geteui() function is not removed by this revert. Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/config_generate | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index b473eba9e9..3ca035ca8b 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -3,7 +3,6 @@ CFG=/etc/board.json . /usr/share/libubox/jshn.sh -. /lib/functions/system.sh [ -s $CFG ] || /bin/board_detect || exit 1 [ -s /etc/config/network -a -s /etc/config/system ] && exit 0 @@ -254,22 +253,9 @@ generate_static_system() { add_list system.ntp.server='3.openwrt.pool.ntp.org' EOF - local label_macaddr=$(get_mac_label_dt) - local hostname - - if json_is_a system object; then - json_select system - [ -n "$label_macaddr" ] || json_get_var label_macaddr label_macaddr - json_select .. - fi - - if [ -n "$label_macaddr" ]; then - hostname="OpenWrt-$(macaddr_geteui $label_macaddr)" - uci -q set "system.@system[-1].hostname=$hostname" - fi - if json_is_a system object; then json_select system + local hostname if json_get_var hostname hostname; then uci -q set "system.@system[-1].hostname=$hostname" fi From ad7c6102f2098c3dc8233e4590ac47753dc4900d Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Fri, 18 Oct 2019 08:31:30 -0300 Subject: [PATCH 06/10] busybox: fix missing install with suid bit set if FEATURE_SUID=y MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With FEATURE_SUID=y one can install busybox binary belonging to root with the suid bit set, enabling some applets to perform root-level operations even when run by ordinary users. Busybox then drops privileges for applets that don't need root access, before entering their main() function. Currently we don't install busybox binary with suid bit set, rendering this feature unusable. Note that we can't just "chmod u+s /bin/busybox" at runtime as a "cheaper" solution: it would waste approximately 200KiB of FLASH (the whole /bin/busybox binary gets copied into the overlay). Ref: PR#2502 Signed-off-by: Henrique de Moraes Holschuh [commit title/description facelift, use INSTALL_SUID variable] Signed-off-by: Petr Štetiar --- package/utils/busybox/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 1e1712fe71..1046d68d3e 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -113,6 +113,9 @@ endif ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),) $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug +endif +ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SUID),) + $(INSTALL_SUID) $(PKG_INSTALL_DIR)/bin/busybox $(1)/bin/busybox endif -rm -rf $(1)/lib64 endef From 8eab0a003629d0b60563df5f9eaa973969bbc763 Mon Sep 17 00:00:00 2001 From: Henrique de Moraes Holschuh Date: Fri, 1 Nov 2019 08:56:50 -0300 Subject: [PATCH 07/10] busybox: disable default config option FEATURE_SUID=y MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit ad7c6102f209 ("busybox: fix missing install with suid bit set if FEATURE_SUID=y") actually fixes BUSYBOX_CONFIG_FEATURE_SUID option and thus would install busybox setuid root by default which would result in possibly unwanted change of current behaviour, so let's disable this option by default in order to preserve the current status-quo. For the record: disabling FEATURE_SUID to preserve the status-quo does *not* imply the current status-quo is "safer", or for that matter, in any way desireable. That is a discussion to be had on the mailing lists. Switching the FEATURE_SUID default to "n" is simply a compromise to facilitate the merge of the changes that unbreak FEATURE_SUID. Ref: PR#2502 Signed-off-by: Henrique de Moraes Holschuh [commit title/description facelift] Signed-off-by: Petr Štetiar --- package/utils/busybox/Config-defaults.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in index 37238f05c3..c0aaecbb30 100644 --- a/package/utils/busybox/Config-defaults.in +++ b/package/utils/busybox/Config-defaults.in @@ -60,7 +60,7 @@ config BUSYBOX_DEFAULT_INSTALL_NO_USR default n config BUSYBOX_DEFAULT_FEATURE_SUID bool - default y + default n config BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG bool default n From 6abce4d5e4c06156928929e69864056b482b64f5 Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Thu, 31 Oct 2019 23:33:41 +0800 Subject: [PATCH 08/10] ipq40xx: mdio: remove support for phy-reset-gpio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 6f6c00cfc95f ("ipq40xx: Add support for Unielec U4019") has introduced support for `phy-reset-gpio` DT property, which isn't needed as the MDIO already supports `reset-gpios`[1] which could be used instead. 1. https://elixir.bootlin.com/linux/v4.19.81/source/Documentation/devicetree/bindings/net/mdio.txt Ref: PR#2511 Signed-off-by: DENG Qingfang [commit title and description facelift] Signed-off-by: Petr Štetiar --- .../700-net-add-qualcomm-mdio.patch | 67 +------------------ 1 file changed, 2 insertions(+), 65 deletions(-) diff --git a/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch b/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch index c27d19fc16..e939597b8e 100644 --- a/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch +++ b/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch @@ -1,15 +1,3 @@ -From 234d6f40fb4b771b396b45a9492aab463771bd0b Mon Sep 17 00:00:00 2001 -From: Kristian Evensen -Date: Tue, 6 Aug 2019 11:42:57 +0200 -Subject: [PATCH] phy: Add ipq40xx mdio driver - ---- - drivers/net/phy/Kconfig | 7 + - drivers/net/phy/Makefile | 1 + - drivers/net/phy/mdio-ipq40xx.c | 247 +++++++++++++++++++++++++++++++++ - 3 files changed, 255 insertions(+) - create mode 100644 drivers/net/phy/mdio-ipq40xx.c - --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -519,6 +519,13 @@ config XILINX_GMII2RGMII @@ -38,7 +26,7 @@ Subject: [PATCH] phy: Add ipq40xx mdio driver obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o --- /dev/null +++ b/drivers/net/phy/mdio-ipq40xx.c -@@ -0,0 +1,247 @@ +@@ -0,0 +1,196 @@ +/* + * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. + * @@ -61,10 +49,8 @@ Subject: [PATCH] phy: Add ipq40xx mdio driver +#include +#include +#include -+#include +#include +#include -+#include + +#define MDIO_CTRL_0_REG 0x40 +#define MDIO_CTRL_1_REG 0x44 @@ -164,60 +150,11 @@ Subject: [PATCH] phy: Add ipq40xx mdio driver + return 0; +} + -+static int ipq40xx_phy_reset(struct platform_device *pdev) -+{ -+ struct device_node *mdio_node; -+ int phy_reset_gpio_number; -+ int ret; -+ -+ mdio_node = of_find_node_by_name(NULL, "mdio"); -+ if (!mdio_node) { -+ dev_err(&pdev->dev, "Could not find mdio node\n"); -+ return 0; -+ } -+ -+ ret = of_get_named_gpio(mdio_node, "phy-reset-gpio", 0); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Could not find phy-reset-gpio\n"); -+ return 0; -+ } -+ -+ phy_reset_gpio_number = ret; -+ -+ ret = gpio_request(phy_reset_gpio_number, "phy-reset-gpio"); -+ if (ret) { -+ dev_err(&pdev->dev, "Can't get phy-reset-gpio %d\n", ret); -+ return ret; -+ } -+ -+ ret = gpio_direction_output(phy_reset_gpio_number, 0x0); -+ if (ret) { -+ dev_err(&pdev->dev, -+ "Can't set direction for phy-reset-gpio %d\n", ret); -+ goto phy_reset_out; -+ } -+ -+ usleep_range(1000, 10005); -+ -+ gpio_set_value(phy_reset_gpio_number, 0x01); -+ -+phy_reset_out: -+ gpio_free(phy_reset_gpio_number); -+ -+ return ret; -+} -+ +static int ipq40xx_mdio_probe(struct platform_device *pdev) +{ + struct ipq40xx_mdio_data *am; + struct resource *res; -+ int i, ret; -+ -+ ret = ipq40xx_phy_reset(pdev); -+ if (ret) { -+ dev_err(&pdev->dev, "Could not find qca8075 reset gpio\n"); -+ return -ENODEV; -+ } ++ int i; + + am = devm_kzalloc(&pdev->dev, sizeof(*am), GFP_KERNEL); + if (!am) From 8db44964434d0ab82d9fef8e0218d08c94039bda Mon Sep 17 00:00:00 2001 From: Daniel Danzberger Date: Wed, 6 Nov 2019 14:06:39 +0100 Subject: [PATCH 09/10] ipq40xx: wpj419: use reset-gpios property for phy reset The old GPIO based phy reset (phy-reset-gpio) will be removed form the ipq40xx mdio driver in the future. Signed-off-by: Daniel Danzberger --- .../files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts index b6eb99278b..e75d07606a 100644 --- a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts +++ b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts @@ -236,9 +236,10 @@ mdio@90000 { status = "okay"; - phy-reset-gpio = <&tlmm 47 0>; pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; + reset-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + reset-delay-us = <5000>; }; ess-psgmii@98000 { From 6ab84579c6a393301d18ab9bbc2b89c3363c937d Mon Sep 17 00:00:00 2001 From: Kristian Evensen Date: Thu, 7 Nov 2019 17:34:18 +0100 Subject: [PATCH 10/10] ipq40xx: u4019: use reset-gpios instead of phy-reset-gpio Use reset-gpio instead of the custom phy-reset-gpio property to do phy reset on the U4019. phy-reset-gpio was incorrectly introduced when we added support for the U4019, and will be deprecated. Signed-off-by: Kristian Evensen --- .../arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi index cf67fddd2b..c768e25ca0 100644 --- a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi +++ b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi @@ -17,7 +17,8 @@ status = "okay"; pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; - phy-reset-gpio = <&tlmm 47 0>; + reset-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + reset-delay-us = <2000>; }; ess-psgmii@98000 {