4 releases (2 breaking)

0.3.0 Sep 23, 2023
0.2.1 Sep 23, 2023
0.2.0 Jan 29, 2020
0.1.0 Jan 20, 2020

#1687 in Hardware support

ISC license

38KB
658 lines

punt-rs

CI badge docs.rs badge

This is a library for the experimental minimal USB bootloader punt's PC side.

Licence

This code is ISC licenced. See LICENCE.md for details.


lib.rs:

This crate provides a way to interact with a microcontroller with the punt bootloader connected via USB and exposes all bootloader functions.

Example: Basic flashing

use punt::{Context, UsbContext, Operation};
use std::fs::File;
use std::io::{Read, Write};

// Open binary file and read contents
let mut file = File::open("test.bin")?;
let mut buff = Vec::new();
file.read_to_end(&mut buff)?;

// Find a bootloader target
let mut context = Context::new()?;
let mut target_handle = context.pick_target(None)?.open()?;

// Fetch information about the target's bootloader
let start_address = target_handle.bootloader_info()?.application_base;

// Erase the necessary flash area
target_handle.erase_area(start_address, buff.len())?.execute()?;

// Program the buffer into flash
target_handle.program_at(buff.as_slice(), start_address)?.execute()?;

// Verify flash contents
target_handle.verify(buff.as_slice(), start_address)?;

println!("Done!");

In addition to this very basic API, it also provides functionality for progress feedback during operations like reading, erasing and flashing. See the Operation trait for details.

Dependencies

~2MB
~35K SLoC