Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of manual padding in rom tests #1740

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

11 changes: 9 additions & 2 deletions rom/dev/tools/test-fmc/src/fmc.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = .;
Expand Down
22 changes: 0 additions & 22 deletions rom/dev/tools/test-fmc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
"#;
Expand Down Expand Up @@ -299,7 +278,6 @@ fn validate_fmc_rt_load_in_iccm(mbox: &caliptra_registers::mbox::RegisterBlock<R
fmc_iccm[idx]
);
mismatch = true;
cprint!("PAD[{}] = 0x{:08X}", idx, PAD[idx]);
}
}
for (idx, _) in rt_iccm.iter().enumerate().take(rt_size / 4) {
Expand Down
1 change: 1 addition & 0 deletions rom/dev/tools/test-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ caliptra-drivers.workspace = true
ufmt.workspace = true

[build-dependencies]
caliptra-image-types.workspace = true
cfg-if.workspace = true

[features]
Expand Down
4 changes: 3 additions & 1 deletion rom/dev/tools/test-rt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ fn main() {
use std::path::PathBuf;

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
fs::write(out_dir.join("rt.ld"), include_bytes!("src/rt.ld")).unwrap();
let ld_script = include_str!("src/rt.ld")
.replace("#MANIFEST_SIZE#", &caliptra_image_types::IMAGE_MANIFEST_BYTE_SIZE.to_string());
fs::write(out_dir.join("rt.ld"), ld_script).unwrap();

println!("cargo:rustc-link-search={}", out_dir.display());
println!("cargo:rustc-link-arg=-Trt.ld");
Expand Down
15 changes: 0 additions & 15 deletions rom/dev/tools/test-rt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ mod print;
#[cfg(feature = "std")]
pub fn main() {}

// Dummy RO data to max out FW image size.
static PAD: [u32; 26778] = {
let mut result = [0xba5eba11_u32; 26778];
let mut i = 0;
while i < result.len() {
result[i] = result[i].wrapping_add(i as u32);
i += 1;
}
result
};

const BANNER: &str = r#"
____ _ _ _ ____ _____
/ ___|__ _| (_)_ __ | |_ _ __ __ _ | _ \_ _|
Expand All @@ -49,10 +38,6 @@ const BANNER: &str = r#"
pub extern "C" fn rt_entry() -> ! {
cprintln!("{}", BANNER);

for (x, item) in PAD.iter().enumerate() {
cprint!("PAD[{}] = 0x{:08X}", x, *item);
}

caliptra_drivers::ExitCtrl::exit(0)
}

Expand Down
10 changes: 10 additions & 0 deletions rom/dev/tools/test-rt/src/rt.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 = .;
Expand Down
Loading