AnsweredAssumed Answered

STemWin: MPU configuration for SDRAM and LTDC

Question asked by Alex Gab on May 29, 2018
Latest reply on Jun 2, 2018 by Alex Gab

Hello to everyone!

 

Recently I was faced with a problem using GUI_GIF_Draw() function. That function works properly with a graphical memory assigned to internal RAM using GUI_ALLOC_AssignMemory() and fails if memory assigned to SDRAM.

My chip is STM32F777ZI.

SDRAM is MT48LC32M16A2.

 

My old thread:

STemWin: problem drawing GIF with a memory assigned to the SDRAM 

 

I suggest my problem is that MPU not properly configured for SDRAM regions. In LTDC manual (AN4861) there is a chapter with special recommendations for Cortex-M7 at page 81. This chapter containing an information about MPU regions configuration.

 

I created following regions:

 

Region0: defines the whole SDRAM memory (64 MByte in my case);
(graphical memory (aMemory) assigned to STemWin using GUI_ALLOC_AssignMemory() (#define GUI_NUMBYTES  0x2000000) and allocated at lower 32 Mbyte of SDRAM. It has a start address 0xC000000 as SDRAM connected through FMC Bank1);
Region1: defines the framebuffer memory (#define LCD_LAYER0_FRAME_BUFFER  ((uint32_t)0xC2000000)); upper 32 Mbyte of SDRAM;
First I configured following attributes:
Region0: normal memory; cacheable; write-through; full access; enable execution.
Region1: normal memory; cacheable; write-through; full access; execute never.
Here is some code:
const unsigned char _acpictgif[4790UL + 1] = {...GIF array...};
int main(void)
{
  MPU_Config();
  SCB_EnableICache();
  SCB_EnableDCache();
   ...
  // Code sections with MCU, HAL, System clock, GPIO, Peripherals configuration, nothing interesting...
   ...
 
 // Start showing the GIF
  GUI_Init();
  GUI_Clear();

  status = GUI_GIF_Draw(_acpictgif, 4790UL + 1, 0, 0); 

  while (1) {

   GUI_Delay(100);

  }

}
void MPU_Config(void)
{
  LL_MPU_Disable();
  LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER0, 0x0, 0xC0000000, LL_MPU_TEX_LEVEL0|LL_MPU_REGION_SIZE_64MB|LL_MPU_REGION_FULL_ACCESS|LL_MPU_INSTRUCTION_ACCESS_ENABLE|LL_MPU_ACCESS_NOT_SHAREABLE|LL_MPU_ACCESS_CACHEABLE|LL_MPU_ACCESS_NOT_BUFFERABLE);

  LL_MPU_EnableRegion(LL_MPU_REGION_NUMBER0);
 
 LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER1, 0x0, 0xC2000000, LL_MPU_TEX_LEVEL0|LL_MPU_REGION_SIZE_32MB|LL_MPU_REGION_FULL_ACCESS|LL_MPU_INSTRUCTION_ACCESS_DISABLE|LL_MPU_ACCESS_NOT_SHAREABLE|LL_MPU_ACCESS_CACHEABLE|LL_MPU_ACCESS_NOT_BUFFERABLE);

  LL_MPU_EnableRegion(LL_MPU_REGION_NUMBER1);

  LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT);

}
Got an error. status = 1:
Next I reconfigured regions to WBWA:
void MPU_Config(void)
{
  LL_MPU_Disable();

  LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER0, 0x0, 0xC0000000, LL_MPU_TEX_LEVEL1|LL_MPU_REGION_SIZE_64MB|LL_MPU_REGION_FULL_ACCESS|
LL_MPU_INSTRUCTION_ACCESS_ENABLE|LL_MPU_ACCESS_NOT_SHAREABLE|LL_MPU_ACCESS_CACHEABLE|LL_MPU_ACCESS_BUFFERABLE);

  LL_MPU_EnableRegion(LL_MPU_REGION_NUMBER0);

  LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER1, 0x0, 0xC2000000, LL_MPU_TEX_LEVEL1|LL_MPU_REGION_SIZE_32MB|LL_MPU_REGION_FULL_ACCESS|
LL_MPU_INSTRUCTION_ACCESS_DISABLE|LL_MPU_ACCESS_NOT_SHAREABLE|LL_MPU_ACCESS_CACHEABLE|LL_MPU_ACCESS_BUFFERABLE);

  LL_MPU_EnableRegion(LL_MPU_REGION_NUMBER1);

  LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT);

}
And got this one. status = 0. No errors but the GIF contains distortion artifacts:

And again I reassigned aMemory for STemWin to internal RAM and got a fine picture. status = 0:

 

Seems that MPU regions not properly configured in case of aMemory allocation in SDRAM.

 

Can anyone tell a proper MPU configuration?

 

Thanks for your time.

Outcomes