Skip to main content
Eralp
Associate III
April 17, 2023
Question

STM32H7 with TouchGFX __libc_init_array hardfault

  • April 17, 2023
  • 4 replies
  • 2715 views

Hi, i'm using STM32H750VB and it has 128kB embedded flash, so i'm using an external 16MB qspi flash. When i'm trying to fit firmware to internal & external flash, i modified linker script like this: base hal libraries are located in internal flash and touchgfx libs/gui desingn binaries located in qpsi flash. In this configuration i get hard fault because when initializing __libc_init_array lib, its trying to load binaries from qpsi address space.

How to figure out this problem?

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
April 18, 2023

>>How to figure out this problem?

Add code in SystemInit() that's capable of bringing up the external memory before using it via the constructors, etc.

You could make a loader that lives in the Internal Flash, have that bring up the clocks, SDRAM, QSPI, etc, and then put all the app code in QSPI and transfer control to it once you've brough the system up.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Eralp
EralpAuthor
Associate III
April 18, 2023

You mean write external flash lib and stm32 qspi configurator functions in register based format and call it from SystemInit? This is very tedious and irregular programming. Isn't there a shortcut?

I have already done with emWin gui lib but it's not working touchgfx :(

cb.7
Associate III
April 18, 2023

hello, how did you edit the STM32xxx_FLASH.ld file?

Eralp
EralpAuthor
Associate III
April 18, 2023

I have add a section called TGFX_TEXT before all other sections and include all of touchgfx files in it. Like this;

SECTIONS
{
 .TGFX_TEXT :
 {
 . = ALIGN(4);
 *libtouchgfx-float-abi-hard.a:*(.text .text.*)
 *TouchGFX/App/*.o(.text .text.*)
 *TouchGFX/generated/fonts/src/*.o(.text .text.*)
 *TouchGFX/generated/gui_generated/src/common/*.o(.text .text.*)
 *TouchGFX/generated/gui_generated/src/mainscreen_screen/*.o(.text .text.*)
 *TouchGFX/generated/images/src/*.o(.text .text.*)
 *TouchGFX/generated/images/src/__generated/*.o(.text .text.*)
 *TouchGFX/generated/texts/src/*.o(.text .text.*)
 *TouchGFX/gui/src/common/*.o(.text .text.*)
 *TouchGFX/gui/src/main_screen/*.o(.text .text.*)
 *TouchGFX/gui/src/model/*.o(.text .text.*)
 *TouchGFX/target/*.o(.text .text.*)
 *TouchGFX/target/generated/*.o(.text .text.*)
 . = ALIGN(4);
 } >QSPI
 
 /* The startup code goes first into FLASH */
 .isr_vector :
 {
...

cb.7
Associate III
April 18, 2023

I in my projects am using STM32H7B0VBT6 which has 128K internal flash. I created a boot that runs in the internal flash and jumps to the application which instead resides in the external flash together with all the Touchgfx graphic resources (bitmaps, texts and fonts).

I confirm that you need an external charger suitable for your external memory model.

Eralp
EralpAuthor
Associate III
April 18, 2023

You mean split project in two pieces, one of is qspi bootloader and the other one is gui application, am i right? If i do it this way i can't do debug :(

cb.7
Associate III
April 18, 2023

follow this guide and you will be able to use debug even if the program runs on the external flash:

https://www.youtube.com/watch?v=gAyuF20ok8c

Eralp
EralpAuthor
Associate III
April 19, 2023

I tried this about 2 years ago and it failed. I will check out this guide, thanks for reply.