cancel
Showing results for 
Search instead for 
Did you mean: 

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

Alex Gab
Associate III
Posted on May 25, 2018 at 19:15

Hello to everyone,

let me please ask a question.

I'm using

STemWin

on

STM32F777ZI

controller for GUI development on a custom board.

The board has SDRAM (MT48LC32M16A2, 512 Mbit) connected to the controller through

FMC Bank1

(start address is

0xC0000000).

The 10.4 inch display (1024x768) is connected to the controller through LTDC.

I'm using Atollic True Studio IDE.

Some configuration options in

LCDConf.c:

...

#define COLOR_CONVERSION_0 GUICC_M565

#define DISPLAY_DRIVER_0 GUIDRV_LIN_16

#define GUI_NUM_LAYERS 1

...

#define LCD_LAYER0_FRAME_BUFFER 0xC0400000

#define LCD_LAYER1_FRAME_BUFFER 0xC0800000

...

In

CUIConf.c:

...

#define GUI_NUMBYTES 0x0400000

...

// in

GUI_X_Init():

...

static U32

aMemory[GUI_NUMBYTES / 4] __attribute__ ((section(''.sdram_data'')));

...

As we can see

aMemory

assigned to ''.sdram_data'' section configured in linker *.ld file. It has a start address at

0xC0000000

and a size of

0x0400000, so it wouldn't conflict with a frame buffer memory for layer 0 which has a start address at

0xC0400000. Watch window in IDE shows these correct addresses (aMemory

shows

0xC0000000and

layer_prop[0].address

shows

0xC0400000).

I've also read the LTDC manual from ST (AN4861) attentively and configured all the recommendations that described in this manual (SDRAM and LTDC clock restrictions and MPU regions configuration on SDRAM and internal RAM). SDRAM clock is

100

MHz, and LTDC clock is

50

MHz.

I'm successfully configured and initialized

STemWin

(''Hello, world'' etc... basical drawing functions from 2D graphical library...)

After that I made a simple 1024x768 BMP picture in GIMP (Green text ''This is a BMP'' on the yellow background), then I optimized it using Bitmap Converter, then converted it to C-array using Bin2C for GUI_BMP_Draw() function and finally got it on the screen:

0690X00000604NZQAY.jpg

Next I made a same GIF picture (''This is a GIF''), unoptimized it as described in emWin manual (exactly in emWin

UM03001, not in StemWin manual

 

StemWin532.pdf) then again used  Bitmap Converter and converted the GIF to C-array for using with

GUI_GIF_Draw().

And got this one:0690X00000604k2QAA.jpg

Seems that only few first lines of the GIF displayed.

GUI_GIF_Draw()

 

returned 1. That is error.

Next in function

GUI_X_Config()

I reconfigured

aMemory

location to its default address in internal RAM.

static U32 aMemory[GUI_NUMBYTES / 4]; // __attribute__ ... deleted. Watch window shows 0x20001308 address.

Had to reduce the size of aMemory to

300 KB

as internal RAM is only

512 KB

on the chip:

#define GUI_NUMBYTES

(300 * 1024)

...

Frame buffer location for layer 0 remains unchanged:

#define LCD_LAYER0_FRAME_BUFFER 0xC0400000 //

in SDRAM

C-array containing GIF data also remains unchanged. The only change is

aMemory relocation from SDRAM to internal RAM.

And got it:0690X00000604cPQAQ.jpg

GUI_GIF_Draw()

 

returned 0. Works fine.

Can anyone suggest what is wrong with the drawing a GIF with

aMemory

allocated in SDRAM? First I thought that problem is in SDRAM, but

GUI_BMP_Draw()

 

and

GUI_DrawBitmap()

works properly regardless of

aMemoryallocation. May be I missed some options when I configured STemWin? Or while peripheral configuration (DMA2D, FMC, MPU regions...)?

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.

I can provide a code sections if it is needed.

Thanks for your time.

11 REPLIES 11
john doe
Lead
Posted on May 27, 2018 at 12:28

