Expand description
Avr Boot
This crate contains functions to write to the program memory of AVR MCUs, using the spm
instruction.
It could be considered a reimagining of the macros in boot.h from avr-libc, but in Rust, plus some artisanal, hand-crafted asm If you’re looking to create a bootloader, this crate should be useful.
It is hal independent, and optimised for code size.
Regular and extended (>64k) addressing modes are supported.
Getting started
Add the module to your Cargo.toml:
[dependencies]
avr-boot = "0.1.0"
Pick from the high level API:
use avr_boot::{DataPage, PageBuffer};
let page_address: spm::Address = 0x1000;
let data: DataPage = core::array::from_fn(|_| 0x1234);
let buff = PageBuffer::new(page_address);
buff.store_from_slice(&data);
Or the low level one:
use avr_boot::{spm, SPM_PAGESIZE_WORDS};
let page_address = 0x1000;
for w in 0..SPM_PAGESIZE_WORDS {
spm::fill_page(0x1000 + (w * 2) as spm::Address, 0x1234);
}
spm::erase_page(page_address);
spm::busy_wait();
spm::write_page(page_address);
spm::busy_wait();
spm::rww_enable();
Check out the examples module for more usage examples
Re-exports
pub use spm_extended as spm;
Modules
High level page buffer API
Low level API for MCUs with >64k of storage.
use crate::spm to get the correct mode for your target MCU
Low level API for MCUs with <64k of storage.
use crate::spm to get the correct mode for your target MCU
Constants
Type Definitions
An array of memory the same size as the page buffer