Skip to main content
Associate III
October 3, 2024
Solved

STM32 OSMessageQueue Hardfault error

  • October 3, 2024
  • 3 replies
  • 3395 views

Hello,

 

I am using a RIverDI STM32U5A9 and I am facing a strange hardfault issue in my environment.

The connection details as follows:

ESP board <--UART--> STM32 <--MessageQueue---> LCD display

The ESP board sends continuous data through UART and the STM32 UART task receives the data and send the data to LCD display task through message queue. Whenever I try to restart the ESP after firmware update, the STM32 stops getting UART data and reinit the UART once the connection is reestablished. But the application gets into hardfault error when this happens. The hardfault occurs after few packats transfer and not on the first UART reception.

RiverDi_user_0-1727941809164.png

Can someone help me on this?

 

Thanks!

 

Best answer by RiverDi_user

I was able to findout the rootcause and it was before the osMessageQueue. The issue is fixed now after I checked the buffer index which was exceeding the allocated buffer limit.

 

Thanks everyone for your replies!

3 replies

mƎALLEm
Technical Moderator
October 3, 2024

Hello @RiverDi_user ,

Your use case is a bit tricky and not possible to help you with this description. 

You need to provide more details about your code implementation. Share your code etc ..

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
ST Employee
October 3, 2024

Hello @RiverDi_user,

Could you please share how you are dealing with the received packets in your application?  

Associate III
October 3, 2024

Hello,

 

Unfortunately I cant share my code since its proprietary, but I can give you the logic that I am using in my code.

I am using a RiverDI 5 inch display development module, which is having STM32 embedded in it. I am also using TouchGFX to program the 5 inch display. Basically my riverDI application contains multiple tasks, one for receiving the UART from the ESP board and one for updating the display through touchgfx APIs. To share the received UART data between my UART task and touchgfx task, I am using a message queue, where the UART task puts the data in the message queue once UART Rx is received from ESP and TouchGfx task gets the data every ticks (1ms) and displays in the screen.

UART task snippet (when the UARTRx is received):

RiverDi_user_0-1727947291886.png

TouchGfx task snippet:

RiverDi_user_1-1727947409910.png

The hardfault is occurring in the subsequent calls of osMessageQueueGet() as I shared in my previous comment.

RiverDi_user_2-1727949727909.png

 

Regards!

 

ST Employee
October 3, 2024

Thanks for sharing more information.

The values for osMessagesWaiting and osLength do not look reasonable. Since UART is asynchronous, I don't understand why a reinitialization is required by STM32. The connection should just wait for data no matter the sender. Anyway, I suggest clearing the queue after the UART reestablishment.

In addition, it is better to deal with UART errors before sending any data to the GUI to ensure the TouchGFX thread will not be blocked.

RiverDi_userAuthorBest answer
Associate III
October 16, 2024

I was able to findout the rootcause and it was before the osMessageQueue. The issue is fixed now after I checked the buffer index which was exceeding the allocated buffer limit.

 

Thanks everyone for your replies!