ESP32 - Module lvgl not found after firmware burn(lvgl 1.19.1)

Hello,

I built lv_micropython (v1.19.1) for ESP32 and i have strictly followed the instructions.

So what i did :

Install esp-id and toolchain xtensa
cd /esp-idf/
./install.sh
. ./export.sh
cd /
git clone --recurse-submodules GitHub - lvgl/lv_micropython: Micropython bindings to LVGL for Embedded devices, Unix and JavaScript
cd lv_micropython
make -C mpy-cross
make -C ports/esp32 BOARD=GENERIC_SPIRAM

=> all in success

I use the firmware.bon generated into the directory build_GENERIC_SPIRAM with thonny

=> flash succesfull

But when i want to import:

import lvgl as lv

I have module lvgl not found

So i use help(‘modules’) and that is true the module is not present in the ESP32

If some one have a clue to that issue. I don’t know why the lib lvgl is not loaded.

Regards
Arnaud

So the version 1.19.1 is not working i used the release/v8

Very strange

Arnaud

In what way are you trying “v1.19.1”?
Did you checkout the v1.19.1 tag of lv_micropython? If you did, it’s very obvious why lvgl module is not found. lv_micropython tags are superset of upstream micropython tags, so checking out v1.19.1 yields pure micropython without LVGL integration.
You should check out either the “master” branch of lv_micropython for LVGL v9 (still under development), or “release/v8” branch for stable version.
By the way, the master branch is based on upstream v1.19 and adds LVGL integration on top of it.

Thanks for your anwser.

I tested the master branch but without success.

So i will use the release/v8 for begin.

Regards

I’ve built ESP32-SPIRAM successfully today, here is my script.

git clone -b v4.4.4 --recursive https://github.com/espressif/esp-idf.git esp-idf-v4.4.4
cd esp-idf-v4.4.4
./install.sh
source export.sh
cd …
git clone https://github.com/lvgl/lv_micropython.git
cd lv_micropython
git submodule update --init --recursive lib/lv_bindings
make -C mpy-cross
cd ./ports/esp32
make submodules
make LV_CFLAGS=“-DLV_COLOR_DEPTH=16” BOARD=GENERIC_SPIRAM

Hello,

Thanks you

I did that and it’s building but after some tests, my screen need this parameters:
LV_CFLAGS=“-DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=1” BOARD=GENERIC_SPIRAM

Could you build with COLOR_16_SWAP=1 param ? in my side the build crash.

Regards

Ps i used the branch release/v8. If i have time today i will build master :slight_smile:
On the release/v8 i cannot use the SWAP param without crash the build

I’ve found -DLV_COLOR_16_SWAP=1 is no longer available on v9-dev.
I used to do in v8.3
thanks to @kdschlosser, you could find his answer on my query…

the crash output is so much, i know :slight_smile:
let me know, what is your msg and what is your screen?

Hi,

Of course the stack trace. It is better to understand :wink:

What i did:

Same as you example with clone release/v8
cd ./ports/esp32
make submodules
make LV_CFLAGS=“-DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=1” BOARD=GENERIC_SPIRAM

[ 72%] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/home/acam/project/lilypi-micropython/lv_micro/extmod/moduos.c.obj
[ 72%] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/home/acam/project/lilypi-micropython/lv_micro/extmod/moduplatform.c.obj
[ 72%] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/home/acam/project/lilypi-micropython/lv_micro/shared/runtime/pyexec.c.obj
[ 72%] Generating ../../frozen_content.c
[ 72%] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/__/__/frozen_content.c.obj
/home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/frozen_content.c:507:5: error: redeclaration of enumerator 'MP_QSTR_green_h'
     MP_QSTR_green_h,
     ^~~~~~~~~~~~~~~
In file included from /home/acam/project/lilypi-micropython/lv_micro/py/obj.h:33,
                 from /home/acam/project/lilypi-micropython/lv_micro/py/objint.h:30,
                 from /home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/frozen_content.c:16:
/home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/genhdr/qstrdefs.generated.h:3735:7: note: previous definition of 'MP_QSTR_green_h' was here
 QDEF1(MP_QSTR_green_h, 46121, 7, "green_h")
       ^~~~~~~~~~~~~~~
/home/acam/project/lilypi-micropython/lv_micro/py/qstr.h:51:35: note: in definition of macro 'QDEF1'
 #define QDEF1(id, hash, len, str) id,
                                   ^~
/home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/frozen_content.c:508:5: error: redeclaration of enumerator 'MP_QSTR_green_l'
     MP_QSTR_green_l,
     ^~~~~~~~~~~~~~~
