cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to write data to flash memory

SorabhR
Associate

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.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

In your program, wait 1 second before accessing the flash. Doing so just after reset causes the debugger to be unable to attach.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
ahsrabrifat
Associate III

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.

 

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.

TDK
Guru

In your program, wait 1 second before accessing the flash. Doing so just after reset causes the debugger to be unable to attach.

If you feel a post has answered your question, please click "Accept as Solution".