2020-04-30 01:59 PM
Hi All,
I have a problem with bitmap caching. Below is the context
Processor and Peripheral’s details:-
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:-
SRAM (xrw) : ORIGIN = 0xd0061c8c, LENGTH = 7450K
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
} >SDRAM
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);
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
Solved! Go to Solution.
2021-09-13 06:17 AM
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
2021-09-14 06:14 AM
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
2021-09-14 08:14 AM
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.
2021-09-15 01:00 AM
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
2021-09-15 01:32 AM
2021-11-02 02:36 AM
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?
Thank you very much!