STM32F4 and emWin Memory Devices

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 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?

      The post was edited 4 times, last by TMD ().

    • 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 Source Code

      1. //
      2. // Define the available number of bytes available for the GUI
      3. #define GUI_NUMBYTES (1024 * 1024 * 6) // 6 MByte
      4. //#define GUI_NUMBYTES (1024 * 6392) // 6.392 MByte
      5. /*********************************************************************
      6. *
      7. * Static data
      8. *
      9. **********************************************************************
      10. */
      11. //
      12. // 32 bit aligned memory area
      13. //
      14. #ifdef __ICCARM__
      15. static __no_init U32 _aMemory[GUI_NUMBYTES / 4] @ "GUI_RAM";
      16. #endif
      17. #ifdef __CC_ARM
      18. U32 static _aMemory[GUI_NUMBYTES / 4] __attribute__ ((section ("GUI_RAM"), zero_init));
      19. #endif
      20. #ifdef __GNUC__
      21. static U32 _aMemory[GUI_NUMBYTES / 4] __attribute__ ((section (".GUI_RAM")));
      22. #endif
      23. #ifdef _WINDOWS
      24. static U32 _aMemory[GUI_NUMBYTES / 4];
      25. #endif
      26. /*********************************************************************
      27. *
      28. * Public code
      29. *
      30. **********************************************************************
      31. */
      32. /*********************************************************************
      33. *
      34. * GUI_X_Config
      35. *
      36. * Purpose:
      37. * Called during the initialization process in order to set up the
      38. * available memory for the GUI.
      39. */
      40. void GUI_X_Config(void) {
      41. //
      42. // Assign memory to emWin
      43. //
      44. GUI_ALLOC_AssignMemory(_aMemory, GUI_NUMBYTES);
      45. // Set the default font used by the GUI
      46. GUI_SetDefaultFont(GUI_DEFAULT_FONT);
      47. }
      Display All

      where GUI_RAM comes from you linker file and defines the start address for the GUI memory in external SDRAM.
    • 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?
      Files

      The post was edited 1 time, last by TMD ().

    • 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.

      The post was edited 1 time, last by rhum ().

    • 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.