From f8af7354b139e69ed12b37418e06d774d350a0f7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 20 Mar 2026 14:17:49 -1000 Subject: [PATCH] [rp2040] Fix get_mac_address_raw to use ethernet MAC when WiFi unavailable On RP2040, get_mac_address_raw() only queried WiFi.macAddress(). When ethernet is configured without WiFi, the MAC address was left uninitialized, causing get_mac_address() and get_mac_address_pretty() to return all zeros. This affects device identification (API, mDNS, unique ID). Unlike ESP32 which reads from eFuse (always available regardless of network interface), RP2040 must query the actual network driver. Fall back to ethernet::global_eth_component->get_eth_mac_address_raw() when USE_ETHERNET is defined and USE_WIFI is not. --- esphome/components/rp2040/helpers.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome/components/rp2040/helpers.cpp b/esphome/components/rp2040/helpers.cpp index ad69192af9..e360b45ebb 100644 --- a/esphome/components/rp2040/helpers.cpp +++ b/esphome/components/rp2040/helpers.cpp @@ -10,6 +10,7 @@ #include // For cyw43_arch_lwip_begin/end (LwIPLock) #elif defined(USE_ETHERNET) #include // For ethernet_arch_lwip_begin/end (LwIPLock) +#include "esphome/components/ethernet/ethernet_component.h" #endif #include #include @@ -71,6 +72,8 @@ LwIPLock::~LwIPLock() {} void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parameter) #ifdef USE_WIFI WiFi.macAddress(mac); +#elif defined(USE_ETHERNET) + ethernet::global_eth_component->get_eth_mac_address_raw(mac); #endif }