guys,
i try to map the heap in external SRAM device on a STM32F767ZI on a custom target with mbed-os 6.9. unfortunately mbed crashes.
the external SRAM device is mapped at address base 0x60000000 and has a size of 2MB.
MPU configuration to allow unaligned accesses:
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.BaseAddress = 0x60000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_2MB;
MPU_InitStruct.SubRegionDisable = 0x00;
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;
FMC bus configuration:
hsram.Init.NSBank = FMC_NORSRAM_BANK1;
hsram.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
hsram.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;
hsram.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;
hsram.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
hsram.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
hsram.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
hsram.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
hsram.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
hsram.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
hsram.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
hsram.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
hsram.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;
hsram.Init.WriteFifo = FMC_WRITE_FIFO_DISABLE;
hsram.Init.PageSize = FMC_PAGE_SIZE_NONE;
FMC timing configuration according to calculations based on datasheets:
SRAM_Timing.AddressSetupTime = 10;
SRAM_Timing.AddressHoldTime = 3;
SRAM_Timing.DataSetupTime = 5;
SRAM_Timing.BusTurnAroundDuration = 2;
SRAM_Timing.CLKDivision = 4;
SRAM_Timing.DataLatency = 0;
SRAM_Timing.AccessMode = FMC_ACCESS_MODE_A;
i configured the scatter-file accordingly and added configuration params HEAP_START
and HEAP_SIZE
as documented.
the external SRAM device works fine when using it from mbed with heap in internal RAM. extended memory tests show no failure of the external SRAM after billions of different accesses from different threads with different alignments.
but as soon as i switch the heap to external SRAM, mbed crashes. i tried a lot of other MPU settings without success.
- did i miss something?
- does anybody have experience with moving heap to external SRAM?
- is there any other magic to be configured in mbed?
best regards
oli4