Mongoose
for Sean Newton
@STMicroelectronics
by Sergey Lyubka @Cesanta, Jul 2025
Objective
- Outline current issues with implementing network functionality from the firmware developer perspective
- Take Threadx NetxDuo stack as an example - though other alternatives have very similar issues (Cube's LWIP, Zephyr, etc), with STM32H573I-DK board
- Demonstrate Mongoose as a solution
Issues
- Difficult (sometimes, very) to integrate into an existing project, or start from scratch. Only the pre-built examples work
- Use Threadx / NetxDuo as a network stack
- (Integrate from scratch. Use pinout)
- Numerous NetxDuo configuration options
- many of them make sense only for stack devs, or very experienced network devs. not for the rest
- using constants: rigid internal structure which breaks at certain conditions
- stack dev is unsure about values, so puts them as config params, moving the problem to firmware dev's shoulders - and they don't have a clue
Issues
- Subtle dependencies. Example: ICache / DCache, if not enabled, then the driver crashes
- (Open in CubeIDE, add IO retargeting, add trace)
- Fail.
- Ask for help... Where ? ST forum? Threadx project?
int _write(int fd, unsigned char *buf, int len) { // Add before main()
if (fd == 1 || fd == 2) { // stdout or stderr ?
HAL_UART_Transmit(&huart1, buf, len, 999); // Print to the UART
}
return len;
}
while (1) { // Change main() loop to this:
printf("tick: %lu\n", HAL_GetTick());
HAL_Delay(500);
}
Issues
- Following Nx_WebServer example
- Low quality - overcomplicated, tons of irrelevant threads / functionality devs do not need
- SD card reliance - bad! Can't be tried off-the-shelf. Critical UI must not be served off the file system which can fail
- Implement a trivial web server - just serve a hello world?
- Overcomplicated stock example
- Clean and concise API reference - where ?
- this?
- or this?
- Ok, the only choice is to use header file
- similary complicated mqtt client header
Issues
- Longer term: developing Web UI functionality
- No frontend expertise! Result: either badly performing UI that hurts the brand, or hiring an external team which breaks deadlines
- Usual functionality requires a lot of extra efforts: Websocket, uploads, firmware OTA
- TLS - could be a huge issue, especially when RAM is tight
Issues
- Reliance on the Cube driver: very low quality, very complicated driver with a plugin system designed as a spaghetti of weak functions.
- Here: over 3k LoC hal_eth.c. Compare to stm32h.c
- NetxDuo driver plugs in to HAL driver, inheriting its issues
- Recurring "Ethernet not working" stanzas on community.st.com, reddit, and other embedded resources
Mongoose
- Mature product:
- open source since 2004
- used by hundreds of enterprises, including NASA, Qualcomm, Bosch, Siemens, etc
- Designed with the simplicity in mind. Best integration API ever, only 3 files to integrate, minimum config
- Optional EC TLS 1.3 and TCP/IP stack with hand-written drivers
- Excellent documentation, loads of examples and explainer videos
- Mongoose Wizard makes Web UI and cloud functionality development effortless
Mongoose for Sean Newton @ ST Microelectronics
By Sergey Lyubka
Mongoose for Sean Newton @ ST Microelectronics
Mongoose network stack for STM32 microcontrollers
- 26