cancel
Showing results for 
Search instead for 
Did you mean: 

Error: failed to erase memory

ABouk
Associate II

Good afternoon, I was trying to debug a program on my new stm32f103C8T6 chip using the st-link v2 programmer, but i always get the same error : Error: failed to erase memory

I have tried the procedure with multiple boards so i guess that the problem is software, here is the full console output :

STMicroelectronics ST-LINK GDB server. Version 5.2.3

Copyright (c) 2019, STMicroelectronics. All rights reserved.

Starting server with the following options:

    Persistent Mode      : Disabled

    Logging Level       : 1

    Listen Port Number     : 61234

    Status Refresh Delay    : 15s

    Verbose Mode        : Disabled

    SWD Debug         : Enabled

Waiting for debugger connection...

Debugger connected

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.1.0          

   -------------------------------------------------------------------

Log output file:  /tmp/STM32CubeProgrammer_k3pQvR.log

ST-LINK SN : 33FF6D064E59343942520343

ST-LINK FW : V2J33S7

Voltage   : 3.20V

SWD freq  : 4000 KHz

Connect mode: Under Reset

Reset mode : Hardware reset

Device ID  : 0x410

Device name : STM32F101/F102/F103 Medium-density

Flash size : 63.999 MBytes

Device type : MCU

Device CPU : Cortex-M3

Memory Programming ...

Opening and parsing file: ST-LINK_GDB_server_JSWBJu.srec

 File     : ST-LINK_GDB_server_JSWBJu.srec

 Size     : 9716 Bytes

 Address    : 0x08000000 

Erasing memory corresponding to segment 0:

Erasing internal memory sectors [0 9]

Error: failed to erase memory

Error: failed to erase memory

Encountered Error when opening /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.macos64_1.0.0.201904021149/tools/bin/STM32_Programmer_CLI

Error in STM32CubeProgrammer

Error! Failed to read target status 

Debugger connection lost.

Shutting down...

Thanks !

20 REPLIES 20
MSmit.15
Associate

I was having similar problems after I updated STM32CubeIDE from 1.9.0 to 1.10.1 but I had also seen it after I installed v1.9.0 too and forgot how I fixed it.

Basically, the IDE tries to run STLink at 24000 kHz which my target did not seem to like. I reduced it to 21000 kHz and things worked properly.

To set it, in the IDE with the project loaded, right click on the project name in the Project Explorer window. Properties->Run/Debug Settings. Select the project name and then 'Edit'. Under the 'Debugger' tab you can find the interface frequency.

My suspicion is that when I updated the IDE to 1.10.1 it reset the STLink frequency back to the default clock speed.