cancel
Showing results for 
Search instead for 
Did you mean: 

Error: failed to erase memory

Nsg1987
Senior

Hi,

While flashing code in STM32G474VBT6, I am getting below error. After reinstalling cube ide and cube programmer, same error continues.

 

STMicroelectronics ST-LINK GDB server. Version 7.4.0

Copyright (c) 2023, 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

InitWhile : Enabled

 

Waiting for debugger connection...

Debugger connected

Waiting for debugger connection...

Debugger connected

Waiting for debugger connection...

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

STM32CubeProgrammer v2.14.0

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

 

 

 

Log output file: C:\Users\NIKHIL~1\AppData\Local\Temp\STM32CubeProgrammer_a02888.log

ST-LINK SN : 68005200040000363036544E

ST-LINK FW : V2J42S7

Board : --

Voltage : 3.26V

SWD freq : 4000 KHz

Connect mode: Under Reset

Reset mode : Hardware reset

Device ID : 0x469

Revision ID : Rev X

Device name : STM32G47x/G48x

Flash size : 128 KBytes

Device type : MCU

Device CPU : Cortex-M4

BL Version : 0xD5

Debug in Low Power mode enabled

 

 

 

Memory Programming ...

Opening and parsing file: ST-LINK_GDB_server_a02888.srec

File : ST-LINK_GDB_server_a02888.srec

Size : 73.29 KB

Address : 0x08000000

 

 

Erasing memory corresponding to segment 0:

Error: Operation exceeds memory limits

 

 

Error: failed to erase memory

Encountered Error when opening C:\ST\STM32CubeIDE_1.13.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.1.0.202305091550\tools\bin\STM32_Programmer_CLI.exe.

Error in STM32CubeProgrammer

Shutting down...

Exit.

 

Nsg1987_0-1691554608910.png

Can anyone help me to get solution?

Thanks

Nikhil

 

@Sara BEN HADJ YAHYA 

 

20 REPLIES 20

Hello @HMoens 

Yeah Agree with you. 

ManuTest
Associate

I had the same weird erase problem with 1.13 - it worked with older versions and also with STM32CubeProgrammer I can still erase and program the microcontroller (STM32G473 in my case) without a problem using the same ST-LINK/V2 and same frequency setting.

Now I tried the new Version 1.14 - still same problem.

For a product like the STM32CubeIDE, which is still actively developed, it is inacceptable to be forced to use an old version. Calling this downgrade a "solution" is an outrage.

mikez33308
Associate II

I was experiencing the same error on my NUCLEO-WB55RG. It was due to a few things related to my un-orthodox setup.

Setup:

1.) NUCLEO-WB55RG is setup as an I2C Slave connected to Master STM32F7 controller. Powering of the NUCLEO-WB is from the STM32F7 controller.

2.) NUCLEO-WB55RG project is loading the X-CUBE-TOUCHGFX, Note: Still awaiting delivery of my GFX01M2 card

 

First issue (Error: failed to erase memory) was related to the Power source of the NUCLEO-WB.

Resolution: The JP1 jumpers for the NUCLEO-WB need to be set too 5V EXT, thus supplying power for the St-Link and the Board itself.

 

Second Issue (Failed to initialize external memory!) Related to initializing QSPI when the address is not addressable.

 

 

STMicroelectronics ST-LINK GDB server. Version 7.5.0

Copyright (c) 2023, 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

InitWhile : Enabled

 

Failed to initialize external memory!

Resolution: Temporarily disable the External Loader in the Debug configuration.

mikez33308_0-1707517594300.png

WIN_20240209_17_32_40_Pro.jpg

 Hope this saves someone's time.

ManuTest
Associate

Thanks, that is good to know! Surely, the error can be caused by different problems.

 

But the thing discussed here is about the problem with the STM32CubeIDE.

The debugging of STM32G4xx just wouldn't work with IDE 1.13 and 1.14 - which was clearly a bug.

Accessing the CPU with the STM32CubeProgrammer always worked so I could rule out hardware issues.

But now - good news: They finally fixed it. Version 1.14.1 works again (for me).

_kalpesh
Associate II

Hey!
i faced same error when i was trying to write flash memory  for stm32
i changed debug configurations for that project.

need to change Reset Behaviour to None which comes under debugger tab of debug configurations.
i hope this resolves the error

I have a similar problem, my whole team doesnt want to update STMcubeIDE , they are afraid random *** stops working.

 

I am using a STLINK-V3SET, with firmware 

Javier1_0-1710350658820.png

 

 

It works only with IDE v1.10, shich is very sad, I tried with stmCubeIDE v1.12 1.13 1.14 and same error:

Javier1_1-1710350714684.png

 

My guts are telling me ST changed something in the way linker scripts or the makefile is generated (AGAIN) so older projects generated with older IDE versions (older than 1.10) are not linking correctly anymore

 

we dont need to firmware by ourselves, lets talk

this didnt work for me

we dont need to firmware by ourselves, lets talk

hey @RhSilicon pleaze dont give silly solutions like this. 😂 im also getting same issue with cubeIDE and IAR work bench. according to you it was IDE version issue so it should have to work with other tool chains IDE like MDKARM or EWARM.

I tried to flash the code with CubeIDE, IAR work bench and also with Cube Programmer in all of these software it showing only one error that is failed to erase memory.

We found how to go around the problem : 

The issue is with cubeProgrammer versions newer than 2.13.
If using a standalone cubeProgrammer newer than 2.13 and trying to flash an specific .elf file will result in Erasing memory segment 0 error.

 

When using  cubeProgrammer version 2.13 the thing flashes , no complaining.

 

So the problem here is cubeIDE version 1.12.1 comes with a cubeProgrammer v2.13 CLI plugin, this means flashing or debugging our project with cubeIDE 1.12.1 works, but the same thing with newer cubeIDE versions doesnt.

 

How to fix this, folder swapping plugins from two IDE versions, (disclaimer its ugly):

  1. Download both cubeIDE v1.12.1 and your newer IDE (1.15.0 in my case)Javier1_0-1714061942182.png

     

  2. Try (unsuccesfully) to flash or debug your code, at least one time ,with your newest IDE(mine is 1.15.0).
    If you dont do this the IDE will crash when trying to debug after the folder swap.

  3. Erase the contents of com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_..................
    Javier1_1-1714062103009.png
    Javier1_2-1714062170658.png

     

  4. Copy the contents of the equivalent folder from cubeIDE v1.12.1
    com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.600.202301161003
    Javier1_3-1714062364474.png


  5. Paste in your now empty cubeIDE 1.15.0 folder
  6. Enjoy
    Javier1_6-1714062491984.png

 

we dont need to firmware by ourselves, lets talk
mxo
Associate III

Hello @Javier1,

Thank you for solution, oh yes, now my IDE 1.15.1 (it was 1.14.1 till yesterday) with my STM32G473 board finally works!!

I enjoyed so too much while I found your solution..

B.R.

mxo