save tests

This commit is contained in:
2026-04-11 21:34:48 +02:00
parent bc25fef5ec
commit 0d7074bd89
4 changed files with 23 additions and 11 deletions

View File

@@ -577,9 +577,9 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
start
);
to_write -= part.len();
chunk += 1;
self.get_rtc_module()
.write((BACKUP_HEADER_MAX_SIZE + chunk * EEPROM_PAGE) as u32, part)?;
chunk += 1;
}
info!("Backup complete");
self.clear_progress().await;
@@ -591,13 +591,19 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
let mut store = alloc::vec![0_u8; info.size as usize];
self.rtc_module
.read(BACKUP_HEADER_MAX_SIZE as u32, store.as_mut_slice())?;
info!("Read backup data of size {}", store.len());
let mut checksum = X25.digest();
info!("Calculating CRC");
checksum.update(&store[..]);
let crc = checksum.finalize();
info!("CRC is {:04x}", crc);
if crc != info.crc16 {
warn!("CRC mismatch in backup data");
bail!("CRC mismatch in backup data")
}
info!("CRC is correct");
let (decoded, _) = bincode::decode_from_slice(&store[..], CONFIG)?;
info!("Backup data decoded");
Ok(decoded)
}