cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 and MPU

Anton1
Associate II

Hello everyone,

I apply STM32F746BE with externel SDRAM 32MB (MT48LC16M16A2P-75 IT:D) and externel FLASH 16MB (MX25L12845GM2I-10G), Ethernet (LAN8710AI-EZK), LCD.

Vector' table is located at 0x20000000. Firmware is runned from externel FLASH 0x90000000

How me configure correctly MPU? What parameters should be changed?

MPU_InitStruct.Enable                     = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress          = 0x20000000;
MPU_InitStruct.Size                          = MPU_REGION_SIZE_8KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsCacheable           = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable           = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsShareable            = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number                  = MPU_REGION_NUMBER0;
MPU_InitStruct.TypeExtField          = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec            = MPU_INSTRUCTION_ACCESS_ENABLE;
 
// Descriptors for Ethernet' driver
MPU_InitStruct.Enable                    = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress         = 0x20001400;
MPU_InitStruct.Size                         = MPU_REGION_SIZE_1KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsCacheable           = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable           = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsShareable            = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number                  = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField          = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec            = MPU_INSTRUCTION_ACCESS_DISABLE;
 
// Buffer RX for Ethernet' driver
MPU_InitStruct.Enable                     = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress          = 0x20001800;
MPU_InitStruct.Size                          = MPU_REGION_SIZE_8KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsCacheable           = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable           = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsShareable            = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number                  = MPU_REGION_NUMBER2;
MPU_InitStruct.TypeExtField           = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec            = MPU_INSTRUCTION_ACCESS_DISABLE;
 
// Buffer TX for Ethernet' driver
MPU_InitStruct.Enable                    = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress         = 0x20003800;
MPU_InitStruct.Size                         = MPU_REGION_SIZE_8KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsCacheable           = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable           = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsShareable            = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number                  = MPU_REGION_NUMBER3;
MPU_InitStruct.TypeExtField          = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec            = MPU_INSTRUCTION_ACCESS_DISABLE;
 
// LCD buffer
MPU_InitStruct.Enable                    = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress         = 0x61F00000;
MPU_InitStruct.Size                         = MPU_REGION_SIZE_1MB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsCacheable           = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable           = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsShareable            = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number                  = MPU_REGION_NUMBER5;
MPU_InitStruct.TypeExtField           = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec            = MPU_INSTRUCTION_ACCESS_DISABLE;
 
// QSPI at memory-mapped mode
MPU_InitStruct.Enable                     = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress          = 0x90000000;
MPU_InitStruct.Size                          = MPU_REGION_SIZE_16MB;
MPU_InitStruct.AccessPermission = MPU_REGION_PRIV_RO_URO;
MPU_InitStruct.IsCacheable           = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsBufferable           = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsShareable            = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number                  = MPU_REGION_NUMBER6;
MPU_InitStruct.TypeExtField          = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec      = MPU_INSTRUCTION_ACCESS_ENABLE;
 

Thank you,

Anton

10 REPLIES 10
world04
Associate II

If you want to use the MPU, you should have a specific reason for it, because it is only necessary in very rare cases to use it. But it doesn't mean that you shouldn't even bother with it. The recommended document about the use and functioning of the MPU is IMHO, essential to acquire the necessary knowledge. The question would not even arise once you have understood this documentation. I think that Parvel.A wanted to suggest this with his reference.

Nobody except the TO can decide whether or not to use the MPU. So I find the comments about whether it makes sense to use the MPU or not, not very helpful.

However, I also see it the same way as the helpful commentators - if you want to use the MPU, you have to understand how it works. If you do not have this, you simply omit the use.

To go into the comparison with the car. The fastest car won't move if the driver can't drive. A car is of no use without a road.