cancel
Showing results for 
Search instead for 
Did you mean: 

External Flash Loader on STM32G474 with SPI.

MAmem.1
Associate III

Hi,

I'm trying to migrate an old firmware from a STM32F303 to a STM32G474.

The MCU is related to an external Flash W25Q16JV.

The old configuration uses the SPI bus to communicate with the external flash.

So I changed the program in order to adapt the new MCU.

I know by the datasheet that the W25Q16JV can run on QSPI but this configuration is for later.

After I changed the program I can generate the .stldr file and copy it in the external loader folder of the STM32CubeProgrammer. The STM32CubeProgrammer start but keep showing message about Flash protection. On the scope no signal at all.

It seems that the program can't start due to incorrect boot vector and SP pointer.

In the project there is no Startup.s file and no main.

Q1: how the project is suppose to deal with that and where to declare missing starting point.

Q2: Is there any example that shows the correct configuration.

Thanks for your help

2 REPLIES 2

Right, it' more like a DLL, the primary entry point is "Init" function, it doesn't need a vector table, shouldn't use interrupts, or have a lot of C runtime startup code. One should perhaps be conscious of this, and specifically clearing the statics, and perhaps running the scatter loader on platforms like Keil.

The HAL expectations are some what ill suited.

Yeah, the W25Q parts run fine in 1-bit SPI modes, but you will have to provide a "Read" function and change from being a "NOR_FLASH" to "SPI_FLASH" device, so STM32 Cube Programmer doesn't expect it to be a memory mapped into the address space of the MCU.

I could create an example for the G4, but it wouldn't be a zero cost exercise.

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

Thanks you for your support, finally the code was good.

The configuration bit was the problem. On the STM32CubeProgrammer, I always have the refresh one of these bits in order to get the flasher to start.

Is there a way to set configuration bits (SwBoot0, nBoot0 and nBoot1) by some compiler code or any settings in IAR in order to set these bits once ?