cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32N6570-Dk Own Model Deployment, Display Bring up

JaiGanesh
Associate II

 

Hi everyone,

I'm currently working with the STM32N6570-DK and facing challenges in two areas that I’d really appreciate help with:


1. Custom AI Model Deployment (ONNX)

We’re experimenting with deploying a small, simple object detection model converted from an ONNX file for testing purposes on the STM32N6570-DK. I’ve managed to get the model analyzed and validated through STM32 tools (X-CUBE-AI), which generated the typical files like network.c, network.h, and low-level AIfiles such as activation buffers, weights, etc.

Here’s what I’d like guidance on:

  • How to integrate the generated AI files into a full working project

  • How to feed live camera data into the model

  • How to display the model output (e.g., bounding boxes or classification results) on the onboard RGB565 display

We understand that both camera input and display output are necessary for the AI model to be functional in real-time, and we’re struggling to find STM32N6-specific examples covering this pipeline (camera → inference → display).

If anyone has experience in setting up the camera driver, handling frame buffer input, and passing it to the model, I’d be very grateful for any code examples or tips.


2. LTDC Display Initialization Issues (RGB565)

I’ve also been working on bringing up the onboard display. I used an example LTDC config from the software package that CubeIDE downloads for this board.

Observed behavior in my project:

  • Backlight turns ON

  • After ~5–10 seconds, screen turns white

  • Then flashes random colors (e.g., reddish or blue) briefly and then disappears


What I’ve Done:

  • Converted a sample image to RGB565 format using Python

  • Converted it to a C array and verified its correctness by round-tripping it back to an image

  • Used the same LTDC config settings from working examples

  • LTDC pixel format and resolution match the display specs


:wrench: Code Snippet (main.c):

 

c
static void MX_LTDC_Init(void)
{
  LTDC_LayerCfgTypeDef pLayerCfg = {0};

  hltdc.Instance = LTDC;
  hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
  hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
  hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
  hltdc.Init.HorizontalSync = 4;
  hltdc.Init.VerticalSync = 4;
  hltdc.Init.AccumulatedHBP = 12;
  hltdc.Init.AccumulatedVBP = 12;
  hltdc.Init.AccumulatedActiveW = 812;
  hltdc.Init.AccumulatedActiveH = 492;
  hltdc.Init.TotalWidth = 820;
  hltdc.Init.TotalHeigh = 494;
  hltdc.Init.Backcolor.Blue = 0;
  hltdc.Init.Backcolor.Green = 0;
  hltdc.Init.Backcolor.Red = 0;

  if (HAL_LTDC_Init(&hltdc) != HAL_OK) { Error_Handler(); }

  pLayerCfg.WindowX0 = 0;
  pLayerCfg.WindowX1 = 290;
  pLayerCfg.WindowY0 = 0;
  pLayerCfg.WindowY1 = 174;
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
  pLayerCfg.Alpha = 255;
  pLayerCfg.Alpha0 = 0;
  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  pLayerCfg.FBStartAdress = 0;
  pLayerCfg.ImageWidth = 290;
  pLayerCfg.ImageHeight = 174;
  pLayerCfg.Backcolor.Blue = 255;
  pLayerCfg.Backcolor.Green = 0;
  pLayerCfg.Backcolor.Red = 0;

  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) { Error_Handler(); }

  // Security configuration
  RIMC_MasterConfig_t RIMC_master = {0};
  RIMC_master.MasterCID = RIF_CID_1;
  RIMC_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;
  HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_LTDC1 , &RIMC_master);
  HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_LTDCL1 , RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
}

// Later in code:
MX_LTDC_Init();
HAL_LTDC_SetAddress(&hltdc, dolphin_156x129_565, 0);
HAL_LTDC_ConfigMirror(&hltdc, LTDC_MIRROR_HORIZONTAL, 0);

GPIO and Display Defines (in main.h):

 

c
 
#define LCD_BL_CTRL_Pin GPIO_PIN_6
#define LCD_BL_CTRL_GPIO_Port GPIOQ
#define LCD_ONOFF_Pin GPIO_PIN_3
#define LCD_ONOFF_GPIO_Port GPIOQ

#define LAYER_SIZE_Y 156
#define LAYER_SIZE_X 129
#define LAYER_BYTE_PER_PIXEL 2

The image is included as a separate .h file (RGB565 C array) and included in main.c.


Help Needed : 

  • How can we use the network.c/.h files from X-CUBE-AI with live camera input?

  • How should the model output be processed and shown on the RGB565 display?

  • Any working examples (even if for other STM32H7/N6 boards) that demonstrate a real-time camera + AI + LTDC flow?

  • Any guidance on LTDC timing tuning or memory configuration?

I’m also happy to share the project files if someone is willing to review. Please let me know the best way to do that.

Thanks a lot in advance! Any tips or experience from similar setups would really help.

Best regards,
Ganesh

1 REPLY 1
David SIORPAES
ST Employee

Hello,

There are many STM32N6 full application examples with different complexity levels available here

https://www.st.com/en/development-tools/stm32n6-ai.html

I'd suggest to start with "n6-ai-getstarted" example: this should suffice to achieve what you are looking for.

 

Hope this helps

David