Expand description
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.
Re-exports
pub use bootloader_info::BootloaderInfo;
pub use operation::Operation;
Modules
- Contains data structures for information the bootloader reports back to the connecting PC.
- Contains multi-step operations, i.e. erasing an area by erasing multiple pages subsequently abd reading/writing flash memory blockwise.
Structs
- A page in the punt microcontroller’s flash memory.
- Contains necessary information to connect to a target via USB.
- Contains a connected target and allows operations to be carried out.
Enums
- Errors which can occur during target setup and communication.
Constants
- Address of the first byte in the target microcontroller’s flash.
- Flash page size of the target microcontroller.
Traits
- Base trait for a USB context.
Type Aliases
- A punt context, necessary for USB communication.
- Shorthand for a Result with the crate’s own Error type.