Hello everyone,
Im currently having a strange behaviour using OpenOCD.
Im using a STM32VLDiscovery Board, which is a STLINK tied to a STM32F100 via SWD.
I have written a small test application, which I can load successfully onto the STM32 using the original STVP Software from STM, after I remov the Read out Protection.
With the Readout Protection enabled, I can’t do anything on the STM32F100.
Now Im trying to move to OpenOCD and installed the WinUSB driver using the “Zadig”-tool, and OpenOCD establishes the connection just fine.
F:\Apps\openocd\openocd-0.6.0-rc2\openocd-0.6.0-rc2\bin-x64>openocd-x64-0.6.0-rc2.exe -f board/stm32vldiscovery.cfg -c init -c "halt" -c "stm32f1x options_read 0" -c shutdown
Open On-Chip Debugger 0.6.0-rc2 (2012-08-29-09:26)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
adapter speed: 1000 kHz
Info : clock speed 1000 kHz
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Warn : target was in unknown state when halt was requested
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Info : device id = 0x10016420
Info : flash size = 5384kbytes
Option Byte: 0x3fffffe
Readout Protection On
Software Watchdog
Stop: No reset generated
Standby: No reset generated
shutdown command invoked
As you can see, the Readout Protection of the STM32 chip is activated.
Strangely I noticed now the following:
I read around an checked for commands to disable the Read Out Protection, but I cant figure out how to do it. Sadly “stm32f1x unlock 0” does not do anything at all. No matter if I do a “reset halt” or cycle the power supply afterwards. The readout protection is still enabled.
F:\Apps\openocd\openocd-0.6.0-rc2\openocd-0.6.0-rc2\bin-x64>openocd-x64-0.6.0-rc2.exe -f board/stm32vldiscovery.cfg -c init -c "halt" -c "stm32f1x options_read 0" -c "stm32f1x unlock 0" -c "reset halt" -c "stm32f1x options_read 0" -c shutdown
Open On-Chip Debugger 0.6.0-rc2 (2012-08-29-09:26)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
adapter speed: 1000 kHz
Info : clock speed 1000 kHz
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Warn : target was in unknown state when halt was requested
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Info : device id = 0x10016420
Info : flash size = 5384kbytes
Option Byte: 0x3fffffe
Readout Protection On
Software Watchdog
Stop: No reset generated
Standby: No reset generated
Info : Device Security Bit Set
stm32x 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
Option Byte: 0x3fffffe
Readout Protection On
Software Watchdog
Stop: No reset generated
Standby: No reset generated
shutdown command invoked
These are the scripts I am using.
openocd.cfg:
init
proc program {file} {
reset halt
stm32f1x unlock 0
reset halt
stm32f1x mass_erase 0
flash write_image $file
reset run
shutdown
}
External tool configuration in eclipse:
-f board/stm32vldiscovery.cfg
-f ${project_loc}\openocd.cfg
-c "program {${project_loc}\${config_name:${project_name}}\${project_name}.hex}"
With the following result:
Open On-Chip Debugger 0.6.0-rc2 (2012-08-29-09:26)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
adapter speed: 1000 kHz
Info : clock speed 1000 kHz
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
program
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000850 msp: 0x20002000
Info : device id = 0x10016420
Info : flash size = 128kbytes
stm32x 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: 0x08000850 msp: 0x20002000
stm32x mass erase complete
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x2000003a msp: 0x20002000
wrote 2268 bytes from file F:\Projekte\_EclipseWorkspaces\STM32\Test\Debug\Test.hex in 0.306641s (7.223 KiB/s)
shutdown command invoked
As you can see, there is no error message, but also the target does not execute the uploaded program at all.
I also opened a German thread [here, which led me to believe, that this has to be a bug within OpenOCD.
Can anyone confirm? Thanks for any replies! I hope I can return the favour in the future.
Please let me know if you need any more information as I will happily provide it.](OpenOCD und STM32VLDiscovery - Mikrocontroller.net)