AnsweredAssumed Answered

STM32F415F415RG Unprotect Flash

Question asked by webb.brian on Sep 4, 2013
Latest reply on Sep 5, 2013 by Jack Peacock
I'm trying to flash a custom bootloader to one of these devices: http://www.mikroe.com/mini/stm32/, and they seem to have protected their bootloader.  I'm using an STM34F4discovery board for SWD, and OpenOCD (0.7.0) to program the board, and I've tried every openocd command that I can find to unprotect the flash and nothing works.

Here's two examples of what I've tried:

/home/webbb/projects/OpenOCD/bin/openocd -d0 -s /home/webbb/projects/OpenOCD/share/openocd/scripts -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg -c init -c "reset halt" -c "flash probe 0" -c "stm32f2x unlock 0" -c "reset init" -c "flash protect 0 0 last off" -c "stm32f2x mass_erase 0"
Open On-Chip Debugger 0.7.0 (2013-09-03-21:18)
Licensed under GNU GPL v2
For bug reports, read
     http://openocd.sourceforge.net/doc/doxygen/bugs.html
debug_level: 0
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
flash 'stm32f2x' found at 0x08000000
stm32f2x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
cleared protection for sectors 0 through 11 on flash bank 0
Error: stm32x device protected
stm32x mass erase failed
in procedure 'stm32f2x'

and

/home/webbb/projects/OpenOCD/bin/openocd -d0 -s /home/webbb/projects/OpenOCD/share/openocd/scripts -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg -c init -c "reset halt" -c "flash probe 0" -c "stm32f2x unlock 0" -c "reset init" -c "flash protect 0 0 last off" -c "flash erase_sector 0 0 last"
Open On-Chip Debugger 0.7.0 (2013-09-03-21:18)
Licensed under GNU GPL v2
For bug reports, read
     http://openocd.sourceforge.net/doc/doxygen/bugs.html
debug_level: 0
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
flash 'stm32f2x' found at 0x08000000
stm32f2x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
cleared protection for sectors 0 through 11 on flash bank 0
Error: stm32x device protected
Error: failed erasing sectors 0 to 11

I can flash to other parts of flash just fine, but not the first sector.  Any ideas on how I can fix this?

Outcomes