hf2 0.1.1

Microsoft HID Flashing Library for UF2 Bootloaders


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

install and setup

Utilizes the hidapi-sys crate which may require libusb or other dependencies, see hidapi for further directions.


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.


let chk: ChksumPagesResponse = ChksumPages {


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