summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Wisniewski <ondrej.wisniewski@dekitalia.com>2023-05-05 13:08:55 +0200
committerDamien George <damien@micropython.org>2023-05-18 13:06:06 +1000
commit29401a719fa944ae639734c69e95795023704adb (patch)
tree269d1110cb72292d0c03dbf6b82a14506a1d30d9
parent4ce360fa831a35d7bc0e194f11d74632a0fba60b (diff)
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.
-rw-r--r--ports/rp2/mphalport.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ports/rp2/mphalport.c b/ports/rp2/mphalport.c
index f56c2bda1..84a34b2a4 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) {