Showing results for 
Search instead for 
Did you mean: 

External loader for SPI Flash for STM32WL - Fail to Init

Associate II

I have a STM32WLE5 custom board with MX25L4006E SPI Flash.

I created an external loader with CubeIDE based on the article - "How to add your SPI flash into the STM32CubeProgrammer’s external loader"

The result stldr does not work and when I tried to debug it I realize the Init function does not called. I removed all the SPI Flash parts from it and left only a blinking of a led and a printout to the UART I have on board but I did not see any change in the led or the printout data on the terminal.

How can I continue from that point?

Attached is the linker file I sued. 


This is the form I'd use for a loader, but I don't use interrupts or vector tables

Now it normally isn't going to use startup.s or main(), it enters via Init() and you need to initialize RAM and statics (.bss)

To debug what you'll need to do is either make a test-harness app that calls Init(), Write(), SectorErase(), etc or test the SPI Flash code more directly. The more you can test and exercise from your normal debugging environment the better.

For STM32 Cube Programmer you can output telemetry via a USART or status GPIO / LEDs


Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..


I'm still struggling with this issue.

I have a IAR working project that I can use the CubePrpogrammer successfully with it and access the Init and the Read as I make the Init just return 1 and the read memcpy to all the buffer 0x5A (Fill it), that is, I neutralize all the SPI flash parts.

I see that when I use this IAR stldr and connected and read 0x90000000 I get 0x5A as expected.

The problem is that I'm not familiar with IAR and I just downloaded a trial version for two weeks to check if the project I found work properly but I'm not able to add to it the Flash driver.

I tried to create a similar project with CubeIDE, I was able to test it on the board (I follow this instructions) when I use main and I lit a led and print something to the UART but when I try to use the CuebProgrammer it failed.

 I tried to compare the linker file @Tesla DeLorean gave me but it is very different from the one I see in the IAR project as well as the ld of the CubeIDE.

I tried to compare the disassembly of the two projects but it is really different and does not look like a promising trail.

Any help will be great,