cancel
Showing results for 
Search instead for 
Did you mean: 

Using any type of text causes HardFault

HMehr.14
Associate II

Hello,

I followed this guide (https://touchgfx.zendesk.com/hc/en-us/articles/115002741432-Create-custom-Application-Template) to adding TouchGFX to my existing project.

I'm working with IAR 8.30.1 and tgfx 4.10.0 and STM32F429ZG and FreeRTOS V9.0.0 ( with `heap_4.c` as memory manager ).

Everything works well now, except texts. Every time I added components that contain text, Hard Fault occurs during redraw (*.invalidate()) it.

I added 

virtual void handleTickEvent() { container.invalidate(); }

to my ScreenView class to verifying DMA2D and LTDC configurations. All components work well. But existing just a text component causes HardFault.

By tracking `LR` and `PC`, I find out that HardFault occures in `TextProvider` class.

I think stack corrupted. Due to often times, `PC` is in the `DataSection`.

I increased the stack size of my GUI task and `configTOTAL_HEAP_SIZE` of FreeRTOS configuration, But results not changed. Is there any other stack size ( or heap size ) limitation?

Or, May I has been configured `BoardConfiguration.cpp`, `STM32F4DMA.cpp` or `STM32F4HAL.cpp` in a wrong way ?

For more details :

0690X000008BDbFQAW.png

Please share your suggestions about my problem with me.

Thanks in advance.

34 REPLIES 34

Compiling through the CubeIDE works now without Hardfault after I changed the compiler .elf file from:

STM32CubeIDE/Debug/***.elf

to

TouchGFX/build/bin/intflash.elf

So it must be a problem with a makefile that is generated by CubeIDE. The makefile generated from TouchGFX works fine.

ZRego.1
Associate II

Hi, had a same problem, took me hours to fix it. The reason is that some content (image and text is to be placed on external flash). To load onto external flash you need an external loader. CubeIDE, CubeProgrammer or Keil uVision are neither aware of that and you need to set it up manually, while TouchGFX Designer is apparently correctly setup to use external loader.

Keil uVision: Project Options -> Debug -> Use: ST-Link debugger -> settings -> flash download -> ADD -> find flash loader for your evaluation board or create your own loader -> set RAM size to 0x00050000, leave RAM adress unchanged.0693W000007ECiGQAW.pngSTM32CubeIDE:

Debug Configurations -> Debugger -> Scroll down and tick External loader -> Scan -> find appropriate loader for your eval board.

0693W000007ECifQAG.pngSimilar procedure on Cube Programmer and other IDEs.

@Martin KJELDSEN​ I think you should sincerely consider adding this note to Compiling and Flashing section of documentation, because it kind of prevents you from developing an application, as you cannot flash and debug from IDE. It took me hours to figure out the cause and not everyone is as stubborn as me :D

Hi,

Good input, that makes sense. In the case of Touchgfx it is because it is set in the Makefile (gcc folder). We set them manually as well for all IDEs in the application templates in Designer.

It makes a lot of sense that we should make users aware that they need to setup the external loader, it is in some of ST's documentation but it is a real maze, so a reminder never hurts.

/Romain

Sorry for not giving more answers. So this was solved by not using stm32cubeide. I think something was cached by the IDE. not sure.

But since swapping to developing in visual studio code and generating with touchgfx I have no more issues. Previously I built with STM32CUBEIDE.

RPipi.1
Associate II

Sorry for not giving more answers. So this was solved by not using stm32cubeide. I think something was cached by the IDE. not sure.

But since swapping to developing in visual studio code and generating with touchgfx I have no more issues. Previously I built with STM32CUBEIDE.

ASmer.1
Associate II

Its old topic, however I just encountered this thing. TouchGFX 4.2 CubeIDE 1.10.1.

Adding static text - no wildcards- causes immediate HF. Has anyone came to some other then "use VS code" solution?

ASmer.1
Associate II

Problem is not occuring when Text section is placed in internal flash. It's confusing because all other assets work from external flash perfectly well.

I am using vscode for editing and building using touchgfx(makefile). You can edit in cubeidea as well but build with touchgfx(makefile).

since moving things to internal flash works I guess there is something messing up in addressing when content is placed in external flash. Maybe it even works if you explicitly place the content at a certain external address.

could it be that cubeidea / eclipse is configured to make its own makefile? Tried explicitly choosing which makefile to use? I never did this my self.

however to me it seemed like adding removing items to the ui for a number of times eventually messed things out. So I am guessing the position of items is off in regards to where it is in the memory.

however for me after switching to vs code + makefile build everything works all the time 🙂 been developing for a year now.

Check what differs in map when building in idea vs in touchgfx

Martin KJELDSEN
Chief III

Try to ensure that QuadSpi is initialized before TouchGFX. TouchGFX will attempt to access the flash to init texts, but if not initialized yet then you'll get a HF.

What does your main function look like?

/Martin