diff options
| author | Ian McIntyre <me@mciantyre.dev> | 2025-03-12 21:50:39 -0400 |
|---|---|---|
| committer | Ian McIntyre <me@mciantyre.dev> | 2025-03-13 20:14:25 -0400 |
| commit | 4ecbed698241e637a13048a199d29c142445c360 (patch) | |
| tree | 5bafdd61d301a8222f00b37a9ffa00f9bff76c6a /examples | |
| parent | 49385f56eab2dcdbe89cd156ba4e8be95b14e99e (diff) | |
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.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/blink-rtic.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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(); } |
