cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX dynamicBitmapCreateExternal() not working for RGB565 bitmaps

PFlor.2
Senior II

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

1 ACCEPTED SOLUTION

Accepted Solutions
PFlor.2
Senior II

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.

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/dynamicbitmapcreateexternal-does-not-work-for-a-rgb565-image/m-p/605117/highlight/true#M35160

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

 

View solution in original post

4 REPLIES 4
LouisB
ST Employee

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,

Louis BOUDO
ST Software Developer | TouchGFX

Any timeframe as to when this next release will take place?

PFlor.2
Senior II

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.

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/dynamicbitmapcreateexternal-does-not-work-for-a-rgb565-image/m-p/605117/highlight/true#M35160

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

 

Hello @PFlor.2,


We are working on it but, right now I cant give you a specific timeframe.

BR,

Louis BOUDO
ST Software Developer | TouchGFX