adafruit / micropython-adafruit-rgb-display

MicroPython library for RGB pixel displays.
MIT License
53 stars 31 forks source link

OSError Errno 5 EIO #4

Closed xwct closed 6 years ago

xwct commented 7 years ago

using a pyboard v1.1 with a 2gb micro sdcard for the files, and the adafruit ili9341, 2.8" captouch breakout same thing happens when i use machine.Pin for the pins.

d/c --- 'x4' cs --- 'x5' /ss clk --- 'x6' sck mosi -- 'x8' mosi vin --- vin

MicroPython v1.9.1-229-g025e5f2b on 2017-08-18; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> import ili9341
>>> import rgb
>>> import pyb
>>> spi = machine.SPI(1, baudrate=32000000)
>>> spi
SPI(1, baudrate=42000000, polarity=0, phase=0, bits=8)
>>> display = ili9341.ILI9341(spi, cs=pyb.Pin('X4'), dc=pyb.Pin('X5'))
>>> display
<ILI9341 object at 200050c0>
>>> display.fill(ili9341.color565(0, 255, 0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rgb.py", line 111, in fill
  File "rgb.py", line 100, in fill_rectangle
  File "rgb.py", line 72, in _block
  File "rgb.py", line 162, in _write
OSError: [Errno 5] EIO
>>>
deshipu commented 7 years ago

Interesting, I didn't even know SPI write can fail. Can you try doing a write yourself, without using the library?

import machine
spi = machine.SPI(1, baudrate=32000000)
spi.write(b'abc')
xwct commented 7 years ago


update: upgraded my pyboard to 1.9.2-123-gbdc6e86e while changing to network support firmware, now they both don't work with the same error message, while getting no error messages when doing manual write.
deshipu commented 7 years ago

That's interesting, because it should be pretty much the same code.

rick2018 commented 6 years ago

I had the same error. It's caused by writing a zero length buffer to the SPI HAL C code. It seems the DMA code doesn't like zero length buffers and errors. Its easy to fix by adding a single line of code to the following file ..../ports/stm32/spi.c

if(len == 0) return;

It goes here.

STATIC void spi_transfer(const pyb_spi_obj_t self, size_t len, const uint8_t src, uint8_t *dest, uint32_t timeout) {

HAL_StatusTypeDef status;
if(len == 0) return;

...

Its possible to do the same in the MicroPython code and may be a better solution but you would need to test it.

This has been tested with builds 1.9.1, 1.9.2 & 1.9.3 as they all have the same issue.

Gashax commented 6 years ago

Hi i had the same Error With SSD1331 , On pyboard V1.1, Firmware version v1.9.3-500-gbc3a5f19 . i removed the content from line 37-46 from ssd1331.py And used "Spi = SPI(mosi = Pin('X8'), sck = Pin('X6'), miso = Pin('X7'), polarity = 1, phase = 1) ", and display = ssd1331.SSD1331(spi, dc = Pin('X4'), cs = Pin('X5'), rst = Pin('X3')) declaring pins as mosi = 'X8' should yield the same result.

Regards Gashax. And thank you so much for having spent time on writing this driver . !!!