Thomas shares makes


ILI9341 SPI TFT on the raspberry pi4


I've been running network services on embedded arm platforms for for more than 8 years now, and when things go wrong, had to drag around HDMI monitors to hook up. For the last years I had a pi connected to the serial console to avoid that.

I have been mounting all my networking and smarthome devices on a DIN rail, and I had some small 2.2" TFT displays around for a different project.

I thought it would be nice to create a raspberry pi enclosure that included such a display so there's a real video console on the device that can also be used as status display.

I run Ubuntu 20.04 server on my raspberry pi 4, and discovered there are already loadable kernel modules (drivers) for these TFT displays in /lib/modules.

I couldn't find a suitable device tree blob, so I tweaked an existing one to make it work.

Tryout with raspbian

Tft again

I found a very nice article on how to use the display on the internet:

I flashed a raspbian to an SD card and followed the instructions, this worked so I was sure the wiring and hardware is working OK.

I want to use this on Ubuntu by using device tree, so I needed a device tree blob.

I couldn't find an exact match on internet, but the pitft22a.dts file was close, so I modified it to use different pins and the 9341 instead of 9340.

On startup, this appears in the kernel debug log:

[    9.027191] Console: switching to colour frame buffer device 30x40
[    9.028488] graphics fb0: fb_ili9341 frame buffer, 240x320, 150 KiB video memory, 16 KiB buffer memory, fps=31, spi0.0 at 8 MHz

And presto, a tiny working video console appears on the TFT.

Next I gave this a try on Ubuntu 20.04 arm64. The kernel log shows the same message, but the TFT remains white.

I took logic traces for both, and the SPI bus looks functional in both cases, and the data mostly identical.

One big difference between the two setups is that Ubuntu is using a 64bit kernel 5.4, while Raspbian is using a 32bit Linux 4.19.118-v7l+

Other than that, I tried playing with con2fbmap, and tried to start X11 on /dev/fb0, but no success.

To be continued...

Reference device tree source examples:

Liked something? Worked on something similar? Let me know what you think on Mastodon!
You can use your Mastodon account to reply to this post.

Reply to post

You can respond to this post with an account on the Fediverse or Mastodon. Since Mastodon is decentralized, you can use your existing account or create your account on a server of your choice.

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

Learn how @carlschwan wrote the code that loads Mastodon posts into this webpage here.

Follow me on Mastodon!