2013-09-04 09:14 AM
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 v2For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.htmldebug_level: 0target state: haltedtarget halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffcflash 'stm32f2x' found at 0x08000000stm32f2x unlocked.INFO: a reset or power cycle is required for the new settings to take effect.target state: haltedtarget halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffccleared protection for sectors 0 through 11 on flash bank 0Error: stm32x device protectedstm32x mass erase failedin 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 v2For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.htmldebug_level: 0target state: haltedtarget halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffcflash 'stm32f2x' found at 0x08000000stm32f2x unlocked.INFO: a reset or power cycle is required for the new settings to take effect.target state: haltedtarget halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffccleared protection for sectors 0 through 11 on flash bank 0Error: stm32x device protectedError: failed erasing sectors 0 to 11I 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-openocd2013-09-04 11:16 AM
Use St-link utility http://www.st.com/web/en/catalog/tools/PF258168 to unprotect the flash area.
2013-09-04 03:53 PM
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