W5500 ethernet driver


I want to add ethernet capabilities to my board (STM32F411CEU6 blue pill) and connect to an MQTT broker. I have two modules: ENC28J60 and W5500. The goal was riched using UIPEthernet library and MQTT library that uses UIPEthernet, however, it is not the best approach.

As I understand, the correct way is to use a driver that implements an Mbed ethernet interface. This is the trickiest part, I’ve found a lot of drivers for W5500: W5500Interface, W5500, wiznet-eth-driver and the latest one on GitHub w5500-eth-driver but no one works.

Did I miss somethings? Wiznet W5500 is a quite popular chip and, strangely, Mbed OS doesn’t have the correct driver for it.

I’ve opened an issue for the latest driver but it is unclear who supports it and whether it’ll be fixed or not.

After a lot of googling one more library has been found: WIZnetInterface.

I don’t know whether it is okay or not that it is so hard to find the correct library but at least it works (only when reset pin isn’t connected or reset functionality is commented out, but it’s a separate issue).

This library implements mbed os5 EthInterface class

I’ve already tried it, unable to compile with the latest Mbed OS.

Error: Redefinition of enumerator ‘SOCK_CLOSED’ in “W5500Interface/WIZnet/W5500.h”, Line: 40, Col: 5

C enums are global for a project so there is a naming conflict. You should change C enums to C++ style

Jsut change enum Status { SOCK_CLOSED, …}
enum class WStatus {SOCK_CLOSEd, … etc. }
and every use of this enum to WStatus::SOCK_CLOSED

This driver is a piece of shit. It sets mac, ip, gateway and others upon initialisation. And then it resets the chip and gets all addresses of 0

Alexey, by this you mean WIZnetInterface?
I gonna try to fix W5500Interface driver today evening (using your suggestions).

WIZnetInterface has been improved and PR was created.
I managed to compile W5500Interface library with some fixes but it doesn’t work (unable to get IP using DHCP).

Alexey, big thank you for your help.

Hi all, are we any further on?

I’m currently using STM32F103 and W5500 module running OS2 with this forked W5500 library https://os.mbed.com/users/zhangyx/code/WIZnet_Library/

All works well, but I’d like to move to OS6 bare metal if possible

For that particular project, I decided to do not use Mbed, but AFAIR I managed to run the WIZnet lib with some fixes mentioned here https://github.com/WIZnet-MbedEthernet/WIZnetInterface/issues/10

Thanks for that @strange_v, the setup has been pretty reliable for me, but I don’t have the reset pin connected to my STM32 so guess I haven’t seen this bug.

I can recommend to use a F407 and a LAN8720. This combination with chinese boards / modules is about 15 € and the F407 has enough resources for a HTTP server and a MQTT client.
The Wiznet chip has its own interpretation of network api and the Mbed implementation had more bugs. In the wiznet forum I was told that they work on a better library, but for month nothing happened. With an integrated MAC, you’ll get a solution that is fast and reliable by using the lwIP stack.


@JojoS I’ve already bought STM32F407 based board and DP83848 ethernet module. It should be easy to use this combination because it is used in Seeed Arch Max. But… I never tried (haven’t used Mbed for a long time, but still have plans for that board).

yes, that should work. The emac has got some settings in the Mbed configuration system and different PHYs can be used.

Both, LAN8720 and DP83848 work fine with STM32F407VE. An alternative to W5500 could be the ENC28J60. It doesn’t have RMII but works fine over SPI (using less wires than RMII) with STM32F103 and STM32F407VE too. However, the speed is only 10Mbit/s and requires an Ethernet crossover cable for direct connection between two Mbed boards. But no crossover cable is needed when connected to a present day Ethernet switch or rooter (since it can automatically swap the pins on its side).

1 Like