tons of fixes

This commit is contained in:
Robin Müller 2024-09-27 20:44:10 +02:00
parent ea35221d41
commit ee8a481c4f
Signed by: muellerr
GPG Key ID: A649FB78196E3849
4 changed files with 34 additions and 14 deletions

View File

@ -45,7 +45,7 @@ APP_B_MAX_SIZE = APP_A_END_ADDR - APP_A_START_ADDR - 8
APP_IMG_SZ = (APP_B_END_ADDR - APP_A_START_ADDR) // 2 APP_IMG_SZ = (APP_B_END_ADDR - APP_A_START_ADDR) // 2
CHUNK_SIZE = 512 CHUNK_SIZE = 400
MEMORY_SERVICE = 6 MEMORY_SERVICE = 6
ACTION_SERVICE = 8 ACTION_SERVICE = 8

View File

@ -13,7 +13,7 @@ use va108xx_hal::prelude::*;
const SYSCLK_FREQ: Hertz = Hertz::from_raw(50_000_000); const SYSCLK_FREQ: Hertz = Hertz::from_raw(50_000_000);
const MAX_TC_SIZE: usize = 1024; const MAX_TC_SIZE: usize = 524;
const MAX_TC_FRAME_SIZE: usize = cobs::max_encoding_length(MAX_TC_SIZE); const MAX_TC_FRAME_SIZE: usize = cobs::max_encoding_length(MAX_TC_SIZE);
const MAX_TM_SIZE: usize = 128; const MAX_TM_SIZE: usize = 128;
@ -29,10 +29,10 @@ pub enum ActionId {
} }
// Larger buffer for TC to be able to hold the possibly large memory write packets. // Larger buffer for TC to be able to hold the possibly large memory write packets.
const BUF_RB_SIZE_TC: usize = 2048; const BUF_RB_SIZE_TC: usize = 1024;
const SIZES_RB_SIZE_TC: usize = 16; const SIZES_RB_SIZE_TC: usize = 16;
const BUF_RB_SIZE_TM: usize = 512; const BUF_RB_SIZE_TM: usize = 256;
const SIZES_RB_SIZE_TM: usize = 16; const SIZES_RB_SIZE_TM: usize = 16;
// Ring buffers to handling variable sized telemetry // Ring buffers to handling variable sized telemetry
@ -71,7 +71,7 @@ mod app {
use rtic::Mutex; use rtic::Mutex;
use rtic_monotonics::systick::prelude::*; use rtic_monotonics::systick::prelude::*;
use rtt_target::rprintln; use rtt_target::rprintln;
use satrs::pus::verification::VerificationReportCreator; use satrs::pus::verification::{FailParams, VerificationReportCreator};
use spacepackets::ecss::PusServiceId; use spacepackets::ecss::PusServiceId;
use spacepackets::ecss::{ use spacepackets::ecss::{
tc::PusTcReader, tm::PusTmCreator, EcssEnumU8, PusPacket, WritablePusPacket, tc::PusTcReader, tm::PusTmCreator, EcssEnumU8, PusPacket, WritablePusPacket,
@ -160,7 +160,6 @@ mod app {
uart_rx: rx, uart_rx: rx,
uart_tx: tx, uart_tx: tx,
rx_context, rx_context,
// rom_spi: Some(cx.device.spi3),
tm_cons: DataConsumer { tm_cons: DataConsumer {
buf_cons: buf_cons_tm, buf_cons: buf_cons_tm,
sizes_cons: sizes_cons_tm, sizes_cons: sizes_cons_tm,
@ -258,6 +257,7 @@ mod app {
priority = 2, priority = 2,
local=[ local=[
tc_buf: [u8; MAX_TC_SIZE] = [0; MAX_TC_SIZE], tc_buf: [u8; MAX_TC_SIZE] = [0; MAX_TC_SIZE],
readback_buf: [u8; MAX_TC_SIZE] = [0; MAX_TC_SIZE],
src_data_buf: [u8; 16] = [0; 16], src_data_buf: [u8; 16] = [0; 16],
verif_buf: [u8; 32] = [0; 32], verif_buf: [u8; 32] = [0; 32],
tc_cons, tc_cons,
@ -407,11 +407,29 @@ mod app {
.nvm .nvm
.write(offset as usize, data) .write(offset as usize, data)
.expect("writing to NVM failed"); .expect("writing to NVM failed");
let tm = cx let tm = if !cx
.local .local
.nvm
.verify(offset as usize, data)
.expect("NVM verification failed")
{
log::warn!("verification of data written to NVM failed");
cx.local
.verif_reporter
.completion_failure(
cx.local.src_data_buf,
started_token,
0,
0,
FailParams::new(&[], &EcssEnumU8::new(0), &[]),
)
.expect("completion success failed")
} else {
cx.local
.verif_reporter .verif_reporter
.completion_success(cx.local.src_data_buf, started_token, 0, 0, &[]) .completion_success(cx.local.src_data_buf, started_token, 0, 0, &[])
.expect("completion success failed"); .expect("completion success failed")
};
write_and_send(&tm); write_and_send(&tm);
log::info!( log::info!(
target: "TC Handler", target: "TC Handler",

View File

@ -40,12 +40,14 @@ fn main() -> ! {
// Memory can be read in one go. // Memory can be read in one go.
nvm.read(0, &mut read_buf).unwrap(); nvm.read(0, &mut read_buf).unwrap();
assert_eq!(&read_buf, &write_buf); assert_eq!(&read_buf, &write_buf);
assert!(nvm.verify(0, &write_buf).unwrap());
read_buf.fill(0); read_buf.fill(0);
// Write along page boundary // Write along page boundary
nvm.write(PAGE_SIZE - 2, &write_buf[0..8]).unwrap(); nvm.write(PAGE_SIZE - 2, &write_buf[0..8]).unwrap();
nvm.read(PAGE_SIZE - 2, &mut read_buf[0..8]).unwrap(); nvm.read(PAGE_SIZE - 2, &mut read_buf[0..8]).unwrap();
assert_eq!(&read_buf[0..8], &write_buf[0..8]); assert_eq!(&read_buf[0..8], &write_buf[0..8]);
assert!(nvm.verify(PAGE_SIZE - 2, &write_buf[0..8]).unwrap());
nvm.write(0, &orig_content).unwrap(); nvm.write(0, &orig_content).unwrap();
loop { loop {

View File

@ -43,7 +43,7 @@ use regs::*;
use va108xx_hal::{ use va108xx_hal::{
pac, pac,
prelude::*, prelude::*,
spi::{RomMiso, RomMosi, RomSck, Spi, SpiConfig, BMSTART_BMSTOP_MASK}, spi::{RomMiso, RomMosi, RomSck, Spi, SpiClkConfig, SpiConfig, BMSTART_BMSTOP_MASK},
}; };
pub type RomSpi = Spi<pac::Spic, (RomSck, RomMiso, RomMosi), u8>; pub type RomSpi = Spi<pac::Spic, (RomSck, RomMiso, RomMosi), u8>;
@ -65,7 +65,7 @@ impl M95M01 {
sys_clk, sys_clk,
spi, spi,
(RomSck, RomMiso, RomMosi), (RomSck, RomMiso, RomMosi),
SpiConfig::default(), SpiConfig::default().clk_cfg(SpiClkConfig::new(2, 4)),
); );
let mut spi_dev = Self { spi }; let mut spi_dev = Self { spi };
spi_dev.clear_block_protection().unwrap(); spi_dev.clear_block_protection().unwrap();
@ -132,7 +132,7 @@ impl M95M01 {
// Pump the FIFO. // Pump the FIFO.
self.spi.write_fifo_unchecked(0); self.spi.write_fifo_unchecked(0);
// Ignore the first 4 bytes. // Ignore the first 4 bytes.
self.spi.read_fifo_unchecked(); nb::block!(self.spi.read_fifo())?;
} }
Ok(()) Ok(())
} }
@ -176,7 +176,7 @@ impl M95M01 {
.unwrap(); .unwrap();
for val in data.iter().take(data.len() - 1) { for val in data.iter().take(data.len() - 1) {
nb::block!(self.spi.write_fifo(*val as u32)).unwrap(); nb::block!(self.spi.write_fifo(*val as u32)).unwrap();
self.spi.read_fifo_unchecked(); nb::block!(self.spi.read_fifo()).unwrap();
} }
nb::block!(self nb::block!(self
.spi .spi