From 29401a719fa944ae639734c69e95795023704adb Mon Sep 17 00:00:00 2001 From: Ondrej Wisniewski Date: Fri, 5 May 2023 13:08:55 +0200 Subject: [PATCH] rp2/mphalport: Only use CYW43 MAC for WLAN0 interface. Building the Pico-W needs the MICROPY_PY_NETWORK_CYW43 flag to be set in order to include building the CYW43 Wifi driver. But then mp_hal_get_mac() handles the MAC assignment for all nics the "CYW43 way", copying the real MAC provided by the WiFi hardware. This will fail for all other NIC types, resulting in an invalid MAC address. The solution in this commit is to add a check for the NIC type parameter idx and handle the MAC address respectively. --- ports/rp2/mphalport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ports/rp2/mphalport.c b/ports/rp2/mphalport.c index f56c2bda13..84a34b2a40 100644 --- a/ports/rp2/mphalport.c +++ b/ports/rp2/mphalport.c @@ -204,10 +204,12 @@ MP_WEAK void mp_hal_get_mac(int idx, uint8_t buf[6]) { // The mac should come from cyw43 otp when CYW43_USE_OTP_MAC is defined // This is loaded into the state after the driver is initialised // cyw43_hal_generate_laa_mac is only called by the driver to generate a mac if otp is not set - memcpy(buf, cyw43_state.mac, 6); - #else - mp_hal_generate_laa_mac(idx, buf); + if (idx == MP_HAL_MAC_WLAN0) { + memcpy(buf, cyw43_state.mac, 6); + return; + } #endif + mp_hal_generate_laa_mac(idx, buf); } void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {