[mprotect][kconfig] Add safe defaults for MPU region count options - #11766
[mprotect][kconfig] Add safe defaults for MPU region count options#11766Zepp-Hanzj wants to merge 1 commit into
Conversation
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
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-08-28 18:13 CST)
📝 Review Instructions
|
描述 / Description
修复
NUM_MEM_REGIONS/NUM_CONFIGURABLE_REGIONS/NUM_EXCLUSIVE_REGIONS缺少 Kconfig 默认值导致的问题:开启RT_USING_HW_STACK_GUARD但未显式配置时,rtconfig.h会生成空宏(如#define NUM_CONFIGURABLE_REGIONS),进而展开成非法 C 表达式((2 + )、for (i = 0U; i < ; i++)),导致 cortex-m4/m7/m33 的 MPU 代码编译失败。Fix empty-macro compile failure caused by missing Kconfig defaults on the three MPU region count options.
修复 / Changes
components/mprotect/Kconfig:为三个 int 配置项添加安全默认值NUM_MEM_REGIONS = 8(Cortex-M4/M7/M33 常见值,按实际 MCU 修改)NUM_CONFIGURABLE_REGIONS = 0NUM_EXCLUSIVE_REGIONS = 0components/mprotect/README.md:补充 CubeMX 生成的MemManage_Handler与 mpu.c 强符号冲突的说明及解决方式验证 / Validation
RT_USING_HW_STACK_GUARD且不显式配置 NUM_*:生成NUM_MEM_REGIONS 8/NUM_CONFIGURABLE_REGIONS 0/NUM_EXCLUSIVE_REGIONS 0,不再为空宏mpu.o正常编译、LINK rt-thread.elf成功MemManage_Handler符号唯一(来自 mpu.c),stm32f4xx_it.c默认不参与编译参考 / Reference