cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I have a problem with Cortex-m7 MPU configuration.

KMora.2
Associate

I use ETH / LWIP and SDcard in stm32h750 and config MPU and DMA and it not work, this config is work in along project but i merge it in one project not work please Help me!

static void MPU_Config(void)

{

 MPU_Region_InitTypeDef MPU_InitStruct;

 HAL_MPU_Disable();

 // 1) Enable and config this part for ETH / LWIP

 MPU_InitStruct.Enable = MPU_REGION_ENABLE;

 MPU_InitStruct.BaseAddress = 0x30040000;

 MPU_InitStruct.Size = MPU_REGION_SIZE_256B;

 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

 MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;

 MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;

 MPU_InitStruct.Number = MPU_REGION_NUMBER0;

 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

 MPU_InitStruct.SubRegionDisable = 0x00;

 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);

 MPU_InitStruct.Enable = MPU_REGION_ENABLE;

 MPU_InitStruct.BaseAddress = 0x30044000;

 MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;

 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

 MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

 MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;

 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;

 MPU_InitStruct.Number = MPU_REGION_NUMBER1;

 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

 MPU_InitStruct.SubRegionDisable = 0x00;

 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);

 // 2) Enable and config this part for SD_card

 MPU_InitStruct.Enable = MPU_REGION_ENABLE;

 MPU_InitStruct.BaseAddress = 0x24000000;

 MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;

 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

 MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;

 MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;

 MPU_InitStruct.Number = MPU_REGION_NUMBER0;

 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;

 MPU_InitStruct.SubRegionDisable = 0x00;

 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);

 HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

3 REPLIES 3
TDK
Guru

What does "not work" mean in particular? Do all HAL functions return HAL_OK?

If you feel a post has answered your question, please click "Accept as Solution".
simosilva
Senior

As TDK suggest, the lines of code you reported does not give a clear view on what can be wrong.

In the CubeMX generated project, the MPU Region init typedef is initialized to :

MPU_Region_InitTypeDef MPU_InitStruct = {0};

Other thing missing here with respect to the cubeMX project is the number of the region number:

e.g. MPU_InitStruct.Number = MPU_REGION_NUMBER0;

alister
Lead

Region #0 (MPU_REGION_NUMBER0) is being configured twice.