Skip to content

Commit

Permalink
Remove dumper and sp-ctrl from rot-carrier
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Apr 4, 2024
1 parent cadf1d2 commit 06c2788
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 85 deletions.
2 changes: 1 addition & 1 deletion app/oxide-rot-1/app-dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ name = "drv-lpc55-sprot-server"
priority = 6
max-sizes = {flash = 51168, ram = 32768}
uses = ["flexcomm8", "bootrom"]
features = ["spi0"]
features = ["spi0", "sp-ctrl"]
start = true
notifications = ["spi-irq"]
interrupts = {"flexcomm8.hs_spi" = "spi-irq"}
Expand Down
2 changes: 1 addition & 1 deletion app/oxide-rot-1/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ name = "drv-lpc55-sprot-server"
priority = 6
max-sizes = {flash = 51168, ram = 32768}
uses = ["flexcomm8", "bootrom"]
features = ["spi0"]
features = ["spi0", "sp-ctrl"]
start = true
notifications = ["spi-irq"]
interrupts = {"flexcomm8.hs_spi" = "spi-irq"}
Expand Down
57 changes: 3 additions & 54 deletions app/rot-carrier/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ start = true
notifications = ["spi-irq"]
interrupts = {"flexcomm8.hs_spi" = "spi-irq"}
stacksize = 16384
task-slots = ["gpio_driver", "syscon_driver", "update_server", "dumper", "attest", "swd"]
task-slots = ["gpio_driver", "syscon_driver", "update_server", "attest"]

