LVGL with platformio lv_conf.h not found

Description

I’m attempting to run LVGL on the ESP32 using PlatformIO. It seems like menuconfig is not finding the kconfig file and therefore an lv_conf.h file is not created. At least thats my understanding of how its supposed to work.

What MCU/Processor/Board and compiler are you using?

ESP32-WROOM-32D with an SSD1306 compiled with PlatformIO/CMake

What do you want to achieve?

I would like to get past the compilation errors saying that lv_conf.h can’t be found. This definitely seems related to the kconfig files not being detected by menuconfig.

What have you tried so far?

I would like to include the libraries for lvgl and lvgl_esp32_drivers using lib_deps but I also tested bringing them in as a submodule. Both methods failed with the same errors.

Code to reproduce

Add the relevant code snippets here.
In platformio.ini

lib_deps = 
	lvgl/lvgl @ ^7.10.0
	lvgl_esp32_drivers=https://github.com/lvgl/lvgl_esp32_drivers.git#6b08c3fcce0e12b44a171ef88059b52efc0269ad

The errors:

Compiling .pio/build/alphaCaseDebug/lib446/lvgl/lv_core/lv_group.o
In file included from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/../lv_hal/../lv_misc/lv_color.h:16,
                 from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/../lv_hal/lv_hal_disp.h:21,
                 from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/../lv_hal/lv_hal.h:16,
                 from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/lv_disp.h:16,
                 from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/lv_disp.c:9:
.pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/../lv_hal/../lv_misc/../lv_conf_internal.h:46:14: fatal error: ../../lv_conf.h: No such file or directory
 #    include "../../lv_conf.h"                 /*Else assume lv_conf.h is next to the lvgl folder */
              ^~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio/build/alphaCaseDebug/lib446/lvgl/lv_core/lv_indev.o
In file included from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/lv_obj.h:16,
                 from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/lv_group.h:17,
                 from .pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/lv_group.c:9:
.pio/libdeps/alphaCaseDebug/lvgl/src/lv_core/../lv_conf_internal.h:46:14: fatal error: ../../lv_conf.h: No such file or directory
 #    include "../../lv_conf.h"                 /*Else assume lv_conf.h is next to the lvgl folder */
              ^~~~~~~~~~~~~~~~~
compilation terminated.

And it goes on beyond that but you get the idea… Can’t find lv_conf.h

You need to add an lv_conf.h in your src directory.

Brilliant!! Why didn’t I think of creating the file that it said is missing? Now… what actually goes in lv_conf.h??

The instructions for lvgl mention copying from inside lvgl folder to parent folder and enabling by changing a zero to a one. You can also stick it elsewhere with correct defines/build flags.
https://docs.lvgl.io/master/get-started/quick-overview.html#add-lvgl-into-your-project

I’m on the same boat but adding the lv_conf.h file did not work for me, any advise?
I’ve copied lv_conf.h to every single folder in my project directory without any luck.

Executing task: C:\Users\Dev\.platformio\penv\Scripts\platformio.exe run --environment esp32doit-devkit-v1 

Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing lvgl/lvgl @ ^9.2.2
Unpacking  [####################################]  100%
Library Manager: lvgl@9.2.2 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (6.10.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- lvgl @ 9.2.2
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
Building .pio\build\esp32doit-devkit-v1\bootloader.bin
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\lib779\FS\FS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib779\FS\vfs_api.cpp.o
esptool.py v4.5.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio\build\esp32doit-devkit-v1\lib041\LittleFS\LittleFS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libbec\SPI\SPI.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libdc0\SD\SD.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libdc0\SD\sd_diskio.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libdc0\SD\sd_diskio_crc.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_group.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_class.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_draw.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_event.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_id_builtin.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_pos.c.o
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_group.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_group_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_group.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_property.c.o
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_scroll.c.o
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj.h:16,
Compiling .pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_style.c.o
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_group.c.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj.c.o] Error 1
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_types.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_class.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_class_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_class.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_class.c.o] Error 1
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_types.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_draw.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_draw_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_draw.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_draw.c.o] Error 1
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_types.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_class.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_class_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_id_builtin.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_types.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_event.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_event_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_event.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_id_builtin.c.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_event.c.o] Error 1
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_area.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_area_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_pos.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_pos.c.o] Error 1
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_property.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_property.c.o] Error 1
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/lv_area.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_scroll.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_scroll_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_scroll.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../misc/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
In file included from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj.h:16,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_private.h:17,
                 from .pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/lv_obj_style.c:9:
