Getting started with lv_port_esp32 and squareline studio

Description

Hi!
It’s the first time i’m using lvgl and i’m quite stuck with setting it up. I’m also new to the espressif ide/idf environment, so that’s not helping either…

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

esp32 with espressif IDE

What do you want to achieve?

I want to get a squareline project running on my esp32 with lvgl.

What have you tried so far?

I cloned the lv_port_esp32 project and I can build and flash it on the esp32. I can get other examples to work from the menuconfig but I can’t get examples working that are not given as a choice in menuconfig. I tried using the lv_demo_music demo but I keep getting an ‘undefined reference’ error during building the project. It’s the same when trying to include the squareline ui files. I think it has something to do with the CMakeList files but I can’t find it.

Screenshot and/or video

undefined reference:


CMakeLists.txt in main:

Can somebody see what i’m doing wrong and help me?
Thanks in advance!

Hi, I think what’s happening is that you are calling the music demo function when you don’t have the lv_examples library installed and/or configured and/or included. lv_demo_music is the music player demo and isn’t your SquareLine Studio UI

If you want to use the demo, make sure to include the examples library, then configure it to enable the music player in lv_demo_conf.h and finally then you can call the music player function.

To use your UI from SquareLine Studio, export the c files and include the ui.h header file and then call ui_init function.

Sorry if I have said anything wrong, I am a beginner too.

Hi Windorey

Thanks for your answer!

I think the lv_examples library is installed together with the lv_port_esp32?

However, I’m not able to enable the music player demo in lv_demo_conf.h. It looks like it’s not an option in the port for the esp32.

The music player demo is not that important to me, I just wanted to figure out how to get my squareline project running. I assume you can get it to work on your system? Do you have a guide on how to because i’m really stuck with that.

Thanks!

I can make a tutorial for you, but it’s for PlatformIO, I have never used ESP-IDF, but I think with the same method it should work for you too. Is it fine?

Yes! I think it can only help :grin:

Thanks!

I’m working on it

Here you go, hope this can help some others too :grinning_face_with_smiling_eyes:

1 Like

Thanks for the effort of the video! However, I still get the same error…

The steps i’ve taken:

  1. I exported the files and put them just in the main folder.

  2. I included ui.h in the main c file.

  3. I called the ui_init() function.

  4. I changed lvgl/lvgl.h to lvgl.h in the ui.h file.


But I still get the annoying error while building the project…

c:/espressif/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj):(.literal.create_demo_application+0x0): undefined reference to `ui_init'
c:/espressif/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj): in function `create_demo_application':
C:/Espressif/frameworks/esp-idf-v4.4.3/workspace/lv_port_esp32/main/main.c:176: undefined reference to `ui_init'

Does anybody know what I’m doing wrong?

Thanks!

Can you send the full code? Maybe I can find something that might be unusual.

Here is my code. It’s just the lv_port_esp32 example with the ui files changed.

Thanks again!

I’m having a struggle understanding this code, I’m certainly not an expert at ESP-IDF.
Try to find someone else to help you, or you can try to use readily available code.
Sorry about it.

No problem!

Esp-idf is also new to me. For arduino, there are enough examples on the internet. when working with esp-idf, there is only lv_port_esp32 and that uses an outdated version of lvgl.

So i’m looking for someone who gets lvgl 8 working in esp-idf! Please reach out to me if you can :grin:.

Thanks!

I’m successfully ported lvgl 8.3 to esp-idf. Tested with hardware ESP32-S3 Parallel TFT with Touch 3.5'' ILI9488 | Makerfabs
Please let me know if any support is required to build the project.

Examples: esp-idf/examples/peripherals/lcd at master · espressif/esp-idf · GitHub

Do you mean the lvgl_esp32_drivers? If so, can you make a PR to upstream, and share the repo for those of us who would quite like LVGL 8.3? I use PlatformIO, but it should work.

@shymega I’m talking about lvgl repo GitHub - lvgl/lvgl at release/v8.3. You can pick required driver code as per your LCD driver. No need complete lvgl_esp32_driver repo .

Hi!

I finaly got lvgl 8.3 to work with my esp32 in espressif ide and squareline! :tada:

I found a working project in a github issue. Thanks to icodk to change the esp32 drivers so it works with lvgl 8!

You can use the driver component from this project and then clone lvgl 8.3 to your project as component. It’s important to clone release 8.3. If you don’t specify this while cloning, you will clone the master branch. This doesn’t work because they are doing the development of lvgl 9 in there.

After that, you need to call some functions to do the initialisation of lvgl in your main c file. This is described in the porting guide of lvgl or you can use the lv_port_esp32 example as reference for this.

Lastly, you can put the generated squareline files in the main folder (or another one). After you included the c files in the CMakeLists.txt file and the ui.h in the main c file, you can call the ui that you designed with squareline!

I hope this might help somebody. If you have any questions or need a more detailed explanation, let me know!