STM32H735 Multiplexed Memory Mapped OSPI Hyperram Hardfault
Hi, I use OCTOSPI1 and OCTOSPI2 in multiplexed mode to interface with two S27KL0641 ram in Memory Mapped mode.
Those Rams are used for LTDC Frame Buffer and for other application data (structure, data ...).
I started from the STM32Cube_FW_H7_V1.9.0\Drivers\BSP\Components\s70kl1281 and STM32Cube_FW_H7_V1.9.0\Drivers\BSP\STM32H735G-DK from cubeMX to initialise the OSPI, I changed pin affectation, added HAL_OSPIM_Config and enabled IoManager clock.
The application starts correctly but after some minutes it enters in Hardfault.
Depending on MPU initilization, the problem occurs faster.
Here is my MPU configuration
//ospi2 data
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = OCTOSPI2_BASE;
MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;
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_NUMBER0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
//ospi 1 data
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = OCTOSPI1_BASE;
MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;
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_DISABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
//octospi1 frame buff, size = 0x200000
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = OCTOSPI1_BASE;
MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = ~0x03;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
Here is the Ram parameters
hospi->Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
hospi->Init.MemoryType = HAL_OSPI_MEMTYPE_HYPERBUS;
hospi->Init.DeviceSize = Init->MemorySize;
hospi->Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
hospi->Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
hospi->Init.WrapSize = HAL_OSPI_WRAP_128_BYTES;
hospi->Init.SampleShifting = Init->SampleShifting;
hospi->Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_ENABLE;
hospi->Init.ChipSelectBoundary = 23; /* memory die boundary 2^23=8MBs*/
hospi->Init.Refresh = 275; //250; /*4us @100MHz*/
hospi->Init.FifoThreshold = 1;
hospi->Init.ChipSelectHighTime = 20;
hospi->Init.ClockPrescaler = 4; //clocked from 275Mhz
ospi_ram_init.LatencyType = BSP_OSPI_RAM_FIXED_LATENCY;
ospi_ram_init.BurstType = BSP_OSPI_RAM_LINEAR_BURST;
ospi_ram_init.BurstLength = BSP_OSPI_RAM_BURST_32_BYTES;
Can you tell me if there is something wrong in my code that may cause this issue? Thanks in advance
