From a0dd354bdc299d7d089bd4ed143f6a213852a905 Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Thu, 3 Apr 2025 16:44:15 -0400 Subject: Add section for boot ROM reservations The boot ROM is allowed to use allocations of OCRAM as scratch space. If you interact with the boot ROM -- using it to interact with FlexSPI, for instance -- then you cannot also use these OCRAM regions. See the system boot chapter in the reference manual for more info. The boot ROM typically reserves the start of OCRAM. The size varies by chip. This commit describes a new section, .bootrom_reservation, at the start of OCRAM. Users are encouraged to place a MaybeUninit buffer that's sized for your ROM's requirements. If users don't place anything in this section, then the new directive is a no-op. On the other hand, the section is defined before other RAM regions, so that it takes precedence over other sections users might want to place in OCRAM. Tested using the runtime's test suite. I'm testing with the Teensy 4 binary, since the test suite can support features in this build. The updated test suite shows that the linker will place the boot ROM reservation before placing the stack, suggesting that we're respecting section priority. --- board/src/teensy4.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'board/src/teensy4.rs') diff --git a/board/src/teensy4.rs b/board/src/teensy4.rs index cf1f734..426fbfa 100644 --- a/board/src/teensy4.rs +++ b/board/src/teensy4.rs @@ -50,3 +50,11 @@ pub static DEVICE_CONFIGURATION_DATA: [u8; 8] = [0xD2, 0x00, 0x08, 0x41, 0xC0, 0 #[unsafe(no_mangle)] #[used] pub static DEVICE_CONFIGURATION_DATA: [u8; 7] = [0xD2, 0x00, 0x08, 0x41, 0xC0, 0x00, 0x04]; + +/// Make sure this reservation appears at the start of OCRAM. +#[cfg(feature = "__bootrom_reservation")] +#[unsafe(link_section = ".bootrom_reservation")] +#[unsafe(no_mangle)] +#[used] +pub static BOOTROM_RESERVATION: core::mem::MaybeUninit<[u8; 48 * 1024]> = + core::mem::MaybeUninit::new([0; 48 * 1024]); -- cgit v1.2.3