Esp32 wrover kit 4.1 ili9341 + micropython + lvgl

I’m new to lvgl and would like to try it with micropython on esp-wrover-kit v4.1

I’ve tried different versions of both lv_micropython and esp-idf,
and it looks like only some versions can work together, for example, I only managed to compile and flash lv_micropython master with esp-idf v4.2.

However then I didn’t manage to find any working example.

Could you suggest a commit ID of lv_micropython, commit of esp-idf, and some ili9341 example that are known to work together?

Here is an example that doesn’t even try to print anything but still crashes:

import sys
sys.path.append("")

# Imports
import gc
import lvgl as lv

lv.init()

gc.collect()
from ili9XXX import ili9341

disp = ili9341(miso=25, mosi=23, clk=19, cs=22, dc=21, rst=18, backlight=5, power=-1)
disp.init()

print("init done")
disp_buf1 = lv.disp_draw_buf_t()
buf1_1 = bytearray(240 * 10)
disp_buf1.init(buf1_1, None, len(buf1_1) // lv.color_t.__SIZE__)
disp_drv = lv.disp_drv_t()
disp_drv.init()
print("disp_drv init done")

disp_drv.draw_buf = disp_buf1
disp_drv.flush_cb = disp.flush
disp_drv.hor_res = 240
disp_drv.ver_res = 320
disp_drv.register()
print("disp_drv.register()")

Example output:

cp main.py :main.py
Connected to MicroPython at /dev/ttyUSB1
Use Ctrl-] to exit this shell
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x1e (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:5572
load:0x40078000,len:13136
ho 0 tail 12 room 4
load:0x40080400,len:4356
entry 0x400806b0
Double buffer
ILI9341 initialization completed
Enable backlight
ILI9341 initialization completed
Enable backlight
init done
disp_drv init done
disp_drv.register()
MicroPython v1.15-836-ge71a9729c-dirty on 2021-09-06; ESP32 module (spiram) with ESP32
Type "help()" for more information.
>>> Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x40243e4a  PS      : 0x00060031  A0      : 0x80128f59  A1      : 0x3ffbe400  
A2      : 0x3f81a160  A3      : 0x00060023  A4      : 0x00060021  A5      : 0x3ffd30f0  
A6      : 0x00000006  A7      : 0x00000003  A8      : 0x00000000  A9      : 0x00000000  
A10     : 0x3ffc5624  A11     : 0x3ff0017c  A12     : 0x00000006  A13     : 0x00060021  
A14     : 0x000000fe  A15     : 0x00000001  SAR     : 0x0000001e  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000018  LBEG    : 0x400935ac  LEND    : 0x400935c8  LCOUNT  : 0xffffffff  

Backtrace:0x40243e47:0x3ffbe400 0x40128f56:0x3ffbe420 0x4008e083:0x3ffbe440 0x4008e250:0x3ffbe460 0x40084532:0x3ffbe4a0 0x0004001e:0x00000000 |<-CORRUPTED


ELF file SHA256: d7c75ab00fca8dd7

Rebooting...
ets Jun  8 2016 00:22:57

Finally, I’ve managed to get async example to work, here is mine from the master with updated pin numbers https://gist.github.com/kumekay/11f1a3afa0fbafe8df2ac741a95ecc44

However, it’s still not clear to me what is wrong with the original one.

Hi @kumekay!
lv_micropython on esp-wrover + ili9341 is well supported.

Latest lv_micropython works with esp-idf v4.3 and should also work with v4.0.2 and possibly other versions. The CI checks these versions.

When you create an instance of ili9341 you are not supposed to register display driver, this is already done in ili9341.

If you are looking for an example to run, I recommend advanced_demo.py.
ili9341 is initialized there like this:

@amirgon Thank you so much, it works just fine