Firmware updater over SPI
- define a rough control flow for the update.
- have a general SPI interface easy to inject as mock to be able to write tests.
- write the happy path first.
- consider pending features and write down TODOS.
- Integrate function calls to the Bootloader.
- Make sure the size of the spi frame is not too big, otherwise writing the incoming data to flash might take too long and miss the next incoming frame.
- ensure memory alignment for the data in the SPI frame, maybe the size should match the memory pages sizes.
- The function to write to memory provided by the bootloader assumes fix address, and it is not required to be send via SPI, although it is more convenient.
- Add error handling for clear error logs and reporting.
- User standarized error types for SPI instead of a general one.
- Consider that the SPI might be also used to access the Flash.
- add plausibility check for the setup, example: address boundaries, maximum number of blocks, etc.
- use constant to reference fields in buffers instead of indices.
- Build with
cargo build
- Run tests with
cargo test
use fw_updater::{run, SpiSlave, SpiError};
let mut spi_config = spi::Config::default();
// configure HW specific SPI driver as slave
// set parameters to spi_config...frequency, phase, polarity...
// probably the SPI is also used to access the flash therefore it has to be
// shared.
let spi = Spi::new_blocking(p.SPI1, clk, mosi, miso, spi_config.clone());
// create instance implementing SpiSlave trait
let mut spi_slave = MySpiSlave::new(&mut spi);
run(&mut spi_slave);