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
Solved! Go to Solution.
2025-11-05 2:01 AM
The issue is solved! It turned out to be a power problem, my previous power source was unstable, causing flash erase/program failures. After changing it everything worked perfectly. Thanks to everyone for the help and suggestions!
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 ...
2025-11-04 1:45 PM
Dear @GHanj ,
Is that possible to share a picture of the device marking on top of your F4 discovery board ? It may happen the device or board is damaged - try to program in 8-bit and do a Mass Erase . If not helping - try to erase the upper sectors of the flash having 64k and 128kbytes if working that means the small sectors 0 , 1 etc reached maximum cumulative Erase cycle which is up to 10kcyles .
hope it is helping you.
STOne-32
2025-11-05 2:01 AM
The issue is solved! It turned out to be a power problem, my previous power source was unstable, causing flash erase/program failures. After changing it everything worked perfectly. Thanks to everyone for the help and suggestions!
2025-11-05 2:06 AM
Dear @GHanj ,
Thank you for feedback and Happy to see your board is working perfectly now .
Have a great day,
STOne-32