2024-05-07 03:13 AM - edited 2024-05-07 03:15 AM
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:
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
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 :)
Solved! Go to Solution.
2024-05-10 07:50 AM - edited 2024-05-10 07:50 AM
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.
2024-05-07 09:49 AM
Do you have any suggestion for this?
2024-05-07 11:32 AM - edited 2024-05-09 10:36 AM
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.
2024-05-09 05:55 AM
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.
2024-05-09 06:22 AM
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...
2024-05-09 10:21 AM
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?
2024-05-09 10:48 AM - edited 2024-05-09 10:57 AM
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
2024-05-10 07:40 AM - edited 2024-05-10 07:48 AM
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?
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().
2024-05-10 07:50 AM - edited 2024-05-10 07:50 AM
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.
2024-05-10 08:18 AM
It works!!! Thank you so much :)