cancel
Showing results for 
Search instead for 
Did you mean: 

Using FontFlashSection in QSPI Flash Memory

Gökhan
Associate II

Hello,

I've created a test touchGFX project for stm32h747i-disco by using TouchGFX Designer-4.21.4. It has only one screen that has one background image and one text. You can see it below:

Screenshot_1.png

When I generate the code by using TouchGFX Designer-4.21.4 and when I compile and download it with stm32CubeIDE, it works without any problem. 

But when I write this linker code to move FontFlashSection into QSPI flash memory, it stucks in the ErrorHandler.

 

FontFlashSection :
{
	*(FontFlashSection FontFlashSection.*)
	*(.gnu.linkonce.r.*)
        . = ALIGN(0x4);
} >QSPI

 

image.png

ExtFlashSection, FontSearchFlashSection and TextFlashSection work in the QSPI flash memory without any problem. But when I add FontFlashSection as well to the QSPI Flash, the code somehow stucks in the ErrorHandler. 

 

What else should I do to use FontFlashSection in QSPI Flash memory? What am I missing? Can you help me for this? I need to use FontFlashSection in the QSPI Flash memory. Thank you for the answers :)

1 ACCEPTED SOLUTION

Accepted Solutions

As i said, this sentence in linker script set in code address for reading fonts from RAM, but RAM is empty after sw start, because system loader not preload from QSPI. This must do your code in main before use fonts...

Simply after init QSPI memcpy fontsize area to ram choiced in ld.

View solution in original post

10 REPLIES 10
Gökhan
Associate II

Do you have any suggestion for this?

Not sure

If you can track down what's calling Error_Handler() it might shed some light on the issue.

HardFault_Handler() might occur if the memory isn't properly mapped when data is copied out of it.

Perhaps there are some DISCO/EVAL examples using the fonts, and you might be able to check the linker scripts there, or the ELF file construction.

The H747I-DISCO should have it's External Loader, so the data should be in memory successfully.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you for the answer. I tracked down in the code. After the function being called below, it goes to the ErrorHandler.

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]);
}

Also, I have checked some of the TouchGFX examples for the stm32h747i-disco. Unfortunately, FontFlashSection is being used in internal flash memory in these examples.

 

 

Seems long problem based on somethink in lib and adressing in memory. Read FontFlashSection in memory mapped SDRAM - STMicroelectronics Community

And if your font info is short try store it in QSPI, but load into some RAM unused segment for example ITCM in linker script...

In my real application, total font size is ~130KB. Currently, I can store it in QSPI with the linker script below:

FontFlashSection :
{
	*(FontFlashSection FontFlashSection.*)
	*(.gnu.linkonce.r.*)
        . = ALIGN(0x4);
} >QSPI

After that, how can I load it into RAM?

Somethink as , but RAM replaced with dedicated segment

 

} >RAM AT> QSPI

 

but system loader not copied data , this must your code in QSPI init. And QSPI init must be called before TochGFX init.

But maybe this Solved: Re: Crash after placing TouchGFX fonts in memory m... - STMicroelectronics Community

Thank you for the suggestions. I checked timeout counter for the QSPI. In the MX_QUADSPI_Init function, it contains "BSP_QSPI_EnableMemoryMappedMode(0)" and in the BSP_QSPI_EnableMemoryMappedMode function, it contains "MT25TL01G_EnableMemoryMappedModeDTR(&hqspi, QSPI_Ctx[Instance].InterfaceMode)". 

MT25TL01G_EnableMemoryMappedModeDTR function contains the lines below:

 

 /* Configure the memory mapped mode */
  s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
  s_mem_mapped_cfg.TimeOutPeriod     = 0;

  if (HAL_QSPI_MemoryMapped(Ctx, &s_command, &s_mem_mapped_cfg) != HAL_OK)
  {
    return MT25TL01G_ERROR_MEMORYMAPPED;
  }

  return MT25TL01G_OK;

 

So... I think the timeout  counter flag has already been disabled in the initialization.

For your suggestion "} >RAM AT> QSPI", I used it like below:

 

FontFlashSection :
	{
		*(FontFlashSection FontFlashSection.*)
		*(.gnu.linkonce.r.*)
        . = ALIGN(0x4);
	} >RAM_D1 AT> QSPI

 

I think we made some progress because the code does not stuck in the ErrorHandler anymore with this linker script. But I have another problem now. It works, I can see the screen but I can not see the text anymore. Do you know or have any idea why I can not see the text in the screen anymore?

image.png

I also tested the linker script with other RAM sections (RAM_D2, RAM_D3, ITCMRAM, DTCMRAM). The result is same.

And yes, MX_QUADSPI_Init() is being called before the MX_TouchGFX_Init().

As i said, this sentence in linker script set in code address for reading fonts from RAM, but RAM is empty after sw start, because system loader not preload from QSPI. This must do your code in main before use fonts...

Simply after init QSPI memcpy fontsize area to ram choiced in ld.

Gökhan
Associate II

It works!!! Thank you so much :)