From 7a6c4a3b72d5be2076dd1c64a27799de808c5326 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Fri, 25 Oct 2024 20:44:57 +0200 Subject: [PATCH] Get rid of manual padding in rom tests Use the linker script to automatically pad test FMC and RT images. Signed-off-by: Arthur Heymans --- Cargo.lock | 1 + rom/dev/tools/test-fmc/src/fmc.ld | 11 +++++++++-- rom/dev/tools/test-fmc/src/main.rs | 22 ---------------------- rom/dev/tools/test-rt/Cargo.toml | 1 + rom/dev/tools/test-rt/build.rs | 4 +++- rom/dev/tools/test-rt/src/main.rs | 15 --------------- rom/dev/tools/test-rt/src/rt.ld | 10 ++++++++++ 7 files changed, 24 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70faca31c3..ed1a1a2e20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -790,6 +790,7 @@ version = "0.1.0" dependencies = [ "caliptra-cpu", "caliptra-drivers", + "caliptra-image-types", "cfg-if 1.0.0", "ufmt", ] diff --git a/rom/dev/tools/test-fmc/src/fmc.ld b/rom/dev/tools/test-fmc/src/fmc.ld index d0dd9b36de..df23e4b606 100644 --- a/rom/dev/tools/test-fmc/src/fmc.ld +++ b/rom/dev/tools/test-fmc/src/fmc.ld @@ -24,8 +24,7 @@ STACK_ORG = 0x5001C000; ESTACK_ORG = 0x5001F800; NSTACK_ORG = 0x5001FC00; - -ICCM_SIZE = 128K; +ICCM_SIZE = 16K; DCCM_SIZE = 128K; DATA_SIZE = 93K; STACK_SIZE = 14K; @@ -81,6 +80,14 @@ SECTIONS _edata = .; } > DATA AT> ICCM + .padding : ALIGN(4) + { + _padding = .; + . += ICCM_SIZE - SIZEOF(.rodata) - SIZEOF(.text) - SIZEOF(.data) - 1; + BYTE(0xff); + _epadding = .; + } > ICCM + .bss (NOLOAD) : ALIGN(4) { _sbss = .; diff --git a/rom/dev/tools/test-fmc/src/main.rs b/rom/dev/tools/test-fmc/src/main.rs index a75f87ee9b..da6a6ca3cf 100644 --- a/rom/dev/tools/test-fmc/src/main.rs +++ b/rom/dev/tools/test-fmc/src/main.rs @@ -40,27 +40,6 @@ const FW_LOAD_CMD_OPCODE: u32 = mailbox_api::CommandId::FIRMWARE_LOAD.0; #[cfg(feature = "std")] pub fn main() {} -// Dummy RO data to max out FMC image size to 16K. -// Note: Adjust this value to account for new changes in this FMC image. -#[cfg(all(feature = "interactive_test_fmc", not(feature = "fake-fmc")))] -const PAD_LEN: usize = 4988; // TEST_FMC_INTERACTIVE -#[cfg(all(feature = "fake-fmc", not(feature = "interactive_test_fmc")))] -const PAD_LEN: usize = 5224; // FAKE_TEST_FMC_WITH_UART -#[cfg(all(feature = "interactive_test_fmc", feature = "fake-fmc"))] -const PAD_LEN: usize = 5452; // FAKE_TEST_FMC_INTERACTIVE -#[cfg(not(any(feature = "interactive_test_fmc", feature = "fake-fmc")))] -const PAD_LEN: usize = 0; - -static PAD: [u32; PAD_LEN / 4] = { - let mut result = [0xdeadbeef_u32; PAD_LEN / 4]; - let mut i = 0; - while i < result.len() { - result[i] = result[i].wrapping_add(i as u32); - i += 1; - } - result -}; - const BANNER: &str = r#" Running Caliptra FMC ... "#; @@ -299,7 +278,6 @@ fn validate_fmc_rt_load_in_iccm(mbox: &caliptra_registers::mbox::RegisterBlock ! { cprintln!("{}", BANNER); - for (x, item) in PAD.iter().enumerate() { - cprint!("PAD[{}] = 0x{:08X}", x, *item); - } - caliptra_drivers::ExitCtrl::exit(0) } diff --git a/rom/dev/tools/test-rt/src/rt.ld b/rom/dev/tools/test-rt/src/rt.ld index 4edeb0204d..edfd86cc0d 100644 --- a/rom/dev/tools/test-rt/src/rt.ld +++ b/rom/dev/tools/test-rt/src/rt.ld @@ -80,6 +80,16 @@ SECTIONS _edata = .; } > DATA AT> ICCM + .padding : ALIGN(4) + { + _padding = .; + // The manifest size gets replaced in build.rs + . += ICCM_SIZE - SIZEOF(.rodata) - SIZEOF(.text) - SIZEOF(.data) - 1 - #MANIFEST_SIZE#; + BYTE(0xff); + _epadding = .; + } > ICCM + + .bss (NOLOAD) : ALIGN(4) { _sbss = .;