Do you have the MPU configured as write-through for the SDRAM region?  its the only thing I can think of, with my limited experience

Posted on May 27, 2018 at 20:08

add

WM_MULTIBUF_Enable(0);

Posted on May 28, 2018 at 17:23

Ne rabotaet (

Doesn't work. I do not use Window Manager, just drawing a GIF with GUI_GIF_Draw() after GUI_Init().

I generated a new project with STM32CUBEMX selecting 'GRAPHICS->STemWin' and configuring all the layer's options, hoping Cube will generate a proper 'LCD_Conf.c' file (if the problem in this file). Actually I had to generate the project on STM32F767ZI and change it manually for STM32F777ZI (somehow, the Cube has not 'GRAPHICS' option for this chip).

I also tried various combinations of MPU regions configuration.

But the problem still exist (

Posted on May 28, 2018 at 17:27

Hello, John!

Oh, I've been making a mess with this discussion. I was certain I deleted this question and created a new one. But to my surprise this question still exist )) 

There is a new one:

https://community.st.com/0D50X00009XkWIYSA3

 

This one is updated and there are some screenshots of peripheral configuration including MPU regions.

Can you please tell me, is MPU properly configured or not?

Thank you!

Posted on May 28, 2018 at 17:28

my project with GIF (attach)

https://community.st.com/0D50X00009XkXi4SAF

Posted on May 29, 2018 at 07:27

WM_MULTIBUF_Enable(0):

0690X00000604boQAA.jpg

WM_MULTIBUF_Enable(1):

0690X00000603tnQAA.jpg

The same behaviours. The wings are shown and animated in both cases. And also there is my problem with a bad GIF drawing.

WindowDLG.c is generated by GUI_Builder. It has a hardware abstract code and it doesn't solve the problem.

Posted on May 29, 2018 at 10:59

Is your picture distorted?  

Very strange...

I have an undistorted picture in both cases, for

WM_MULTIBUF_Enable(0);  &   

WM_MULTIBUF_Enable(1);

Posted on May 29, 2018 at 14:06

Seems that problem in wrong MPU configuration. Not solved yet...

Vitaliy Kostyrev
Associate II
Posted on June 01, 2018 at 05:37

#define START_GIF 0xD0600000

#define NEXT_ADDRESS_GIF(A) START_GIF+(A)

void GIF (void)

{

GUI_GIF_IMAGE_INFO ImageInfo = {0}; // Info structure of one particular GIF image of the GIF file

GUI_GIF_INFO GifInfo = {0}; // Info structure of GIF file

int i;

int j;

int XPos;

int YPos;

uint32_t selByt = 0;

fresult=f_open(&MyFile,'123.gif', FA_READ);

do

{

f_read(&MyFile, (char*)NEXT_ADDRESS_GIF(selByt), 512, &bytesread);

selByt+=512;

}while(bytesread > 511);

GUI_GIF_GetInfo((char*)START_GIF, MyFile.fsize, &GifInfo);

WM_MULTIBUF_Enable(1);

while(1)

{

for (j = 0; j < GifInfo.NumImages; j++)

{

GUI_GIF_DrawSub((char*)START_GIF, MyFile.fsize,400, 100, j); // Draw sub image

GUI_GIF_GetImageInfo((char*)START_GIF, MyFile.fsize, &ImageInfo, j); // Get sub image information

}

}

}

static void MPU_Config (void) {   MPU_Region_InitTypeDef MPU_InitStruct;    /* Disable the MPU */   HAL_MPU_Disable();    /* Configure the MPU attributes for SDRAM */   MPU_InitStruct.Enable = MPU_REGION_ENABLE;   MPU_InitStruct.BaseAddress = 0xD0000000;   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_NUMBER0;   MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;   MPU_InitStruct.SubRegionDisable = 0x00;   MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;    HAL_MPU_ConfigRegion(&MPU_InitStruct);    /* Enable the MPU */   HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); }

If you want to use the GUI_GIF_Draw () function, you need to monitor the frame addresses yourself!