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.

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for your guides. My problem solved and everything works well now. I forgot to set the 'Wildcard Characters' and 'Character Ranges' parameters in the designer!

View solution in original post

33 REPLIES 33
Martin KJELDSEN
Chief III

Hi @HMehr.14​,

You cannot use STMF4DMA or -HAL in a wrong way. You simply use them in your BoardConfiguration to tell TouchGFX which MCU you're using. Where are the generated texts placed? In external flash? Is it configured and working?

/Martin

HMehr.14
Associate II

Hi @Martin KJELDSEN​ .

Thanks for your reply. I haven't any external flash on my board. and generated texts placed in internal flash.

HMehr.14
Associate II

Generated text in the region of internal flash memory :0690X000008BH0rQAG.png

I'm sorry for disturbing you. But I couldn't solve my problem.

I tried with an alone text on my screen. More details below:

0690X000008BPQdQAO.png0690X000008BPQsQAO.png

Hi @HMehr.14​,

Don't be sorry =) I'm here to help. Can i see your linker script? The font/text generators generate a symbol which is expanded based on the type of compiler that tells the linker where to place things. For texts, on some platforms, it can sometimes be a problem placing texts in external flash because the flash chip hasn't been initialized yet when constructors related to texts/languages are being called.

In relation to the if statement, i suspect this is to check whether a function pointer (also generated) has been configured for e.g. ligatures in this case. If it has, it is called, but maybe that memory address isn't available or the address is straight up wrong. This could be the cause of the hard fault.

Thanks for your guides. My problem solved and everything works well now. I forgot to set the 'Wildcard Characters' and 'Character Ranges' parameters in the designer!

Hi,

Glad it worked out for you. I would have liked to be able to see at least some assert in debug mode that told us something about this - I will check up on this. Seems dangerous that we can end up in a Hard Fault on memory reference because you forgot to do something in the designer.

I'm curious. If you forgot that, then this couldn't have worked perfectly in the simulator either.

/Martin

Hi again,

We were kind of curious about this, so we did some tests. It seems that in some cases, if no wildcard is specified, the text area will try to read some memory that may (in your case also) generate a fault. However, this should never be the case if the code is generated by the designer because even if the application tries to initialize a TextAreaWithWildCard that has no wildcard it will work with a null pointer.

Can you share some information on how you created this application?

Thanks!

/Martin