cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429: TouchGFX UI freeze because memory is overwritten

PLan
Associate II

Hi,

I setup a project for STM32F429 MCU by using STM32CubeMX with LTDC, DMA2D, FreeRTOS and TouchGFX enabled. It works very well with a splash screen and a main screen. However, when I added another simple screen, the UI freezes after some screen switch operations. The problem can be reproduced 100%, and always at the some place.

After some investigation, I found the UI task is hung in OSWrappers:waitForVSync() -> xQueueReceive() -> prvUnlockQueue() -> xTaskRemoveFromEventList()->configASSERT(pxUnblockedTCB).

The reason is: memory of vsync_q (in OSWrappers.cpp) is overwritten by unknown reason. vsync_q.xTasksWaitingToSend.uxNumberOfItems is no longer 0, which cause the assert fail.

I added a memory write access breakpoint, and tried to catch the 'evil' code, but it breaks in the interrupt handler: DMA2D_IRQHandler(), and the memory has been changed already. So, I lost clue here, and it seems DMA2D did some incorrect operation towards the memory.

Can anyone give me some suggestion to debug and resolve this problem? Many thanks!

BTW, I have tried to increase the stack size and heap size, and the problem still exist.

Br,

Peter

1 ACCEPTED SOLUTION

Accepted Solutions
PLan
Associate II

The problem is fixed by:

  1. Switch FreeRTOS heap management from heap_4 to heap_x
  2. Switch back to heap_4
  3. add heap_4.c into the project manually

I don't know what happened and how the bug is fixed, but it works. Seems there is some problem in STM32CubeMX, and the generated project has some hidden error.

Br,

Peter

View solution in original post

8 REPLIES 8
PLan
Associate II

The problem is fixed by:

  1. Switch FreeRTOS heap management from heap_4 to heap_x
  2. Switch back to heap_4
  3. add heap_4.c into the project manually

I don't know what happened and how the bug is fixed, but it works. Seems there is some problem in STM32CubeMX, and the generated project has some hidden error.

Br,

Peter

Martin KJELDSEN
Chief III

Hi @PLan​,

Nice find. That sounds like a very weird error. Basically you're saying that you ended up with the same thing you started with - But changing files back and forth made it work?

/Martin

Yes. Configuration of FreeRTOS heap mgnt is strange to me.

Before the problem happened, I have NEVER changed heap configuration, and heap_4 is used by default.

Because the corrupted memory is located in heap area, I suspected that it maybe a heap management problem.

So I changed it from heap_4 to heap_2/3/5, but all failed (link error and runtime error).

At last, I changed it back to heap_4, and it gives me a link error, and I must copy the heap_4.c into the project manually.

And the problem is gone (what a surprise!).

Yes, that is really strange. Well, i'll keep this in mind as an issue that may be related to project generation in CubeMX.

/Martin

MiladChalipa
Senior

@PLan​ @Martin KJELDSEN​ Hi

I faced the same problem, what do you mean by adding heap_4.c into the project manually?

Hi,

This post is 2 years old. Are you facing the exact same issue ? Are you working on a custom board or on one of the application templates for ST development boards available in TouchGFX Designer ? Are you working with STM32CubeMX ? What RTOS are you using ?

/Romain

SLavi
Associate II

@Martin KJELDSEN​ @PLan​  @Romain DIELEMAN​ I seem to have run in to a similar problem but my problem started way later when I had around 15-20 screens and loads of hardware interaction with the views. At some point as I was adding a buffer to communicate with hardware, my project starts well, graphic runs and gets stuck as my progress bar is loading and always at the same point, and on debug there seems to be no fault caught. Anywhere on graphics side if i reduced a buffer or a view the program would run normally. Seems like theres a memory limit which when exceeded freezes the whole program. Tried the normal adding stack and heap size but doesnt work. The manually adding heap_4.c seems really strange, so is there any other solution that can be implemented or the cause of this problem explained?

Project uses STM32F746NGH6 on my own custom board, and using STM32CubeIDE and necessary configurations undertaken using MX of CubeIDE.

Esbenimu
Associate II

I also faced the same problem. Adding heap_4.c manually to the project fixes the problem. But when I add any widget to the same screen, it still freezes. When I manually add heap_4.c to the project again, the problem is not resolved.

Also, when I move the last widget I added on the same screen, it doesn't freeze.