Skip to main content
bully
Senior
April 20, 2020
Solved

HardFault with TouchGFX ?

  • April 20, 2020
  • 20 replies
  • 6259 views

Hello,

I have a project with custom stm32f769 oard and TouchGFX as GUI. I've done a lot of testing on simpler GUI (showing background and one button).

I've also prepared additional task that will do communication with other boards.

Everything seems to be working normal. I've chosen same Normal prioritiy also for this additional task.

Now I have imported more complex GUI i(approx. 26MB in external flash) nto the project by using TouchGFX Designer (opened existing, imported new one and generated code & recbuilt whole project) and now I get Hard Fault error.

Although not experienced debugger, I've single stepped problematic part and it seems that the first non-GUI task is started and then when it switches to another task, hardfault happens. By using HardFault analyzer in my CubeIDE, PC points to this line in code :

const uint8_t* GeneratedFont::getPixelData(const GlyphNode* glyph) const
{
 const uint8_t* const* table = (const uint8_t* const*)glyphData;
 return &(table[glyph->unicode / 2048][glyph->dataOffset]);
}
 

PC in HArdFault points to last line - but it seems weird to me.

But 'd like to learn, how to debug TouchGFX part of the application.

Where is entry point, main loop? Where can I stop safely ?

On the other side, I have a question, how to properly debug, check and supervise the ecxecution of TouchGFX also from other tasks, from FreeRTOS supervising features ?

It somehow seems to be not so easy to debug after startup (at least for me).

Thanks in advance,

regards,

B.

Update: went into disassembly on PC's address and it makes sense :

0800e0d6: ldr r3, [r3, #0]

and Registers view shows value of R3 to be

r3	0x91b8d822 (Hex)

that is not a multiple of 4....

 Update2: Breakpoint in that position is reached.

For information, glyph->DataOffset has value of 12522., glyph->unicode 76...

Hmm, it seems that it doesn't hard fault at these values, but it gets into hardfault

next time... I cannot retriev the actual values...

This topic has been closed for replies.
Best answer by Martin KJELDSEN

It boils down to the fact that internal flash is always initialized when you need it, but external isn't. You must initialize external flash before touchgfx is initialized, not just before the scheduler is started.

/Martin

20 replies

Juan Delgado
Associate II
April 20, 2020

I have similiar Undefined behavior.

I was able to fix it but it was inexplicably damaged again.

Please read and see if you can fix your problem:

https://community.st.com/s/question/0D53W000004nXcYSAU/hard-fault

Juan Delgado
Associate II
April 20, 2020

Undefined behavior. But I did app runs

1.- Open designer

2.- Config tab ==> checklist binary font

3.- Generate Code

4.- Close designer

5.- Open keil, compile and flash your app

6.- Your app will runs perfectly but without texts

7.- Close keil.

8.- Open designer

9.- Config tab ==> UNchecklist binary font

10.- Texts tab ==> Typographies tab ==> Write wildcard character. eg. 123456789. or 0x00-0xFF for all your fonts

11.- Generate code

12.- Close designer.

13.- Open keil, compile and flash your app

14.- Now my app runs perfectly with texts and all that I want

I don't know how this works but these steps work for me

bully
bullyAuthor
Senior
April 20, 2020

Thanks will try this one...

bully
bullyAuthor
Senior
April 21, 2020

hmm, did go through the sequence... "8mm" is first text to be displayed... "8" comes with Unicod 56 and glyph address is aligned, but next "m" comes into with unicode 109 and glph address is only even aligned and reading dataOffset (which is 32bits) causes problems... We're using Verdana.ttf - is this problem maybe related to font we are using or code that extracts from the Font...

And what is more weird, why this works on Discovery board ----

bully
bullyAuthor
Senior
April 21, 2020

Hi, have tried some things and also to put fonts into internal Flash (this is the second difference I found in comparison with the similar project running on DISCO board). And it works...

What is the difference between accessing fonts and images in external flash? Maybe there is a problem with memory mapped mode of external flash...

I have the project working, but am interested in the final answer...

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
April 21, 2020

It boils down to the fact that internal flash is always initialized when you need it, but external isn't. You must initialize external flash before touchgfx is initialized, not just before the scheduler is started.

/Martin

RMolins
Associate II
February 22, 2022

I know it is an old thread but where you able to determine the cause? I have had similar issues and cleaning the .o from Debug/TouchGFX/generated/fints/src fixed the issue in my scenario and would like to know if you have any additional information regarding the root cause.