In file included from /home/acam/project/lilypi-micropython/lv_micro/py/obj.h:33,
                 from /home/acam/project/lilypi-micropython/lv_micro/py/objint.h:30,
                 from /home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/frozen_content.c:16:
/home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/genhdr/qstrdefs.generated.h:3736:7: note: previous definition of 'MP_QSTR_green_l' was here
 QDEF1(MP_QSTR_green_l, 46125, 7, "green_l")
       ^~~~~~~~~~~~~~~
/home/acam/project/lilypi-micropython/lv_micro/py/qstr.h:51:35: note: in definition of macro 'QDEF1'
 #define QDEF1(id, hash, len, str) id,
                                   ^~
make[3]: *** [esp-idf/main/CMakeFiles/__idf_main.dir/build.make:7675: esp-idf/main/CMakeFiles/__idf_main.dir/__/__/frozen_content.c.obj] Error 1
make[3] : on quitte le répertoire « /home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM »
make[2]: *** [CMakeFiles/Makefile2:4820: esp-idf/main/CMakeFiles/__idf_main.dir/all] Error 2
make[2] : on quitte le répertoire « /home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM »
make[1]: *** [Makefile:136: all] Error 2


In my case, redeclaration error was occurred by conflict between some modules mp and lvgl.

LV_USE_PNG 1 → lib/lv_bindings/lv_conf.h
MP_LODEPNG (1) → ports/esp32/mpconfigport.h

I’ve never used lilygo product.
I think ‘MP_QSTR_green_l’ is not a part of lv_micropython.

We couldn’t find any issues matching ‘green_l’ in lvgl/lv_micropython

Hi.

But this error come from the branch release/v8 build.
I use only lv_microython default stack.

I agree it is for a lilygo product but i would like in first be able to build lv_micropython.
And After that maybe add some lib if needed.

And about the Master branch i have another build errror. I will add to in the conversation when i m on my computer

Thanks for the Hello

Arnaud

Can you provide those file,

  • lib/lv_bindings/driver/esp32/ili9XXX.py
  • lib/lv_bindings/lv_conf.h
  • ports/esp32/mpconfigport.h
  • /home/acam/project/lilypi-micropython/lv_micro/ports/esp32/build-GENERIC_SPIRAM/frozen_content.c (is it generated?)

The latest version of lv_micropython does not have MP_QSTR_green_h, but release/v8 does. what about build the latest version, you could still use color_swap option with display driver.

Let us find out together :slight_smile:

Hi,

The files about release/v8
lv_conf.h (26.4 KB) => modified LV_COLOR to 16 and swap=1 because parameters are not take into account
mpconfigport.h (9.3 KB)
ili9XXX.py.h (34.3 KB)

For the master branch i have issue during build mpy-cross …

I’ve built with no error,
modified lv_conf.h with the file by @acamu,
make with and without LV_COLOR params are successfully built.

I could not find any conflict in original release/v8 branch, below is a find result after built.

…/lv_micropython> find . | grep --color=auto -rn ‘MP_QSTR_green_h’ --exclude-dir=CMakeFiles

./mpy-cross/build/genhdr/qstr.i.last:3206547:            case MP_QSTR_green_h: dest[0] = mp_obj_new_int_from_uint(data->green_h); break;
./mpy-cross/build/genhdr/qstr.i.last:3206559:                case MP_QSTR_green_h: data->green_h = (uint16_t)mp_obj_get_int(dest[1]); break;
./mpy-cross/build/genhdr/qstrdefs.generated.h:2219:QDEF1(MP_QSTR_green_h, 46121, 7, "green_h")
./mpy-cross/build/lvgl/lv_mpy.c:5755:            case MP_QSTR_green_h: dest[0] = mp_obj_new_int_from_uint(data->green_h); break; // converting from uint16_t;
./mpy-cross/build/lvgl/lv_mpy.c:5767:                case MP_QSTR_green_h: data->green_h = (uint16_t)mp_obj_get_int(dest[1]); break; // converting to uint16_t;
./ports/esp32/build-GENERIC_SPIRAM/genhdr/qstr.i.last:2670035:            case MP_QSTR_green_h: dest[0] = mp_obj_new_int_from_uint(data->green_h); break;
./ports/esp32/build-GENERIC_SPIRAM/genhdr/qstr.i.last:2670047:                case MP_QSTR_green_h: data->green_h = (uint16_t)mp_obj_get_int(dest[1]); break;
./ports/esp32/build-GENERIC_SPIRAM/genhdr/qstrdefs.generated.h:3735:QDEF1(MP_QSTR_green_h, 46121, 7, "green_h")
./ports/esp32/build-GENERIC_SPIRAM/lv_mp.c:5755:            case MP_QSTR_green_h: dest[0] = mp_obj_new_int_from_uint(data->green_h); break; // converting from uint16_t;
./ports/esp32/build-GENERIC_SPIRAM/lv_mp.c:5767:                case MP_QSTR_green_h: data->green_h = (uint16_t)mp_obj_get_int(dest[1]); break; // converting to uint16_t;
./ports/esp32/build-GENERIC_SPIRAM/frozen_content.c:8108:    MP_QSTR_green_h,
Binary file ./ports/esp32/build-GENERIC_SPIRAM/micropython.elf matches
Binary file ./ports/esp32/build-GENERIC_SPIRAM/esp-idf/main/libmain.a matches