[tasks.sprot.config]
pins = [
Expand All @@ -133,47 +133,6 @@ pins = [
{ name = "SP_RESET", pin = { port = 0, pin = 9}, alt = 0, direction = "input"},
]

[tasks.swd]
name = "drv-lpc55-swd"
priority = 4
max-sizes = {flash = 16384, ram = 4096}
uses = ["flexcomm3", "iocon"]
start = true
stacksize = 1000
notifications = ["spi-irq", "timer"]
task-slots = ["gpio_driver", "syscon_driver"]
interrupts = {"flexcomm3.irq" = "spi-irq"}

[tasks.swd.config]
# MOSI = PIO0_3
# MISO = PIO0_2

# Out = MOSI on, MISO off
out_cfg = [
{ pin = { port = 0, pin = 3 }, alt = 1 },
{ pin = { port = 0, pin = 2 }, alt = 0, mode = "PullDown" },
]
# In = MISO on, MOSI off
in_cfg = [
{ pin = { port = 0, pin = 2 }, alt = 1 },
{ pin = { port = 0, pin = 3 }, alt = 0, mode = "PullDown" },
]
pins = [
# SCK
{ pin = { port = 0, pin = 6 }, alt = 1 },
# CS, not strictly necessary but handy for debugging
# { pin = {port = 0, pin = 20}, alt = 1},
]
spi_num = 3

[tasks.dumper]
name = "task-dumper"
priority = 5
max-sizes = {flash = 16384, ram = 4096}
start = true
stacksize = 2600
task-slots = ["swd"]

[tasks.pong]
name = "task-pong"
priority = 7
Expand All @@ -185,21 +144,11 @@ notifications = ["timer"]
[tasks.hiffy]
name = "task-hiffy"
priority = 6
features = ["lpc55", "gpio", "spctrl", "spi"]
features = ["lpc55", "gpio", "spi"]
max-sizes = {flash = 32768, ram = 16384 }
stacksize = 2048
start = true
task-slots = ["gpio_driver", "swd", "update_server"]

[tasks.sp_measure]
name = "task-sp-measure"
priority = 6
max-sizes = {flash = 131072, ram = 8192}
task-slots = ["swd"]
stacksize = 2048

[tasks.sp_measure.config]
binary_path = "../../target/gemini-bu/dist/final.bin"
task-slots = ["gpio_driver", "update_server"]

[tasks.attest]
name = "task-attest"
Expand Down
6 changes: 4 additions & 2 deletions drv/lpc55-sprot-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ drv-lpc55-gpio-api = { path = "../lpc55-gpio-api" }
drv-lpc55-spi = { path = "../lpc55-spi" }
drv-lpc55-syscon-api = { path = "../lpc55-syscon-api" }
drv-lpc55-update-api = { path = "../lpc55-update-api" }
drv-sp-ctrl-api = { path = "../sp-ctrl-api" }
drv-sprot-api = { path = "../sprot-api" }
drv-update-api = { path = "../update-api" }
dumper-api = { path = "../../task/dumper-api" }
lpc55_romapi = { path = "../../lib/lpc55-romapi" }
mutable-statics = { path = "../../lib/mutable-statics" }
ringbuf = { path = "../../lib/ringbuf" }
task-jefe-api = { path = "../../task/jefe-api" }
userlib = { path = "../../sys/userlib" }
lpc55-rom-data = { path = "../../lib/lpc55-rom-data" }

drv-sp-ctrl-api = { path = "../sp-ctrl-api", optional = true }
dumper-api = { path = "../../task/dumper-api", optional = true }

[build-dependencies]
build-lpc55pins = { path = "../../build/lpc55pins" }
build-util = { path = "../../build/util" }
Expand All @@ -41,6 +42,7 @@ idol = { workspace = true }
[features]
spi0 = []
no-ipc-counters = ["idol/no-counters"]
sp-ctrl = ["drv-sp-ctrl-api", "dumper-api"]

# This section is here to discourage RLS/rust-analyzer from doing test builds,
# since test builds don't work for cross compilation.
Expand Down
63 changes: 49 additions & 14 deletions drv/lpc55-sprot-server/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ use crate::Trace;
use attest_api::Attest;
use crc::{Crc, CRC_32_CKSUM};
use drv_lpc55_update_api::{RotPage, SlotId, Update};
use drv_sp_ctrl_api::SpCtrl;
use drv_sprot_api::{
AttestReq, AttestRsp, CabooseReq, CabooseRsp, DumpReq, DumpRsp, ReqBody,
Request, Response, RotIoStats, RotPageRsp, RotState, RotStatus, RspBody,
AttestReq, AttestRsp, CabooseReq, CabooseRsp, DumpReq, ReqBody, Request,
Response, RotIoStats, RotPageRsp, RotState, RotStatus, RspBody,
SprocketsError, SprotError, SprotProtocolError, SwdReq, UpdateReq,
UpdateRsp, WatchdogError, CURRENT_VERSION, MIN_VERSION, REQUEST_BUF_SIZE,
UpdateRsp, CURRENT_VERSION, MIN_VERSION, REQUEST_BUF_SIZE,
RESPONSE_BUF_SIZE,
};
use dumper_api::Dumper;
use lpc55_romapi::bootrom;
use ringbuf::ringbuf_entry_root as ringbuf_entry;
use sprockets_rot::RotSprocket;
Expand All @@ -24,10 +22,12 @@ mod sprockets;

task_slot!(UPDATE_SERVER, update_server);

#[cfg(feature = "sp-ctrl")]
task_slot!(DUMPER, dumper);

task_slot!(ATTEST, attest);

#[cfg(feature = "sp-ctrl")]
task_slot!(SP_CTRL, swd);

pub const CRC32: Crc<u32> = Crc::<u32>::new(&CRC_32_CKSUM);
Expand Down Expand Up @@ -60,7 +60,9 @@ pub struct Handler {
update: Update,
startup_state: StartupState,
attest: Attest,
sp_ctrl: SpCtrl,

#[cfg(feature = "sp-ctrl")]
sp_ctrl: drv_sp_ctrl_api::SpCtrl,
}

impl<'a> Handler {
Expand All @@ -74,7 +76,9 @@ impl<'a> Handler {
max_response_size: RESPONSE_BUF_SIZE.try_into().unwrap_lite(),
},
attest: Attest::from(ATTEST.get_task_id()),
sp_ctrl: SpCtrl::from(SP_CTRL.get_task_id()),

