ST-LINK Download Program Error: flash download failed – ‘cortex m4‘

Possible cause: Project testing using ST-link download program debugging, before all good to download the program, after some tests such as power-down storage may make the chip locked up
Tried solutions: I have looked for some solutions, but most of them are not add in the programming algorithm of flash download in debug, but they don’t seem to work for me.
Final solution: Download the STM32 ST-LINK Utility software to handle the problem.

1. Connect the board to the computer using ST-LINK and open the STM32 ST-LINK Utility.

2. Click Option Bytes in Target
You don’t need to click connect in Target here, just click Option Bytes directly after opening the software, otherwise mine will prompt a can’t read memory error.
3. Change this to disable, and click apply.


4. After that, you can download the program normally in keil5.

Read More: