cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to erase flash STM32L05 using bootloader via SPI cmds

dstegs
Associate II
Posted on November 19, 2015 at 20:35

The AN4286.pdf SPI Bootloader application note specifies two different commands for erasing flash. On page 24 it specifies 0x44 with checksum 0xBB. However, on page 25 the datasheet specifies 0x43 with a checksum of 0xBC. Which is the proper command to erase flash? I'm communicating with a STM32L05 with bootloader version 1.1. 

After doing some testing I'm only able to receive a ACK back when using the command 0x44 with checksum 0xBB. Might want to update the documentation.

Byte Structure sent to SMT32L05 for erase command: [0x5A,0x44, 0xBB] 

This brings me to the next issue. After receiving the ACK back for the command erase, I send it a special 3 byte special erase command 0xFF 0xFF with the checksum 0x00. This immediately returns a NACK. I have verified using a logic analyzer that the packets are correctly being sent. I would expect to wait a bit for an ACK (up to 100ms) and not receive an NACK. 

Byte Structure sent to SMT32L05 for special erase: [0xFF,0xFF, 0x00] 

Thoughts?

Thank You!

Side Note: I'm able to successfully write a program to flash and execute it. I just cannot seem to erase flash using the global erase. I didn't see any mention of this issue in the errata. 

#stm32l-bootloader-flash-erase
2 REPLIES 2
Amel NASRI
ST Employee
Posted on November 24, 2015 at 10:58

Hi Danny,

I confirm the error you are reporting regarding AN4286. This is highlighted internally and will be corrected.

Regarding the second issue with Mass-erase, please note that this feature isn't supported in L0 devices based on bootloader commands. That is why you get a NACK after the special erase sequence.

As said in AN2606:

Some products don’t support Mass erase operation. To perform a mass erase operation using bootloader, two options are available:

 

– Erase all sectors one by one using the Erase command

 

– Set protection level to Level 1. Then, set it to Level 0 (using the Read protect command and then the Read Unprotect command). This operation results in a mass erase of the internal Flash memory

In your case, I recommend you to use the second solution: Set protection level to Level 1, then set it to Level 0.

-Mayla-

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.

Adam1
Associate II

Hello Amel,

I would like to ask if you could tell me in which specification and where it's clearly described which MCU families don't support mass erase? In AN2606 there is only info that mass erase is not support in all chips. I would like to know which erase method should be used for connected chip, instead of making try-fail procedure, because NACK may means many things (wrong CRC, corrupted transmission etc.).

Additionally how I can get flash size through bootloader? I couldn't find any command to read it. When I try to read 'Flash size register' content with Read Memory command, I've got NACK because this register's address is out of allowed memory range to read.

To give you more information to be able to reproduce it:

-I'm using nucleo STM32L073 with 192kB flash (PID 0x447)

-reading from System Memory is allowed only in range 0x1FF00000 - 0x1FF01FFF (AN2606 Rev35 page.277)

-Flash size register is at address 0x1FF8007C

What's surpised me, reading from address 0x1FF80000 is ok, but from 0x1FF8007C gives NACK.

BR,

Adam