cancel
Showing results for 
Search instead for 
Did you mean: 

H743 FMC SRAM memory fault

snkparty1
Associate III

I tested FMC speed on F403 and H743. F403 works fine but H743 code will stopped due to memory fault.

I set FMC parameter like below

F407.pngF407_code.png

My plan is to connect stm32 to fpga by using FMC so did this test to check the speed. F407 test succeeded.

But H743, the same code will stop due to memory error?

H743.pngH743_code.pngF743 memory error.png

 

I did this test without connecting FMC to anything.(FPGA is much faster so I only need to verify stm32 fmc speed.)

I have no idea why f743 has this issue...

1 ACCEPTED SOLUTION

Accepted Solutions

@snkparty1 wrote:

I found out this issue was caused by MPU. In cubeide due to some reason I do not know MPU unit was turned on and FSMC address was protected...After I turned off MPU then it works as expected.


Indeed, The MPU configuration set by default is the MPU background configuration to prevent the speculative access of CM7. So I don't recommend to disable that MPU configuration but to add another configuration to make FMC access possible with a new MPU region.

This is an example to make it work (from the SDRAM example from CubeH7 package):

static void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct;

  /* Disable the MPU */
  HAL_MPU_Disable();

  /* Configure the MPU as Strongly ordered for not defined regions */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x00;
  MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
  MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x87;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

  HAL_MPU_ConfigRegion(&MPU_InitStruct);

  /* Configure the MPU attributes as WB for SDRAM */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = SDRAM_BANK_ADDR;
  MPU_InitStruct.Size = MPU_REGION_SIZE_16MB;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_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);

  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Pavel A.
Super User

Wrong alignment? Note that you wrote "F403 works" but on the Cube config picture: F407.

The code snippets also are different: the first one:

for(uint16_t i=0; i<32768; i++)
{
  *(_I0 uint16_t*) (Bank1_SRAM1_ADDR + i)=(uint16_t)(0x1000);
}

The 2nd (for H743)

for(uint16_t i=0; i<32768; i++)
{
  *(_I0 uint16_t*) (Bank1_SRAM1_ADDR + 2*i)=(uint16_t)(0x1000+i);
}

When the MemManage fault occurs, have you tried to look at the registers (the address etc) that help diagnose the reason?

Have you set up the external RAM region in the MPU?

 

I found out this issue was caused by MPU. In cubeide due to some reason I do not know MPU unit was turned on and FSMC address was protected...After I turned off MPU then it works as expected.


@snkparty1 wrote:

I found out this issue was caused by MPU. In cubeide due to some reason I do not know MPU unit was turned on and FSMC address was protected...After I turned off MPU then it works as expected.


Indeed, The MPU configuration set by default is the MPU background configuration to prevent the speculative access of CM7. So I don't recommend to disable that MPU configuration but to add another configuration to make FMC access possible with a new MPU region.

This is an example to make it work (from the SDRAM example from CubeH7 package):

static void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct;

  /* Disable the MPU */
  HAL_MPU_Disable();

  /* Configure the MPU as Strongly ordered for not defined regions */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x00;
  MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
  MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x87;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

  HAL_MPU_ConfigRegion(&MPU_InitStruct);

  /* Configure the MPU attributes as WB for SDRAM */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = SDRAM_BANK_ADDR;
  MPU_InitStruct.Size = MPU_REGION_SIZE_16MB;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_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);

  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.