-1

I want to write a specific value to an address in flash using openocd. The address is 0x0003FFF0. ANd the value I want to write to it is 0xFFFFC000.

To erase that address I used: flash erase_address 0x0003FFF0 2048

but got an error message address range 0x0003fff0 .. 0x0003ffff is not sector-aligned

To fix this I ran flash info 0 to find the address to start from and then ran flash erase_address 0x38000 2048 and this worked.

Finally to write the value to flash I tried:

reset halt

mww 0x0003FFF0 0xFFFFC000

but got this error:

SWD ack not OK: 4 FAULT SWD IDCODE 0x2ba01477

artless noise
  • 21,212
  • 6
  • 68
  • 105
homeGrown
  • 375
  • 1
  • 8
  • 25
  • Could you show the code before `mww`? – Déjà vu Nov 29 '17 at 13:16
  • @RingØ Updated now, just a `reset halt` – homeGrown Nov 29 '17 at 13:30
  • this is a microcontroller and very specific to the chip (cortex-m3 is not the chip, not really related at all other than a blob that the debugger communicates through to get at the chip specific peripheral). so first off there is no reason to expect flashing from openocd to work, once we went from parallel to serial flashes that all ended (chip specific, where it wasnt necessarily before). so what chip are you using, and what openocd version and what command line and/or openocd script are you using to gain access? – old_timer Nov 29 '17 at 18:24
  • Few µC will allow direct writes to flash with `mww`. That is why openOCD has special flash write commands. – Turbo J Dec 16 '17 at 22:41

2 Answers2

0

That error message (assuming it's accurate) indicates that the debug port on the chip (the slave for the SWD connection) has detected an error. This might be a parity error on the SWD, a read polling mismatch or an AHB error response. See table 2.10 here. Without digging into which of these openOCD can handle, its hard to tell. This is only a symptom of your problem though - it is quite likely that writes directly to the flash are not supported in your chip (or at least not without some preamble to prepare the flash controller)

Sean Houlihane
  • 1,698
  • 16
  • 22
0

You cannot "just" write any value to flash memory. In (almost?) all cases you have to follow a very specific procedure to actually write something there (like set this bit, wait for some other bit, write the address to this register, write the value to that register, set another bit, wait for "done" bit, repeat...). That's why the thing you are trying to do just won't work unless you implement this particular procedure with more mww (and mmw and mdw, or variants which use 16-bits of 8-bits, as sometimes you may write only 2 bytes at once, not all 4) commands before the actual write.

Freddie Chopin
  • 8,440
  • 2
  • 28
  • 58