cancel
Showing results for 
Search instead for 
Did you mean: 

How to Cache Bitmaps Stored on an SD Card with TouchGFX

Leo_Berna99
Associate II

Hello, everyone,

I am following the following youtube video posted by ST: https://www.youtube.com/watch?v=jE_nL1GObmA.

My intention is to use an SD card to go and insert images due to a lack of space in flash or external ram.

I followed the video, creating a bitmap cache in a portion of external RAM away from frame buffers and other important resources.

In the LD file, I then added a virtual section called SDCARD into which I went to place all the contents of the ExtFlashSection.

Then following the video I am right at the point where from the .elf file I should have created the .bin file through the command arm-none-eabi-objcopy.exe --dump-section ExtFlashSection=images.bin STM32H7S78-DK_24bpp_Appli.elf.

However, I unfortunately get the following error: STM32H7S78-DK_24bpp_Appli.elf[ExtFlashSection]: can't dump section - it has no contents: File in wrong format
C:\TouchGFX\4.24.1\env\MinGW\msys\1.0\gnu-arm-gcc\bin\arm-none-eabi-objcopy.exe: unable to rename 'STM32H7S78-DK_24bpp_Appli.elf'; reason: File exists

Has anyone been through this before and has a possible solution to the problem?

13 REPLIES 13

As a result of these problems, I tried to go deeper into the problem and take a step back.
I opened the project for my DK STM32H7S78-Dk “Animation TextureMapper Exemple” on TouchGFX version 4.24.1.
Generate the code and program the flash with CubeIDE.
Up to which all is OK, the image1 below attached appears on the screen of my board.
Next I go slightly further and add just the SDMMC1, with the basic configurations and the fat, without changing anything from before (without adding my code!!!, just adding from the .ioc)
I re-compile the code and end up with the one in figure 2. I can't explain it. I tried diff merging the folders before and after the addition but I can't find anything that could have caused this huge change in the display.

Debugging the code I came across the init of SDMMC1 which looops endlessly here :

 

while ((HAL_GetTick() - tickstart) < wait)
{
}

 


Probably because if RTOS is on, the tick handling is passed to the scheduler, and this is triggered after the call to the SDMMC init.

Have you modified the linker script in the new project?

 

In the new project, check that your timebase under SYS in CubeMX is set to a timer and not systick. Also make sure that the interrupt for that timer is set to a higher priority (lower number) than 5.

The problem with the HAL delay should be fixable by setting the time base timer to a higher priority. FreeRTOS intercepts the usual SysTick interrupt, but setting a timer as time base and setting the priority of that high enough allows the timer to drive the HAL ticks. 

I was not aware you were running an H7S78. I think your original problem is probably related to MPU settings. For that template project, a base region is set up to allow no access to all areas, and regions are then set up on top of that to allow acces to specific regions. You should create a region for your SD address space with the settings used for region 1.

I believe we are almost here. Thanks.

So I changed the priority of the Timer and the SDMMC1 init now is ok.

I tried to also add a new address space for my SD (Region 8) according to the next image :

Leo_Berna99_0-1732810065171.png

I can't see any image on the screen yet. The program is running without error.

void TouchGFXHAL::initialize()
{
    // Calling parent implementation of initialize().
    //
    // To overwrite the generated implementation, omit call to parent function
    // and implemented needed functionality here.
    // Please note, HAL::initialize() must be called to initialize the framework.


 	uint16_t* cacheStartAddr = (uint16_t*)0x9180000C;
	uint32_t cacheSize = 0x800000;

    TouchGFXGeneratedHAL::initialize();
    touchgfx::Bitmap::removeCache();
    touchgfx::Bitmap::setCache(cacheStartAddr, cacheSize,128); // dopo cache size c'era 128
    instrumentation.init();
    setMCUInstrumentation(&instrumentation);
    enableMCULoadCalculation(true);

    /* The LCD instance is set as auxiliary LCD */
    setAuxiliaryLCD(&lcd16);
    lcd16.enableTextureMapperAll();
    activateNeoChrom(true);
    enableDMAAcceleration(false);
}

 I forgot to tell you that I have a Bitmap cache in that portion of SDRAM. Could be this a problem?

This is also my linker file :

Leo_Berna99_1-1732810508386.png

Thanks for your help @mathiasmarkussen