Skip to content

Commit 38953d2

Browse files
authored
Load dummy packrat config for grapefruit (#1986)
This is another part of #1983
1 parent a2f2928 commit 38953d2

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/grapefruit/app.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ priority = 4
177177
max-sizes = {flash = 131072, ram = 16384 }
178178
stacksize = 2600
179179
start = true
180-
task-slots = ["sys", {spi = "spi2_driver"}, "auxflash", "jefe"]
180+
task-slots = ["sys", {spi = "spi2_driver"}, "auxflash", "jefe", "packrat"]
181181

182182
[tasks.thermal]
183183
name = "task-thermal"

drv/grapefruit-seq-server/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
drv-spi-api = { path = "../spi-api" }
8-
drv-cpu-seq-api = { path = "../cpu-seq-api" }
7+
counters = { path = "../../lib/counters" }
8+
drv-auxflash-api = { path = "../auxflash-api" }
99
drv-cpu-power-state = { path = "../cpu-power-state" }
10+
drv-cpu-seq-api = { path = "../cpu-seq-api" }
11+
drv-spi-api = { path = "../spi-api" }
1012
drv-stm32xx-sys-api = { path = "../stm32xx-sys-api" }
11-
drv-auxflash-api = { path = "../auxflash-api" }
12-
counters = { path = "../../lib/counters" }
1313
gnarle = { path = "../../lib/gnarle" }
14+
task-packrat-api = { path = "../../task/packrat-api" }
1415
ringbuf = { path = "../../lib/ringbuf" }
1516
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
1617
task-jefe-api = { path = "../../task/jefe-api" }

drv/grapefruit-seq-server/src/main.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use drv_stm32xx_sys_api as sys_api;
1313
use idol_runtime::{NotificationHandler, RequestError};
1414
use sha3::{Digest, Sha3_256};
1515
use task_jefe_api::Jefe;
16+
use task_packrat_api::{CacheSetError, MacAddressBlock, Packrat, VpdIdentity};
1617
use userlib::{
1718
hl, sys_recv_notification, task_slot, FromPrimitive, RecvMessage,
1819
UnwrapLite,
@@ -29,6 +30,8 @@ enum Trace {
2930
ContinueBitstreamLoad(usize),
3031
WaitForDone,
3132
Programmed,
33+
MacsAlreadySet(MacAddressBlock),
34+
IdentityAlreadySet(VpdIdentity),
3235

3336
#[count(skip)]
3437
None,
@@ -48,13 +51,39 @@ counted_ringbuf!(Trace, 128, Trace::None);
4851
task_slot!(SYS, sys);
4952
task_slot!(SPI, spi);
5053
task_slot!(AUXFLASH, auxflash);
54+
task_slot!(PACKRAT, packrat);
5155

5256
#[export_name = "main"]
5357
fn main() -> ! {
5458
let sys = sys_api::Sys::from(SYS.get_task_id());
5559
let spi = drv_spi_api::Spi::from(SPI.get_task_id());
5660
let aux = drv_auxflash_api::AuxFlash::from(AUXFLASH.get_task_id());
5761

62+
// Populate packrat with dummy values, because talking to the EEPROM is hard
63+
let packrat = Packrat::from(PACKRAT.get_task_id());
64+
let macs = MacAddressBlock {
65+
base_mac: [0; 6],
66+
count: 0.into(),
67+
stride: 0,
68+
};
69+
match packrat.set_mac_address_block(macs) {
70+
Ok(()) => (),
71+
Err(CacheSetError::ValueAlreadySet) => {
72+
ringbuf_entry!(Trace::MacsAlreadySet(macs));
73+
}
74+
}
75+
let identity = VpdIdentity {
76+
serial: *b"GRAPEFRUIT ",
77+
part_number: *b"913-0000083",
78+
revision: 0,
79+
};
80+
match packrat.set_identity(identity) {
81+
Ok(()) => (),
82+
Err(CacheSetError::ValueAlreadySet) => {
83+
ringbuf_entry!(Trace::IdentityAlreadySet(identity));
84+
}
85+
}
86+
5887
match ServerImpl::init(&sys, spi, aux) {
5988
// Set up everything nicely, time to start serving incoming messages.
6089
Ok(mut server) => {

0 commit comments

Comments
 (0)