Skip to content

Commit

Permalink
Measure SP on reset
Browse files Browse the repository at this point in the history
Hiffy commands db_measure_sp and db_reset_sp are there temporarily for
testing.
  • Loading branch information
lzrd committed Dec 13, 2024
1 parent 9e82dfb commit 12d5949
Show file tree
Hide file tree
Showing 10 changed files with 863 additions and 73 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 7 additions & 12 deletions app/oxide-rot-1/app-dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ start = true
[tasks.update_server]
name = "lpc55-update-server"
priority = 3
max-sizes = {flash = 26080, ram = 17000, usbsram = 4096}
# TODO: Size this appropriately
stacksize = 8192
start = true
sections = {bootstate = "usbsram"}
Expand Down Expand Up @@ -82,7 +80,6 @@ task-slots = ["syscon_driver"]
[tasks.sprot]
name = "drv-lpc55-sprot-server"
priority = 6
max-sizes = {flash = 54016, ram = 32768}
uses = ["flexcomm8", "bootrom"]
features = ["spi0", "sp-ctrl"]
start = true
Expand All @@ -103,20 +100,17 @@ pins = [
{ name = "CHIP_SELECT", pin = { port = 1, pin = 1}, alt = 5},
# ROT_IRQ = P0_18 = FUN0
{ name = "ROT_IRQ", pin = { port = 0, pin = 18}, alt = 0, direction = "output"},
# SP_RESET = P0_9 = FUN0
{ 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 = ["flexcomm5", "iocon"]
start = true
stacksize = 1000
stacksize = 3072
task-slots = ["gpio_driver", "syscon_driver", "attest"]
notifications = ["spi-irq", "timer", "sp_reset-irq"]
interrupts = {"flexcomm5.irq" = "spi-irq", "pint.irq0" = "sp_reset-irq"}
notifications = ["spi-irq", "timer", "sp_reset-irq", "jtag_detect-irq"]
interrupts = {"flexcomm5.irq" = "spi-irq", "pint.irq0" = "sp_reset-irq", "pint.irq1" = "jtag_detect-irq" }

[tasks.swd.config]
# MOSI = PIO0_8
Expand All @@ -136,9 +130,10 @@ in_cfg = [
pins = [
# SCK
{ pin = { port = 0, pin = 7 }, alt = 3 },
{ name = "SP_TO_ROT_JTAG_DETECT_L", pin = { port = 0, pin = 20 }, alt = 0, direction = "input" },
{ name = "ROT_TO_SP_RESET_L_OUT", pin = { port = 0, pin = 13 }, alt = 0, value = true, direction = "output", opendrain = "opendrain", setup = false },
{ name = "ROT_TO_SP_RESET_L_IN", pin = { port = 0, pin = 13 }, alt = 0, direction = "input", pint = 0 },
{ name = "SP_TO_ROT_JTAG_DETECT_L", pin = { port = 0, pin = 20 }, alt = 0, direction = "input", mode = "nopull", pint = 1 },
# SP NRST has an internal 30-50k pull-up in SP
{ name = "ROT_TO_SP_RESET_L_IN", pin = { port = 0, pin = 13 }, alt = 0, direction = "input", mode = "nopull", pint = 0 },
{ name = "ROT_TO_SP_RESET_L_OUT", pin = { port = 0, pin = 13 }, alt = 0, direction = "output", mode = "nopull", opendrain = "opendrain", setup = false },
]
spi_num = 5

Expand Down
10 changes: 5 additions & 5 deletions app/oxide-rot-1/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ pins = [
name = "drv-lpc55-swd"
priority = 4
max-sizes = {flash = 16384, ram = 4096}
uses = ["flexcomm5", "iocon", "pint"]
uses = ["flexcomm5", "iocon"]
start = true
stacksize = 1000
task-slots = ["gpio_driver", "syscon_driver"]
task-slots = ["gpio_driver", "syscon_driver", "attest"]
notifications = ["spi-irq", "timer", "sp_reset-irq"]
interrupts = {"flexcomm5.irq" = "spi-irq", "pint.irq0" = "sp_reset-irq" }

Expand All @@ -122,8 +122,8 @@ pins = [
# SCK
{ pin = { port = 0, pin = 7 }, alt = 3 },
{ name = "SP_TO_ROT_JTAG_DETECT_L", pin = { port = 0, pin = 20 }, alt = 0, direction = "input" },
{ name = "ROT_TO_SP_RESET_L_OUT", pin = { port = 0, pin = 13 }, alt = 0, value = true, direction = "output", opendrain = "opendrain"},
{ name = "ROT_TO_SP_RESET_L_IN", pin = { port = 0, pin = 13 }, alt = 0, value = true, direction = "output", pint = 0 },
{ name = "ROT_TO_SP_RESET_L_OUT", pin = { port = 0, pin = 13 }, alt = 0, value = true, direction = "output", opendrain = "opendrain", setup = false },
{ name = "ROT_TO_SP_RESET_L_IN", pin = { port = 0, pin = 13 }, alt = 0, direction = "input", pint = 0 },
]
spi_num = 5

Expand All @@ -137,7 +137,7 @@ task-slots = ["swd"]

[tasks.attest]
name = "task-attest"
priority = 5
priority = 3
max-sizes = {flash = 35400, ram = 16384}
stacksize = 12304
start = true
Expand Down
17 changes: 17 additions & 0 deletions drv/lpc55-gpio/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ impl ServerImpl<'_> {
.write(|w| unsafe { w.dirsetp().bits(1 << pin) }),
}
}

fn get_pin_direction(&self, port: usize, pin: usize) -> Direction {
if self.gpio.dir[port].read().bits() & (1 << pin) == 0 {
Direction::Input
} else {
Direction::Output
}
}
}

impl idl::InOrderPinsImpl for ServerImpl<'_> {
Expand Down Expand Up @@ -176,6 +184,15 @@ impl idl::InOrderPinsImpl for ServerImpl<'_> {
Ok(())
}

fn get_dir(
&mut self,
_: &RecvMessage,
pin: Pin,
) -> Result<Direction, RequestError<core::convert::Infallible>> {
let (port, pin) = gpio_port_pin_validate(pin);
Ok(self.get_pin_direction(port, pin))
}

//
// Functions for managing GPIO interrupts:
//
Expand Down
4 changes: 4 additions & 0 deletions drv/lpc55-swd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ idol-runtime = { workspace = true }
lpc55-pac = { workspace = true }
num-traits = { workspace = true }
zerocopy = { workspace = true }
sha3 = { workspace = true }

attest-api = { path = "../../task/attest-api" }
drv-lpc55-gpio-api = { path = "../lpc55-gpio-api" }
drv-lpc55-spi = { path = "../lpc55-spi" }
drv-lpc55-syscon-api = { path = "../lpc55-syscon-api" }
Expand All @@ -28,6 +30,8 @@ serde = { workspace = true }

[features]
no-ipc-counters = ["idol/no-counters"]
# TODO: Make measuring the SP a feature flag.
# measure_sp = []

# This section is here to discourage RLS/rust-analyzer from doing test builds,
# since test builds don't work for cross compilation.
Expand Down
Loading

0 comments on commit 12d5949

Please sign in to comment.