pico-sdk
pico-sdk copied to clipboard
Error in runtime_install_stack_guard()
See https://forums.raspberrypi.com/viewtopic.php?t=339467
The function runtime_install_stack_guard() in https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/pico_runtime/runtime.c writes to the MPU's RBAR register:
mpu_hw->rbar = (addr & (uint)~0xff) | 0x8 | 0;
I think the ' 0x8 ' is attempting to set the VALID bit so that the ' | 0 ' specifies region 0. But the VALID flag is in bit 4 - so the REGION field is actually ignored. (But the command sets up region 0 anyway, since the RNR register is 0 after reset.)
It would seem this line should be:
mpu_hw->rbar = (addr & (uint)~0xff) | 0x10 | 0;