pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

Error in runtime_install_stack_guard()

Open esky-software opened this issue 3 years ago • 0 comments

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;

esky-software avatar Aug 28 '22 14:08 esky-software