This is an automated email from the ASF dual-hosted git repository.
michallenc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new ba7f7a56552 arch/mips/pic32mz: add an option for the Ethernet MAC
address.
ba7f7a56552 is described below
commit ba7f7a56552835bc4388b53d34730b1723d4b839
Author: Daniel P. Carvalho <[email protected]>
AuthorDate: Sun Oct 18 15:04:02 2026 -0300
arch/mips/pic32mz: add an option for the Ethernet MAC address.
The PIC32MZ-W1 has no factory programmed station address, so the
Ethernet interface came up with 00:00:00:00:00:00 and the address had to
be assigned from user space (ifconfig eth0 hw ...) before it could carry
any traffic.
Add PIC32MZ_ETH_MACADDR to give the interface a fixed address at
registration. The default of zero keeps the current behavior: the
address programmed at reset, or one assigned later with SIOCSIFHWADDR.
Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Daniel P. Carvalho <[email protected]>
---
arch/mips/src/pic32mz/Kconfig | 13 +++++++++++++
arch/mips/src/pic32mz/pic32mz_ethernet.c | 19 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/arch/mips/src/pic32mz/Kconfig b/arch/mips/src/pic32mz/Kconfig
index ad359313e73..cc2a5aeaf5c 100644
--- a/arch/mips/src/pic32mz/Kconfig
+++ b/arch/mips/src/pic32mz/Kconfig
@@ -1276,6 +1276,19 @@ config PIC32MZ_ETH_NTXDESC
---help---
Configured number of Tx descriptors. Default: 2
+config PIC32MZ_ETH_MACADDR
+ hex "Ethernet MAC address"
+ default 0x000000000000
+ depends on PIC32MZ_ETHERNET
+ ---help---
+ MAC address of the Ethernet interface, for chips without a
factory
+ programmed station address (the PIC32MZ-W1 has none). Use a
+ locally administered address (second least significant bit of
the
+ first octet set), e.g. 0x02e0deadbeef.
+
+ Zero keeps the address programmed at reset, or one assigned
later
+ with SIOCSIFHWADDR.
+
config PIC32MZ_ETH_NRXDESC
int "Number Rx descriptors"
default 4
diff --git a/arch/mips/src/pic32mz/pic32mz_ethernet.c
b/arch/mips/src/pic32mz/pic32mz_ethernet.c
index 8f7976e018d..5d4a7162bd0 100644
--- a/arch/mips/src/pic32mz/pic32mz_ethernet.c
+++ b/arch/mips/src/pic32mz/pic32mz_ethernet.c
@@ -3494,6 +3494,25 @@ static inline int pic32mz_ethinitialize(int intf)
return -EAGAIN;
}
+#if CONFIG_PIC32MZ_ETH_MACADDR != 0
+ /* The chip has no factory station address (PIC32MZ-W1): use the
+ * configured one.
+ */
+
+ priv->pd_dev.netdev.d_mac.ether.ether_addr_octet[0] =
+ (CONFIG_PIC32MZ_ETH_MACADDR >> (8 * 5)) & 0xff;
+ priv->pd_dev.netdev.d_mac.ether.ether_addr_octet[1] =
+ (CONFIG_PIC32MZ_ETH_MACADDR >> (8 * 4)) & 0xff;
+ priv->pd_dev.netdev.d_mac.ether.ether_addr_octet[2] =
+ (CONFIG_PIC32MZ_ETH_MACADDR >> (8 * 3)) & 0xff;
+ priv->pd_dev.netdev.d_mac.ether.ether_addr_octet[3] =
+ (CONFIG_PIC32MZ_ETH_MACADDR >> (8 * 2)) & 0xff;
+ priv->pd_dev.netdev.d_mac.ether.ether_addr_octet[4] =
+ (CONFIG_PIC32MZ_ETH_MACADDR >> (8 * 1)) & 0xff;
+ priv->pd_dev.netdev.d_mac.ether.ether_addr_octet[5] =
+ (CONFIG_PIC32MZ_ETH_MACADDR >> (8 * 0)) & 0xff;
+#endif
+
/* Register the device with the OS so that socket IOCTLs can be performed */
ret = netdev_lower_register(&priv->pd_dev, NET_LL_ETHERNET);