ESP32-c3 Micropython + LVGL. Please help

I’ve been trying to get LVGL Installed on my esp32-c3 for the past like 15 hours. I know its not ideal to be used on a esp32-c3 but that’s all i have on hand at the moment. I keep getting errors at the “idf.py build” stage of the installation.

Here is the error in question.

FAILED: genhdr/qstr.i.last C:/Espressif/frameworks/esp-idf-v5.3.3/lv_micropython/ports/esp32/build/genhdr/qstr.i.last
esp-idf\main_esp32c3\CMakeFiles\qstr.i.last-417609e.bat 52abe893b499bc47
The system cannot execute the specified program.
Batch file failed at line 3 with errorcode 1
[29/1190] Building C object esp-idf/espressif__mdns/CMakeFiles/__idf_espressif__mdns.dir/mdns.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the C:\Espressif\frameworks\esp-idf-v5.3.3\lv_micropython\ports\esp32\build\log\idf_py_stderr_output_2088 and C:\Espressif\frameworks\esp-idf-v5.3.3\lv_micropython\ports\esp32\build\log\idf_py_stdout_output_2088

C:\Espressif\frameworks\esp-idf-v5.3.3\lv_micropython\ports\esp32>

I’ve tried nearly everything. I’ve tried looking for prebuilt firmware files for esp32-c3 micropython+lvgl but i just cant find them. i need to build every single one with the command which doesn’t work. If any of you have suggestions please share them. It’s probably a stretch but if anyone has a .bin firmware file for the Esp32-c3, MicroPython + LVGL included please let me know, I really need it.

I’m trying to build some UI/GUI with lvgl. I have firmware that includes ili9341 driver to create ui but LVGL is the best from what i’ve heard and easiest to understand.

@kdschlosser are you familiar with what @Anixtzer is running into?

as a matter of fact I am…

The issue that has come up is because of an update to GCC. I am working on correcting the issue in lvgl_micropython which is not the same as lv_micrpython.

I am going to have it fixed within the next few minutes for the binding I have been working on.

Awesome! Thank you so much!
Please link me where your fix is once your completed so i can attempt to build the firmware.

I just pushed a commit that I am hoping will fix the problem with it…

Here is the link to the repo I am working on. Make sure you read the readme file as it will tell you hot to compile it. You do not need to have any requirements like the ESP-IDF downloaded or anything like that. It will do everything for you…

Thank you! Though does this binding work for windows? I read through a little of the documentation and it says the installation instructions for linux, macos. etc but it says windows isn’t supported in the docs?

I’ve tried just going through with the binding and the terminal says “RuntimeError: compiling on windows is not supported at this time” which further confirms why it’s not supported. Is there any other way I can get this to work? Maybe you can a pre-configured esp32-c3 firmware with lvgl and micropython?

Alright well I figured out how to compile the firmware via your instructions. Allthough your github compiler doesnt include esp32c3 firmware. Only esp32_generic. ( aka esp32)

choices=['esp32', 'windows', 'stm32', 'unix', 'rp2', 'renesas-ra', 'nrf', 'mimxrt', 'samd', 'macOS',  'raspberry_pi' ]

Do you perchance have a make.py file that works with esp32-c3?

There is a “BOARD” definition for the C3 and also the C6.

You need to read the readme.md file and that will explain how to use the build script.

Thanks @kdschlosser! I got it working although one major problem. Not sure if its just a me thing or i forgot a step or something. I built the firmware that includes lvgl. Flashed it. Tried it out and realized that the firmware doesn’t include SPI / Doesn’t work with your firmware. SPI is usually essential if not required for lvgl. If you could follow up and lmk if i missed a step or something but as of now it sadly doesn’t work…

Error.

MPY: soft reboot
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: can't create 'SPI' instances
>>> 

^ Importing spi works fine but can’t do anything with SPI instances.

from machine import SPI
print(SPI(1)) 

When i flash another ESP32-c3 With official firmware it works fine which leads me to believe its something going on with your firmware build

UPDATE: I’ve just gone ahead and used softspi instead of SPI. Slower but it’ll do. Another thing, what version of LVGL is in the firmware that i built? It’s missing a lot of features therefor doesn’t let me code with LVGL.

version 9.2.2 is compiled into the firmware. The API is different that the standard C API that LVGL has. It is structured into classes.

as an example.

import lvgl as lv


scrn = lv.screen_active()

slider = lv.slider(scrn)
slider.set_value(80)
slider.center()

def value_callback(event):
    print(slider.get_value())

slider.add_event_cb(value_callback, lv.EVENT.VALUE_CHANGED, None)

There is a python stub file that is generated when you compile. It gets placed into the root directory of the repo. lvgl.pyi is the file name. There are errors in it but it will give the basic idea as to how the API is.

As far as the SPI goes. Because of how vanilla MicroPython was written it didn’t allow for proper sharing of an SPI bus and you cannot have an SDCard reader on the same bus with any other devices. I have corrected the problems associated with that and in order to correct those problems I had to change how the SPI worked. The SPI also now supports dual, quad and octal bus types as well.

here is an example of use…

import machine

spi_bus = machine.SPI.Bus(host=1, mosi=13, miso=12, sck=11)
tp_spi_device = machine.SPI.Device(spi_bus=spi_bus, freq=10000000, cs=14)

import lcd_bus

display_bus = lcd_bus.SPIBus(spi_bus=spi_bus, dc=19, freq=80000000, cs=20)

import st7796
import lvgl as lv

display = st7796.ST7796(
    display_bus, 
    display_width=480, 
    display_height=320, 
    power_pin=8,
    backlight_pin=7,
    color_space=lv.COLOR_FORMAT.RGB565, 
    rgb565_byte_swap=True
)

display.set_power(True)
display.init()
display.set_backlight(100)

import xpt2046

indev = xpt2046.XPT2046(tp_spi_device)

if not indev.is_calibrated:
    indev.calibrate()

...

If you read the readme.md file all of this is gone over in it…

Thanks so much! I’ll get it working! P.S Sorry for not reading the read.me fully through. My bad.