Hi,
my project's MPU is completely same as the EW build Environment's MPU, I just changed the SDRAM address from 0xD0000000 to 0xC0000000 according to the memory layout of my board.
And I don't have full allowed access between 0xC0000000 and 0xD0000000, if you mean this part:
/* Configure the MPU attributes for SDRAM_Banks area to strongly ordered
This setting is essentially needed to avoid MCU blockings!
See also STM Application Note AN4861 */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER4;
MPU_InitStruct.BaseAddress = 0xC0000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_512MB;
MPU_InitStruct.SubRegionDisable = 0x0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
As it mentions above, it's for configuring SDRAM banks to strongly ordered, as you can see "AccessPermission" has this value: "MPU_REGION_NO_ACCESS"
the main SDRAM MPU config is the bellow section, which I have allowed access for the first 8 MB only:
/* Configure the MPU attributes for SDRAM 32MB to normal memory Cacheable */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER5;
MPU_InitStruct.BaseAddress = 0xC0000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;
MPU_InitStruct.SubRegionDisable = 0x0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
I even tested MPU of STM32H750B-Discovery board's project (which is working properly) and I changed a lot of SDRAM MPU setting and still was able to run my demo without any issue on the STM32H750B-Discovery (And even ignored the MPU_Config() function and commented it in the code and still was able to run my demo).
So looks like the problem is not about MPU in my custom board's project.
Regards.