Skip to main content

pyfu-usb: Python USB Firmware Updater

License: MIT

A small library for firmware updates over USB with devices that support the DFU and DfuSe protocols. Specifically, pyfu-usb supports listing DFU capable devices and downloading binary files to them.

Compared to dfu-util

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

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 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 directory for more detailed examples.

Developer Guide

This project uses uv for Python tooling. It also uses 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 prior to contributing.

License

Licensed under the MIT license.

Release files for pyfu-usb 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfu-usb 2.0.2
File Size Uploaded
pyfu_usb-2.0.2.tar.gz 858.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfu-usb 2.0.2
File Interpreter ABI Platform
pyfu_usb-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 869.0 kB

Release files / pyfu_usb-2.0.2.tar.gz

Download URL pyfu_usb-2.0.2.tar.gz
Size 858.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0e5f81602aefa5373a2301e90fcdf6c285702bfe9f1f9105d5a0ca843231e465
BLAKE2b-256 checksum
How to use checksums
982a229eabbd3788954e6bfcf20c0bad36439c2757ace0ef9685ac55b5043881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release files / pyfu_usb-2.0.2-py3-none-any.whl

Download URL pyfu_usb-2.0.2-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e98ad0ac90ba4ddf20ed2959e80eae42186822660f7365a9e194763555b76de9
BLAKE2b-256 checksum
How to use checksums
8a03f5d94c9168ceb2d77f51b3f719872f0614d7f78ea7be8b989b084bad2827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

1 release file

2.0.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page