Module MPU_STACK_GUARD on Cortex-M0+

Hi all, While playing with MPU on Cortex-M23, I encountered a weird thing. The module MPU_STACK_GUARD defines a 32-bytes area at the end of a stack to detect stack overflow and generate a MEM_FAULT (HARDFAULT for Cortex-m0+). [1]

I guess the 32-bytes size was chosen because it is the minimal permitted value according to ARM doc [2]. Unfortunately, Cortex-m0+ has a minimal permitted value of 256 bytes [3].

Alexandre ran some tests on nucleo-l053re (using tests/mpu_stack_guard) and they were successful. But I really like to understand why this test is working with wrong parameters… Do we have some MPU experts among us ? :slight_smile:

Note: If you’re willing to run tests/mpu_stack_guard on cortex-m0+, don’t try on SAM0 based board, they don’t have MPU (but they are whitelisted in this test… I’ll change that soon).

[1] https://github.com/RIOT-OS/RIOT/pull/5564

[2] http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/Cihegaib.html#BABHCHBH

[3] http://infocenter.arm.com/help/topic/com.arm.doc.dui0662b/Cihegaib.html#BABHCHBH