Skip to main content
MOtto.1
Associate III
May 13, 2025
Question

flashing external SPI Flash with STM32CubeProgrammer

  • May 13, 2025
  • 4 replies
  • 649 views

Hi, i have recognize some odd behavior inside the CubeProgrammer external flashing feature.

When flashing files less or equal to 128KB, then it flashes size at boundary of the block size of the Flash device which is 64K. As soon i get bigger than that it no more send data in that boundary but 67072 bytes. Why is that? I had to rewrite my APIs to get that working properly. I mean it is working now but sounds strange too me.

 

Thanks

4 replies

Maryem
Technical Moderator
May 13, 2025

Hello @MOtto.1 ,

 

Could you please provide any logs and error details related to the flashing process?

Thank you,

Maryem.

Maryem
Technical Moderator
May 27, 2025

Hello @MOtto.1 ,

 

I was wondering if you have any updates or feedback regarding the flashing issue?

 

Maryem.

MOtto.1
MOtto.1Author
Associate III
May 27, 2025

Well, usually i would expect that flash sizes are on some even boundaries like "0xffff". But those downloads sizes are a little bit odd. Size is 0x10700 but also changeing.

Printf from my code.

Here the write address and amount of bytes. 

Write addr=0x00000000 size=67328
Write addr=0x00010700 size=67328
Write addr=0x00020e00 size=67328
Write addr=0x00031500 size=67328
Write addr=0x00041c00 size=67328
Write addr=0x00052300 size=67328
Write addr=0x00062a00 size=67328
Write addr=0x00073100 size=67328
Write addr=0x00083800 size=67328
Write addr=0x00093f00 size=67328
Write addr=0x000a4600 size=67328
Write addr=0x000b4d00 size=67328
Write addr=0x000c5400 size=67328
Write addr=0x000d5b00 size=67328
Write addr=0x000e6200 size=52992
Write addr=0x000f3100 size=52992

But not a big deal for me you can mark it as resolved.

 

Pavel A.
Super User
May 27, 2025

at boundary of the block size of the Flash device which is 64K

STM32F4 has flash blocks of several sizes: from 16K to 128K. Please see the RM.

 

Tesla DeLorean
Guru
May 27, 2025

Not sure, but generally it depends on the available RAM, the loader consumes a portion of it, perhaps 512 bytes for a stack, and it then splits the remaining into Ping-Pong buffers the SWD/JTAG can fill whilst you're Write()'ing to the external FLASH.

The QSPI NOR typically have 256-byte page buffers, and you can't write directly across page boundaries, the code in the loader needs to manage/handle the spanning. The ERASE sizes can be 4KB, 32KB and 64KB in most cases, and their are outliers which are non-uniform in size, and perhaps larger.

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