#[cfg(feature = "sp-ctrl")]
sp_ctrl: drv_sp_ctrl_api::SpCtrl::from(SP_CTRL.get_task_id()),
}
}

Expand Down Expand Up @@ -269,10 +273,24 @@ impl<'a> Handler {
None,
)),
ReqBody::Dump(DumpReq::V1 { addr }) => {
ringbuf_entry!(Trace::Dump(addr));
let dumper = Dumper::from(DUMPER.get_task_id());
let err = dumper.dump(addr).err();
Ok((RspBody::Dump(DumpRsp::V1 { err }), None))
#[cfg(feature = "sp-ctrl")]
{
use dumper_api::Dumper;
ringbuf_entry!(Trace::Dump(addr));
let dumper = Dumper::from(DUMPER.get_task_id());
let err = dumper.dump(addr).err();
Ok((
RspBody::Dump(drv_sprot_api::DumpRsp::V1 { err }),
None,
))
}
#[cfg(not(feature = "sp-ctrl"))]
{
let _ = addr;
Err(SprotError::Protocol(
SprotProtocolError::BadMessageType,
))
}
}
ReqBody::Update(UpdateReq::GetBlockSize) => {
let size = self.update.block_size()?;
Expand Down Expand Up @@ -415,16 +433,33 @@ impl<'a> Handler {
// Enabling the watchdog doesn't actually do any SWD work, but
// we'll call `setup()` now to make sure that the SWD system is
// working.
#[cfg(feature = "sp-ctrl")]
match self.sp_ctrl.setup().and_then(|()| {
self.sp_ctrl.enable_sp_slot_watchdog(time_ms)
}) {
Ok(()) => Ok((RspBody::Ok, None)),
Err(_e) => Err(SprotError::Watchdog(WatchdogError::SpCtrl)),
Err(_e) => Err(SprotError::Watchdog(
drv_sprot_api::WatchdogError::SpCtrl,
)),
}

#[cfg(not(feature = "sp-ctrl"))]
{
let _ = time_ms;
Err(SprotError::Protocol(
SprotProtocolError::BadMessageType,
))
}
}
ReqBody::Swd(SwdReq::DisableSpSlotWatchdog) => {
self.sp_ctrl.disable_sp_slot_watchdog();
Ok((RspBody::Ok, None))
#[cfg(feature = "sp-ctrl")]
{
self.sp_ctrl.disable_sp_slot_watchdog();
Ok((RspBody::Ok, None))
}

#[cfg(not(feature = "sp-ctrl"))]
Err(SprotError::Protocol(SprotProtocolError::BadMessageType))
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion drv/lpc55-sprot-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ use handler::Handler;
#[derive(Copy, Clone, PartialEq)]
pub(crate) enum Trace {
None,
Dump(u32),
ReceivedBytes(usize),
Flush,
FlowError,
Expand All @@ -76,6 +75,9 @@ pub(crate) enum Trace {
Err(SprotProtocolError),
Stats(RotIoStats),
Desynchronized,

#[cfg(feature = "sp-ctrl")]
Dump(u32),
}
ringbuf!(Trace, 32, Trace::None);

Expand Down
16 changes: 4 additions & 12 deletions drv/lpc55-swd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,18 +775,10 @@ impl ServerImpl {
}

fn swd_dongle_detected(&self) -> bool {
cfg_if::cfg_if! {
if #[cfg(any(
target_board = "oxide-rot-1",
))] {
use drv_lpc55_gpio_api::*;

let gpio = Pins::from(self.gpio);
gpio.read_val(SP_TO_ROT_JTAG_DETECT_L) == Value::Zero
} else {
false
}
}
use drv_lpc55_gpio_api::*;

let gpio = Pins::from(self.gpio);
gpio.read_val(SP_TO_ROT_JTAG_DETECT_L) == Value::Zero
}

fn swd_setup(&mut self) -> Result<(), Ack> {
Expand Down

0 comments on commit 06c2788

Please sign in to comment.