cancel
Showing results for 
Search instead for 
Did you mean: 

STM32N6 ICache issue

Chirag_Shah
Associate

Hello everyone!

I am using stm32n6570-dk. My project has only FSBL and was generated using STM32CubeMX. I was able to run it in debug mode without issues. The code does not execute when flashed to external flash memory. I had to comment out "MX_ICACHE_Init();" for the code to run from external memory. 

I thought there may be a configuration issue from my side. So I ran the "Starter project" provided by STM located at "STM32CubeN6\Projects\STM32N6570-DK\Templates_Board". This code also runs fine in debug mode. It does not work when flashed to external memory without commenting out "MX_ICACHE_Init();".

I expect the example code to work without modifications. 

 

I figured out that the program does not reach the error handler and gets stuck in HAL_ICACHE_ConfigAssociativityMode(). This is when flashed to external memory.

if (HAL_ICACHE_ConfigAssociativityMode(ICACHE_1WAY) != HAL_OK)

{

Error_Handler();

}
Within HAL_ICACHE_ConfigAssociativityMode() it gets stuck in READ_BIT(ICACHE->CR, ICACHE_CR_EN) 

 

In debug mode I tried executing 

uint32_t HAL_ICACHE_IsEnabled(void)

{

return ((READ_BIT(ICACHE->CR, ICACHE_CR_EN) != 0U) ? 1UL : 0UL);

}

after which the program stops responding.


I tried

if (HAL_ICACHE_Invalidate() != HAL_OK)

{

Error_Handler();

}

inside MX_ICACHE_Init which does not help. This is when flashed to external memory.

The program does not reach the Error_Handler() and stops at HAL_ICACHE_Invalidate().

My plan is to first get the ICache working on the example code, then I can apply the same fix to my project.

Any help is appreciated. Thanks!

 

4 REPLIES 4
Saket_Om
ST Employee

Hello @Chirag_Shah 

I cannot see MX_ICACHE_Init(); in the example "STM32CubeN6\Projects\STM32N6570-DK\Templates_Board"

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Hi @Saket_Om ,

You are correct.

ST released v1.3.0 for STM32CubeN6 MCU Firmware Package 3 days ago (23rd Jan 2026), which does not have MX_ICACHE_Init();. As expected this code runs properly after building and loading to the external flash.

Chirag_Shah_0-1769429110780.png

v1.3.0

v1.2.0 does have MX_ICACHE_Init();

Chirag_Shah_1-1769429146208.png

 

Nevertheless the question remains; Why am I unable to use v1.2.0 with MX_ICACHE_Init()?
I feel it may have something to do with the security/RIF settings but I have not been able to fix it so far.
Answer to this question will help me implement the same in my own project. 

Thank you Saket for looking into it!

 

 

Hello @Chirag_Shah 

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: 225931 (This is an internal tracking number and is not accessible or usable by customers).

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Hello @Chirag_Shah 

The MX_ICACHE_Init() initializes the AXI Cache which is used to improve the performance of the data traffic when the NPU (Neural Processing Unit) accesses them thru AXI (section 12 of the RM).

To enable the Cortex cache (the 'usual' cache let's say), Cortex functions must be used: SCB_EnableICache() and SCB_EnableDCache();

In the starter board project, the NPU is NOT enabled, this is why there is no use to call MX_ICACHE_Init(), and so it was removed from STM32CubeN6 v1.3.0 (it was incorrectly present in v1.2.0).

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om