Working SPI Display

Oh, excellent , a way forward! I’ll give this a try!

Considering you haven’t got my hardware, regarding debugging the situation, I think you’re doing an excellent job, and I’m grateful for your help.

Also, if you want I’d gladly buy you this display if you want one.

I’m also strugging to get an LCD display to work. I did a previous topic on loading DT overlays. Now the device-tree processing part is clear, but I still don’t get a /dev/spidev0,0 device file on the system - a plain ArchlinuxArm with a vanilla linux-aarch64 kernel.

I will follow your advice to try and talk to it on the lines.

Other thing I tried recently : boot latest Ubuntu server edition. There I get the spidev1,0 device, but when using it with gpiod as root it fails (see log below). I specially ported a script to gpiod to make sure it works on a Raspberry Pi 4B. I’m using it with a Waveshare 1in44 LCD pHat, so the pins are static.

Traceback (most recent call last):
  File "qr.py", line 10, in <module>
    from gpiod_lcd import LCD_1in44
  File "/home/lafleur/source/radioboite/gpiod_lcd/__init__.py", line 3, in <module>
    from gpiod_lcd.LCD import LCD, LCD_1in44, LCD_1in8
  File "/home/lafleur/source/radioboite/gpiod_lcd/LCD.py", line 36, in <module>
    _raw_screen = LCD_GPIO()
  File "/home/lafleur/source/radioboite/gpiod_lcd/LCD_GPIO.py", line 52, in __init__
    self.bl_pin = LCD_GPIO._request_pin_out(LCD_BL_PIN, "BL")
  File "/home/lafleur/source/radioboite/gpiod_lcd/LCD_GPIO.py", line 75, in _request_pin_out
    line.request(config)
  File "/usr/local/lib/python3.8/dist-packages/gpiod/libgpiodcxx/__init__.py", line 572, in request
    rv = libgpiod.gpiod_line_request(_m_line, conf, default_val)
  File "/usr/local/lib/python3.8/dist-packages/gpiod/libgpiod/__init__.py", line 499, in gpiod_line_request
    return gpiod_line_request_bulk(bulk, config, [default_val])
  File "/usr/local/lib/python3.8/dist-packages/gpiod/libgpiod/__init__.py", line 542, in gpiod_line_request_bulk
    return _line_request_values(bulk, config, default_vals)
  File "/usr/local/lib/python3.8/dist-packages/gpiod/libgpiod/__init__.py", line 403, in _line_request_values
    status = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, req)
OSError: [Errno 16] Device or resource busy

I think if you have to work on SPI natively without needing to compile your own device tree overlays or kernel driver, you might need to look at libmraa to interface with spidev. With that you can probably define pin assignments and be able to use python wrappers and use it for your stuff.

I have strong reserves against libmraa because I had erroneous display with the same Waveshare LCD on a RPi4, whereas both RPi.GPIO and libgpiod succeeded (same hardware, same pin assignment). Would you say libmraa has capabilities the two others don’t ?

@mrkprdo In the end I followed your advice and succeeded in piloting my display using libmraa. I’m running Arch Linux and found a working mraa PKGBUILD for Radxa boards on the AUR. I’ll still try to port my script to libgpiod because it feels better integrated in Arch systems ; that will be another story.

As you mentioned, there is no need to compile a specific DT overlay to get SPI display support. I can witness SPI_A works fine using the default overlay. It’s just that the display’s connection instructions I had (written for a RaspberryPi) need to be adapted - specifically, the instructions I had said to use physical pin 22, but this pin is an open drain on the Radxa Zero, which makes it unsuited for input/output as is (followers, see Radxa Zero GPIO specifics).

In the end, what’s unclear to me is when are your LCD driver or SPI display instructions needed - or what benefit they would bring over using the default overlay together with hardware-specific libraries. As @SCIFI.radio mentioned, there would be a need for newcomers’ documentation on this subject. I hope that my questions will help us understanding what happens in a newcomer’s head :slight_smile:

Anyway thank you very much for pointing me in the right direction !

1 Like

That’s good to hear you have made it to work.
The SPI display instructions i made is to compile dto with fbtft kernel driver and use the display as framebuffer. End goal is to make these displays as monitor like this.. But unfortunately radxa zero spi is quite slow.

I just debug the st7789vw lcd on my radxa zero,It’s running ok,but there is some issues should be avoided:

  1. the reset pin on ZERO should be careful of these open drain pins
  2. It seems difficult to compute or look for the phandler value of the first gpio group,if
    U want use these pins as dc or res pins for tft lcds.
    3.the ko file should be compiled on you host machine,or the magic problem of linux driver would bother you all times

Hi,

I have a Rock 3c and would like to connect a 2,2" QVGA TFT LCD Display, ILI9341 Driver with SPI.(https://www.elektor.de/2-2-spi-tft-display-module-ili9341-240x320 )

