2025-05-29 3:32 PM - edited 2025-05-29 6:37 PM
I have successfully used dynamicBitmapCreateExternal() with RGB888 on another project but on a different project this causes a hard fault when the bitmap is used to render an image to the display when RGB565 is used. I have been able to change the parameter to RGB888 and it works but of course since the image loaded is RGB565 it is not formatted correctly on the display...but it proves that works with the only difference being the RGB565 entered for the format parameter...
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
: FrontendApplicationBase(m, heap)
{
/*
* Initialize dynamic bitmap cache;
* bookkeeping memory for external bitmaps not stored in cache
*/
uint16_t* const cacheStartAddr = (uint16_t*)myBmpCache;
const uint32_t cacheSize = sizeof(myBmpCache);
Bitmap::setCache(cacheStartAddr, cacheSize, 1);
void* srcPtr = logoGetImagePtr();
BitmapId bmpId = Bitmap::dynamicBitmapCreateExternal(LCD_X_Size, LCD_Y_Size, srcPtr,
Bitmap::RGB888, 0);
oprSetLogoBmpId(bmpId);
}
The above works but just changing the parameter from Bitmap::RGB888 to Bitmap::RGB565 does not work. See the hardfault in the attached screen capture when the framebuffer is accessed..
Any suggestions? Seen other post about this but nothing about it being addressed. I'm using TouchGFX v4.25.0 and STM32CubeIDE v1.17.0
Solved! Go to Solution.
2025-05-30 11:22 AM
There is a workaround that is explained here, but this requires a cache setup for the entire bitmap image whereas the dynamicBitmapCreateExternal() only uses a small cache for bookkeeping data.
Here is my implementation of this that works as long as I don't run out of RAM...
#include <gui/common/FrontendApplication.hpp>
#include <touchGFX/Bitmap.hpp>
extern "C" {
#include "../../../core/inc/opr.h"
#include "../../../core/inc/logo.h"
}
#if 0
// for use with dynamicBitmapCreateExternal()
Uint8 myBmpCache[2*1024];
#else
// for use with dynamicBitmapCreate()
Uint8 myBmpCache[155*1024];
#endif
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
: FrontendApplicationBase(m, heap)
{
#ifndef SIMULATOR
compileTimeAssert(MyBmpId_invalid == BITMAP_INVALID);
#endif
/*
* Initialize dynamic bitmap cache;
* bookkeeping memory for external bitmaps not stored in cache
*/
uint16_t* const cacheStartAddr = (uint16_t*)myBmpCache;
const uint32_t cacheSize = sizeof(myBmpCache);
Bitmap::setCache(cacheStartAddr, cacheSize, 1);
void* srcPtr = logoGetImagePtr(); // from external Flash - 0x90DDA000
#if 0
BitmapId bmpId = Bitmap::dynamicBitmapCreateExternal(LCD_X_Size, LCD_Y_Size, srcPtr, Bitmap::RGB888, 0);
#else
// workaround for lack of support of RGB565 in dynamicBitmapCreateExternal()
BitmapId bmpId = Bitmap::dynamicBitmapCreate(LCD_X_Size, LCD_Y_Size, Bitmap::BitmapFormat::RGB565);
uint8_t* bitmapPointer = Bitmap::dynamicBitmapGetAddress(bmpId);
memcpy(bitmapPointer, srcPtr, LogoCFG_memImageSize);
#endif
oprSetLogoBmpId(bmpId);
}
Hopefully a new release will be out soon to fix dynamicBitmapCreateExternal() so it can be used with RGB565
2025-05-30 1:52 AM - edited 2025-05-30 1:57 AM
Hello @PFlor.2 ,
There's a bug with 565 (DynamicBitmapCreateExternal() for RGB565 - Page 2 - STMicroelectronics Community) that will be fixed in a next release.
BR,
2025-05-30 7:19 AM
Any timeframe as to when this next release will take place?
2025-05-30 11:22 AM
There is a workaround that is explained here, but this requires a cache setup for the entire bitmap image whereas the dynamicBitmapCreateExternal() only uses a small cache for bookkeeping data.
Here is my implementation of this that works as long as I don't run out of RAM...
#include <gui/common/FrontendApplication.hpp>
#include <touchGFX/Bitmap.hpp>
extern "C" {
#include "../../../core/inc/opr.h"
#include "../../../core/inc/logo.h"
}
#if 0
// for use with dynamicBitmapCreateExternal()
Uint8 myBmpCache[2*1024];
#else
// for use with dynamicBitmapCreate()
Uint8 myBmpCache[155*1024];
#endif
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
: FrontendApplicationBase(m, heap)
{
#ifndef SIMULATOR
compileTimeAssert(MyBmpId_invalid == BITMAP_INVALID);
#endif
/*
* Initialize dynamic bitmap cache;
* bookkeeping memory for external bitmaps not stored in cache
*/
uint16_t* const cacheStartAddr = (uint16_t*)myBmpCache;
const uint32_t cacheSize = sizeof(myBmpCache);
Bitmap::setCache(cacheStartAddr, cacheSize, 1);
void* srcPtr = logoGetImagePtr(); // from external Flash - 0x90DDA000
#if 0
BitmapId bmpId = Bitmap::dynamicBitmapCreateExternal(LCD_X_Size, LCD_Y_Size, srcPtr, Bitmap::RGB888, 0);
#else
// workaround for lack of support of RGB565 in dynamicBitmapCreateExternal()
BitmapId bmpId = Bitmap::dynamicBitmapCreate(LCD_X_Size, LCD_Y_Size, Bitmap::BitmapFormat::RGB565);
uint8_t* bitmapPointer = Bitmap::dynamicBitmapGetAddress(bmpId);
memcpy(bitmapPointer, srcPtr, LogoCFG_memImageSize);
#endif
oprSetLogoBmpId(bmpId);
}
Hopefully a new release will be out soon to fix dynamicBitmapCreateExternal() so it can be used with RGB565
2025-06-03 4:49 AM
Hello @PFlor.2,
We are working on it but, right now I cant give you a specific timeframe.
BR,