cancel
Showing results for 
Search instead for 
Did you mean: 

ExtMemLoader for STM32N6 on custom board

max_verem
Associate II

Hi

Like many other developers that have to deal with custom board on STM32N6 MCU i have to develop custom ExtMemLoader. And like other stuck with MCU hangs.

I discovered that STM32CubeProgramer does not properly work with my board and after any attempt to Erase or Load MCU become unresponsive until next POR (Power On Reset).

I found workaround for that and used CLI with only one operation:
- erase, power-off-power-on
- write, power-off-power-on
- read, , power-off-power-on

It worked, but i decided to find issue.

Leak of debugging output from STM32_Programmer_CLI is a problem but i found that MCU hangs on a second call to *Init* function from ExtMemLoader.stldr

Debugging from STM32CubeIDE main function of stm32_loader_api.c did not provide any results - calling API functions and multiple calls to Init did not hang MCU.

So, i minimized API functions (MassErase, SectorErase, Write) to just return 1 and started bisecting code of Init function with a test call:

D:\ST\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe ^
-c port=jlink mode=UR -vb 3 ^
-el "D:\ST\STM32CubeProgrammer\bin\ExternalLoader\FancyProject_ExtMemLoader.stldr" ^
-e [0 1]

so i could find a part of code where it hangs.

And i found it:

  /* Deactivate SYSCFG clock */
  RCC->APB4ENCR2 = RCC_APB4ENCR2_SYSCFGENC;

commenting out that line makes my ExtMemLoader works!

I don't know if it is related to my MCU (STM32N657L0HxQ) or it is related to J-LINK or another weird NRST behavior not documented in errata, but i hope my founds would be useful in similar cases:

https://community.st.com/t5/stm32cubeprogrammer-mcus/inquiry-regarding-extmemloader-implementation-for-stm32n657/td-p/902021
https://community.st.com/t5/stm32-mcus-products/stm32n6-is-only-flashable-after-por/td-p/857626

P.S.

and yes, i use latest software with latest drivers.

 

0 REPLIES 0