STM32F103VB: Error: No flash at address 0x00000000

Title says most.

I’m running version 0.4.0, using the Olimex JTAG-tiny, and starting up with

openocd -f interface/olimex-jtag-tiny.cfg -f target/stm32.cfg

I can query RAM, write registers and have ports work correctly (lighting up the LEDs is always an essential first step – yes?)

But when I try to write to flash I get the message “Error: No flash at address 0x00000000”.

I’m typing “reset halt”, then “flash write_image erase code/st/Debug/myprogram.elf”. Open OCD responds with:

auto erase enabled

Info : device id = 0x20036410

Info : flash size = 128kbytes

Error: No flash at address 0x00000000

Error: No flash at address 0x0001b358

wrote 0 bytes from file code/st/Debug/myprogram.elf in 0.004079s (0.000 kb/s)

Does anyone have a clue what I’m doing wrong here? This process works perfectly on my Luminary parts.

What, no answers? Wait long enough and the student will find it himself!

My problem comes in two parts. The first was that, the ST parts have the flash “actually” residing at 0x08000000, but aliased to 0x00000000 on appropriate setting of the boot mode – so when I tried to program flash at 0x00000000, OF COURSE there was no flash there. The second was that the ST part needs to have the flash unlocked before it’ll write – and it needs it done through a special ST-specific command.

So the procedure is:

Type ```
stm32x unlock 0

OpenOCD will advise you that you need to reset the processor -- do so.

Now you can write to flash, remembering the offset:

flash write_image erase myfile.elf 0x08000000


And -- joy. Or at least joy that you've programmed flash. I'm off to find out if I can run this puppy without hosing JTAG: wish me luck!