Hello,

Thanks for your anwser. after attempt and attempt …i built a LV_COLOR_16 Version it working without SWAP_FLAG=1
But it seem CFLAGS parameter is not taking into account … (so strange)

Now i’m attempt to display something :slight_smile: i added the drivers ST7786 made by @ kdschlosser
https://forum.lvgl.io/t/st7796s-driver-lv-micropython/4123/9
But without success. The driver start and initalize but i have a white screen.

So i decided to use the ST77xx_test.py and it is working with low level command.
https://github.com/lvgl/lv_binding_micropython/blob/master/driver/generic/st77xx-test.py

My script initial script if you can give me your opinion !

import machine
import sys
sys.path.append('.')
import espidf as esp
import lvgl as lv
import utime

from st7796 import *

# init display
disp = st7796(
    miso=23,
    mosi=19,
    clk=18,
    cs=5,
    dc=27,
    rst=-1,
    backlight=12,
    power=-1,
    width=480,#480
    height=320,#320
    rot=0, #PORTRAIT
)

# Create a screen with a button and a label
scr = lv.obj()
btn = lv.btn(scr)
btn.align_to(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Hello World!")

# Load the screen
lv.scr_load(scr)


The driver class

class st7796(ili9XXX.ili9XXX):
xxx from the link

Thanks for your time
Arnaud

Hello,

Here the stack trace when a i want to build the master maybe some one will be interested by :slight_smile:

acam@localhost lilypi-micropython]$ cd lv_micropython/
[acam@localhost lv_micropython]$ make -C mpy-cross V=1
make : on entre dans le répertoire « /home/acam/project/lilypi-micropython/lv_micropython/mpy-cross »
LVGL-GEN build/lvgl/lv_mpy.c
mkdir -p build/lvgl/
gcc -E   -Wno-unused-function -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DPYCPARSER -x c -I ../lib/lv_bindings/pycparser/utils/fake_libc_include -I../lib/lv_bindings -I. -Ibuild -I.. ../lib/lv_bindings/lvgl/lvgl.h > build/lvgl/lvgl.pp.c
python3 ../lib/lv_bindings/gen/gen_mpy.py -M lvgl -MP lv -MD build/lvgl/lv_mpy.json -E build/lvgl/lvgl.pp.c ../lib/lv_bindings/lvgl/lvgl.h > build/lvgl/lv_mpy.c
  File "../lib/lv_bindings/gen/gen_mpy.py", line 1763
    return (user_data if user_data_found else None), *get_user_data_accessors(containing_struct, containing_struct_name)
                                                     ^
SyntaxError: invalid syntax
make: *** [../py/py.mk:47: build/lvgl/lv_mpy.c] Error 1
make: *** Suppression du fichier « build/lvgl/lv_mpy.c »
make : on quitte le répertoire « /home/acam/project/lilypi-micropython/lv_micropython/mpy-cross »
[acam@localhost lv_micropython]$ ^C

I’m not sure what is the source of the problem you are seeing, I just want to point out that the automated tests on GitHub builds the ESP32 port of lv_micropython without any errors.

For example:

Perhaps you could try to find out the differences between your case vs. the automated test.
Possibly some differences in environment, packages, tooling etc.

Hello,

I chose to switch to a fresh install of centos9 and the build from master is working perfectifly.
I will begin to play :slight_smile:

something strange the parameter FLAGS seem to not be taking into account i must modify the lv_conf.h => this is on all version i tested

Regards
Arnaud

Some parameters are set on runtime on v9 (for example the V_COLOR_16_SWAP is now set on runtime according to color_format)

Hello @amirgon,

I tested the v9 but i have the Red and the Blue color inverted.
Some idea ? i attempted to switch to BGR but the display was bad.

Regards

Try to change color_format.
Try lv.COLOR_FORMAT.NATIVE_REVERSED or lv.COLOR_FORMAT.NATIVE