cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474 device detected but unable to flash. "Error: failed to erase memory"

AScen.1
Associate II

I have been flashing to my custom board that has STM32G474 MCU. But once when I tried to set the BFB2 bit manually using ST Link utility (while keeping nSWBOOT0 reset, and nBOOT0 set), the device is now no more programmable. The device is still detectable using STLink, and I am able to change the option bytes successfully using ST Link. But when I try to flash a binary it always give me programming error.

Also tried with SEGGER Jlink to flash. Below is the log while trying to flash using Jlink:

SEGGER J-Link Commander V6.86f (Compiled Oct 23 2020 18:01:48)

DLL version V6.86f, compiled Oct 23 2020 18:00:13

J-Link Command File read successfully.

Processing script file...

J-Link connection not established yet but required for command.

Connecting to J-Link via USB...O.K.

Firmware: J-Link V11 compiled Oct 5 2020 14:56:48

Hardware version: V11.00

S/N: 261000745

License(s): FlashBP, GDB

OEM: SEGGER-EDU

VTref=3.309V

Target connection not established yet but required for command.

Device "STM32G474RC" selected.

Connecting to target via SWD

Found SW-DP with ID 0x2BA01477

DPIDR: 0x2BA01477

Scanning AP map to find all available APs

AP[1]: Stopped AP scan as end of AP map has been reached

AP[0]: AHB-AP (IDR: 0x24770011)

Iterating through AP map to find AHB-AP to use

AP[0]: Core found

AP[0]: AHB-AP ROM base: 0xE00FF000

CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)

Found Cortex-M4 r0p1, Little endian.

FPUnit: 6 code (BP) slots and 2 literal slots

CoreSight components:

ROMTbl[0] @ E00FF000

ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7

ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT

ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB

ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM

ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU

ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM

Cortex-M4 identified.

Reset delay: 0 ms

Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.

Reset: Halt core after reset via DEMCR.VC_CORERESET.

Reset: Reset device via AIRCR.SYSRESETREQ.

Downloading file [C:\Users\azeem\Office\Charge_Controller_Pvt\cloudsolar-node-firmware\zephyr\build\zephyr\zephyr.bin]...

****** Error: Failed to erase sectors 0 @ address 0x08000000 ((erase error))

Failed to erase sectors.

Unspecified error -1

Reset delay: 0 ms

Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.

Reset: Halt core after reset via DEMCR.VC_CORERESET.

Reset: Reset device via AIRCR.SYSRESETREQ.

Writing DP register 1 = 0x00000000 (0 write repetitions needed)

Reading DP register 1 = 0x20000040 (0 read repetitions needed)

Script processing completed.

1 REPLY 1
Imen.D
ST Employee

Hello @AScen.1,

If your problem is resolved, please share your solution. This can be very helpful for Community users.

If you have already this issue, please download and use STM32CubeProgrammer to erase memory.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen