Flash programming with Eclipse + OpenOCD, & read protect

Hello,

I am using Eclipse + OpenOCD (ver. 0.1.0) to program the FLASH of STM32F103ZCT6 in the Eclipse environment, which was working

very good so far.

But now it has stopped working & It produces following dump in the console of the ECLIPSE.

Open On-Chip Debugger 0.1.0 (2009-01-21-21:15) Release

BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS

$URL: https://kc8apf@svn.berlios.de/svnroot/r … /openocd.c $

500 kHz

500 kHz

Info : JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (Manufacturer: 0x23b, Part: 0xba00, Version: 0x3)

Info : JTAG Tap/device matched

Info : JTAG tap: stm32.bs tap/device found: 0x06414041 (Manufacturer: 0x020, Part: 0x6414, Version: 0x0)

Error: JTAG tap: stm32.bs got: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)

Error: JTAG tap: stm32.bs expected 1 of 1: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)

Error: trying to validate configured JTAG chain anyway…

Info : JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (Manufacturer: 0x23b, Part: 0xba00, Version: 0x3)

Info : JTAG Tap/device matched

Info : JTAG tap: stm32.bs tap/device found: 0x06414041 (Manufacturer: 0x020, Part: 0x6414, Version: 0x0)

Error: JTAG tap: stm32.bs got: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)

Error: JTAG tap: stm32.bs expected 1 of 1: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)

Error: trying to validate configured JTAG chain anyway…

target state: halted

target halted due to debug-request, current mode: Handler HardFault

xPSR: 0x41000003 pc: 0x20000014

verify Capture-IR is disabled

target state: halted

target halted due to debug-request, current mode: Handler HardFault

xPSR: 0x41000003 pc: 0x20000014

Info : device id = 0x10016414

Error: SWJ-DP STICKY ERROR

Error: dcb_dhcsr 0x30003, nvic_shcsr 0x20000, nvic_cfsr 0x1, nvic_bfar 0xe000edf8

Warn : STM32 flash size failed, probe inaccurate - assuming 512k flash

Info : flash size = 512kbytes

Error: stm32x device protected

stm32x mass erase complete

Error: timed out while waiting for target halted

Error: error executing stm32x flash write algorithm

Error: flash writing failed with error code: 0xfffffc7a

Error: error writing to flash at address 0x08000000 at offset 0x00000000 (-902)

By the way, before i got this message, i downloaded program to READ PROTECT the Flash,

using the following code

if(FLASH_GetReadOutProtectionStatus() != SET)

{

FLASH_Unlock();//This MUST done first

FLASH_ReadOutProtection(ENABLE);

NVIC_GenerateSystemReset();

}

Can someone explain what went wrong & help me in getting this working again?

You must download a corresponding program to UNPROTECT the flash.

Look in the same place where you found the READ PROTECT code.

Also read STM32F10xxx Flash programming manual (PM0042) section 2.4.1

Hello mlu,

After this problem, I wanted to download the code to unprotect the flash.

But now i can NOT download any code, since flash writing fails, after mass erase, as per the dump in Eclipse.

There are two ways to do this

  • Put the unprotect code in RAM

or

  • Go through the exact writes to the flash controller registers that is needed, and do this by hand with a sequence of mww operations.

You should not need more a dozen flash controller operations

Its a pain but it is doable

try using the following to unlock the device, assuming flash is on bank 0

stm32x unlock 0

then perform a hardware reset, sometimes a power cycle may be required.

Cheers

Spen