cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F415F415RG Unprotect Flash

webbbn
Associate
Posted on September 04, 2013 at 18:14

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?

#flash #f415-flash-unprotect-openocd
2 REPLIES 2
totti001
Associate II
Posted on September 04, 2013 at 20:16

Use St-link utility http://www.st.com/web/en/catalog/tools/PF258168 to unprotect the flash area.

jpeacock2399
Associate II
Posted on September 05, 2013 at 00:53

You probably have the write protect bits turned on in the opton byte.  The first 4 sectors are 16KB, targeted for a bootloader.  Sounds like sector 0 has a write protected bootloader so you can't accidently erase it.  If your JTAG has a utility to clear the WP option bits use that, otherwise you can send commands to the flash unit to clear the option byte.

  Jack Peacock