.pio/libdeps/esp32doit-devkit-v1/lvgl/src/core/../lv_conf_internal.h:60:18: fatal error: ../../lv_conf.h: No such file or directory
         #include "../../lv_conf.h"                /*Else assume lv_conf.h is next to the lvgl folder*/
                  ^~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_style.c.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib355\lvgl\core\lv_obj_scroll.c.o] Error 1
================================================================================== [FAILED] Took 13.45 seconds ==================================================================================

 *  The terminal process "C:\Users\Dev\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32doit-devkit-v1'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

lv_conf.h

/**
 * @file lv_conf.h
 * Configuration file for LVGL v9.2.x
 */

/* clang-format off */

#if 1 /* <-- Set to "1" to enable all the content below! */

#ifndef LV_CONF_H
#define LV_CONF_H

/**********************
 *       COLOR
 **********************/

/* 16-bit color for ILI9488 in RGB565 mode */
#define LV_COLOR_DEPTH 16

/*********************
 *   STDLIB WRAPPERS
 *********************/
#define LV_USE_STDLIB_MALLOC    LV_STDLIB_BUILTIN
#define LV_USE_STDLIB_STRING    LV_STDLIB_BUILTIN
#define LV_USE_STDLIB_SPRINTF   LV_STDLIB_BUILTIN

/* Built-in memory manager size: 64 KB */
#define LV_MEM_SIZE (64U * 1024U)

/********************
 *   HAL SETTINGS
 ********************/

 /* Refresh rate ~30 FPS */
#define LV_DEF_REFR_PERIOD      33  /* [ms] */

/* Default DPI. Not super critical; can tweak widget scaling if needed */
#define LV_DPI_DEF              130

/* We do NOT enable an operating system for basic Arduino usage. */
#define LV_USE_OS               LV_OS_NONE

/***************************
 * RENDERING CONFIGURATION
 ***************************/
#define LV_DRAW_BUF_STRIDE_ALIGN 1
#define LV_DRAW_BUF_ALIGN        4

/* Use the SW renderer; no specialized hardware acceleration. */
#define LV_USE_DRAW_SW 1

/************************
 * FEATURE CONFIGURATION
 ************************/
#define LV_USE_LOG 0  /* Disable logs by default */

#define LV_USE_ASSERT_NULL   1
#define LV_USE_ASSERT_MALLOC 1

/*****************
 *   FONTS
 *****************/

/* Enable Montserrat 14 for a decent default text size. */
#define LV_FONT_MONTSERRAT_14 1

/* Set the default font */
#define LV_FONT_DEFAULT       &lv_font_montserrat_14

/***************************
 *  WIDGET USAGE EXAMPLES
 ***************************/
#define LV_BUILD_EXAMPLES 1

/* Enable essential widgets. Turn off anything you don't need. */
#define LV_USE_LABEL      1
#define LV_USE_BTN        1
#define LV_USE_IMG        1
#define LV_USE_SLIDER     1
#define LV_USE_TABVIEW    1
/* etc... */

/**********************
 * THEMES & LAYOUTS
 **********************/
#define LV_USE_THEME_DEFAULT 1
#define LV_USE_FLEX 1
#define LV_USE_GRID 1

/**************
 * DRIVERS
 **************/

/* We’ll use our own `TFT_eSPI` + flush callback externally. */
#define LV_USE_TFT_ESPI         1

/*******************
 * EXAMPLES/DEMOS
 *******************/
#define LV_USE_DEMO_WIDGETS 0
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
#define LV_USE_DEMO_BENCHMARK 0
#define LV_USE_DEMO_STRESS 0
/* etc. */

/* End of configuration */
#endif /* LV_CONF_H */

#endif /* Set to "1" to enable content */
/* clang-format on */

Hey there! I just wanted to say thanks for the great support you’ve been offering! It really helped me move forward with the issue I was facing with lv_conf.h and menuconfig. I had the same problem where it couldn’t find the lv_conf.h file, and I was pulling my hair out trying to figure out what was going wrong

It turned out that I just needed to add the lv_conf.h file in the src directory, but the tricky part was actually figuring out what to put in that file. I read through the docs and the instructions you mentioned about copying the config from the LVGL folder, and with a little tweaking, everything worked perfectly. The platform just needed that configuration to run smoothly

I did try a couple of other things before I got there (including messing around with the library paths and trying different versions), but once I added the config file, it was all good. A huge relief! Now that the issue is sorted, I was wondering if anyone here has some tips on optimizing performance for ESP32 when working with LVGL?

Thanks again for all your help. This community rocks :black_heart: