1

We are trying to read out portions of our STM32F0x microcontrollers with OpenOCD, which we also use to program them. However, the flash read_bank command doesn't work as documented. Whatever we input, the error is:

flash read_bank 0 test.bin: command requires more arguments

We invoke it for example by:

sudo openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c "init" -c "reset init" -c "flash read_bank 0 test.bin" -c "exit"

Other flash operations work as expected, such as:

openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c init -c "flash info 0" -c exit

or

openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c init -c "flash banks" -c exit

The command flash read_bank seems to be very rarely used. This is at least, was my google search said. Does anybody have an idea on how to use this command?

Janos
  • 796
  • 1
  • 9
  • 26

1 Answers1

2

The flash read_bank comannd requires 2 more arguments: Offset and length.

So on a STM32 MCU I you could use

flash read_bank 0 test.bin 0x8000000 0x4000

to read the first 16KB of the flash memory.

Remember there is a "help" command in OpenOCD, too.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • Have you tried this? For us, it doesn't matter which and how many arguments we pass. The error is always "requires more arguments": `sudo openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c "init" -c "reset init" -c "flash read_bank 0 test.bin 0x8000000 0x4000" -c "exit"` – Janos Nov 10 '17 at 08:38
  • `flash read_bank 0 test.bin 0x8000000 0x4000: command requires more arguments in procedure 'flash'` – Janos Nov 10 '17 at 08:51
  • http://openocd.org/doc/html/Flash-Commands.html#Erasing_002c-Reading_002c-Writing-to-Flash The documentation says offset and length are optional. – Janos Nov 10 '17 at 08:55
  • Check the docs shipped with your OpenOCD version. Mine still has both offsert and length not marked as optional. – Turbo J Nov 10 '17 at 16:55
  • Regardless of the documentation - with or without the offset and length arguments, the command doesn't work and asks for "more arguments". I can add many more arguments and it still asks for more. – Janos Nov 15 '17 at 08:35
  • `flash read_bank 0 test.bin` works in current OpenOCD git, just tested that with my LPC17xx. Note that this is significanly newer than 10.0 release. – Turbo J Nov 16 '17 at 20:13