From f8e124f6f9b36885cda28cea5d73357979057fa7 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 29 Sep 2025 18:41:29 +0800 Subject: [PATCH] limit writeable area to the active data area the top of memory is reserved for various security structures the security structures do have some hardware protection but life is better when we also help programmers avoid triggering the protections by accident and then just being confused. --- libs/bao1x-api/src/offsets.rs | 4 ++++ libs/bao1x-hal/src/rram.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/bao1x-api/src/offsets.rs b/libs/bao1x-api/src/offsets.rs index b89ea4971..80cf1eac2 100644 --- a/libs/bao1x-api/src/offsets.rs +++ b/libs/bao1x-api/src/offsets.rs @@ -6,6 +6,10 @@ pub const BOOT1_START: usize = 0x6002_0000; pub const LOADER_START: usize = 0x6006_0000; pub const BAREMETAL_START: usize = LOADER_START; pub const KERNEL_START: usize = 0x6008_0000; + +// total storage area available in RRAM. Above this are reserved vectors for security apparatus. +pub const RRAM_STORAGE_LEN: usize = 0x3D_A000; + // loadable apps all "start" at this address for UF2 updates // however these are remapped into external flash based on a defragmentation table // and app ID. The app ID also has to get encoded into this offset, likely to be diff --git a/libs/bao1x-hal/src/rram.rs b/libs/bao1x-hal/src/rram.rs index d26c87e85..43bcd92a2 100644 --- a/libs/bao1x-hal/src/rram.rs +++ b/libs/bao1x-hal/src/rram.rs @@ -38,7 +38,7 @@ impl Reram { array: unsafe { core::slice::from_raw_parts_mut( utralib::HW_RERAM_MEM as *mut u32, - utralib::HW_RERAM_MEM_LEN / core::mem::size_of::(), + bao1x_api::RRAM_STORAGE_LEN / core::mem::size_of::(), ) }, }