cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP crashes on STM32H563

pbayton9
Associate II

I have an STM32H563 running FreeRTOS and LwIP with the netcon interface.

For the most part its working OK, however when I send a lot of data (around 250KB/s for a few seconds) it crashes with a HARD_FAULT

It looks like the memory (pbufs) are being corrupted

The driver (etherentif.c) is based on LwIP/LwIP_HTTP_Server_Socket_RTOS/Src/ethernetif.c

taken from the STM32H7 cube

Is there an updated driver for the STM32H5 or one with known reliability ?

 

6 REPLIES 6
Andrew Neil
Super User

LwIP debug options:

https://community.st.com/t5/stm32-mcus-products/lwip-ethernet-in-stm32h7-working-in-stm32cubeide-but-not-in-iar/m-p/748501/highlight/true#M267524

Debugging Hard Faults in general:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/tac-p/708193/highlight/true#M51

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
sergey23
Associate II

You can try the alternative to LWIP - Mongoose. That's a TCP/IP stack with drivers, TLS 1.3, embedded web server, MQTT client, and remove firmware update - all in two files, https://github.com/cesanta/mongoose . Works under any RTOS or bare metal. The easy way to try it out on H563 is to visit https://mongoose.ws/wizard/#/output?board=h563&ide=CubeIDE&rtos=baremetal&file=README.md , select destination directory in the settings tab, click "generate" button at top right corner, and load the project in your Cube IDE.  Attach serial console, flash, and you'll see the device IP address in the logs. Point your browser to that IP address, and then you can use modify the project any way you want.

pbayton9
Associate II

Update:

The driver is far more stable with the following settings, although it is still not 100% (crashes after ~100MB now)

#define ETH_RX_BUFFER_SIZE 1600U

#define ETH_RX_BUFFER_CNT 12U

#define ETH_RX_DESC_CNT 4U

I increased ETH_RX_DESC_CNT previously to 12 which caused the problems - The comments in the file explain this.

ETH_RX_BUFFER_SIZE was set to 1000, but this is less than the max ethernet MTU which could be an issue (although no overrun errro should occur due to heth.Init.RxBuffLen being set)

 

STackPointer64
ST Employee

Hello @pbayton9

Could you please provide a minimal version of the project that reproduces the issue so I can investigate it? If the project is private, feel free to let me know, and I can provide a secure channel.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
pbayton9
Associate II

Many thanks for that. I will set up a sample project together with some application test software.

 

Hi

Please find attached test project:

EthDbg - main STM32 project. Main application code is under /Test

PFTest - windows program to test data
Press Connect, Connect2 (indicator should go green) , then the Acquire button

Notes:

All MAC address and IP are defined in get_dev_addr
Current settings are IP 192.168.1.34 etc.

The PHY is a LAN8720, similar to the LAN8742 from which the example was taken
There is no real MDIO communication with the Phy - it is hard coded to be assumed 100MB, full duplex
PC0 is the PHY reset pin - you may need to disable eth_rst_phy() 
GPIOs may also  be different - see HAL_ETH_MspInit