How to setup the cache to use Dynamic bitmap ?
Hello everyone,
I'm currently developing a project using TouchGFX on a custom board with a STM32F469II and a 1024x600 screen in RGB interface.
Right now, I'm trying to add a SD card to the system so that eventually I'll be able to print pictures from it. If I understood the documentation correctly, this means adding a cache space in the external SDRAM where I could place images so that TouchGFX can interact with it with the dynamic bitmap functionnality.
The problem is that I cannot set up properly the cache space for TouchGFX. Here's what I'm doing in the TouchGFXHAL.cpp file :
#include <TouchGFXHAL.hpp>
/* USER CODE BEGIN TouchGFXHAL.cpp */
#include "stm32f4xx.h"
#include <cstdlib>
using namespace touchgfx;
namespace {
LOCATION_PRAGMA("BmpCacheSection")
uint16_t cache[1000000] LOCATION_ATTRIBUTE("BmpCacheSection");
}
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.
//TouchGFXGeneratedHAL::initialize();
HAL::initialize();
registerEventListener(*(Application::getInstance()));
setFrameBufferStartAddresses((void*)0xC0000000, (void*)0xC0200000, (void*)0xC0400000);
uint32_t cacheSize = sizeof(cache);
touchgfx::Bitmap::removeCache();
touchgfx::Bitmap::setCache(cache, cacheSize, 4);
uint8_t* res = touchgfx::Bitmap::getCacheTopAddress();
}And the cache section is defined like so in the linker :
/* Memories definition */
MEMORY
{
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
QUADSPI (r) : ORIGIN = 0x90000000, LENGTH = 8M
CACHE (rw) : ORIGIN = 0xC0600000, LENGTH = 2M
}
...
BmpCacheSection (NOLOAD) : { *(BmpCacheSection) } >CACHEI plane to organize the external SDRAM of 8MB like so:
- From 0xC0000000 to 0xC01FFFFF: first frame buffer
- From 0xC0200000 to 0xC03FFFFF: second frame buffer
- From 0xC0400000 to 0xC05FFFFF: animation buffer
- From 0xC0600000 to 0xC07FFFFF: dynamic bitmap cache
I should also mention that based on my screen's resolution, I should be able to input the second address as 0xC012C000 but If I put any lower than 0xC0200000 then the screen jitters for some reason.
However when I reach the line with the "setCache" function, the programs stops and the connection with the probe is lost without any other information. I've also tried setting up the cache like so:
uint16_t* cacheStartAddr = (uint16_t*)0xC0600000;
uint32_t cacheSize = 0x100000;
touchgfx::Bitmap::removeCache();
touchgfx::Bitmap::setCache(cacheStartAddr, cacheSize, 4);and using the following function:
HAL& touchgfx_generic_init(DMA_Interface& dma, LCD& display, TouchController& tc, int16_t width, int16_t height, uint16_t* bitmapCache, uint32_t bitmapCacheSize, uint32_t numberOfDynamicBitmaps = 0)But nothing I did has worked so far.
How can I properly setup the cache ?
Tristan
