From c4ef7baabb7312ee01378af15400a7cc08846de2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 6 Dec 2025 18:21:57 +0800 Subject: [PATCH] add image size checking in image generator flags when the kernel is too big now --- tools/src/sign_image.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/src/sign_image.rs b/tools/src/sign_image.rs index 0452570b1..ebe04aec1 100644 --- a/tools/src/sign_image.rs +++ b/tools/src/sign_image.rs @@ -255,6 +255,19 @@ pub fn sign_image( } dest_file.write_all(&protected)?; + + if function_code == FunctionCode::Kernel { + let target = bao1x_api::RRAM_STORAGE_LEN - (bao1x_api::KERNEL_START - bao1x_api::BOOT0_START); + if dest_file.len() > target { + println!( + "ERROR: Xous RRAM image is too big to fit: {} bytes too large ({} bytes; {} limit)", + dest_file.len() - target, + dest_file.len(), + target, + ); + return Err(String::from("Image doesn't fit").into()); + } + } Ok(dest_file) } }