cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-H753ZI - Add new MPU regions

KLedi.2
Associate II

Hello.

I succeeded to run my own app with SBSFU on a NUCLEO-H753ZI. But now, my app uses Lwip and differents DMAs. Then, I need these 3 MPU regions:

MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.BaseAddress = 0x24000000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;
  MPU_InitStruct.SubRegionDisable = 0x0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
  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_NOT_CACHEABLE;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
  /** Initializes and configures the Region and the memory to be protected
  */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER1;
  MPU_InitStruct.BaseAddress = 0x30040000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
  MPU_InitStruct.SubRegionDisable = 0x0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
  /** Initializes and configures the Region and the memory to be protected
  */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER2;
  MPU_InitStruct.BaseAddress = 0x30044000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
  MPU_InitStruct.SubRegionDisable = 0x0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

The first one is for DMAs on SRAM1. The two other ones are for LwIP on SRAM2.

I expect to put these 3 regions on the SBSFU MPU config at the end. For the moment, I desactivated all SBSFU securities and I encounter an issue with MPU region for SRAM1. I can see with debuger that my app crashes when it returns from MPU_Config(). If I remove this MPU region I have no issue to start my app.

Thank you in advance for your help.

Kevyn

1 ACCEPTED SOLUTION

Accepted Solutions
Jocelyn RICARD
ST Employee

Hello Kevyn,

The MPU configuration in SBSFU is setup to be used in SBSFU only.

When you jump to application, the hide protect memory is activated (if enabled) and MPU is disabled.

You need to setup the MPU in your application.

And, one important thing to take care: SBSFU is setting up all MPU regions and just disabling MPU before jump to application.

So, before reactivating MPU on your side, you need to make sure all 8 regions are setup according to your needs.

For this, you can just disable the regions you don't use.

Best regards

Jocelyn

View solution in original post

2 REPLIES 2
Jocelyn RICARD
ST Employee

Hello Kevyn,

The MPU configuration in SBSFU is setup to be used in SBSFU only.

When you jump to application, the hide protect memory is activated (if enabled) and MPU is disabled.

You need to setup the MPU in your application.

And, one important thing to take care: SBSFU is setting up all MPU regions and just disabling MPU before jump to application.

So, before reactivating MPU on your side, you need to make sure all 8 regions are setup according to your needs.

For this, you can just disable the regions you don't use.

Best regards

Jocelyn

KLedi.2
Associate II

Hello Jocelyn,

Thank you for your help. I followed your instructions and it works !

I set the MPU config that I need directly into my application. I had a conflict with the activation of DCache et ICache into my application. I solved it by not enabling ICache and DCache in SBSFU.

Best regards

Kevyn