docs: Can't determine origin of MAC for W5500-PICO-EVB or W5500 chip, WIZNET5k module
Documentation URL
https://docs.micropython.org/en/latest/library/network.WIZNET5K.html
Description
In this case, I am working with the W5500-PICO-EVB, but also tried this with a external W5500 chip to confirm.
Each time that the nic is configured, whether its the onboard w5500-PICO-EVB or using a pico with an external w5500, with:
#SPI SETUP for onboard WizNET chip
MOSI = Pin(19)
MISO = Pin(16)
SCK = Pin(18)
CS = Pin(17)
RST = Pin(20)
INT = Pin(21)
#W5500 onboard chip initialization
def w5500_init_dhcp():
spi=SPI(0,2_000_000, mosi=MOSI,miso=MISO,sck=SCK)
print(spi)
nic = network.WIZNET5K(spi,CS,RST, INT) # type: ignore #spi,cs,reset pin DONT FORGET THE INT (interrupt), or ELSE WE INTRODUCE POLL DELAYS
nic.active(True)
#It looks like we have a mac address...
mac = nic.config('mac')
print("''''''''''''''''''''''''''")
print("MAC ADDR: -> ", ':'.join('{:02x}'.format(mac[i]) for i in range(6)))
a mac address is generated for the pico. It does not appear to be random, and will always come up with the same MAC each time it is powered up and run. Also, between different w5500-PICO-EVB's, they all seem to generate a unique MAC address.
I was playing around with manually resetting the w5500's registers directly from SPI, and I was able to write a 'new' mac of '00:00:00:00:00:00', and then was able to verify by reading that same mac from the chip. However, after resetting the chip, starting the wiznet5k module again, it would appear with its unique generated MAC.
So basically, I'm trying to figure out where exactly this comes from:
-I'm pretty sure this is not a true assigned MAC, given the original design for the pico
-The MAC stayed the same if I used a w5500-PICO-EVB, or reconfigured and used the same w5500-PICO-EVb but with an external w5500 chip unit (not the onboard one, I also switched all pins to ensure I wasn't still using the onboard w5500). This makes me think it is somehow tied in with the Pico itself
Where are these MACs coming from, and how are they generated? It would be really nice if there was a little more documentation on the wiznet5k module. Note, I recently had opened an issue, and found that there was an INT parameter in the setup for the interrupt pin which wasn't documented, and was causing many bugs in my programs.
If this is a valid method of generating MACs, then I'll probably just let it do its thing. If not, then I'll need to find an alternative and assign my own.
Code of Conduct
Yes, I agree
ports/rp2: Allow building MP for Pico-W plus Ethernet.
When building Micropython for the Pico-W with Wifi nic plus Ethernet nic (WIZNET W5500) there is an issue with the MAC handling in function mp_hal_get_mac() (source file mphalport.c).
Building the Pico-W port needs the MICROPY_PY_NETWORK_CYW43 flag to be set in order to include building the CYW43 Wifi driver. But with this flag set, mp_hal_get_mac() handles the MAC assignment for all nics the "CYW43 way" (copying the real MAC provided by the HW). This will fail for all other nic types, resulting in an invalid MAC address. And this makes the nic unusable.
So the solution is to add a check for the nic type parameter idx and handle the MAC address respectively.