Skip to content

Commit 358a0cd

Browse files
committed
Fix MPU region enablement in stack guard installation
Updated the MPU region enablement logic in the `install_stack_guard` function to correctly set the region limit by using the stack bottom address plus 256 minus one, ensuring proper memory protection configuration. See Table 235. MPU_RLAR Register in RP2350 documentation See Section 4.5 MPU_RLAR in armv8m MPU documentation
1 parent 6186d11 commit 358a0cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

embassy-rp/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
567567
unsafe {
568568
core.MPU.ctrl.write(5); // enable mpu with background default map
569569
core.MPU.rbar.write(stack_bottom as u32 & !0xff); // set address
570-
core.MPU.rlar.write(1); // enable region
570+
core.MPU.rlar.write(((stack_bottom as usize + 255) as u32) | 1);
571571
}
572572
Ok(())
573573
}

0 commit comments

Comments
 (0)