Hello to everyone,
let me please ask a question.
I had requested with this question to ST community but I didn't receive a helpful answer. Maybe someone can help me with my problem on this forum.
I'm using precompiled emWin library (STemWin) for GUI development on a custom board with SDRAM and LCD panel.
My chip is STM32F777ZIT6.
SDRAM chip is MT48LC32M16A2 (64 MByte) connected to the chip through FMC bank1 (start address is 0xC0000000).
LCD panel is G104XVN01.0 (10.4 inch, 1024x768) connected to the chip through LTDC using RGB-LVDS transceiver.
I successfully configured and initialized emWin ("Hello, world" etc... basical drawing functions from 2D graphical library...). But my problem is drawing a GIF when allocating memory in SDRAM.
I created a simple project with one framebuffer layer. I split SDRAM memory space in half to simplify the project: lower 32 MBytes allocated to emWin, higher 32 MBytes allocated to framebuffer layer 0. Also I made a simple GIF picture (green text "This is a GIF" on the yellow background), unoptimized it as described in emWin manual, then used Bitmap Converter and converted the GIF to C-array with BIN2C for using with GUI_GIF_Draw().
Some configuration options and code sections:
Display All
I'm using System Workbench IDE. Watch window in IDE shows correct addresses (extMem shows 0xC0000000 and layer_prop[0].address shows 0xC2000000).
Code section with main():
Display All
First I configured the MPU regions (in my view it is "WRITE THROUGH")
Display All
And got this one. status = 1. That is an error. Only first few lines of the GIF are displayed:
[img]https://forum.segger.com/index.php/Attachment/2604-IMG-4643-JPG/?tiny=1[/img]
Next I reconfigured MPU regions (in my view it is "WBWA"):
Display All
And got this one. status = 0. No errors but the GIF contains distortion artifacts:
[img]https://forum.segger.com/index.php/Attachment/2605-IMG-4644-JPG/?tiny=1[/img]
Next I reassigned extMem to internal RAM:
Had to reduce GUI_NUMBYTES to 130 KBytes as the chip has only 512 KBytes of infernal RAM.
C-array containing GIF data and frame buffer location for layer 0 remain unchanged. The only change is extMem relocation from SDRAM to internal RAM.
And I got a fine picture:
[img]https://forum.segger.com/index.php/Attachment/2606-IMG-4642-JPG/?tiny=1[/img]
Seems that MPU regions not properly configured in case of extMem allocation in SDRAM. And furthermore, functions GUI_BMP_Draw() and GUI_DrawBitmap() work properly regardless of extMem allocation. The problem appears only when drawing a GIF.
Can anyone tell a proper MPU configuration?
It is critical for my development to use GIFs as they have compact size and the board has only internal flash on the chip (2 MB).
In addition, I'm going to use Window Manager and use GIFs as background images with different widgets over it. So I need to use Memory Devices for fast painting when invalidating windows and I should have sufficient RAM for that purposes as internal RAM is not enough.
My project attached.
Thanks for your time.
let me please ask a question.
I had requested with this question to ST community but I didn't receive a helpful answer. Maybe someone can help me with my problem on this forum.
I'm using precompiled emWin library (STemWin) for GUI development on a custom board with SDRAM and LCD panel.
My chip is STM32F777ZIT6.
SDRAM chip is MT48LC32M16A2 (64 MByte) connected to the chip through FMC bank1 (start address is 0xC0000000).
LCD panel is G104XVN01.0 (10.4 inch, 1024x768) connected to the chip through LTDC using RGB-LVDS transceiver.
I successfully configured and initialized emWin ("Hello, world" etc... basical drawing functions from 2D graphical library...). But my problem is drawing a GIF when allocating memory in SDRAM.
I created a simple project with one framebuffer layer. I split SDRAM memory space in half to simplify the project: lower 32 MBytes allocated to emWin, higher 32 MBytes allocated to framebuffer layer 0. Also I made a simple GIF picture (green text "This is a GIF" on the yellow background), unoptimized it as described in emWin manual, then used Bitmap Converter and converted the GIF to C-array with BIN2C for using with GUI_GIF_Draw().
Some configuration options and code sections:
C Source Code
- ...
- #define COLOR_CONVERSION_0 GUICC_M565
- #define DISPLAY_DRIVER_0 GUIDRV_LIN_16
- #define GUI_NUM_LAYERS 1
- ...
- #define LCD_LAYER0_FRAME_BUFFER 0xC2000000
- ...
- #define GUI_NUMBYTES 0x2000000
- ...
- static U32 extMem[GUI_NUMBYTES / 4] __attribute__ ((section(".sdram_data"))); // ".sdram_data" is a SDRAM section in linker *.ld file, start address is 0xC0000000
- ...
- void GUI_X_Config(void)
- {
- GUI_ALLOC_AssignMemory(extMem, GUI_NUMBYTES); // Assign memory for emWin
- }
- ...
Code section with main():
C Source Code
- extern const unsigned char _acpictgif[4790UL + 1] = {...GIF array...};
- ...
- int status;
- ...
- int main(void)
- {
- MPU_Config();
- SCB_EnableICache();
- SCB_EnableDCache();
- ...
- // Code sections with MCU, HAL, System clock, GPIO, Peripherals, emWin configuration, nothing interesting...
- ...
- // Start showing the GIF
- GUI_Clear();
- status = GUI_GIF_Draw(_acpictgif, 4790UL + 1, 0, 0);
- while (1) {
- GUI_Delay(100);
- }
- }
First I configured the MPU regions (in my view it is "WRITE THROUGH")
C Source Code
- void MPU_Config(void)
- {
- /* Disables the MPU */
- LL_MPU_Disable();
- /**Initializes and configures the Region and the memory to be protected
- */
- // WT
- 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);
- /**Initializes and configures the Region and the memory to be protected
- */
- 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);
- }
And got this one. status = 1. That is an error. Only first few lines of the GIF are displayed:
[img]https://forum.segger.com/index.php/Attachment/2604-IMG-4643-JPG/?tiny=1[/img]
Next I reconfigured MPU regions (in my view it is "WBWA"):
C Source Code
- void MPU_Config(void)
- {
- /* Disables the MPU */
- LL_MPU_Disable();
- // WBWA
- LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER0, 0x0, 0xC0000000, LL_MPU_TEX_LEVEL1|LL_MPU_REGION_SIZE_32MB|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);
- /**Initializes and configures the Region and the memory to be protected
- */
- 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);
- /* Enables the MPU */
- LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT);
- }
And got this one. status = 0. No errors but the GIF contains distortion artifacts:
[img]https://forum.segger.com/index.php/Attachment/2605-IMG-4644-JPG/?tiny=1[/img]
Next I reassigned extMem to internal RAM:
Had to reduce GUI_NUMBYTES to 130 KBytes as the chip has only 512 KBytes of infernal RAM.
C-array containing GIF data and frame buffer location for layer 0 remain unchanged. The only change is extMem relocation from SDRAM to internal RAM.
And I got a fine picture:
[img]https://forum.segger.com/index.php/Attachment/2606-IMG-4642-JPG/?tiny=1[/img]
Seems that MPU regions not properly configured in case of extMem allocation in SDRAM. And furthermore, functions GUI_BMP_Draw() and GUI_DrawBitmap() work properly regardless of extMem allocation. The problem appears only when drawing a GIF.
Can anyone tell a proper MPU configuration?
It is critical for my development to use GIFs as they have compact size and the board has only internal flash on the chip (2 MB).
In addition, I'm going to use Window Manager and use GIFs as background images with different widgets over it. So I need to use Memory Devices for fast painting when invalidating windows and I should have sufficient RAM for that purposes as internal RAM is not enough.
My project attached.
Thanks for your time.
The post was edited 7 times, last by LexaGB ().