Skip to main content
Associate III
June 25, 2026
Solved

STM32N6 AI Model Memory Sections Wrong

  • June 25, 2026
  • 1 reply
  • 28 views

Hello everyone,

 

I can run my model through the stedgeai / STM32Cube AI Studio and see the following:

 

But when I now go into the resulting application and build it myself, I see these memory sections, which tell a totally different story:

 

How can I fix this? I added the AXISRAMx sections (they are not provided per default) which results in them being used by 0%, so that also can’t be right.

 

Best regards, rphii

Best answer by rphii

I guess this is what I’ll do for now, it doesn’t seem to break the inference, at least.

 

#define KB_IN_BYTES(N)    (1024UL * (N))

/* set these KB according the STM32Cube AI Studio */
#define AI_NPURAM5_SIZE KB_IN_BYTES(400)
#define AI_NPURAM4_SIZE KB_IN_BYTES(192)
__attribute__((section(".AI_NPURAM5")))
static uint8_t ai_npuram5[AI_NPURAM5_SIZE];
__attribute__((section(".AI_NPURAM4")))
static uint8_t ai_npuram4[AI_NPURAM4_SIZE];


/****in linker script, sections *****


AXISRAM4 : ORIGIN = 0x34270000, LENGTH = 0x70000
AXISRAM5 : ORIGIN = 0x342E0000, LENGTH = 0x70000


************** after .text **********

.AI_NPURAM4 (NOLOAD): {
. = ALIGN(4);
KEEP(*(.AI_NPURAM4))
. = ALIGN(4);
} >AXISRAM4

.AI_NPURAM5 (NOLOAD): {
. = ALIGN(4);
KEEP(*(.AI_NPURAM5))
. = ALIGN(4);
} >AXISRAM5


*************************************/

Since my axisram4 is not filled a lot, I used the rest of that space for something else, and (again) the inference still works. I therefore take this as a confirmation to my assumption that the AI studio/model/exported code simply uses the beginning of that memory… (hopefully)

1 reply

rphiiAuthorBest answer
Associate III
July 9, 2026

I guess this is what I’ll do for now, it doesn’t seem to break the inference, at least.

 

#define KB_IN_BYTES(N)    (1024UL * (N))

/* set these KB according the STM32Cube AI Studio */
#define AI_NPURAM5_SIZE KB_IN_BYTES(400)
#define AI_NPURAM4_SIZE KB_IN_BYTES(192)
__attribute__((section(".AI_NPURAM5")))
static uint8_t ai_npuram5[AI_NPURAM5_SIZE];
__attribute__((section(".AI_NPURAM4")))
static uint8_t ai_npuram4[AI_NPURAM4_SIZE];


/****in linker script, sections *****


AXISRAM4 : ORIGIN = 0x34270000, LENGTH = 0x70000
AXISRAM5 : ORIGIN = 0x342E0000, LENGTH = 0x70000


************** after .text **********

.AI_NPURAM4 (NOLOAD): {
. = ALIGN(4);
KEEP(*(.AI_NPURAM4))
. = ALIGN(4);
} >AXISRAM4

.AI_NPURAM5 (NOLOAD): {
. = ALIGN(4);
KEEP(*(.AI_NPURAM5))
. = ALIGN(4);
} >AXISRAM5


*************************************/

Since my axisram4 is not filled a lot, I used the rest of that space for something else, and (again) the inference still works. I therefore take this as a confirmation to my assumption that the AI studio/model/exported code simply uses the beginning of that memory… (hopefully)