Skip to content

Commit

Permalink
rp2/mphalport: Only use CYW43 MAC for WLAN0 interface.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ondrej Wisniewski authored and dpgeorge committed May 18, 2023
1 parent 4ce360f commit 29401a7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ports/rp2/mphalport.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 29401a7

Please sign in to comment.