I’m trying to get a Waveshare 2" SPI TFT display working, with screen dimensions of 240v, 320w.
I’m attempting to use the instructions presented in the repository here: https://github.com/mrkprdo/radxa-zero-spi-display
There are no instructions available from Radxa directly on how to do this.
Okay - a very careful reading on the instructions gives me what I think is a complete understanding of how it’s supposed to work.
-
Install the Radxa official Ubuntu bootable distro (“Buster”).
Open a terminal shell and access your root account. Everything else you do will be via this open shell. sudo bash
should do the trick. Change to your home directory with cd ~
.
-
Set up wifi via the main console (keyboard, mouse and screen). Access rootTo do this, open a shell and type:
nmcli dev wifi connect <yourWifiMountPointName> password <yourWifiPassword>
-
You can update your repository, but DO NOT UPGRADE anything. If you do, you can end up with multiple kernel-specific directories for different kernels. Only the currently active kernel as described in the /boot/uEnv.txt file will matter, so there’s no point in upgrading the kernel before you get this working the first time. Change as few variables as possible while you fiddle with it, then migrate the changes to the new kernel if you want to update the kernel afterwards.
-
Install git, the device tree compiler, and the framebuffer command line tool: sudo apt install git fbi device-tree-compiler
-
Use git
to get the repository from Github:
git clone https://github.com/mrkprdo/radxa-zero-spi-display
-
Navigate to your device tree path: cd /boot/dtbs/5.10.xx-x-amlogic-xxxxxxxxxxxxx/amlogic/overlay
-
Copy the sample .dts file from the repository you cloned into the current directory:
cp /root/radxa-zero-spi-display/meson-g12a-spi-lcd.dts .
-
Edit the file meson-g12a-spi-lcd.dts, and edit the screen dimensions to match your device. Mine has a width of 320 pixels and a height of 240 pixels.
Now this is where things get fuzzy.
- The instructions suggest changing pins for to something one looks up from a header file located at https://wiki.radxa.com/Zero/hardware/gpio, and they say that the value here should be GPIOH_8 for the Radxa Zero. Then we are told to check to see whether we should set it to initialize it as either HIGH or LOW, and that this second value should be 1 or 0 respectively.
Unfortunately exactly how we check this, or where to find this out, isn’t covered in the instructions.
Also unfortunately, nothing in the .dts file actually matches <pin>
, and there is no inkling as to what this means. I am assuming they mean reset-gpios
because it’s already set for <0x2b 8 1>
, but it’s a leap of faith because I don’t know what <0x2b 8 1>
actually means in context.
-
After that, we are told to save the file and compile it to a dtbo file (ignoring the warnings - it generates five of them).
dtc -@ -I dts -O dtb -o meson-g12a-spi-lcd.dtbo meson-g12a-spi-lcd.dts
-
Then you update the file /boot/uEnv.txt
to tell it to load the new overlay meson-g12a-spi-lcd, adding the following contents if missing (do not create a second “overlays” parameter line, just append meson-g12a-spi-lcd
if it’s not present. Separate overlay names with spaces, not commas.):
overlays=meson-g12a-spi-lcd
param_spidev_spi_bus=1
param_spidev_max_freq=10000000
-
Save the file, then go to the code repository you’ve downloaded from Github and run the “make” command:
cd /root/radxa-zero-spi-display/kernel-linux-5.10.y-radxa-zero/drivers/staging make
This will produce the two .ko files you need.
-
Copy fbtft.ko and fb_st7789v.ko to the staging directory for your currently active kernel:
cp fbtft.ko /usr/lib/modules/5.10-xx-x-amlogic-xxxxxxxxxxxxx/kernel/drivers/staging
-
Now all you have to do is reboot:
reboot now
If one does do an apt upgrade
, one gets a second modules directory under /usr/lib/modules
for a new version of the kernel, and a new subdirectly under /boot/dtbs into which one must copy the code for the device driver and compile it. The /boot/dtbs and /usr/lib/modules directory contents must be in sync or the magic trick does not work.
Anyway, when it comes back up, you should be able to see it via dmesg:
dmesg | grep fbtft
For me, so far so good.
However, then we test the newly created SPI framebuffer device with the fbi command line tool:
fbi -d /dev/fb1 -T 1 -noverbose -a <sample_image>
and that’s where I break.
If one follows the above steps exactly, it compiles and the modules load. However, there should be an /dev/fb1 device, and there isn’t one.
Apparently it’s related to the GPIO pin setting somehow. A search through the dmesg output produces several error messages to this effect:
[ 0.069614] OF: /soc/bus@ffd00000/spi@15000/st7789v@0: could not get #gpio-cells for /soc/bus@ff600000/bus@34400/pinctrl@40/i2c3-sck-a1
Does this mean my Radxa is broken? Shouldn’t it be able to get GPIO cells from the pinctrl device manager?
… and one important one bug that looks serious:
[ 7.088944] fb_st7789v spi1.0: error -EINVAL: Failed to request reset GPIO [ 7.099764] fb_st7789v: probe of spi1.0 failed with error -22
This error is probably why my device driver isn’t coming up, and I believe the problem may be related to step #10 above. Apparently the pinctl kernel module isn’t finding necessary GPIO data for the new device descriptors, but I can’t tell why. This is especially frustrating since others have followed the instructions and have apparently not hit this issue.
Anybody got any ideas?
Update
Apparently that’s exactly what it means: my Radxa is broken.
I have a defective Radxa Zero, because when I tried the entire above process on a second unit I had on hand, I got no GPIO error messages. However, now I have a new error when I try to use the fbi
command line tool to display a graphics file:
fe-dai-link-0: ASoC: no backend DAIs enabled for fe.dai-link-0
This appears to be a kernel bug, but the version of the kernel I’m using isn’t supposed to have it. I also don’t know if it’s related at all to the SPI display not displaying anything, but it’s now the only error message I have.
My SPI display backlight lights up when the Radxa powers up, but otherwise it does nothing.
I’m following the connection directions from Waveshare as described here.