樹莓派官方支持 av 及 HDMI 輸出,板子上預留了一個 csi 接口的液晶顯示屏,但是一直沒有相應的模組出現(xiàn)。在很多應用場合我們需要一些小型的液晶屏顯示一些基本的信息,所以小屏驅(qū)動很是必要。
在 github 上有一個開源工程:notro/fbtft,完整的實現(xiàn)了 framebuffer 驅(qū)動,讓樹莓派完美支持 tft 液晶,下面對移植過程進行一個簡單說明。
fbtft 源碼:https://github.com/notro/fbtft
編譯好的固件(基于3.12.25+):https://github.com/notro/rpi-firmware
使用說明(wiki):https://github.com/notro/fbtft/wiki
環(huán)境:樹莓派
https://github.com/notro/rpi-firmware
樹莓派默認 spi 是關(guān)掉的,我們需要打開
sudo vi /etc/modprobe.d/raspi-blacklist.conf
把下面這句話前面的#
號刪掉
blacklist spi-bcm2708
sudo modprobe fbtft_device name=adafruit22
name 后面的名字,要跟相應的液晶驅(qū)動芯片移植,使用的液晶芯片為:fb_ra8875,所以這里寫的是:er_tftm050_2
。其它芯片請查閱:https://github.com/notro/fbtft/blob/master/fbtft_device.c 文件。正常會提示以下信息。
fbtft_device: SPI devices registered:
fbtft_device: spidev spi0.0 500kHz 8 bits mode=0x00
fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
fbtft_device: 'fb' Platform devices registered:
fbtft_device: bcm2708_fb id=-1 pdata? no
fbtft_device: Deleting spi0.0
fbtft_device: GPIOS used by 'adafruit22':
fbtft_device: 'reset' = GPIO25
fbtft_device: 'led' = GPIO23
fbtft_device: SPI devices registered:
fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
fbtft_device: fb_hx8340bn spi0.0 32000kHz 8 bits mode=0x00
graphics fb1: fb_hx8340bn frame buffer, 176x220, 75 KiB video memory, 16 KiB buffer memory, fps=20, spi0.0 at 32 MHz
在/dev/目錄下出現(xiàn): /dev/fb1 設備
sudo vi /etc/modules
加入以下語句,既可以在啟動時自動加載模塊。
spi-bcm2708
fbtft_device name=er_tftm050_2 speed=28000000 fps=25 verbose=0
X Windows 顯示在 fb1 上:
$FRAMEBUFFER=/dev/fb1 startx
Console 顯示在 fb1 上:
$con2fbmap 1 1
sudo vi /etc/inittab
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
sudo vi /etc/rc.local
su -l pi -c "env FRAMEBUFFER=/dev/fb1 startx &"
https://github.com/notro/fbtft/wiki/Framebuffer-use#framebuffer-mirroring
$git clone https://github.com/tasanakorn/rpi-fbcp
$cd rpi-fbcp/
$mkdir build
$cd build/
$cmake ..
$make
$sudo install fbcp /usr/local/bin/fbcp
啟動:fbcp & 關(guān)閉fbcp:killall fbcp
$sudo apt-get install xserver-xorg-video-fbdev
$sudo vi /usr/share/X11/xorg.conf.d/99-fbdev.conf
加入以下語句:
Section "Device"
Identifier "myfb"
Driver "fbdev"
Option "fbdev" "/dev/fb1"
EndSection
啟動:startx
測試:
apt-get -y install fbi
fbi -d /dev/fb1 -T 1 -noverbose -a test.jpg
$cd linux(進入下載好的內(nèi)核源碼目錄)
$cd drivers/video
$git clone https://github.com/notro/fbtft.git
修改內(nèi)核源碼的 Kconfig 及 Makefine
Add to drivers/video/Kconfig: source "drivers/video/fbtft/Kconfig"
Add to drivers/video/Makefile: obj-y += fbtft/
$make menuconfig(在配置界面加入所選用液晶的驅(qū)動支持)
Device Drivers --->
Graphics support --->
<M> Support for small TFT LCD display modules --->
<M> FB driver for the HX8353D LCD Controller
<M> FB driver for the ILI9320 LCD Controller
<M> FB driver for the ILI9325 LCD Controller
<M> FB driver for the ILI9340 LCD Controller
<M> FB driver for the ILI9341 LCD Controller
< > FB driver for the ILI9481 LCD Controller
<M> FB driver for the ILI9486 LCD Controller
<M> FB driver for the PCD8544 LCD Controller
<M> FB driver for the RA8875 LCD Controller
更多建議: