Skip to main content
SSRIN.1
Associate III
September 7, 2021
Solved

how to prevent the Lwip stack from shutting down after few transmissions in STM32?

  • September 7, 2021
  • 3 replies
  • 2444 views

I am currently writing a code to send joystick data from a PC to an STM32 Nucleo board. I use pygame to read joystick values and use the socket library of python to send data to MCU via a router. Both MCU and PC is connected to the router. On the MCU side, I use a modified example code of LWIP given in STM32 Cube pkg. The MCU also runs a FreeRTOS scheduler on which LWIP is running. I was able to get it run flawlessly in a 2 threaded FreeRTOS code. However, when I shift the code to a 16 threaded code[main project], LWIP stops working after a few exchanges. In a sense, I don't receive any ping after 4-5 exchanges.

Some things that were experimented with to resolve the issue

  1. reduced the publishing frequency from the PC side to 20hz. This increases the exchange duration but fails after few minutes.
  2. Tried reducing the ConfigMaxPriority parameter of FreeRTOS config from 56(cube ide default) to 16.[Operating time increased]
  3. tried changing FreeRTOS main heap memory and LWIP thread stack memory [no difference]

I think, its a memory issue. But not sure how to resolve. can anyone advice me on this ?

This topic has been closed for replies.
Best answer by SSRIN.1

I was able to resolve this by downgrading to CMSIS v1

3 replies

SSRIN.1
SSRIN.1Author
Associate III
September 7, 2021

Update 1: I tried to find out heap utilisation with xPortGetFreeHeapSize() . When the ping stops , it still shows 35kb of unused memory.

SSRIN.1
SSRIN.1Author
Associate III
September 7, 2021

Update 2 : The code is stuck at a free RTOS assert function

configassert( pxqueue- uxitemsize == 0 )

Walid ZRELLI
Visitor II
September 8, 2021

Hello @SSRIN.1​ ,

You could perform a stack analysis or activate stack overflow detection in your RTOS in order to rule out a stack issue.

Please refer to this reference which may help you.

BeST Regards,

Walid

SSRIN.1
SSRIN.1AuthorBest answer
Associate III
September 21, 2021

I was able to resolve this by downgrading to CMSIS v1

Walid ZRELLI
Visitor II
September 21, 2021

Hello @SSRIN.1​ ,

Good news! Thanks for sharing this.

Can you tell us which version of CMSIS is causing the problem?

BeST Regards,

Walid