pyfu-usb


Namepyfu-usb JSON
Version 2.0.2 PyPI version JSON
download
home_pageNone
SummaryPython USB firmware update library.
upload_time2024-12-20 21:10:26
maintainerNone
docs_urlNone
authorBlock, Inc.
requires_python>=3.8
licenseMIT
keywords dfu-util pydfu
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyfu-usb: Python USB Firmware Updater

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A small library for firmware updates over USB with devices that support the [DFU](https://www.usb.org/sites/default/files/DFU_1.1.pdf) and [DfuSe](http://dfu-util.sourceforge.net/dfuse.html) protocols. Specifically, `pyfu-usb` supports _listing_ DFU capable devices and _downloading binary files_ to them.

## Compared to [`dfu-util`](http://dfu-util.sourceforge.net/)

`dfu-util` is the popular host side tool for interacting with DFU/DfuSe devices. `pyfu-usb` has only a small sliver the functionality contained in `dfu-util`: Listing and downloading binary files. The reason you would use `pyfu-usb` over `dfu-util` is if you have a Python project that needs firmware update capabilities and don't want an external (non-Python) dependency.

## Compared to [`pydfu.py`](https://github.com/openmv/openmv/blob/9f06eb4fe15f4f181250aa5848c3e3e51bb85506/tools/pydfu.py)

`pydfu.py` is a tool in the _OpenMV_ project that solves the exact problem described above, but it is only for DfuSe devices (e.g. STM32) and also hard codes a number of parameters including device address and max transfer size. It also appears to only work with `.dfu` files, which require an extra conversion step. Since binary files can be directly generated by many embedded toolchains using them is simpler, although less portable.

The code in this package originates from `pydfu.py` and the _OpenMV_ license agreement has been copied into the repository. Along with refactoring the code and adding support for "classic" DFU devices, several modernizations were added:

- Colored logs and progress bar with `rich`
- Using `logging` instead of `print` for output messages
- Consistent style and linting with `ruff`

## Dependencies

Even though this package may appear pure Python, by relying on `pyusb` we rely on `libusb` being installed. See the [`pyusb` docs](https://github.com/pyusb/pyusb#requirements-and-platform-support) for more details on platform support.

## User Guide

Install with `pip`:

    pip install pyfu-usb

List connected DFU devices:

    pyfu-usb --list

Download a file to a DfuSe capable device, specifying a start address in hex:

    pyfu-usb --download <filename> -a <start_address>

Download a file to a DFU capable device:

    pyfu-usb --download <filename>

Use the `--device` argument to specify the `vid:pid` of the device in hex if multiple are connected. See the [examples](examples/) directory for more detailed examples.

## Developer Guide

This project uses [`uv`](https://docs.astral.sh/uv/) for Python tooling. It also uses [`just`](https://github.com/casey/just) to simplify running project specific specific commands.

To install pre-commit hooks (e.g. style, linting):

    just setup

To run pre-commit hooks:

    just lint

To run unit tests:

    just test

To view code coverage:

    just coverage

To build the package:

    uv build

## Contributing

Please see the [documentation](.github/CONTRIBUTING.md) prior to contributing.

## License

Licensed under the [MIT license](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyfu-usb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "dfu-util, pydfu",
    "author": "Block, Inc.",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/98/2a/229eabbd3788954e6bfcf20c0bad36439c2757ace0ef9685ac55b5043881/pyfu_usb-2.0.2.tar.gz",
    "platform": null,
    "description": "# pyfu-usb: Python USB Firmware Updater\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA small library for firmware updates over USB with devices that support the [DFU](https://www.usb.org/sites/default/files/DFU_1.1.pdf) and [DfuSe](http://dfu-util.sourceforge.net/dfuse.html) protocols. Specifically, `pyfu-usb` supports _listing_ DFU capable devices and _downloading binary files_ to them.\n\n## Compared to [`dfu-util`](http://dfu-util.sourceforge.net/)\n\n`dfu-util` is the popular host side tool for interacting with DFU/DfuSe devices. `pyfu-usb` has only a small sliver the functionality contained in `dfu-util`: Listing and downloading binary files. The reason you would use `pyfu-usb` over `dfu-util` is if you have a Python project that needs firmware update capabilities and don't want an external (non-Python) dependency.\n\n## Compared to [`pydfu.py`](https://github.com/openmv/openmv/blob/9f06eb4fe15f4f181250aa5848c3e3e51bb85506/tools/pydfu.py)\n\n`pydfu.py` is a tool in the _OpenMV_ project that solves the exact problem described above, but it is only for DfuSe devices (e.g. STM32) and also hard codes a number of parameters including device address and max transfer size. It also appears to only work with `.dfu` files, which require an extra conversion step. Since binary files can be directly generated by many embedded toolchains using them is simpler, although less portable.\n\nThe code in this package originates from `pydfu.py` and the _OpenMV_ license agreement has been copied into the repository. Along with refactoring the code and adding support for \"classic\" DFU devices, several modernizations were added:\n\n- Colored logs and progress bar with `rich`\n- Using `logging` instead of `print` for output messages\n- Consistent style and linting with `ruff`\n\n## Dependencies\n\nEven though this package may appear pure Python, by relying on `pyusb` we rely on `libusb` being installed. See the [`pyusb` docs](https://github.com/pyusb/pyusb#requirements-and-platform-support) for more details on platform support.\n\n## User Guide\n\nInstall with `pip`:\n\n    pip install pyfu-usb\n\nList connected DFU devices:\n\n    pyfu-usb --list\n\nDownload a file to a DfuSe capable device, specifying a start address in hex:\n\n    pyfu-usb --download <filename> -a <start_address>\n\nDownload a file to a DFU capable device:\n\n    pyfu-usb --download <filename>\n\nUse the `--device` argument to specify the `vid:pid` of the device in hex if multiple are connected. See the [examples](examples/) directory for more detailed examples.\n\n## Developer Guide\n\nThis project uses [`uv`](https://docs.astral.sh/uv/) for Python tooling. It also uses [`just`](https://github.com/casey/just) to simplify running project specific specific commands.\n\nTo install pre-commit hooks (e.g. style, linting):\n\n    just setup\n\nTo run pre-commit hooks:\n\n    just lint\n\nTo run unit tests:\n\n    just test\n\nTo view code coverage:\n\n    just coverage\n\nTo build the package:\n\n    uv build\n\n## Contributing\n\nPlease see the [documentation](.github/CONTRIBUTING.md) prior to contributing.\n\n## License\n\nLicensed under the [MIT license](LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python USB firmware update library.",
    "version": "2.0.2",
    "project_urls": null,
    "split_keywords": [
        "dfu-util",
        " pydfu"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a03f5d94c9168ceb2d77f51b3f719872f0614d7f78ea7be8b989b084bad2827",
                "md5": "a6eab4ff1cb6135d3f88942a03fa6da0",
                "sha256": "e98ad0ac90ba4ddf20ed2959e80eae42186822660f7365a9e194763555b76de9"
            },
            "downloads": -1,
            "filename": "pyfu_usb-2.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a6eab4ff1cb6135d3f88942a03fa6da0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11049,
            "upload_time": "2024-12-20T21:10:25",
            "upload_time_iso_8601": "2024-12-20T21:10:25.486292Z",
            "url": "https://files.pythonhosted.org/packages/8a/03/f5d94c9168ceb2d77f51b3f719872f0614d7f78ea7be8b989b084bad2827/pyfu_usb-2.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "982a229eabbd3788954e6bfcf20c0bad36439c2757ace0ef9685ac55b5043881",
                "md5": "d376987303d5ff97fcd69bf4e6162d0b",
                "sha256": "0e5f81602aefa5373a2301e90fcdf6c285702bfe9f1f9105d5a0ca843231e465"
            },
            "downloads": -1,
            "filename": "pyfu_usb-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d376987303d5ff97fcd69bf4e6162d0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 857994,
            "upload_time": "2024-12-20T21:10:26",
            "upload_time_iso_8601": "2024-12-20T21:10:26.727532Z",
            "url": "https://files.pythonhosted.org/packages/98/2a/229eabbd3788954e6bfcf20c0bad36439c2757ace0ef9685ac55b5043881/pyfu_usb-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-20 21:10:26",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyfu-usb"
}
        
Elapsed time: 0.39789s