Problem with bitmap caching touchGFX
Hi All,
I have a problem with bitmap caching. Below is the context
Processor and Peripheral’s details:-
- STM32F429ZITX micro
- 8 Mega bytes external SD RAM
- 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
Steps I followed:-
- In the linker script I used below snippet and segregated all the assets
SRAM (xrw) : ORIGIN = 0xd0061c8c, LENGTH = 7450K
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
} >SDRAM
- Then using python script I have split the assets binary starting from that memory location and separated the application binary and assests binary
- 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)
- 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);
- 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_OK) return 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

