[OpenWrt-Devel] [PATCH v2 07/14] ath79/mikrotik: don't use mtd-mac-address in DTS

mail at adrianschmutzler.de mail at adrianschmutzler.de
Mon Apr 20 09:58:35 EDT 2020


Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Thibaut VARÈNE
> Sent: Montag, 20. April 2020 15:35
> To: openwrt-devel at lists.openwrt.org
> Cc: Thibaut VARÈNE <hacks at slashdirt.org>; koen.vandeputte at ncentric.com
> Subject: [OpenWrt-Devel] [PATCH v2 07/14] ath79/mikrotik: don't use mtd-
> mac-address in DTS
> 
> As evidenced here[1] the device MAC address can be stored at a random
> offset in the hard_config partition. Rely on sysfs to update the MAC address
> correctly.
> 
> Note: this will trigger a harmless kernel message during boot:
> ag71xx 19000000.eth: invalid MAC address, using random address
> 
> There is no clean workaround to prevent this message from being emitted.
> 
> [1] https://github.com/openwrt/openwrt/pull/2850#issuecomment-
> 610809021
> 
> Signed-off-by: Thibaut VARÈNE <hacks at slashdirt.org>
> ---
>  .../ath79/dts/qca9556_mikrotik_routerboard-wap-g-5hact2hnd.dts     | 3 ---
>  .../ath79/dts/qca9558_mikrotik_routerboard-922uags-5hpacd.dts      | 2 --
>  target/linux/ath79/mikrotik/base-files/etc/board.d/02_network      | 7
> +++++++
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/target/linux/ath79/dts/qca9556_mikrotik_routerboard-wap-g-
> 5hact2hnd.dts b/target/linux/ath79/dts/qca9556_mikrotik_routerboard-
> wap-g-5hact2hnd.dts
> index 529ac1cf3b..3c0dc84a37 100644
> --- a/target/linux/ath79/dts/qca9556_mikrotik_routerboard-wap-g-
> 5hact2hnd.dts
> +++ b/target/linux/ath79/dts/qca9556_mikrotik_routerboard-wap-g-
> 5hact2hn
> +++ d.dts
> @@ -11,7 +11,6 @@
>  	model = "MikroTik RouterBOARD wAP G-5HacT2HnD";
> 
>  	aliases {
> -		label-mac-device = &eth1;
>  		mdio-gpio1 = &mdio2;
>  		serial0 = &uart;
>  	};
> @@ -53,8 +52,6 @@
>  &eth1 {
>  	status = "okay";
> 
> -	mtd-mac-address = <&hard_config 0x10>;
> -
>  	pll-data = <0x03000101 0x80000101 0x80001313>;
>  	phy-handle = <&phy0>;
> 
> diff --git a/target/linux/ath79/dts/qca9558_mikrotik_routerboard-922uags-
> 5hpacd.dts b/target/linux/ath79/dts/qca9558_mikrotik_routerboard-
> 922uags-5hpacd.dts
> index 3f2a1a51a6..ff806ff88d 100644
> --- a/target/linux/ath79/dts/qca9558_mikrotik_routerboard-922uags-
> 5hpacd.dts
> +++ b/target/linux/ath79/dts/qca9558_mikrotik_routerboard-922uags-
> 5hpacd
> +++ .dts
> @@ -11,7 +11,6 @@
>  	model = "MikroTik RouterBOARD 922UAGS-5HPacD";
> 
>  	aliases {
> -		label-mac-device = &eth0;
>  		led-boot = &led_user;
>  		led-failsafe = &led_user;
>  		led-upgrade = &led_user;
> @@ -80,7 +79,6 @@
>  &eth0 {
>  	status = "okay";
> 
> -	mtd-mac-address = <&hard_config 0x10>;
>  	phy-handle = <&phy4>;
>  	pll-data = <0x8f000000 0xa0000101 0xa0001313>;
> 
> diff --git a/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
> b/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
> index ee795c7496..20c670f702 100755
> --- a/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
> +++ b/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
> @@ -21,8 +21,15 @@ ath79_setup_interfaces()
>  ath79_setup_macs()
>  {
>  	local board="$1"
> +	local lan_mac=""
> +	local wan_mac=""
> +	local mac_base="/sys/firmware/mikrotik/hard_config/mac_base"

One of the concepts I tried to maintain for this section has been to always deal with MAC addresses directly (and not other types of data, like a path in this case).
Thus, I'd prefer to have

local mac_base="$(cat /sys/firmware/mikrotik/hard_config/mac_base)"

and

lan_mac="$mac_base"
...

Despite, we save one cat ...

Despite that, you removed the label-mac-device above, so one should add it as label_mac here.

Best

Adrian

> 
>  	case "$board" in
> +	*)
> +		lan_mac="$(cat $mac_base)"
> +		wan_mac="$(cat $mac_base)"
> +		;;
>  	esac
> 
>  	[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
> --
> 2.11.0
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200420/24c1531c/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list