Sunday, February 25th 2018, 2:41am UTC+1

You are not logged in.

  • Login
  • Register

TMD

Beginner

Date of registration: Jan 26th 2018

Posts: 3

1

Friday, January 26th 2018, 5:19pm

STM32F4 and emWin Memory Devices

Hi, I'm using an STM32F429-Discovery development board with STemWin. The STM32F429 has a 240 x 320 LCD screen on the board. I'm wanting to use an emWin Memory Device to avoid flicker. I'm trying to use code that is very similar to the example code shown in section 16.4 of the emWin User Reference Guide v5.4.0. The code:

//// Create a Memory Device associated with layer 1//
GUI_SelectLayer(1);
hMem = GUI_MEMDEV_Create(0, 0, 100, 100);
GUI_MEMDEV_Select(hMem);
GUI_DrawLine(0, 0, 99, 99);
GUI_MEMDEV_Select(0);
//// Select layer 0//
GUI_SelectLayer(0);
//// The following line copies the Memory Device to layer 1 and not to layer 0//
GUI_MEMDEV_CopyToLCD(hMem);

The above code works. However, I'd like my MEMDEV to cover the entire screen (240 x 320) and not just 100 x 100. So, I change the parameters to the GUI_MEMDEV_Create call to:

hMem = GUI_MEMDEV_Create(0, 0, 240, 320);

This compiles and runs, but the MEMDEV is not successfully created. hMem gets a return value of zero and there is flickering during the drawing operations that do not exist when I used the smaller (100 x 100) dimensions. I've learned the issue is that the GUI_NUMBYTES in GUIConf.c is not large enough to support the chunk of memory necessary for the 240 x 320 MEMDEV and that I must increase the multiplier. For example, the default was this:

//// Define the available number of bytes available for the GUI//
#define GUI_NUMBYTES (1024) * 150

...and I need to increase the "150" to maybe "200" or more like this:

//// Define the available number of bytes available for the GUI//
#define GUI_NUMBYTES (1024) * 200


The problem I run into when doing this is that the RAM necessary for the resulting binary overflows the amount available on the board:

10:15:34 **** Incremental Build of configuration Debug for project STM32F429I_DISCO_MB1075 ****
make all
Building target: STM32F429I_DISCO_MB1075.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -L"C:\tmp\STM32Cube_FW_F4_V1.18.0\Middlewares\ST\STemWin\Lib" -specs=nosys.specs -specs=nano.specs -T"../STM32F429ZITx_FLASH.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "STM32F429I_DISCO_MB1075.elf" @"objects.list" -l:STemWin540_CM4_GCC.a -lm
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.15.0.201708311556/tools/compiler/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld.exe: STM32F429I_DISCO_MB1075.elf section `.bss' will not fit in region `RAM'
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.15.0.201708311556/tools/compiler/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 30880 bytes
collect2.exe: error: ld returned 1 exit status
makefile:39: recipe for target 'STM32F429I_DISCO_MB1075.elf' failed
make: *** [STM32F429I_DISCO_MB1075.elf] Error 1

I'm wondering if anyone else has run into this problem and how they've best dealt with it? Am I just not going to be able to create a MEMDEV the size of the entire screen?

This post has been edited 4 times, last edit by "TMD" (Jan 26th 2018, 5:29pm)


rhum

Beginner

Date of registration: Nov 21st 2017

Posts: 5

2

Wednesday, January 31st 2018, 8:05am

For a 240x320 memory device you need at least 240x320x4 Bytes (in ARGB mode). Therefore you have to put the memory pool used by emwin into your external sdram if internal sram is too small.
See GUIConf.c and you should find something like:

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Define the available number of bytes available for the GUI
#define GUI_NUMBYTES  (1024 * 1024 * 6)  // 6 MByte
//#define GUI_NUMBYTES  (1024 * 6392)  // 6.392 MByte

/*********************************************************************
*
*   	Static data
*
**********************************************************************
*/

//
// 32 bit aligned memory area
//
#ifdef __ICCARM__
  static __no_init U32 _aMemory[GUI_NUMBYTES / 4] @ "GUI_RAM";
#endif
#ifdef __CC_ARM
  U32 static _aMemory[GUI_NUMBYTES / 4] __attribute__ ((section ("GUI_RAM"), zero_init));
#endif
#ifdef __GNUC__
  static U32 _aMemory[GUI_NUMBYTES / 4] __attribute__ ((section (".GUI_RAM")));
#endif
#ifdef _WINDOWS
  static U32 _aMemory[GUI_NUMBYTES / 4];
#endif

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	GUI_X_Config
*
* Purpose:
*   Called during the initialization process in order to set up the
*   available memory for the GUI.
*/
void GUI_X_Config(void) {
  //
  // Assign memory to emWin
  //
  GUI_ALLOC_AssignMemory(_aMemory, GUI_NUMBYTES);
  // Set the default font used by the GUI
  GUI_SetDefaultFont(GUI_DEFAULT_FONT);
}

where GUI_RAM comes from you linker file and defines the start address for the GUI memory in external SDRAM.

TMD

Beginner

Date of registration: Jan 26th 2018

Posts: 3

3

Wednesday, January 31st 2018, 11:16pm

Hi Rhum - Thanks for the reply. I'm not seeing a GUI RAM section in my linker script. The linker script I'm using came with STemWin example's for the STM32F429. It only has the following sections: RAM, CCMRAM and FLASH. I've attached the linker script if you're interested in taking a look. ...So, I'm not sure if I can do this since 240x320x4 bytes = 300K and the STM32F429 has only 256K of RAM. It does have 2 MB of flash, but I can't imagine I can use flash memory for this, right?
TMD has attached the following file:

This post has been edited 1 times, last edit by "TMD" (Jan 31st 2018, 11:17pm)


rhum

Beginner

Date of registration: Nov 21st 2017

Posts: 5

4

Thursday, February 1st 2018, 11:58am

Flash memory which is ROM cannot be used.
IMHO the STM32F429I-Discovery has 8MB of external SDRAM. All you have to do is to initialize the FMC to gain access to the SDRAM. Then add the SDRAM as additonal region to your linker script and place the GUI memory block inside the region.

Maybe it would be best to start looking on examples about the FMC (STM32Cube_FW_F4_V1.1X.0\Projects\STM32F429I-Discovery\Examples\FMC\FMC_SDRAM).

You could also take STM32Cube_FW_F4_V1.18.0\Projects\STM32F429I-Discovery\Demonstrations\STemWin as starter projekt because the project uses SDRAM allready. I noticed that they place the framebuffers into SDRAM, however there is no region defined in the linker file.

This post has been edited 1 times, last edit by "rhum" (Feb 1st 2018, 12:08pm)


TMD

Beginner

Date of registration: Jan 26th 2018

Posts: 3

5

Thursday, February 1st 2018, 5:30pm

Ah, you're right!!! When I originally looked at the datasheet it was not clear to me that this extra memory existed on the board and I did not have any experience with the FMC before. Okay, so now I see I have a whole 8 MB of extra RAM on the board that I can access through properly configuring the FMC. Super!!! Thank you for pointing this out. Very much appreciate it!

Note to others: I suspect it will take me a bit (maybe a week or two) to get this working but if anyone is interested in the code, feel free to reply here or PM me and I can post it somewhere.

Similar threads