[−][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, 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
bootloader_info | Contains data structures for information the bootloader reports back to the connecting PC. |
operation | Contains multi-step operations, i.e. erasing an area by erasing multiple pages subsequently abd reading/writing flash memory blockwise. |
Structs
Page | A page in the punt microcontroller's flash memory. |
Target | Contains necessary information to connect to a target via USB. |
TargetHandle | Contains a connected target and allows operations to be carried out. |
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
UsbContext | Base trait for a USB context. |
Type Definitions
Context | A punt context, necessary for USB communication. |
Result | Shorthand for a Result with the crate's own Error type. |