* [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
@ 2026-09-20 10:00 Chukun Pan
2026-09-20 10:05 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Chukun Pan @ 2026-09-20 10:00 UTC (permalink / raw)
To: Yixun Lan
Cc: Rob Herring, Paul Walmsley, Albert Ou, Alexandre Ghiti,
Palmer Dabbelt, Conor Dooley, Krzysztof Kozlowski, linux-riscv,
linux-kernel, devicetree, spacemit, Chukun Pan
The EEPROM on the OrangePi R2S and OrangePi RV2 stores the MAC address.
Assign it to Ethernet, with eth1 having a MAC offset of 1. Remove the
Ethernet alias to avoid U-Boot patching incorrect MAC addresses.
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
---
arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts | 8 +++++---
arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
index 7125f2882ce8..073cc975135f 100644
--- a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
@@ -16,8 +16,6 @@ aliases {
i2c2 = &i2c2;
i2c8 = &i2c8;
serial0 = &uart0;
- ethernet0 = ð0;
- ethernet1 = ð1;
};
chosen {
@@ -66,6 +64,8 @@ &emmc {
};
ð0 {
+ nvmem-cells = <&mac_address 0>;
+ nvmem-cell-names = "mac-address";
phy-handle = <&rgmii0>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
@@ -90,6 +90,8 @@ rgmii0: phy@1 {
};
ð1 {
+ nvmem-cells = <&mac_address 1>;
+ nvmem-cell-names = "mac-address";
phy-handle = <&rgmii1>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
@@ -129,7 +131,7 @@ eeprom@50 {
nvmem-layout {
compatible = "onie,tlv-layout";
- mac-address {
+ mac_address: mac-address {
#nvmem-cell-cells = <1>;
};
diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
index 837616255464..609c4755775d 100644
--- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
@@ -15,8 +15,6 @@ / {
aliases {
serial0 = &uart0;
- ethernet0 = ð0;
- ethernet1 = ð1;
i2c2 = &i2c2;
i2c8 = &i2c8;
mmc0 = &emmc;
@@ -93,6 +91,8 @@ &emmc {
};
ð0 {
+ nvmem-cells = <&mac_address 0>;
+ nvmem-cell-names = "mac-address";
phy-handle = <&rgmii0>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
@@ -117,6 +117,8 @@ rgmii0: phy@1 {
};
ð1 {
+ nvmem-cells = <&mac_address 1>;
+ nvmem-cell-names = "mac-address";
phy-handle = <&rgmii1>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
@@ -156,7 +158,7 @@ eeprom@50 {
nvmem-layout {
compatible = "onie,tlv-layout";
- mac-address {
+ mac_address: mac-address {
#nvmem-cell-cells = <1>;
};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-20 10:00 [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi Chukun Pan
@ 2026-09-20 10:05 ` sashiko-bot
2026-09-21 12:42 ` Yixun Lan
2026-09-22 8:55 ` Troy Mitchell
2 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-09-20 10:05 UTC (permalink / raw)
To: Chukun Pan; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dts: removing standard aliases to bypass bootloader behavior
--
commit 8bb8e326a73a3935458461c280ad331fa5713466
Author: Chukun Pan <amadeus@jmu.edu.cn>
riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
This commit configures the OrangePi R2S and RV2 device trees to read
the Ethernet MAC address from an EEPROM. It also removes the ethernet0
and ethernet1 aliases to prevent U-Boot from patching the MAC address
incorrectly.
> diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> index 7125f2882ce85..073cc975135f4 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> @@ -16,8 +16,6 @@ aliases {
> i2c2 = &i2c2;
> i2c8 = &i2c8;
> serial0 = &uart0;
> - ethernet0 = ð0;
> - ethernet1 = ð1;
[Severity: Medium]
Is it appropriate to remove these standard network aliases to bypass a
bootloader limitation?
The device tree is intended to accurately describe the hardware structure
independent of bootloader software bugs or workarounds. Removing standard
aliases can disrupt predictable network interface naming and standard device
enumeration.
As stated in the commit message, this change is made solely to avoid U-Boot
patching incorrect MAC addresses. Modifying an OS device tree to hack around
bootloader limitations, such as U-Boot's fdt_fixup_ethernet, is generally
considered an anti-pattern.
Could this be addressed by changing U-Boot's configuration for this board
instead?
> };
>
> chosen {
[ ... ]
> diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> index 837616255464a..609c4755775df 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> @@ -15,8 +15,6 @@ / {
>
> aliases {
> serial0 = &uart0;
> - ethernet0 = ð0;
> - ethernet1 = ð1;
[Severity: Medium]
Does removing these aliases here also risk disrupting predictable network
interface naming for the OS?
As mentioned above, it might be safer to fix the U-Boot configuration
rather than omitting standard hardware aliases in the OS device tree.
> i2c2 = &i2c2;
> i2c8 = &i2c8;
> mmc0 = &emmc;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260920100000.3888256-1-amadeus@jmu.edu.cn?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-20 10:00 [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi Chukun Pan
2026-09-20 10:05 ` sashiko-bot
@ 2026-09-21 12:42 ` Yixun Lan
2026-09-22 6:50 ` Chukun Pan
2026-09-22 8:55 ` Troy Mitchell
2 siblings, 1 reply; 8+ messages in thread
From: Yixun Lan @ 2026-09-21 12:42 UTC (permalink / raw)
To: Chukun Pan
Cc: Rob Herring, Paul Walmsley, Albert Ou, Alexandre Ghiti,
Palmer Dabbelt, Conor Dooley, Krzysztof Kozlowski, linux-riscv,
linux-kernel, devicetree, spacemit
Hi Chukun,
On 18:00 Sun 20 Sep , Chukun Pan wrote:
> The EEPROM on the OrangePi R2S and OrangePi RV2 stores the MAC address.
> Assign it to Ethernet, with eth1 having a MAC offset of 1. Remove the
> Ethernet alias to avoid U-Boot patching incorrect MAC addresses.
>
Could you point me where the u-boot patching the MAC address?
I'm not fully aware of this problem..
> Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
> ---
> arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts | 8 +++++---
> arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts | 8 +++++---
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> index 7125f2882ce8..073cc975135f 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> @@ -16,8 +16,6 @@ aliases {
> i2c2 = &i2c2;
> i2c8 = &i2c8;
> serial0 = &uart0;
> - ethernet0 = ð0;
> - ethernet1 = ð1;
..
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-21 12:42 ` Yixun Lan
@ 2026-09-22 6:50 ` Chukun Pan
2026-09-22 7:29 ` Yixun Lan
0 siblings, 1 reply; 8+ messages in thread
From: Chukun Pan @ 2026-09-22 6:50 UTC (permalink / raw)
To: dlan
Cc: alex, amadeus, aou, conor+dt, devicetree, krzk+dt, linux-kernel,
linux-riscv, palmer, pjw, robh, spacemit
Hi,
> Could you point me where the u-boot patching the MAC address?
> I'm not fully aware of this problem..
This is handled by U-Boot's fdt_fixup_ethernet() function:
https://github.com/u-boot/u-boot/blob/main/boot/fdt_support.c#L639
do_bootm_linux()
|
boot_prep_linux()
|
image_setup_linux()
|
image_setup_libfdt()
|
fdt_fixup_ethernet()
Thanks,
Chukun
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-22 6:50 ` Chukun Pan
@ 2026-09-22 7:29 ` Yixun Lan
2026-09-23 6:40 ` Chukun Pan
0 siblings, 1 reply; 8+ messages in thread
From: Yixun Lan @ 2026-09-22 7:29 UTC (permalink / raw)
To: Chukun Pan
Cc: alex, aou, conor+dt, devicetree, krzk+dt, linux-kernel,
linux-riscv, palmer, pjw, robh, spacemit
Hi Chukun,
On 14:50 Tue 22 Sep , Chukun Pan wrote:
> Hi,
>
> > Could you point me where the u-boot patching the MAC address?
> > I'm not fully aware of this problem..
>
> This is handled by U-Boot's fdt_fixup_ethernet() function:
> https://github.com/u-boot/u-boot/blob/main/boot/fdt_support.c#L639
>
> do_bootm_linux()
> |
> boot_prep_linux()
> |
> image_setup_linux()
> |
> image_setup_libfdt()
> |
> fdt_fixup_ethernet()
>
So checked the code, it's not a direct problem of /alias, but due to the
env variable provided to override the mac address, see
https://github.com/u-boot/u-boot/blob/main/boot/fdt_support.c#L698
tmp = env_get(mac);
if (!tmp)
continue;
In this case, I don't think it's necessary to drop the ethernet alias,
I mean it's totally fine if there is uboot ethaddr env and it wins
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-20 10:00 [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi Chukun Pan
2026-09-20 10:05 ` sashiko-bot
2026-09-21 12:42 ` Yixun Lan
@ 2026-09-22 8:55 ` Troy Mitchell
2 siblings, 0 replies; 8+ messages in thread
From: Troy Mitchell @ 2026-09-22 8:55 UTC (permalink / raw)
To: Chukun Pan, Yixun Lan
Cc: Rob Herring, Paul Walmsley, Albert Ou, Alexandre Ghiti,
Palmer Dabbelt, Conor Dooley, Krzysztof Kozlowski, linux-riscv,
linux-kernel, devicetree, spacemit, Troy Mitchell
[-- Attachment #1: Type: text/plain, Size: 1664 bytes --]
On Sun, Sep 20, 2026 at 06:00:00PM +0800, Chukun Pan wrote:
> The EEPROM on the OrangePi R2S and OrangePi RV2 stores the MAC address.
> Assign it to Ethernet, with eth1 having a MAC offset of 1. Remove the
> Ethernet alias to avoid U-Boot patching incorrect MAC addresses.
>
> [...]
>
> --- a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
> @@ -16,8 +16,6 @@ aliases {
> i2c2 = &i2c2;
> i2c8 = &i2c8;
> serial0 = &uart0;
> - ethernet0 = ð0;
> - ethernet1 = ð1;
> };
>
> chosen {
Where do the incorrect MAC addresses come from? Linux prefers a valid
DT MAC over NVMEM, allowing a bootloader override. Could we keep the
aliases? Removing them also prevents intentional ethaddr/eth1addr
overrides.
> @@ -66,6 +64,8 @@ &emmc {
> };
>
> ð0 {
> + nvmem-cells = <&mac_address 0>;
> + nvmem-cell-names = "mac-address";
> phy-handle = <&rgmii0>;
> phy-mode = "rgmii-id";
> pinctrl-names = "default";
> @@ -90,6 +90,8 @@ rgmii0: phy@1 {
> };
>
> ð1 {
> + nvmem-cells = <&mac_address 1>;
> + nvmem-cell-names = "mac-address";
> phy-handle = <&rgmii1>;
> phy-mode = "rgmii-id";
> pinctrl-names = "default";
> @@ -129,7 +131,7 @@ eeprom@50 {
> nvmem-layout {
> compatible = "onie,tlv-layout";
>
> - mac-address {
> + mac_address: mac-address {
> #nvmem-cell-cells = <1>;
> };
>
Have you tested with AT24 and ONIE TLV built as modules, including
network-root boot? Without a bootloader-provided MAC, Ethernet probe
may defer until these dependencies are available.
--
Troy Mitchell
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 248 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-22 7:29 ` Yixun Lan
@ 2026-09-23 6:40 ` Chukun Pan
2026-09-24 1:23 ` Troy Mitchell
0 siblings, 1 reply; 8+ messages in thread
From: Chukun Pan @ 2026-09-23 6:40 UTC (permalink / raw)
To: dlan
Cc: alex, amadeus, aou, conor+dt, devicetree, krzk+dt, linux-kernel,
linux-riscv, palmer, pjw, robh, spacemit
Hi,
> So checked the code, it's not a direct problem of /alias, but due to the
> env variable provided to override the mac address, see
> In this case, I don't think it's necessary to drop the ethernet alias,
> I mean it's totally fine if there is uboot ethaddr env and it wins
Once U-Boot overwrites the MAC address in the DT, of_get_mac_address()
will return 0, and of_get_mac_address_nvmem() will not be called.
Then I think this patch is useless.
Thanks,
Chukun
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi
2026-09-23 6:40 ` Chukun Pan
@ 2026-09-24 1:23 ` Troy Mitchell
0 siblings, 0 replies; 8+ messages in thread
From: Troy Mitchell @ 2026-09-24 1:23 UTC (permalink / raw)
To: Chukun Pan, dlan
Cc: alex, aou, conor+dt, devicetree, krzk+dt, linux-kernel,
linux-riscv, palmer, pjw, robh, spacemit, Troy Mitchell
[-- Attachment #1: Type: text/plain, Size: 847 bytes --]
Hi Chukun,
On Wed Sep 23, 2026 at 2:40 PM +08, Chukun Pan wrote:
> Hi,
>
>> So checked the code, it's not a direct problem of /alias, but due to the
>> env variable provided to override the mac address, see
>
>> In this case, I don't think it's necessary to drop the ethernet alias,
>> I mean it's totally fine if there is uboot ethaddr env and it wins
>
> Once U-Boot overwrites the MAC address in the DT, of_get_mac_address()
> will return 0, and of_get_mac_address_nvmem() will not be called.
> Then I think this patch is useless.
Please check my reply in this thread [1]. Fetching the MAC address from the bootloader is a
permitted user override, which is not meant to be guaranteed or provided 100% of the
time.
Link: https://lore.kernel.org/all/DLLPWUHF8WRQ.13YQTP32MG59Z@linux.spacemit.com/ [1]
--
Troy Mitchell
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 248 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-24 1:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-20 10:00 [PATCH 1/1] riscv: dts: spacemit: set ETH MAC from eeprom for OrangePi Chukun Pan
2026-09-20 10:05 ` sashiko-bot
2026-09-21 12:42 ` Yixun Lan
2026-09-22 6:50 ` Chukun Pan
2026-09-22 7:29 ` Yixun Lan
2026-09-23 6:40 ` Chukun Pan
2026-09-24 1:23 ` Troy Mitchell
2026-09-22 8:55 ` Troy Mitchell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox