Difference between revisions of "Template:S5Pxx18-SPI-2.8TFT"

From FriendlyELEC WiKi
Jump to: navigation, search
(Created page with "===Under S5P4418 & Linux-3.4 Kernel=== Note: the following method only applies for the Matrix-2'8_SPI_Key_TFT-1512 model. To test a Matrix-2'8_SPI_Key_TFT-1706(silkscreen T28-...")
 
(Under S5P4418 & Linux-3.4 Kernel)
Line 1: Line 1:
===Under S5P4418 & Linux-3.4 Kernel===
+
===在S5P4418/S5P6818平台使用SPI 2.8寸屏===
Note: the following method only applies for the Matrix-2'8_SPI_Key_TFT-1512 model. To test a Matrix-2'8_SPI_Key_TFT-1706(silkscreen T28-02 1706) you need to make changes in the S5P4418's kernel file /drivers/char/matrix_ads7846.c.
+
 
<!---
+
以下内容仅适用于Linux-4.4内核, 以NanoPi Fire3为例,开机后,在终端上执行以下命令初始化SPI 2.8寸屏,这些操作只需要执行一次:
===Under H3 & Linux-3.4 Kernel/S5P4418 & Linux-3.4 Kernel===
+
--->
+
====Run Qt Programs on Ubuntu-Core====
+
FriendlyElec's Ubuntu-Core supports Qt. Users can run a Qt application by following the steps below.<br>
+
Boot Ubuntu-Core on a board and clone the Matrix code samples:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ apt-get update && apt-get install git
+
sudo mount /dev/mmcblk0p1 /boot
$ git clone https://github.com/friendlyarm/matrix.git
+
sudo apt-get update
 +
sudo apt-get install device-tree-compiler
 +
sudo fdtput /boot/s5p6818-nanopi3-rev05.dtb spi0/spidev@0 status -t s "disabled"
 +
sudo fdtget /boot/s5p6818-nanopi3-rev05.dtb spi0/spidev@0 status
 +
sudo fdtput /boot/s5p6818-nanopi3-rev05.dtb spi0/fbtft@0 status -t s "okay"
 +
sudo fdtget /boot/s5p6818-nanopi3-rev05.dtb spi0/fbtft@0 status
 +
sudo reboot
 
</syntaxhighlight>
 
</syntaxhighlight>
After it is done a "matrix" directory will be generated.
+
注意,在上述命令中,s5p6818-nanopi3-rev05.dtb是NanoPi Fire3开发板所用的内核dtb文件,其它开发板型号需要自已查看文件 /sys/devices/platform/board/info 中的信息来确定文件名,输入如下命令: <br />
 
+
Compile and Run Qt Test Program:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd matrix/demo/nanopi-status
+
cat /sys/devices/platform/board/info
./build.sh
+
./run.sh /dev/fb-st7789s
+
 
</syntaxhighlight>
 
</syntaxhighlight>
The nanopi-status is a simple Qt program which shows system information. Here is what you expect to observe:<br>
+
在NanoPi Fire3开发板上,info文件的内容如下: <br />
[[File:st7789s-status.png|frameless|600px|st7789s-status]]<br>
+
Hardware        : NANOPI3<br />
The run.sh script will load TFT's driver and run the Qt program. After the driver is successfully loaded a device node /dev/fb-st7789s will be generated. You can check whether or not the driver is loaded successfully by running the following commands
+
Revision        : 0005<br />
 +
Serial          : fa6818dba7110739<br />
 +
其中,Hardware字段是NANOPI3,Revision字段是0005,CPU是S5P6818,所以内核dtb文件名为 s5p6818-nanopi3-rev05.dtb。<br />
 +
<br />
 +
配置完dtb文件,重启开发板后,可以用lsmod命令检查下是否加载了fb_st7789v模块:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
lsmod
 
lsmod
Module                  Size  Used by
 
fbtft_device          29235  0
 
 
</syntaxhighlight>
 
</syntaxhighlight>
After the TFT's driver is loaded you can enable the TFT by running the following commands
+
正常会输出如下内容: <br />
 +
Module                  Size  Used by<br />
 +
fb_st7789v              3315  0<br />
 +
fbtft                  31881  1 fb_st7789v<br />
 +
<br />
 +
以及用dmesg命令可以查看到SPI屏已经被初始化为fb1设备:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd matrix/demo/matrix-lcdtest
+
dmesg | grep fb_st7789v
make
+
export LCDSET_FB_DEV=/dev/fb-st7789s
+
./matrix-lcdtest
+
 
</syntaxhighlight>
 
</syntaxhighlight>
You will watch the display.
+
正常会输出如下内容: <br />
 +
[    6.728000] fb_st7789v: module is from the staging directory, the quality is unknown, you have been warned.<br />
 +
[    6.908000] graphics fb1: fb_st7789v frame buffer, 320x240, 150 KiB video memory, 4 KiB buffer memory, fps=35, spi0.0 at 50 MHz<br />
 +
接下事的情况就比较简单,无论是运行Qt,还是X-Windows,只需要正确设置Framebuffer设备为fb1即可。
  
====Display Debian GUI on 2.8"LCD====
+
 
Boot your ARM board with Debian and and launch the Debian GUI by running the following commands:<br>
+
====在2.8寸屏上运行Lubuntu桌面====
After Debian is loaded clone the matrix code samples:
+
在 lubuntu desktop系统里执行以下操作:
 +
首先删除armsoc的配置文件:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ apt-get update && apt-get install git
+
sudo rm -f /usr/share/X11/xorg.conf.d/20-armsoc.conf
$ git clone https://github.com/friendlyarm/matrix.git
+
 
</syntaxhighlight>
 
</syntaxhighlight>
After it is done a "matrix" directory will be generated.
 
  
For H3 based boards you need to change the X11 configuration file as follows:
+
然后新建一个配置文件 /etc/X11/xorg.conf:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ vi /etc/X11/xorg.conf
+
sudo vi /etc/X11/xorg.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
Change "/dev/fb0" to "/dev/fb-st7789s".
 
  
Launch the Debian GUI by running the following commands:
+
内容如下:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ cd matrix/demo/nanopi-status/
+
Section "Monitor"
$ ./display-debian.sh /dev/fb-st7789s
+
    Identifier          "Primary"
 +
    VendorName          "FriendlyARM"
 +
EndSection
 +
 
 +
Section "Device"
 +
    Identifier          "Primary"
 +
    Driver              "fbdev"
 +
    Option              "fbdev" "/dev/fb1"
 +
EndSection
 
</syntaxhighlight>
 
</syntaxhighlight>
Calibrate the screen by following the four points' movement:<br>
+
重启后可以看到图像: <br />
[[File:fbtft-debian.png|frameless|600px|fbtft-debian]]
+
[[File:s5pxx18-lubuntu-spi2.8tft.png|frameless|600px|s5pxx18-lubuntu-spi2.8tft.png]]
 +
目前暂时不支持触摸屏,可使用鼠标和键盘操作。
  
After calibration is done you will see the following system information:
+
====在2.8寸屏上运行Qt程序====
 +
在friendly-core系统终端里执行以下命令,运行一个Qt示例:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Section "InputClass"
+
. setqt5env
        Identifier      "calibration"
+
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
        MatchProduct    "ADS7846 Touchscreen"
+
export QT_QPA_EGLFS_TSLIB=1
        Option  "Calibration"  "196 3825 3887 358"
+
export QT_QPA_GENERIC_PLUGINS=tslib,evdevkeyboard
        Option  "SwapAxes"      "0"
+
$QTDIR/examples/widgets/widgets/tetrix/tetrix
EndSection
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Copy and paste the information to the "/usr/share/X11/xorg.conf.d/99-calibration.conf" file, save it and this will be used as your calibration data when you reboot your board.<br>
+
Qt示例画面如下所示:<br />
 +
[[File:S5pxx18-friendlycore-spi2.8tft.png|frameless|600px|s5pxx18-lubuntu-spi2.8tft.png]]
 +
目前暂时不支持触摸屏,可使用鼠标和键盘操作。

Revision as of 11:31, 14 December 2017

1 在S5P4418/S5P6818平台使用SPI 2.8寸屏

以下内容仅适用于Linux-4.4内核, 以NanoPi Fire3为例,开机后,在终端上执行以下命令初始化SPI 2.8寸屏,这些操作只需要执行一次:

sudo mount /dev/mmcblk0p1 /boot
sudo apt-get update
sudo apt-get install device-tree-compiler
sudo fdtput /boot/s5p6818-nanopi3-rev05.dtb spi0/spidev@0 status -t s "disabled"
sudo fdtget /boot/s5p6818-nanopi3-rev05.dtb spi0/spidev@0 status
sudo fdtput /boot/s5p6818-nanopi3-rev05.dtb spi0/fbtft@0 status -t s "okay"
sudo fdtget /boot/s5p6818-nanopi3-rev05.dtb spi0/fbtft@0 status
sudo reboot

注意,在上述命令中,s5p6818-nanopi3-rev05.dtb是NanoPi Fire3开发板所用的内核dtb文件,其它开发板型号需要自已查看文件 /sys/devices/platform/board/info 中的信息来确定文件名,输入如下命令:

cat /sys/devices/platform/board/info

在NanoPi Fire3开发板上,info文件的内容如下:
Hardware  : NANOPI3
Revision  : 0005
Serial  : fa6818dba7110739
其中,Hardware字段是NANOPI3,Revision字段是0005,CPU是S5P6818,所以内核dtb文件名为 s5p6818-nanopi3-rev05.dtb。

配置完dtb文件,重启开发板后,可以用lsmod命令检查下是否加载了fb_st7789v模块:

lsmod

正常会输出如下内容:
Module Size Used by
fb_st7789v 3315 0
fbtft 31881 1 fb_st7789v

以及用dmesg命令可以查看到SPI屏已经被初始化为fb1设备:
dmesg | grep fb_st7789v

正常会输出如下内容:
[ 6.728000] fb_st7789v: module is from the staging directory, the quality is unknown, you have been warned.
[ 6.908000] graphics fb1: fb_st7789v frame buffer, 320x240, 150 KiB video memory, 4 KiB buffer memory, fps=35, spi0.0 at 50 MHz
接下事的情况就比较简单,无论是运行Qt,还是X-Windows,只需要正确设置Framebuffer设备为fb1即可。


1.1 在2.8寸屏上运行Lubuntu桌面

在 lubuntu desktop系统里执行以下操作: 首先删除armsoc的配置文件:

sudo rm -f /usr/share/X11/xorg.conf.d/20-armsoc.conf

然后新建一个配置文件 /etc/X11/xorg.conf:

sudo vi /etc/X11/xorg.conf

内容如下:

Section "Monitor"
    Identifier          "Primary"
    VendorName          "FriendlyARM"
EndSection
 
Section "Device"
    Identifier          "Primary"
    Driver              "fbdev"
    Option              "fbdev" "/dev/fb1"
EndSection

重启后可以看到图像:
s5pxx18-lubuntu-spi2.8tft.png 目前暂时不支持触摸屏,可使用鼠标和键盘操作。

1.2 在2.8寸屏上运行Qt程序

在friendly-core系统终端里执行以下命令,运行一个Qt示例:

. setqt5env
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
export QT_QPA_EGLFS_TSLIB=1
export QT_QPA_GENERIC_PLUGINS=tslib,evdevkeyboard
$QTDIR/examples/widgets/widgets/tetrix/tetrix

Qt示例画面如下所示:
s5pxx18-lubuntu-spi2.8tft.png 目前暂时不支持触摸屏,可使用鼠标和键盘操作。