10 releases

0.3.3 Oct 29, 2021
0.3.1 Oct 17, 2020
0.2.1 Jul 29, 2020
0.1.1 Feb 18, 2020
0.1.0 Dec 5, 2019

#571 in Hardware support

Download history 18/week @ 2023-07-28 22/week @ 2023-08-04 17/week @ 2023-08-11 73/week @ 2023-08-18 110/week @ 2023-08-25 13/week @ 2023-09-01 50/week @ 2023-09-08 21/week @ 2023-09-15 14/week @ 2023-09-22 24/week @ 2023-09-29 18/week @ 2023-10-06 32/week @ 2023-10-13 23/week @ 2023-10-20 36/week @ 2023-10-27 19/week @ 2023-11-03 33/week @ 2023-11-10

115 downloads per month
Used in 2 crates


887 lines

Contains (ELF lib, 74KB) src/utils/testdata/blinky_1.47.0, (ELF lib, 17KB) src/utils/testdata/blinky_1.44.0, (ELF exe/lib, 1KB) src/utils/testdata/sections


Implements Microsofts HID Flashing Format (HF2) to upload firmware to UF2 bootloaders. UF2 is factory programmed extensively by Microsoft MakeCode and Adafruit hardware.

Unless you know otherwise, you probably want cargo-hf2


By default enables the hidapi feature and utilizes the hidapi-sys crate which uses libusb. Presumably other transports could be added in the future that implement the ReadWrite trait internally.


Youll need libusb depending on your distro you might do sudo apt-get install libudev-dev libusb-1.0-0-dev.

If you'd like to not use sudo, you'll need udev rules. With your board plugged in and in bootloader mode, use lsusb to find your vendorid, seen here as 239a

Bus 001 Device 087: ID 239a:001b Adafruit Industries Feather M0

Then put your vendorid below and save to something like /etc/udev/rules.d/99-adafruit-boards.rules

ATTRS{idVendor}=="239a", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="usb", ATTRS{idVendor}=="239a", MODE="0666"
SUBSYSTEM=="tty", ATTRS{idVendor}=="239a", MODE="0666"

Then reboot or run

sudo udevadm control --reload-rules
sudo udevadm trigger


On mac, as of Catalina you will get a permissions prompt and must follow directions to allow "Input Monitoring" for the Terminal application.


cargo install cargo-hf2


Assuming using default feature hidapi and sloppily just grabbing the first device

let api = HidApi::new().expect("Couldn't find system usb");
let dev = api.device_list().nth(0).unwrap().open_device(&api).unwrap();
let chk = hf2::checksum_pages(&dev, 0x4000, 1).unwrap();


If it cant find a device, make sure your device is in a bootloader mode ready to receive firmware.

thread 'main' panicked at 'Are you sure device is plugged in and in bootloader mode?: OpenHidDeviceError', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

On the PyGamer, 2 button presses enables a blue and green screen that says PyGamer and also generally creates a flash drive which you should be able to see (though this doesn't use that method).

If you find another error, be sure to run with debug to see where in the process it failed and include those logs when reporting

RUST_LOG=debug cargo run


~20K SLoC