STM32_Programmer_CLI -c port=swd -ob displ STM32_Programmer_CLI -c port=swd -ob nSWBOOT0=1 STM32_Programmer_CLI -c port=swd -ob WRP_SECTOR=0x00000000 Some devices clear lock flags automatically after a full chip erase:
> flash write_image erase firmware.bin 0x08000000 Error: STM32 flash write protection error Error: dap service can't execute requested operation Error: Flash lock flag is locked. Please unlock it first. At this point, the flash controller rejects the write command. The following steps are ordered from safest to most aggressive. Always backup existing firmware and data before proceeding. 5.1 Software Unlock via Debugger For most ARM Cortex-M devices, the unlock is performed by clearing the Option Bytes register.
The lock mechanism can exist at multiple levels:
// Pseudo-code for bootloader if (flash_is_locked(FLASH_SECTOR_BOOT)) flash_unlock(); flash_clear_flag(FLASH_FLAG_WRPERR);