LVGL implementation into STM32 project - multiple errors - have I done the conf correctly?

I have been trying to get LVGL to run on an stm32 project using a 3.5" screen with ST7796. I followed the implementation guidance under LVGL 9.6 documentation as I downloaded the repo last night.

I am using STM32CubeIDE.

I copied everything from the lvgl master branch to my src folder and then as per the guide:

  • I changed the name of the “lv_conf_template” file to “lv_conf” and it is now at the path: …/Core/Src/lvgl/lv_conf.h.
  • I set lv_conf.h line#15 to #if 1 to enable its use.
  • Added a preprocessor called “LV_CONF_INCLUDE_SIMPLE” to the list of preprocessors under C build settings.
  • My display claims to have 65k colours so I left #define LV_COLOR_DEPTH to 16.
  • I added the path / Core /Src / lvgl to my list of include paths in C build settings.
  • I added the lvgl to my project by using #include lvgl.h in the main.c file.
  • I even tried #include “lvgl / lvgl.h” thinking I got the paths confused.

These are the errors I ran into and how I tried to resolve them:

“test_A1_NONE_align64:97:3: error: field name not in record or union initializer”

So I went to the top of the test_A1_NONE_align64.c and found a macro I could use called “LV_LVGL_H_INCLUDE_SIMPLE”, so I added this to my list of preprocessors.

I then started getting errors like:
decomp_raw:5:10: error: #include expects “FILENAME” or

for #include LV_STDDEF_INCLUDE in decomp_raw.c file.

This is something clearly defined in lv_conf.h

#define LV_STDINT_INCLUDE <stdint.h>
#define LV_STDDEF_INCLUDE <stddef.h>

So I changed the decomp_raw.c file to specifically include <stdint.h> and <stddef.h> instead of using macro defines. I then get further errors like:

lv_binfont_loader.h:28:5: error: unknown type name ‘uint32_t’

Which means it clearly cannot find the stdint.h file or does not know what it is. Before I go changing code I probably should not in the LVGL files, could someone more experienced and a different set of eyes please see if I have missed something out when following the implementation guidance? Thank you.

Note: I had to remove the topic template and paths to files above because it thinks I am trying to post more than 3 links. I could try to post them in a seperate reply if needed?

This is what i usually do, to use LVGL in an STM32 project (not using STM32CubeIDE but is using vanilla Eclipse with https://eclipse-embed-cdt.github.io/. Transitioning to VsCode “CMake” at the moment…

  • Create a Folder named lvgl and a subfolder named lvgl.

  • Copy the lv_conf_template.h to the root of the first lvgl folder and rename to lv_conf.h

    • lv_conf.h needs to be on subfolder where lvgl source is located…
  • Change the #if in line 15 to 1 to enable the configuration, and adjust the rest as needed based on hardware / Display

  • Inside the Subdirectory lvgl, for my uses cases i just use the src folder and the *.h files on LVGL source root, but you can have the rest, just delete the tests and docs folders to reduce “garbage” not required and avoid extra c files to be parsed/compiled by the compiler, or exclude those extra folders from the IDE directly.

  • No “prepocessors” directives are required to be added

  • Just need to add two include directories to compiler
    image

  • After that just use #include "lvgl.h" in the source code where we want to use.
    My folder structure on the PC looks like this:

1 Like

Hi @shakedown,

If I can suggest, select a specific release (i.e v9.5, ) and download, It will be easier to manage your project. There are some useful links that you can use to set up your project.

The LVGL Community already supports different developer kits that can be reused in your project.

1 Like

Thanks both. I restarted and used some of your steps e.g. lv_conf.h in the root of my src folder. I also included lvgl as lvgl/lvgl.h in main.c and re-copied the entire lvgl folder into root of my src folder while deleting unwanted stuff. I also looked at the stm32 disco repo which helped. No preprocessors this time, no include paths and it works.