2025-03-12 10:36 AM
Hey,
I have a stm32f407 discovery board, I flashed a code using stm32ide to store some integer data in sector 11 of flash memory(0x080E0000) and then read the data and blink led if it matched.
Now I commented the code to write data and tried just read data at that location, but when i tried to flash code using stm32ide onto the board it failed. Got this error in the console.
Error: ST-LINK error (DEV_TARGET_NOT_HALTED)
Error message from debugger back end:
Error finishing flash operation
Failed to execute MI command:
load D:\\Stm32_projects\\flash_memory\\Debug\\flash_memory.elf
Error message from debugger back end:
Error finishing flash operation
Failed to execute MI command:
load D:\\Stm32_projects\\flash_memory\\Debug\\flash_memory.elf
Error message from debugger back end:
Error finishing flash operation
Error finishing flash operation
But if I try to flash code using stlink utility it works fine.
Solved! Go to Solution.
2025-03-12 12:00 PM
In your program, wait 1 second before accessing the flash. Doing so just after reset causes the debugger to be unable to attach.
2025-03-12 11:05 AM
If you enabled Watchdog Timer (IWDG) or certain low-power modes, the MCU might reset or lock up before the debugger can connect.
Try a full chip erase using ST-Link Utility or STM32CubeProgrammer
st-flash erase
Then reflash your firmware.
2025-03-12 11:35 AM
I do not have any watchdog enabled
Yes it does work after full chip erase but it that case my purpose of storing data in flash goes away as the data is no more available.
2025-03-12 12:00 PM
In your program, wait 1 second before accessing the flash. Doing so just after reset causes the debugger to be unable to attach.