CubeMX 6.18.1 doesn't generate the MPU attribute config on STM32U3 (HAL_MPU_ConfigMemoryAttributes missing)
- 1 reply
- 16 views
On the STM32U385 the generated MPU_Config() never configures any MPU attributes. Region settings are generated fine, but the attribute call is missing, so MPU_MAIR0 stays at its UNKNOWN reset value.
Setup
- STM32CubeMX 6.18.1
- STM32U385CGTx (eg. using the Nucleo-U385RG-Q), TrustZone disabled (CORTEX_M33_NS)
Steps
- System Core → CORTEX_M33 → MPU Control Mode: "Background Region Privileged accesses only + MPU Disabled during hard fault, NMI and FAULTMASK handlers"
- Region 0: enabled, base 0x08080000, limit 0x080FFFFF, Attributes Number = ATTRIBUTE 0
- Attributes Settings tab: Attributes 0 enabled, memory type "Normal non-cacheable"
- Generate code
Expected: MPU_Config() contains a HAL_MPU_ConfigMemoryAttributes() call for attribute 0.
Actual: only HAL_MPU_ConfigRegion() and HAL_MPU_Enable() are generated. I tried every memory type (Device, Normal non-cacheable, Normal cacheable) and none of them generates anything.
The .ioc does contain CORTEX_M33_NS.Attributes0-Cortex_Memory_Protection_Unit_Attributes0_Settings=MPU_ATTRIBUTES_NUMBER0. db/mcu/config/CORTEX_M33_NS-STM32U3xx_Configs.xml has a MPU_ConfigMemoryAttributes0 entry with HAL_MPU_ConfigMemoryAttributes, under the condition M33_MPU_ATTRIBUTES_ENABLED0_NS. As far as I can tell that condition is met, so I'd expect the call to be generated.
Workaround: set the attribute by hand in USER CODE BEGIN 1, before MPU_Config() is called:
MPU_Attributes_InitTypeDef mpu_attributes = {
.Number = MPU_ATTRIBUTES_NUMBER0,
.Attributes = INNER_OUTER(MPU_NOT_CACHEABLE),
};
HAL_MPU_ConfigMemoryAttributes(&mpu_attributes);
Attached is a minimal .ioc file to reproduce it.
