Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make uf2conv.py available via pip #42

Open
galak opened this issue Feb 5, 2021 · 5 comments
Open

Make uf2conv.py available via pip #42

galak opened this issue Feb 5, 2021 · 5 comments

Comments

@galak
Copy link

galak commented Feb 5, 2021

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.

@mmoskal
Copy link
Member

mmoskal commented Feb 5, 2021

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

@ladyada
Copy link
Collaborator

ladyada commented Feb 5, 2021

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!

@brentru
Copy link

brentru commented Jun 21, 2021

+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

vkottler added a commit to vkottler/yambs that referenced this issue May 17, 2023
Uses code originally from microsoft/uf2 on GitHub.
microsoft/uf2#42
@vkottler
Copy link

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

(usage is also here)

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 vkottler/yambs#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.

@vkottler
Copy link

vkottler commented May 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants