Skip to content

Commit

Permalink
boot only prints out component messages after both messages decrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
Athryx committed Mar 8, 2024
1 parent 4fc3c92 commit 3c89b1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions application_processor/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use design_utils::messages::{
};
use max78000_hal::prelude::*;
use max78000_hal::i2c::{I2cAddr, MAX_I2C_MESSAGE_LEN};
use tinyvec::ArrayVec;

use crate::ApError;
use crate::ectf_params::{
Expand All @@ -38,6 +39,7 @@ struct ComponentBootState {
protocol_in_progress: bool,
expected_reply_nonce: Nonce,
key_index: Option<usize>,
boot_message: Option<ArrayVec<[u8; MAX_I2C_MESSAGE_LEN]>>,
}

impl ComponentBootState {
Expand Down Expand Up @@ -68,11 +70,17 @@ fn send_m3_and_boot(
// recieved encrypted boot message
component.protocol_in_progress = false;

let boot_message = decrypt(&mut encrypted_boot_message, &BOOT_DATA_ENC_KEY)?;
let boot_message = str::from_utf8(boot_message.as_slice())?;
component.boot_message = Some(
decrypt(&mut encrypted_boot_message, &BOOT_DATA_ENC_KEY)?.clone()
);
}

// print boot messages only after both messages have been decrypted
for component in state.iter_mut() {
let boot_message = str::from_utf8(
component.boot_message.as_ref().unwrap().as_slice()
)?;

// Print boot message from component
// TODO: maybe only print these messages after both components have sent them back
uprintln_info!("0x{:x}>{}", component.component_id, boot_message);
}

Expand Down
2 changes: 2 additions & 0 deletions component/src/post_boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extern "C" {
}

// FIXME: don't use static mut
// Can't use critical section cause interrupts need to be turned on while
// a mutable reference to this is needed
static mut COMPONENT_DRIVER: Option<ComponentDriver> = None;

unsafe fn with_driver<T>(f: impl FnOnce(&mut ComponentDriver) -> T) -> T {
Expand Down

0 comments on commit 3c89b1c

Please sign in to comment.