cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer failed to erase memory after one successful download

BJian
Associate

Hi there,

First time to this community, glad to see you!

I have an weird programming issue when using STM32CubeProgrammer.

I use NUCLEO-F302R8, and try to download a blink.elf to the MCU.

I can have successful download, and the LED is blinking. However, if I then try another download, it failed by saying "failed to erase memory", below is the log:

09:57:07 : Memory Programming ...
09:57:07 : Opening and parsing file: STM32F302R8-Nucleo.elf
09:57:07 : File : STM32F302R8-Nucleo.elf
09:57:07 : Size : 3420 Bytes
09:57:07 : Address : 0x08000000
09:57:07 : Erasing memory corresponding to segment 0:
09:57:07 : Erasing internal memory sectors [0 1]
09:57:07 : Download in Progress:
09:57:07 : File download complete
09:57:07 : Time elapsed during download operation: 00:00:00.247
09:57:07 : Verifying ...
09:57:07 : Read progress:
09:57:07 : Download verified successfully
09:57:16 : Memory Programming ...
09:57:16 : Opening and parsing file: STM32F302R8-Nucleo.elf
09:57:16 : File : STM32F302R8-Nucleo.elf
09:57:16 : Size : 3420 Bytes
09:57:16 : Address : 0x08000000
09:57:16 : Erasing memory corresponding to segment 0:
09:57:16 : Erasing internal memory sectors [0 1]
09:57:16 : Error: failed to erase memory
09:57:16 : Error: failed to erase memory

You can see I started download by 09:57:07, which turns out to be successful.

But when by 09:57:16, I try download again, it failed.

The problem only occurs after one successful download. So if I persist on clicking start programming, it will be: success->fail->success->fail... 

I found that there's no problem when I use "hardware reset" instead of "software reset" for "reset mode". But I don't experience this problem by using ST link utility even with "software reset".

I have tried on two win10 PC, STM32CubeProgrammer V1.4.0.

port SWD

frequency 4MHz

mode Normal

reset mode Software reset

firmware version V2J33M25

This seems to be a quite often problem, can you help me?

Thank you!

😉 :> 😅

Edit:

I think I can narrow the problem:

First, it seems related to the specific program I used for download. If I use the blink.elf(uploaded FYI), which is very small, it will always reproduce the problem. I have tried on both 302R8 and a 302CB custom board. However, if I use our custom board's production firmware(on 302CB), there will be no problem at all.

Second, I can also reproduce the similar problem by:

1.successful download blink.elf to 302R8

2. try to erase flash sectors 0,1(which blink.elf occupy) or mass erase

It always says:

Error: Sector erase operation has failed at least for one of the existing specified sectors.Please verify flash memory protection.

 But of course I don't use flash memory protection!

2 REPLIES 2

>>This seems to be a quite often problem, can you help me?

I'd wave a magic wand if it would help, but the software is a bit fragile, hopefully in time it will get fixed, and someone with some user interface experience and understanding of work flow will step in to explain how the tools should work, and actually test and validate things properly.

My personal frustration has been telling it to save an external memory (SPI FLASH) image tab I have open, it reads the internal memory, saves it to disk, and then fails, complaining it can't go beyond 1MB when i've picked an external address and a multi-megabyte size. So it picked the size field we both agreed on, and plucked an address out of the air. The GUI is very non-intuitive, and inconsistent.

I've found the command line version to at least do the job properly, and I can use scripting.

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

Nice to meet you Zero.

So I'm not alone in the darkness...