From 4ecbed698241e637a13048a199d29c142445c360 Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Wed, 12 Mar 2025 21:50:39 -0400 Subject: Place .xip sections into flash We added the `.xip` section to ensure that the reset handler and pre-init functions would be placed in flash. This commit lets users place other content into that section. `.xip` is intended for instructions. The runtime builder will place these instructions into the same load region as `.text`. However, there's no pre-`main` relocation. Aligning the `.xip` and the `.text` section produces more predictable behavior between GNU's ld and LLVM's lld. --- examples/blink-rtic.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/blink-rtic.rs b/examples/blink-rtic.rs index 04446e3..e463f33 100644 --- a/examples/blink-rtic.rs +++ b/examples/blink-rtic.rs @@ -12,6 +12,13 @@ use imxrt_rt as _; /// This is checked in an automated test. static mut DATA: u32 = 5; +#[unsafe(link_section = ".xip")] +#[unsafe(no_mangle)] +#[inline(never)] +fn increment_data() { + unsafe { crate::DATA = crate::DATA.wrapping_add(1) }; +} + #[rtic::app(device = board::rtic_support, peripherals = false)] mod app { const PIT_PERIOD_US: u32 = 1_000_000; @@ -35,7 +42,7 @@ mod app { #[task(binds = PIT, local = [led, pit])] fn pit(cx: pit::Context) { - unsafe { crate::DATA += 1 }; + crate::increment_data(); cx.local.led.toggle(); cx.local.pit.clear_interrupts(); } -- cgit v1.2.3