Open galak opened 3 years ago
I would be happy for someone from community to take this on. I don't really know much about Python ecosystem.
Someone from Adafruit maybe? cc @ladyada
one needs to register the package with pypi to have it available over pip, we couldn't do it on microsoft's behalf - but happy to give advice!
+1 for making this available via pip so we can easily include uf2conv it in Actions CI scripts instead of cloning this repo and navigating
I added this code as a sub-command of yambs:
$ python -m venv venv
$ ./venv/bin/pip install yambs
...
$ ./venv/bin/mbs uf2conv --help
usage: mbs uf2conv [-h] [-b BASE] [-f FAMILY] [-o FILE] [-d DEVICE_PATH] [-l] [-c] [-D] [-w] [-C] [-i] [INPUT]
positional arguments:
INPUT input file (HEX, BIN or UF2)
options:
-h, --help show this help message and exit
-b BASE, --base BASE set base address of application for BIN format (default: 0x2000)
-f FAMILY, --family FAMILY
specify familyID - number or name (default: 0x0)
-o FILE, --output FILE
write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible
-d DEVICE_PATH, --device DEVICE_PATH
select a device path to flash
-l, --list list connected devices
-c, --convert do not flash, just convert
-D, --deploy just flash, do not convert
-w, --wait wait for device to flash
-C, --carray convert binary file to a C array, not UF2
-i, --info display header information from UF2, do not convert
I split the code up a bit and had to do some refactoring to satisfy mypy/pylint/etc. CI for this project.
I'm very early into building this package (working on https://github.com/vkottler/yambs/issues/5), but I have a Metro M4 Grand Central and stumbled upon this repository and issue.
I also added unit testing which hits most of the statements, but still had to # pragma: nocover
a lot of code that deals with malformed-file error handling and USB storage device copying.
Noting here because I'm going to make a behavioral change to my fork - the uf2conv
command will write the output file to drive(s) that it finds connected by default, even if you don't specify -D / --deploy
at the command-line.
Seems sane/convenient depending on the project and build setup, but I'm building UF2's for multiple boards, so this opens up the possibility to put a UF2 on the wrong board.
The tool just ought not to go updating firmware if -D / --deploy
isn't specified.
By having this available via pip it makes it easier for people to use this in other projects and keep track as updates are made to support additional boards and such.