florisla / stm32loader

Flash firmware to STM32 microcontrollers using Python.
GNU General Public License v3.0
109 stars 53 forks source link

KeyError length error when reading flash #18

Closed N0ury closed 5 years ago

N0ury commented 5 years ago

I wanted to download the firmware from a STM32F103 Here's the command I'm using:
stm32loader -r -p /dev/cu.usbserial-A5XK3RJT -f F1 dump.bin

And here's the output:

Bootloader version 22
Chip id: 0x410 (STM32F10x Medium-density)
Device UID: FF55-0672-56497751-87184731
Flash size: 64 KiB
Traceback (most recent call last):
  File "/usr/local/bin/stm32loader", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/stm32loader/__main__.py", line 37, in main
    stm32loader_main(*sys.argv[1:])
  File "/usr/local/lib/python3.7/site-packages/stm32loader/main.py", line 318, in main
    loader.perform_commands()
  File "/usr/local/lib/python3.7/site-packages/stm32loader/main.py", line 197, in perform_commands
    self.configuration["address"], self.configuration["length"]
KeyError: 'length'

Any idea ?

florisla commented 5 years ago

When reading, you should add a -l [length] switch to indicate how many bytes you want to read and also the start address (-a [address]).

E.g. -l 4096 -a 0x08000000.

N0ury commented 5 years ago

Thanks, it works! Just one more question, if I want all content what should be the best arguments

florisla commented 5 years ago

The F103 has 64KiB of flash, but unofficially supports 128KiB.

Use -l 0x10000 or -l 0x20000. The address 0x08000000 is already correct.

N0ury commented 5 years ago

Thanks for all