bitcraze / crazyflie-clients-python

Host applications and library for Crazyflie written in Python.
Other
307 stars 471 forks source link

Accept flashing of .zip files without target #664

Closed krichardsson closed 1 year ago

krichardsson commented 1 year ago

This PR fixes a bug in the cfloader (from command line) that makes it imposiible to flash .zip files. There is currently a requirement that a target is supplied, also if everything in the zip should be flashed. The changes in the PR makes cfloader behave as stated in the documentation.

knmcguire commented 1 year ago

Tried it out and it works! We should probably make an better error message when you give the wrong target (like a list of options) but this is beyond the scope of the PR. We can make a seperate issue

(venv310) PS C:\Users\kimbe\Downloads> cfloader flash .\firmware-cf2-2023.02.zip -w radio://0/80/2M/E7E7E7E704
Reset to bootloader mode ...
Flashing 1 of 2 to stm32 (fw): 262363 bytes (257 pages) ..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10.......7Flashing 2 of 2 to nrf51 (fw): 67739 bytes (67 pages) .1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1Could not save cache, no writable directory
Could not save cache, no writable directory
(venv310) PS C:\Users\kimbe\Downloads> cfloader flash .\cf2-2023.02.bin -w radio://0/80/2M/E7E7E7E704
Reset to bootloader mode ...
The flash action with a non .zip file requires a target
(venv310) PS C:\Users\kimbe\Downloads> cfloader flash .\cf2-2023.02.bin cf2 -w radio://0/80/2M/E7E7E7E704
Traceback (most recent call last):
  File "C:\Users\kimbe\Development\bitcraze\python\venv310\Scripts\cfloader-script.py", line 33, in <module>
    sys.exit(load_entry_point('cfclient', 'console_scripts', 'cfloader')())
  File "c:\users\kimbe\development\bitcraze\python\crazyflie-clients-python\src\cfloader\__init__.py", line 116, in main
    [target, type] = t.split("-")
ValueError: not enough values to unpack (expected 2, got 1)
(venv310) PS C:\Users\kimbe\Downloads> cfloader flash .\cf2-2023.02.bin stm32-fw -w radio://0/80/2M/E7E7E7E704
Reset to bootloader mode ...
Flashing 1 of 1 to stm32 (fw): 262363 bytes (257 pages) ..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10.......7