lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
237 stars 156 forks source link

ILI9341 display and XPT2046 touch on different SPI-hosts fail with DMA error #249

Closed x821938 closed 1 year ago

x821938 commented 1 year ago

When I try to initialize both the ILI9341 display and the xpt2046 (that is on a different SPI host), I get a DMA error.

from ili9XXX import ili9341
disp = ili9341( miso=12, mosi=13, clk=14, cs=15, dc=2, rst=4, backlight=21, power=-1, backlight_on=1, spihost=1)

from xpt2046 import xpt2046
touch = xpt2046(miso=39, mosi=32, clk=33, cs=25, spihost=2)

This is the error that I get:

spi: alloc_dma_chan(221): no available dma channel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "xpt2046.py", line 49, in __init__
  File "xpt2046.py", line 105, in spi_init
RuntimeError: Failed initializing SPI bus

I compiled for version v1.19.1-657-g89c3b3943. I am using the ESP32-Wroom and chose the GENERIC board. I am binding to espressif version 4.4. I get the same result with 4.4.3.

x821938 commented 1 year ago

bump

amirgon commented 1 year ago

Hi @x821938 ,

The error you are getting "no available dma channel" is printed by esp-idf, and is not directly related to LVGL or to the LVGL bindings.
It could be related to the ili9341 and xpt2046 drivers, to other drivers you are using or to system configuration.

Looking at https://github.com/lvgl/lv_binding_micropython/blob/master/driver/generic/xpt2046.py on lines 49 and 105, it looks like you are either using some other version of this driver or made changes in it, because these lines don't point where I would expect.

Unfortunately, currently I don't have the time to try to reproduce your issue on my side.

I would suggest you try to perform the same esp-idf function calls directly in C and try to reproduce this issue separately from LVGL and its Micropython bindings. If you can do that, it could help determining if the problem is related to the ili9341/xpt2046 drivers or to something else.

Another option is to try to use the generic drivers which are not esp32 specific and see if the problem happens there as well.