diff options
| author | Adam Newell <[email protected]> | 2025-06-09 17:15:24 -0400 |
|---|---|---|
| committer | Adam Newell <[email protected]> | 2025-06-09 22:06:40 -0400 |
| commit | 358a0cd464c0798c7d6a1178b5a633f5d90ad515 (patch) | |
| tree | 1693886ab253504323bd4bebe4f7a3eaa4aeb299 /embassy-rp/src | |
| parent | 6186d111a5c150946ee5b7e9e68d987a38c1a463 (diff) | |
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
Diffstat (limited to 'embassy-rp/src')
| -rw-r--r-- | embassy-rp/src/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index f3c5a35bb..94b20bce3 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs | |||
| @@ -567,7 +567,7 @@ unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { | |||
| 567 | unsafe { | 567 | unsafe { |
| 568 | core.MPU.ctrl.write(5); // enable mpu with background default map | 568 | core.MPU.ctrl.write(5); // enable mpu with background default map |
| 569 | core.MPU.rbar.write(stack_bottom as u32 & !0xff); // set address | 569 | 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); |
| 571 | } | 571 | } |
| 572 | Ok(()) | 572 | Ok(()) |
| 573 | } | 573 | } |
