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.
This commit is contained in:
Ondrej Wisniewski 2023-05-05 13:08:55 +02:00 committed by Damien George
parent 4ce360fa83
commit 29401a719f

View File

@ -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) {