cancel
Showing results for 
Search instead for 
Did you mean: 

Cheap way to add Wifi+Ethernet to an STM32 project

SLasn.1
Associate III

Hi dear community! :)

My project is based on an STM32, probably one in the F range (have not decided fully yet).

I would like to add Ethernet and WiFi to my project, ideally in a cheap way (in terms of manufacturing costs, for let's say 1000 units), I was thinking there must exist an IC which could do that? Ideally I would also like to have both 2.4GHz and 5Ghz for the WiFi chip.

So far my best solution is to use Wiznet w5500 for Ethernet (about 2$/chip) and ESP8089 for WiFi (about 1$/chip). Unfortunately the ESP can only manage 2.4GHz but it clearly seems to be the cheapest on the market.

I also know some of the STM32 have integrated Ethernet MAC, but I would still need an external PHY and another chip for the WiFi, which I was thinking will raise the cost.

So a lot of debatting, hence why I would love to hear your thoughts on this!

Thank you!

Simon

16 REPLIES 16

KSZ8851 doesn't solve anything. One will have to write a driver for an external MAC connected on SPI or even custom parallel interface. If one can do that, then writing a driver for internal MAC is easier and you have more examples on the Internet. Take a note that here I'm talking about the Ethernet driver (L2), not the IP stack (L3+).

  

Is this some religion with a commandment: "Thou shalt not write a driver for STM32 peripherals"? I've said it multiple times - for STM32 writing ETH driver is harder than for USART, but easier than for I2C. Take the reference manual and this example as a starting point and you'll get a basic working driver in a few hours! But most likely you haven't even tried to do it...

  

As for the whole networking thing, the hardest part is not an Ethernet driver, but an IP stack! In essence the complexity is not specific to STM32, Ethernet and not even lwIP, because all decent IP stacks are of non-trivial complexity. The only thing that is specific to STM32, is the fact that it's manufacturer provided code is absolute crap.

  

My only "political" message here is - don't blame decent hardware for utterly shi11y software's flaws. Does my networking "how to" topic look like I'm describing it "in colors"? The forum is also full of my honest descriptions of HAL/CubeMX code - non-working bloatware made by brainless code monkeys, which is not worth the effort of fixing it, as writing a decent code from the ground up is easier. And it's the polite version of the description the HAL/CubeMX team deserves...

Piranha
Chief II

As for DAC, first candidates could be PCM1681 and AK4438. There are other options also. But that's not a real recommendation as I have no practical experience with those.

SLasn.1
Associate III

Thanks again guys - very helpful stuff :)

For the DAC, I was also thinking PCM1681 - very cheap and widely used it seems :)

Regarding the Ethernet, I am happy you brought IP because that was gonna be my next question: the really nice thing about the Wiznet w5500 is that it takes care of L3 & L4, so I do not have to worry about TCP/IP. I guess in this case I will have to handle all of that on the MCU. Are there no pre-written libraries I could use?

> Take the reference manual and this example as a starting point and you'll get a basic working driver in a few hours! But most likely you haven't even tried to do it...

Well IMHO the hardest part of getting any decent eth mac driver - especially with DMA - is thorough testing and validation.

For which I indeed don't have time.

Yes, writing is easy. Anyone can write code. Solid, reliable, production ready network driver takes much more effort/time.

-- pa

SLasn.1
Associate III

Hi guys

I am still quite confused about how to do this (= internal Ethernet MAC + external PHY + ESP8089 for WiFi). This ESP8089 seems to have a WiFi MAC, which means I will have to write a TCP/IP stack from scratch and interface it with the Ethernet MAC and the WiFi MAC.

I am still looking at my options and I was thinking a much simpler option (but maybe slightly more expensive) would be to use an ESP32 which actually has an Ethernet MAC, I then end up with two MCU's, the ESP32 handling all Ethernet/WiFi communication and the STM32 doing the rest.

Pavel A.
Evangelist III

I do not know about ESP8089, but on their site you can find documentation on their current models.

https://www.espressif.com/en/products/modules/esp8266

User of this thing sends some "AT commands" over UART and does not bother about any TCP/IP.

The Wiznet device seems to work in a similar way.

Download the documentation and have a pleasant time reading.

On the other hand, Espressif has microcontrollers with wi-fi MAC & Phy, Ethernet MAC (no PHY), BT and lot of other peripherals, and you can run the application on the same chip. But their processor is not ARM.

-- pa

SLasn.1
Associate III

Thanks for the reply - but that's the point I could not find any info about the ESP8089, it is not even mentionned on the Espressif website! And yes the ESP8266 is much easier it seems to have the whole TCP/IP stack on it. But it is also a lot more expensive.

At the end I opted for the more complete Espressif chips (ESP32-U4WDH) with indeed the whole package in it - including an Ethernet MAC and bluetooth which I might use at the end - so it might be a bit more complicated to program (as I will have code for 2 different microcontrollers), but I will have everything I need without having to do the whole TCP/IP coding.

The interesting thing is I need to have a way to update the firmware once the product is release, this means during the update the STM32 will have to write to its own flash but also to the ESP32's flash.