2024-10-03 12:50 AM
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.
Can someone help me on this?
Thanks!
Solved! Go to Solution.
2024-10-16 05:16 AM
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!
2024-10-03 01:16 AM
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 ..
2024-10-03 01:46 AM
Hello @RiverDi_user,
Could you please share how you are dealing with the received packets in your application?
2024-10-03 02:25 AM - edited 2024-10-03 03:02 AM
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):
TouchGfx task snippet:
The hardfault is occurring in the subsequent calls of osMessageQueueGet() as I shared in my previous comment.
Regards!
2024-10-03 05:30 AM
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.
2024-10-03 05:45 AM - edited 2024-10-03 07:49 AM
Hello Mohammad,
Thanks for looking into my post. To isolate the issue, I removed the message queue implementation and tried the direct copy through extern variable. But the hardfault hits in a different API now. Any ideas?
Regarding reinit: Sometimes our app doesnt get the UART Rx packets, so I had to reinit to refresh the communication and continue receiving the uart rx packets.
2024-10-04 02:15 AM
Okay, that is interesting
It seems like the core of the issue is deeper. I suggest creating a project without TouchGFX, focusing only on the UART communication. Focus on receiving sound data from the communication even after restarting the ESP board. If you are able to communicate data after the restart, then it shows that the problem is from the combination of UART and TouchGFX.
In that case, I think sending trivial data to the GUI while the UART connection restarts might help the issue.
2024-10-08 04:12 AM
Hello,
I have tried your suggestion of having a simple application with UART Tx and RX. I tried the update and restart in my ESP board, but I was able to continuously receive the data in the UART without any hardfault issue. I am not sure why having the TouchGfx tasks disrupts the communication and hardfaults. Can you shed some light on this please? DO you have any further suggestion for me to check?
Thanks and Regards
2024-10-09 03:20 AM
Okay, good to hear the simple application can work with no issues.
I'm suspicious that waiting for the reestablishment of the UART connection is blocking which causes an error for the TouchGFX tick function (I am not sure about this, but it can be a reason for the error). One possible test could be to handle the UART communication in a separate thread and continuously send data to the GUI (even when the UART connection is lost, just keep sending trivial data) to see if the hardfault persists or not.
2024-10-09 04:42 AM
HI,
I do have the UART Tx in a task and the UART Rx is with interrupt mode. When the UART receives the interrupt, I parse the data and put it in a message queue, eventhough if the UART reinit happens or not, the messagequeue will be holding previous data, but its weird its hardfaulting. I tried to wait in the UART task when there is no Rx data after my ESP reset, but the hardfault hits in a different location like below. FYI, I have removed the reinit logic to test, but the result is still the same.