[−][src]Crate punt
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, 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 = context.pick_target(None)?.open(&mut context)?; // Fetch information about the target's bootloader let start_address = target.bootloader_info.application_base; // Erase the necessary flash area target.erase_area(start_address, buff.len())?.execute()?; // Program the buffer into flash target.program_at(buff.as_slice(), start_address)?.execute()?; // Verify flash contents target.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.
Structs
BootloaderInfo | Suppository information read back from the bootloader. |
Context | A punt context. |
Page | A page in the punt microcontroller's flash memory. |
Target | Contains a connected target and allows operations to be carried out. |
TargetInfo | Contains necessary information to connect to a target via USB. |
Enums
Error | Errors which can occur during target setup and communication. |
Constants
FLASH_BASE | Address of the first byte in the target microcontroller's flash. |
PAGE_SIZE | Flash page size of the target microcontroller. |
Traits
Operation | General-purpose trait for operations which take multiple command transmissions via USB, e.g. reading or writing a larger section of memory in smaller blocks. |
Type Definitions
Result | Shorthand for a Result with the crate's own Error type. |