pub fn install_core0_stack_guard() -> Result<(), ()>
Expand description
Installs a stack guard for the CORE0 stack in MPU region 0.
Will fail if the MPU is already configured. This function requires
a _stack_end
symbol to be defined by the linker script, and expects
_stack_end
to be located at the lowest address (largest depth) of
the stack.
This method can only set up stack guards on the currently executing core. Stack guards for CORE1 are set up automatically, only CORE0 should ever use this.
ยงUsage
use embassy_rp::install_core0_stack_guard;
use embassy_executor::{Executor, Spawner};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
// set up by the linker as follows:
//
// MEMORY {
// STACK0: ORIGIN = 0x20040000, LENGTH = 4K
// }
//
// _stack_end = ORIGIN(STACK0);
// _stack_start = _stack_end + LENGTH(STACK0);
//
install_core0_stack_guard().expect("MPU already configured");
let p = embassy_rp::init(Default::default());
// ...
}