cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with bitmap caching touchGFX

Kpodu.1
Associate II

Hi All,

I have a problem with bitmap caching. Below is the context

Processor and Peripheral’s details:-

  1. STM32F429ZITX micro
  2. 8 Mega bytes external SD RAM
  3. 16 Megabytes SPI flash(not quad)

Our use case:- We have GUI application with several screens(setup , functionality, presets …etc). The total assets size is of 11 Mega bytes which are stored in the SPI Flash. As our SD Ram is only 8 Mega bytes size we just want to dynamically copy the assets from SPI Flash screen by screen on demand to SD ram and try to display them.

In order to achieve the above I followed below two links

https://support.touchgfx.com/docs/development/ui-development/scenarios/using-non-memory-mapped-flash/

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/caching-bitmaps/

Steps I followed:-

  1. In the linker script I used below snippet and segregated all the assets

SRAM (xrw)     : ORIGIN = 0xd0061c8c, LENGTH = 7450K

ExtFlashSection :

{

*(ExtFlashSection ExtFlashSection.*)

} >SDRAM

  1. Then using python script I have split the assets binary starting from that memory location and separated the application binary and assests binary
  2. I have made a custom bootloader which takes these binaries and place them accordingly(application binary in user space and assets binary in SPI flash)

  1. Then I have kept below two lines of code for enabling the caching

  uint16_t* cacheStartAddr = (uint16_t*)0xd0061a80;

  uint32_t cacheSize = 0x300000; //3 MB, as example

  HAL& hal = touchgfx_generic_init<STM32F4HAL>(dma, display, tc, dispWidth, dispHeight,cacheStartAddr, cacheSize);

  1. Then I have created the block copy function in STM32F4HAL.cpp

bool STM32F4HAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)

{

       if(serialFlashread((uint8_t*)dest , (uint32_t)src - (uint32_t)0xd0061c8c, numBytes) != HAL_OKreturn false;

       return true;

}

I created a smaller application for this experiment. Total assets size is only 3 MB. When I use Bitmap::cacheAll() at begining and keep a breakpoint at blockCopy function I can clearly see the src , destination as described in the linker script and cacheStartAddr. And my serialFlashread api is properly returning the images. I was able to get picture on screen without any problem.

My problem is:-

When I do the below step as described in document instead of cache all( because my sd ram wont be sufficient for full application assets)  https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/caching-bitmaps/

void Screen1View::setupScreen()

{

//ensure background is cached

Bitmap::cache(BITMAP_SCREEN2_ID);

//cache some icons

Bitmap::cache(BITMAP_ICON10_ID);

Bitmap::cache(BITMAP_ICON11_ID);

Bitmap::cache(BITMAP_ICON12_ID);

}

void Screen1View::tearDownScreen()

{

//Remove all bitmaps from the cache

Bitmap::clearCache();

}

I see that the block copy is invoking and src address is properly as per the bitmap database….so my spi flash is returning the right image. But the destination address is (cacheStartAddr + 524 bytes). It makes sense because it is taking image from assests binary and putting at start of the cache address, so toucchGFX can use it.

But the problem is this image is not getting displayed on the screen and some random noise is getting shown( I can understand this because the bitmap database is not readjusted and touchGFX is still using the same old database so it is showing noise).

How can I solve this problem and what am I missing. I am literally blocked.

I have seen the dynamic bitmaps but I felt my application didn’t fit into that case. Am I wrong?

Any help is highly appreciated.

Thanks,

Krishna 

15 REPLIES 15
MBely.1
Associate II

Exactly the same problem with TouchGFX 4.17 on STM32F407 MCU. Caching individual bitmaps does not work as expected - "garbage" is displayed on the screen. In this case, copying bitmaps from the SPI flash to the cache is performed correctly, but the TouchGFX does not refer to the cache area further.

I wonder if this will ever be fixed? Or will removed from the technical documentation? The cache feature is declared but not implemented correctly.

Max

Hi,

Bitmap caching does work. The Board Specific Demo on the STM32H7B3-eval uses it for example. It is not the same board but the implementation is the same. Try to check your memory management.

/Romain

MBely.1
Associate II

Hi!

Romain, could you point out which specific demo of the  STM32H7B3-eva uses caching of individual bitmaps? (not Bitmap::cacheall() ).

I want to see that code.

I have a custom board with a STM32F407ZGT6 MCU and 512kb SRAM. 150kb are used for a video buffer (one full video buffer configuration), the remaining 362 KB I try to use as the bitmap cache. The memory works fine. The video buffer works fine. Everything works fine! Until I enable caching... :(

I have tried placing the cache in the internal MCU RAM - the same result: does not work correctly.

Max.

Hi,

When you create a project in TouchGFX Designer go to the "Demos" tab. In this view click on the "Board Specific Demo" tab in the top. There you will find demos made for specific ST development kit, but the code can still be analyzed/used as source of inspiration. Select the one called "STM32H7B3I Evaluation Board" which uses caching.

/Romain

Found a very old demo I did which could maybe be useful to see the implementation. It was on the STM32F429 disco with TouchGFX 4.13 and STM32CubeMX 5.6 but the idea is the same.

/Romain

Hi, @Romain DIELEMAN​ 

I have followed your instructions but it seems that my project is still having problems

Can you take a moment to look at my problem and give me some advice?

https://community.st.com/s/question/0D53W00001AxhnLSAR/how-to-communicate-stm32f429-discovery-with-sd-card-using-spi-communication

Thank you very much!