cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401RE SPI-Bootloader Erase - does not work

janisheil
Associate II
Posted on July 28, 2016 at 21:50

Hello,

I have a problem with the erase command for the SPI-bootloader.

1) The documentation says 0x44 in the text and 0x43 in the figures (AN4286 DocID024458 Rev 2)

2) The documentation is inconsistent with the use of the terms ''page'' and ''sector''. This has huge impact on my question below. For details also see: 

/1c6d26e

3) The discription in chapter 2.8 does not fit the Figures 18 and 19: Is a checksum required after transmitting the ''number of pages''? Text says no, figure 18 and 19 say yes.

Now to my actual question:

I am currently trying to implement the SPI-bootloader command ''erase'' on a STM32F401RE MCU with 512kb flash memory. It works when I perform a mass-erase (length = 0xFFFF), but not when I try to erase single sectors. Write protection is off.

The bootloader sends only ACKs and seems to work - but the sectors are not erased (as I said: mass erase works, but I need single sector erase).

Some more background why the documentation needs correction:

The confusing part is that - according to AN4286 -  the erase-comand takes 16bit page-numbers. Pages are not mentioned anywhere else on the STM32F401 documentation. So I figure that sectors are actually meant. Is that correct?

If so: Why does the bootloader take 16bit wide sector-IDs when there are only 8 different sectors? (Larger MCUs have only marginally more sectors, so that cannot be the reason.)

Is my pseudo-code correct for erasing sector 0 (at flash address 0x08000000):

StartBootloader();

SpiSend(0xA5,0x44,0xBB);  // documentation says 0x43,0xBC in Figure 18??

WaitForAckOrNack();

SpiSend(0x00, 0x00); // N = 1 sectors shall be erased, bootloader wants N-1 = 0

SpiSend(0x00); // checksum, required?? Figure 18+19 say yes, text says no

WaitForAckOrNack();

SpiSend(0x00,0x00); // sector 0

SpiSend(0x00); // checksum

WaitForAckOrNack();

--> I get an ACK, but the sectors are not erased.

NOTE: I controle the byte at 0x08000000 because even if pages were meant instead of sectors, then I would erase page 0 which would most also start at 0x08000000.

Have a nice evening and thanks for the help :)

Janis Heil

#stm32f401-bootloader-erase
5 REPLIES 5
Nesrine M_O
Lead II
Posted on July 29, 2016 at 12:08

Hi Janis Heil,

Thanks for highlighting these issues:

•1 and 3 are reported internally and will be corrected soon

•About 2 point: the application note is generic for some STM32 series. For this reason the use of the terms ''page'' and ''sector� is a bit confused. I will ask our team to add some notes to clarify this point.

•Please try to erase other sectors to check if you still face same issue

-Syrine-

janisheil
Associate II
Posted on July 29, 2016 at 16:35

Hi Syrine,

thanks for the heads-up about the documentation.

The problem still persists. I tried:

1) Erasing different single sectors

2) Erasing multiple sectors

3) Changing the hardware (different NUCLEO-boards)

I get an ACK by the bootloader, but the data in the sectors persists. Mass-erase (0xFFFF) works fine.

Thanks for the help

Janis

janisheil
Associate II
Posted on July 29, 2016 at 16:38

Hi again,

in my first post I asked ''3) The discription in chapter 2.8 does not fit the Figures 18 and 19: Is a checksum required after transmitting the ''number of pages''? Text says no, figure 18 and 19 say yes.''

So is the checksum required there or is it not?

Best wishes

Janis

janisheil
Associate II
Posted on August 09, 2016 at 12:29

So can nobody help me on this topic? I thought this bootloader was used quite allot...

Posted on August 09, 2016 at 12:56

The pool of respondants is rather shallow, and I'm not using the F401 with SPI

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