'stm32x device protected' error on Electron with OpenOCD

When trying to debug Electron with JTAG, OpenOCD throws following trace.
Any hint appreciated.

Open On-Chip Debugger 0.9.0 (2015-05-19-12:09)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport “jtag”. To override use 'transport select '.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Started by GNU ARM Eclipse
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f2x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f2x.bs tap/device found: 0x06411041 (mfg: 0x020, part: 0x6411, ver: 0x0)
Info : stm32f2x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting ‘gdb’ connection on tcp/3333
Info : device id = 0x20076411
Info : flash size = 1024kbytes
undefined debug reason 7 - target needs reset
Info : JTAG tap: stm32f2x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f2x.bs tap/device found: 0x06411041 (mfg: 0x020, part: 0x6411, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000a98 msp: 0x20020000
semihosting is enabled
Info : JTAG tap: stm32f2x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f2x.bs tap/device found: 0x06411041 (mfg: 0x020, part: 0x6411, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000a98 msp: 0x20020000, semihosting
Error: stm32x device protected
Error: failed erasing sectors 5 to 6
Error: flash_erase returned -4
Info : dropped ‘gdb’ connection

1 Like

Hi,

did you find any solution on your problem? I’m facing the same issue.
Maybe I need to use the ST-Link and disable some protection settings for the flash?

You should be able to set the STM32F2xx readout protection level back to 0 (able to be read) with the OpenOCD commands:

reset halt
stm32f1x unlock 0
reset halt

Note that if you are able to set the unlock to 0 without error but then you still get an error that the device is protected it may be because the processor is damaged. When that happens there’s no way to recover it.

1 Like