After figuring out the GPIO pin names of the Orange Pi Zero expansion port it is relatively easy to configure any TFT display as a FBTFT device attached over the SPI bus, as long as you know the name of the chip used to drive the LCD screen. Here is a list of all the chips supported by the Linux kernel out of the box.
The display I have is very similar to this 3.2″ Waveshare touch-screen display that uses the ILI9340 LCD driver (PDF) chip. It was only a matter of specifying the two GPIO pins used for DC
(Data or Command) and RST
(Reset) in addition to the SPI port.
- H2+ port
PA00
maps to GPIO 0, connected toRST
- H2+ port
PA03
maps to GPIO 3, connected toDC
- H2+ SPI bus 1 is connected to the display module SPI pins.
The following command can be used to load the FBTFT device with the required configuration:
$ sudo modprobe fbtft_device custom name=fb_ili9340 gpios=dc:3,reset:0 speed=16000000 busnum=1 rotate=90
And then map the console output to the newly created framebuffer device:
$ con2fbmap 1 8
where 8 stands for /dev/fb8
.
Here is the display running htop
:
Permanent Setup
Create a new file /etc/modules-load.d/fbtft.conf
with the following content:
fbtft_device
Create another file /etc/modprobe.d/fbtft.conf
with the configuration for the fbtft_device
device:
options fbtft_device custom name=fb_ili9340 gpios=dc:3,reset:0 speed=16000000 busnum=1 rotate=90
Finally, edit /boot/armbianEnv.txt
to map the console output to the framebuffer device during the boot, by appending the following:
extraargs="fbcon=map:8"
Does your lcd screen output the kernel messages during boot up or just show login prompt ?
Have you been able to set led screen brightness using pwm ?
im using other small screen the adafruit22a
It does show a few messages after the
fb_ili9340
module is loaded and before the login screen.adafruit22a seems to be using the
hx8340bn
TFT driver chip which has a slightly different SPI init sequence. Did you get it working?Your gpio pinout guide was most helpful
I do get kernel messages if I use the serial debug port (RX – middle one) as GPIO 5 for the LED pin, but it does not always finish booting up with login prompt. (unstable for some reason) I have disabled the serial console and enabled pwm in the fex file
I also currently cant get PWM screen brightness to work on this GPIO 5 either like with a Raspberry Pi
https://www.xgadget.de/anleitung/2-2-spi-display-ili9341-am-raspberry-betreiben/
When I use GPIO 7 i mostly only see the login prompt
Where did you buy your screen ?
My 320×480 screen does not work correctly either (only part of screen shows)
Does this work or all models of Orange pi, or just with this one ? : )
It should work with almost all single board computers since they all have SPI ports. You only need to know the pin mapping in the Linux kernel.
Hello!
Is it possible to run Android OS on Orange Pi Zero and use this display?
I don’t know. Haven’t tried it with Android.
No desire to try? Would be very interesting material. And unique!
Quiet simplified presentation.
I was wondering if the same method can be applied for the 3.5 inch touch screen LCD module here.
Sure, as long as it uses one of the supported TFT SPI-based driver chips (also linked in the post). Simply replace
name=fb_ili9340
with the name of the chip you have on the module.Have you measured refresh rate?
Nope. It would be interesting to know, though. Here is more information about fbtft and FPS.
Thanks a lot for the instructions.
I managed to get a waveshare 3.5 A clone work by doing it like this:
But with the “Armbian_5.25_Orangepizero_Ubuntu_xenial_default_3.4.113” image the boot halts just after starting to load kernel when I point the vt to fb8
"con2fbmap 1 8"
works ! strangeThanks for sharing that Agge! Are you saying that supplying the
extraargs
argument it doesn’t work while usingcon2fbmap
it does? Are you able to see any errors messages during the boot over UART? Did you add a space before theextraargs
parameter in/boot/armbianEnv.txt
?Should there be a space before extraargs ?
Have to look into that tonight.
The uart halts just when kernel starts booting well halts. So no output from it
Yes, there should be a space before
extraargs
. It probably halts at that line because of a formatting error.Hey. I’m having exactly the same issue. The screen image in my tft seems to be very unstable. It gets stuck very often, did you sorted the problem out at the end ?
Not sure to be honest. You could try adjusting the SPI bus
speed=16000000
value.have ili9340 2,4″ display at home, and pi zero with ext board on the way, looking to build a “internet radio” and “spotify connect” player by connecting external speakers – anyone has experience with this? any good tips on what software to use? Ideal internet radios as playlist of strem-urls, so just need some nice simple ui maybe? to control vlc? or any tips?
and how to provide the spotify connect functionality (to show “play on xy”)? maybe even provide controls for this too?
Maybe start with something very simple — cmus is a CLI music player so you don’t need to run the full desktop.
hi, do you think can be used with this module?
can’t find the chipset on that page, but it seems to work with standard raspbian.
Yes, it should work just fine since it has compatible SPI pins.
Hey, your guide is very helpful for LCD display with Armbian OS. I am trying to do the same with Lubuntu Image available on Orange pi zero website.
What would be the procedure to configure the same for 3.2 TFT LCD
It should be exactly the same as long as you know the TFT chip name, I think. Did you try it already?
where to add the following line:
I don’t see any config.txt or env.txt at /boot/ location
Does it work when you manually run the
con2fbmap 1 8
command after doingsudo modprobe fbtft_device ...
? It should be working before you add it permanently to the boot file.Hi, I’ve managed to get the kumantech 3.5 inch screen kinda working. But unfortunately it stops working a few seconds after booting. It hangs and doesn’t update the screen anymore.
I’m testing it with a waveshare 3.2 inch display right now and this display hangs after a while, too. But this time it took several minutes before it stopped working.
Do you have any idea what’s going wrong here?
I’m on the latest Armbian Ubuntu xenial image.
I’ve had the same issue before but I’m not sure how to solve it. You could try lowering the SPI bus speed setting
speed=16000000
.Hi, I am trying to use this via a 26-pin RasPi GPIO Extension board- ie one of those T-shaped adapters that breaks out all the GPIO pins onto a breadboard.
My challenge is that the labelling on that doesn’t closely match anything else.
Could you please explicitly say which OrangePi Zero GPIO pins you have mapped to each of the ili9341 pins?
Thanks
My particular display connects to the SPI bus #1 (
PA15
isMOSI
,PA16
isMISO
,PA14
isCLK
andPA13
isCS
) and two additional pins atPA00
andPA03
forRST
andDC
. Please note that physical pin numbers are different from the pin names in the Linux kernel and the GPIO numbers that are mapped to those pins. See the expansion port table on this page for how they’re all mapped together.Nice!, it worked as well on the orange pi one, on bus SPI0 with a few changes:
Both SPI modules are desactivated by default during the dtb fixup so in u-boot I’d to set: ‘setenv param_spidev_spi_bus 0’ before booting to have it activated and it worked.
Cheers,
Fred
Thanks for sharing your findings, Fred! I’m sure others will be happy to learn it works with Orange Pi One.
hello Kaspars,
First it all thank you for this great tuto and review. I’d like to send you 2 suggestions:
1st is to say that to follow your tips, we need to use a “hand builded image” of Armbian (https://github.com/armbian/build) instead of the pre-compiled available images on site.
2nd is to use this command:
modprobe fbtft_device custom name=fb_ili9340 gpios=dc:3,reset:0 speed=16000000 busnum=1 rotate=90 bgr=1
This LCD (ili9340) or fbtft, in my case, was with blue and red colors swapped, and bgr=1 make it right again.
Congrats again and best wishes,
tonispa
Thanks for sharing your suggestions! I did use the pre-built Armbian images, though.
Hello
Im getting this error executing the modprobe command on an orange pi zero:
modprobe: ERROR: could not insert ‘fbtft_device’: Invalid argument
Im using the prebuilt Arbian Jessie distro. Any idea what can be happening?
Did you try one of the suggested solutions in this thread?
Thanks, but I managed to solve the problem. My display had a different pinout for the Reset and DC pins. I got the console working in the display. Now I will try to use with graphics (for retro games of course ) hehe. Nice blog by the way
Hey Kaspars!
First off thank you for a awesome guide, I have one question though, do you know how to get the pi to output the framebuffer of the video not the console? As mines just outputting the console at the moment not whats actually going on.
Thanks :)
RH
Here is the Framebuffer guide for outputing all kinds of media. I haven’t used it personally so I won’t be able to comment on the specific OPi nuances.
Can you use the display in gui mode? When it’s no gui it works fine. But after upgrading system to some GUI desktop environment, display goes black…? Anyone had similar issues?
Random tips :
– orange pi zero all have 2 SPI bus: one in the main GPIO port, and one for the flash on the back side. If you don’t have the plus model, you can unsolder the FLASH and use the port. FLASH is port 1, so, GPIO is port 1. This is very important when you follow tutorials written for other opis
– before you start following a tutorial, you need to understand which kernel you are using. If the turial is written after jan 2017, and mentions adding an overlay in armbianEnv.txt, then it’s for kernel 4; if the tuto is before feb 2018, and does not mention altering armbianEnv.txt for SPI compatibility, author is using kernel 3. This is critical.
– I got adressable LEDs working on both kernels, 3 and 4. Easier on 4.
– SPI LCDs work only on kernel 3; I have spend days on kernel 4, just forget them; drivers exist, but they are broken.
– con2fbmap is required only on kernel 3
– to get X working, you need to create /etc/X11/xorg.conf.d/99-fbturbo.conf
– check your FB number with a command like this: dmesg | grep ili | grep graphics | grep -i fb . I have seen people using 0, 1 and 8.
Now, I have ili9486 working perfectly fine … with image Armbian_5.35_Orangepizero_Ubuntu_xenial_default_3.4.113 (kernel 3.4.113).
This is super useful information, thanks for sharing!
First of all, thank you very much for sharing. The display I use is waveshare ILI9486 4inch TFT shield compatibility for arduino. The problem of this shield is SPI config switch is set to ICSP as default. In fact, the switch must not be placed in the side of ICSP. I have wasted my time for not caring about this fact.
Another problem is that fbtft is not available on latest armbian. So, I had to use Debian jessie 3.4 from Armbian Archive Storage, because fbtft_device is gone in linux kernel 5.4 (fbtft wiki).
Finally, it worked well with this command.
$ sudo modprobe fbtft_device custom name=fb_ili9486 gpios=dc:3,reset:0,led:6 speed=16000000 busnum=1 rotate=90
$ con2fbmap 1 8
$ sudo modprobe fbtft_device custom name=fb_ili9486 gpios=dc:3,reset:0,led:6 speed=16000000 busnum=1 rotate=90
$ con2fbmap 1 8
For image!