Intro
Just recently bought this cheap ili9341 spi tft lcd from online store and want to test it whether it's working or not.
Wiring
For a quick and simple check I'm just using the default spi channel 0 from raspberry pi gpio, and here is the connection between them :
No | ili9341 | GPIO | Note |
---|---|---|---|
1 | Vcc | Pin1 | 3v3 |
2 | Gnd | Pin6 | Gnd |
3 | CS | GPIO8 | SPI1 CE0 |
4 | RST | GPIO25 | Rst |
5 | DC | GPIO24 | D/C |
6 | MOSI | GPIO10 | SPI0 MOSI |
7 | SCLK | GPIO11 | SPI0 SCLK |
8 | LED | GPIO18 | Backlight |
9 | MISO | GPIO9 | SPI1 MISO |
Software
On this test I'm using rpi 3A+ because … dunno, it's just laying around on my drawer while the others still wired to some my unfinished project (you may use whatever rpi model from zero to rpi 4 as long as have gpio tho). Ok, so … I fire up a balena etcher to write a raspbian buster lite unto a flashdisk on my laptop and wait several minutes until complete and then fire up on rpi 3A+.
First thing after boot up, I use raspi-config to adjust localization, disable overscan and enable SPI interfacing and follow by a reboot.
After reboot, the spidev is active and I can do a modprobe for fbtft device :
sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000
The backlight of the LCD should kick in and I can see a faint glow on the screen which of course, is a good sign. Then to shows and sets mapping between consoles and LCD framebuffer I use :
con2fbmap 1 1
… and yaaay, it's working.
I've got what i want, the lcd is working good, but while the night is still young, I also want to test the fbcp which I always use for my other lcd projects on this ili9341 lcd. So, first thing first, I have to make this lcd load module stick on every boot before running the fbcp module.
I edit /etc/modules and add this module to load during boot :
spi-bcm2835
fbtft_device
and for the extra parameter setting for this lcd, I create /etc/modprobe.d/fbtft.conf and fill it in with this setting :
options fbtft_device name=fb_ili9341 gpios=reset:25,dc:24,led:18 bgr=1 rotate=90 speed=16000000 custom=1
do note, I use bgr color mode and rotate the screen to landscape to meet my needs. Then I reboot.
After reboot, I can see the lcd backlight is lit which tell me the module is loaded properly and all is good.
Now, for framebuffer copy tool aka fbcp, I do a quick compile as below :
sudo apt-get install cmake
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ../
make
sudo install fbcp
and then finally run fbcp :
fbcp
Great, fbcp is working without problem.
To make it stick so fbcp will always run after boot you can use /etc/rc.local or using systemd or whatever it may suit you but for me right now, this is enough. I know the lcd that I buy is working good and ready for the next adventure.