Skip to main content
Explorer
October 28, 2025
Solved

Blitting JPEG on STM32H757 Eval board to OTM8009A Display using HAL Interfaces

  • October 28, 2025
  • 1 reply
  • 300 views

STM32H757 has FreeRTOS running.

The goal is to stream JPEG data to the display using HAL interfaces to get performance. However, it is not working yet and I am here to get some guidance.  I have it working with using third party library libJPEG.

HAL Interfaces I am relying on:

HAL_JPEG_DeInit(m_phjpeg)

HAL_JPEG_Init(m_phjpeg)

HAL_JPEG_DecodeCpltCallback() and HAL_JPEG_ErrorCallback() have been setup to release semaphore. 

HAL_JPEG_Decode_DMA()  for non blocking decode

DMA2D: RGB888 To ARGB8888

HAL_DMA2D_Init(&hdma2d)

HAL_DMA2D_ConfigLayer()

HAL_DMA2D_Start()

HAL_DMA2D_PollForTransfer() with 1000 timeout

DMA2D: BlendARGB To RGB888 (Blend to FG)

stm32h7xx_hal_dma2d.h has the following macros that I am using:

#define DMA2D_BACKGROUND_LAYER 0x00000000U /*!< DMA2D Background Layer (layer 0) */
#define DMA2D_FOREGROUND_LAYER 0x00000001U /*!< DMA2D Foreground Layer (layer 1) */

Once the dma2d handle members are setup, the following happens:

HAL_DMA2D_Init(&hdma2d)

HAL_DMA2D_ConfigLayer()

HAL_DMA2D_BlendingStart()

HAL_DMA2D_PollForTransfer() with 1000 timeout

Blit to Display

HAL_DMA2D_ConfigLayer()

HAL_DMA2D_Start()

HAL_DMA2D_PollForTransfer() with 1000 timeout

Appreciate any help!

