Files
hanzhijian 2c98902543 [mprotect][kconfig] Add safe defaults for MPU region count options
NUM_MEM_REGIONS / NUM_CONFIGURABLE_REGIONS / NUM_EXCLUSIVE_REGIONS had no
Kconfig defaults. Enabling RT_USING_HW_STACK_GUARD without explicitly
setting them generated empty macros in rtconfig.h (e.g.
'#define NUM_CONFIGURABLE_REGIONS'), which expanded into invalid C
expressions like '(2 + )' and 'for (i = 0U; i < ; i++)', breaking
compilation for cortex-m4/m7/m33 MPU code.

Add safe defaults: NUM_MEM_REGIONS=8, NUM_CONFIGURABLE_REGIONS=0,
NUM_EXCLUSIVE_REGIONS=0. Also document the MemManage_Handler strong-symbol
conflict with CubeMX-generated stm32f4xx_it.c and how to resolve it.

Reported-by: wdfk-prog
2026-09-07 10:31:49 +08:00

37 lines
1.2 KiB
Plaintext

menu "Memory protection"
config RT_USING_MEM_PROTECTION
bool "Enable memory protection"
default n
select RT_USING_HEAP
config RT_USING_HW_STACK_GUARD
bool "Enable hardware stack guard"
default n
select RT_USING_MEM_PROTECTION
if RT_USING_MEM_PROTECTION
config USE_MEM_PROTECTION_EXAMPLES
bool "Use memory protection examples"
default y
config NUM_MEM_REGIONS
int "Total number of memory protection regions supported by hardware"
default 8
help
The number of MPU regions supported by the target MCU. The common value
for Cortex-M4/M7/M33 is 8, but some MCUs expose 4, 12, or 16 regions.
Set this to the actual value reported by the hardware, otherwise the MPU
initialization will reject the configuration at runtime.
config NUM_EXCLUSIVE_REGIONS
int "Total number of exclusive memory regions added using rt_mprotect_add_exclusive_region API"
default 0
config NUM_CONFIGURABLE_REGIONS
int "Maximum number of configurable memory regions for each thread, excluding stack guard and exclusive regions added using rt_mprotect_add_exclusive_region API"
default 0
endif
endmenu