Your guide looks very promising. Did you test it on other Rock’s. What ist the correct configuration of the dto file for ILI9341

Thx

Hey, I think I have had the same setup using the adafruit pi tft spi 240x240 1.3" st7789 display. Mine says that it should be able to work, are you using the same exact display? I am using Ubuntu 20.04. THIS IS THE INSTRUCTION SET TO GET THE RASPI TO WORK WITH THE DISPLAY:

cd ~
sudo pip3 install --upgrade adafruit-python-shell click
sudo apt-get install -y git
git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git
cd Raspberry-Pi-Installer-Scripts
sudo python3 adafruit-pitft.py --display=st7789_240x240 --rotation=0 --install-type=console

Your work is VERY appreciated along with everyone else working on this as it really helps open up portable use implementations of these SBC’s. Please help me with either a simple “yep” or NOPE to get started if you read this.

this version of lcd st7789 is compatible with this image radxa-zero3_debian_bullseye_xfce_b6.img?

hi @houssemmiled, I was able to make the st7735r lcd work on the radxa zero 3w simply by adding an overlay for it (adapted from rk3568-spi3-m0-cs0-waveshare35.dts) (fbft and drivers for st7735r and st7789v are already in the kernel).

The overlay I used is radxa-zero3-spi3-lcd.zip (797 Bytes)

1 Like

Hi, do you have any idea how could I make this overlay to Rock 3C ?

You need to select the corresponding driver according to your screen display ic and touch ic.
As for overlay dts, you can refer to this overlay script.

1 Like

Hi, thank you for the response.

If I activate this overlay script. But had no succes.

Later, I have downloaded the GIT folder (https://github.com/mrkprdo/radxa-zero-lcd-driver-installer) so I modified the meson-g12a-spi-st7735r file to contain the correct pinout that I am using:

// configure pin assigment below
reset-gpios = <0x30 113 1>; // pin 22
dc-gpios = <0x31 106 0>; // pin 18
led-gpios = <0x31 104 0>; // pin 15

After that, I uploaded it to Rock-3c and then ran:
$ sudo ./build.sh -t st7735r -c

However, it fails at the end when moving the created files:

make[1]: Leaving directory '/usr/src/linux-headers-5.10.160-38-rk356x'
Done building.
Installing dto files and kernel driver 
cp: cannot create regular file '/boot/dtbs/5.10.160-38-rk356x/amlogic/overlay': 
No such file or directory 
FATAL ERROR: Couldn't open "/boot/dtbs/5.10.160-38-rk356x/amlogic/overlay/meson-g12a-spi-st7735r.dts" file or directory.

It fails at this installer step:
then
echo “Installing dto files and kernel driver”
echo “$PASSWORD” | sudo -S cp {fb_$TARGETDRIVER.ko,fbtft.ko} /usr/lib/modules/$KERNELVERSION/kernel/drivers/staging/fbtft/
echo “$PASSWORD” | sudo -S cp …/meson-g12a-spi-$TARGETDRIVER.dts $DTOPATH
echo “$PASSWORD” | sudo -S dtc -@ -I dts -O dtb -o $DTOPATH/meson-g12a-spi-$TARGETDRIVER.dtbo $DTOPATH/meson-g12a-spi-$TARGETDRIVER.dts
fi

I also tried copying the .dts files to directory /boot/dtbo/
$ sudo cp *.dts /boot/dtbo/
And running rsetup 's main interface.
But I have received this message: “can’t compile files”

I dont know what to do.

This is the file I have modifyed meson-g12a-spi-st7735r.dts

Hi, I can’t make it work.
Oh god.

What did I make wrong ?

Have you followed this tutorials ?

1 Like

This script https://github.com/mrkprdo/radxa-zero-lcd-driver-installer may not comptable with ROCK 3C.

  1. The SoC for the ROCK 3C is a Rockchip rk3566, not an amlogic, so DTOPATH is wrong, and the overlay path is /boot/dtbo/ in the ROCK 3C 5.10 kernel.
  2. You need to modify the three pins(reset-gpios/dc-gpios/led-gpios) according to your connection.
1 Like

Yes.

I have tryed to use it with this code with no succes:
sudo dd if=/dev/zero of=/dev/fb0 bs=10k count=1

When I try:
ffmpeg -i cat.jpg -f rawvideo -pix_fmt rgb24 -r 60 -s 160x128 /dev/fb0
convert cat.jpg -depth 8 -colorspace RGB -format raw - | sudo dd of=/dev/fb0

Both don’t work.
rock@rock-3c:~/scripts$ convert cat.jpg -depth 8 -colorspace RGB -format raw - | sudo dd of=/dev/fb0
[sudo] password for rock:
51+1 records in
51+1 records out
26435 bytes (26 kB, 26 KiB) copied, 0.000352335 s, 75.0 MB/s

How do I send images to /dev/fb0 ???

Did the driver load successfully? Please check that with cmd “sudo dmesg | grep spi3”.

1 Like