2025-11-04 7:28 AM - edited 2025-11-04 7:43 AM
Hi everyone,
I’m facing a serious issue with my STM32F407 MCU on a custom PCB.
I was flashing firmware from STM32CubeIDE using the onboard ST-Link from a Discovery board over SWD, and everything was working fine until one upload failed during the erase step.
Since that moment, I can’t erase or reprogram the chip anymore, even from STM32CubeProgrammer or ST-Link Utility.
le programming via STM32CubeIDE, I suddenly got this error in the ST-LINK GDB server console:
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 2]
Error: failed to erase memory
Encountered Error when opening ...\STM32_Programmer_CLI.exe
Error in STM32CubeProgrammer
Shutting down...
Exit.
After this, every subsequent attempt (from CubeIDE, CubeProgrammer, or ST-Link Utility) failed the same way.
I have tried :
Connect under Reset mode, SWD frequencies (from 4 MHz → 950 kHz → 100 kHz), RDP = Level 0 (0xAA), no write protection in Option Bytes, Tried Full Chip Erase several times -> worked few times but can no longer erase
Sometimes says “Flash erased” but still cannot program
My first concern is the MCU still OK and not permanently corrupted
What could be the cause of this problem, all I did was just connecting the SWD wires like before
2025-11-04 7:32 AM
Have you tried using the System (ROM) Bootloader ?
2025-11-04 7:42 AM
Not yet
Do you think using the system bootloader could solve it ?
2025-11-04 8:00 AM
If SWD is connected correctly, it's likely that the chip has been damaged or there is some other issue with the design. Perhaps VDDA is not connected or some other power issue. Can you share the schematic?
If this is not a hardware issue, but is instead caused by the currently loaded firmware, holding BOOT0 during reset will allow you to recover.
2025-11-04 8:01 AM
If your problem is with the SWD interface, the Bootloader avoids that ...