Thanks!

    This topic has been closed for replies.
    Best answer by MOBEJ

    Hello @SM_IoT ,

    Thank you for sharing your setup. To better assist you, ,Could you please provide more details on your  issue or error are you encountering when streaming the JPEG data using the HAL ?
    and Did you check the JPEG examples in the STM32CubeH7 package on GitHub? They could help with your project.

    You can find them here:
    STM32CubeH7/Projects/STM32H747I-EVAL/Examples/JPEG at master · STMicroelectronics/STM32CubeH7 · GitHub

    Br

    1 reply

    MOBEJAnswer
    ST Employee
    October 30, 2025

    Hello @SM_IoT ,

    Thank you for sharing your setup. To better assist you, ,Could you please provide more details on your  issue or error are you encountering when streaming the JPEG data using the HAL ?
    and Did you check the JPEG examples in the STM32CubeH7 package on GitHub? They could help with your project.

    You can find them here:
    STM32CubeH7/Projects/STM32H747I-EVAL/Examples/JPEG at master · STMicroelectronics/STM32CubeH7 · GitHub

    Br

    SM_IoTAuthor
    Explorer
    October 30, 2025

    Hello, @MOBEJ 

     

    Thank you kindly for your response.

     

    I did review the example in the process of writing my code. However, that is for the STM32H747I board. We are using STM32H757I Eval board that has the OTM8009A Display. 

    My efforts are towards getting the ARGB8888 blended into RGB888 which does not seem to be happening. I would appreciate it if you can please list any possible areas that need to be looked based on your experience in blending ARGB8888 to RGB888.

    What am I doing

    1. Using a JPEG source, I decode it to RGB888.

    2. Using HAL_DMA2D_Start, I convert from RGB888 to ARGB8888 using the following Settings:

    m_hdma2d->Init.Mode   = DMA2D_M2M_PFC; // DMA2D_M2M_BLEND_FG; 
    m_hdma2d->Init.ColorMode   = DMA2D_OUTPUT_ARGB8888;
    m_hdma2d->Init.OutputOffset   = 0;
    m_hdma2d->Init.AlphaInverted  = DMA2D_REGULAR_ALPHA;
    m_hdma2d->Init.RedBlueSwap   = DMA2D_RB_REGULAR;
    m_hdma2d->Init.LineOffsetMode = DMA2D_LOM_BYTES;
    // Input layer config for RGB888 pixels from decoded JPEG
    DMA2D_LayerCfgTypeDef* hdma2dLayer1Cfg = &(m_hdma2d->LayerCfg[1]);
    hdma2dLayer1Cfg->InputOffset    = 0;
    hdma2dLayer1Cfg->InputColorMode = DMA2D_INPUT_RGB888;
    hdma2dLayer1Cfg->AlphaMode = DMA2D_REPLACE_ALPHA; // DMA2D_NO_MODIF_ALPHA;
    hdma2dLayer1Cfg->AlphaInverted = DMA2D_REGULAR_ALPHA;
    hdma2dLayer1Cfg->RedBlueSwap = DMA2D_RB_REGULAR;
    hdma2dLayer1Cfg->InputAlpha = 0xFF;
    HAL_DMA2D_DeInit(m_hdma2d);
    HAL_DMA2D_Init(m_hdma2d);
    HAL_DMA2D_ConfigLayer(m_hdma2d, 1);
    HAL_DMA2D_Start(m_hdma2d, reinterpret_cast<uint32_t>(rgb888Buffer),
    reinterpret_cast<uint32_t>(argb8888Buffer), width, height);
    HAL_DMA2D_PollForTransfer(m_hdma2d, 1000);

     

    3. I blend ARGB8888 to RGB888

    m_hdma2d->Init.Mode = DMA2D_M2M_BLEND;
    m_hdma2d->Init.ColorMode = DMA2D_OUTPUT_RGB888;
    m_hdma2d->Init.OutputOffset = 0;
    // Input layer config for RGB888 pixels from decoded JPEG
    DMA2D_LayerCfgTypeDef* hdma2dLayer1Cfg = &(m_hdma2d->LayerCfg[1]);
    hdma2dLayer1Cfg->InputOffset    = 0;
    hdma2dLayer1Cfg->InputColorMode = DMA2D_INPUT_RGB888;
    hdma2dLayer1Cfg->AlphaMode = DMA2D_NO_MODIF_ALPHA;
    hdma2dLayer1Cfg->InputAlpha = 0xFF;
    hdma2dLayer1Cfg = &(m_hdma2d->LayerCfg[DMA2D_BACKGROUND_LAYER]);
    hdma2dLayer1Cfg->InputOffset    = 0;
    hdma2dLayer1Cfg->InputColorMode = DMA2D_INPUT_ARGB8888;
    hdma2dLayer1Cfg->AlphaMode = DMA2D_COMBINE_ALPHA;
    HAL_DMA2D_DeInit(m_hdma2d);
    HAL_DMA2D_Init(m_hdma2d);
    HAL_DMA2D_ConfigLayer(m_hdma2d, 1);
    HAL_DMA2D_ConfigLayer(m_hdma2d, DMA2D_BACKGROUND_LAYER);
    HAL_DMA2D_BlendingStart(m_hdma2d, reinterpret_cast<uint32_t>(srcArgb8888Buffer), 0,
    reinterpret_cast<uint32_t>(dstRgb888Buffer), srcWidth, srcHeight);
    HAL_DMA2D_PollForTransfer(m_hdma2d, 1000);

     

    4. Blit to Display

    HAL_DMA2D_DeInit(m_hdma2d);
    HAL_DMA2D_Init(m_hdma2d);
    HAL_DMA2D_ConfigLayer(m_hdma2d, 1);
    uint8_t* pDstStart = dstDisplayFrameBuffer + (dstFbStartY * fbLineStride) + (dstFbStartX * 3);
    HAL_DMA2D_Start(m_hdma2d, reinterpret_cast<uint32_t>(srcRgb888Buffer),
    reinterpret_cast<uint32_t>(pDstStart), srcWidth, srcHeight)
    HAL_DMA2D_PollForTransfer(m_hdma2d, 1000);

     

    Also, yesterday in the process of verifying the CubeMX settings, I regenerated the code and was forced to download 4.25 because 4.24.2 does not exist anymore. Our code base is based off of 4.24.2. How can we download 4.24.2?

    Thank you kindly.

     

    ST Employee
    October 31, 2025

    Hello  @SM_IoT  , 

    I recommend using the STM32H747I eval board as it features the same display module as your board, which utilizes the OTM8009A display driver , You can verify this by checking the stm32h747i_eval_conf.h file located in the Common folder, where the use of the OTM8009A display driver is clearly specified (line 43).

    Br