cancel
Showing results for 
Search instead for 
Did you mean: 

Custom external loader for STM32N655X0

ArunJohn
Associate II

Hi,

I’m developing a custom external loader (.stldr) for an STM32N655X0 custom board to program external XSPI NOR flash using STM32CubeProgrammer via a J-Link interface (board does not have ST-LINK).

I have the loader framework working partially:

  • Init() executes

  • Sector erase succeeds

  • Programming fails during download phase

  • CubeProgrammer logs show repeated “Init flashloader...” calls and eventually errors like:

    • “Init function fail”

    • “Could not start CPU (ErrorCode: -1)”

    • “Cannot read R0 while CPU is running”

The external flash is S25FL064L and erase operation works correctly, so communication with flash seems functional.

I wanted guidance specifically for developing external loaders intended to be used through J-Link in STM32CubeProgrammer:

  1. Are there any additional requirements or limitations when using .stldr loaders via J-Link compared to ST-LINK?

  2. Does CubeProgrammer execute the loader lifecycle differently when J-Link is selected (Init / Erase / Write / Read sequencing)?

  3. Are there RAM regions that CubeProgrammer reserves for staging write buffers which the loader must avoid?

  4. Is there a recommended linker memory layout / maximum loader RAM footprint?

  5. Does CubeProgrammer call Init() multiple times during programming, and should Init() be designed to be fully re-entrant?

  6. Are there guidelines on cache/MPU/XSPI memory-mapped mode usage inside external loaders?

  7. Any recommended debug method to trace loader execution?

If anyone has successfully developed and used a custom STM32CubeProgrammer external loader with J-Link on STM32N6, I’d appreciate any checklist or lessons learned.

Thanks.

3 REPLIES 3
Pavel A.
Super User

Please check with Segger whether J-Link supports STM32N6.

J-Link software (J-Flash) has "universal driver" for xSPI flash. It is not compatible with CubeIDE but if there is support, you can program it via J-Flash.

 

Thanks for the suggestion.

J-Link does support STM32N655X0 and I’m able to connect, download to RAM, and execute code on the target through STM32CubeProgrammer using the J-Link interface.

The limitation I’m facing is not basic STM32N6 support in J-Link, but external flash programming support for my custom hardware.

I looked into J-Flash and the Universal Flash Loader approach. However, my board uses a custom XSPI flash connection / initialization sequence and there is no existing flash device configuration matching my board setup (pin assignment), so the generic J-Flash solution is not directly usable in my case.

That is why I’m currently trying to continue using a custom STM32CubeProgrammer external loader (.stldr), where I can fully control the XSPI initialization and flash operations.

My questions are mainly around whether CubeProgrammer behaves differently when executing .stldr loaders through J-Link versus ST-LINK (loader lifecycle, RAM usage, Init() invocation pattern, debugging recommendations, etc.), since erase currently works but write/read operations fail.

If there are any known limitations or recommendations specifically for CubeProgrammer + custom external loader + J-Link, I’d appreciate guidance.

Thanks.

Hello @ArunJohn 

Please refer to the article below:

How to implement and use your own external flash l... - STMicroelectronics Community

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