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-...")
 
(Connect SPI 2.8"LCD to S5P4418/S5P6818 Based Board)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===Under S5P4418 & Linux-3.4 Kernel===
+
===S5P4418/S5P6818===
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.
+
 
<!---
+
The following steps only apply to Kernel Linux-4.4. We took the NanoPi Fire3 as an example. Run the following commands to initialize FriendlyElec's 2.8" SPI LCD. These commands need to be run only once. <br />
===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.
+
Note: the "s5p6818-nanopi3-rev05.dtb" file is the kernel dtb file for the NanoPi Fire3. For another board you need to check its system's "/sys/devices/platform/board/info" file to figure out its dtb file.: <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>
+
Here is the info file's content for the NanoPi Fire3: <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 />
 +
The "Hardware" here is "NANOPI3", "Revision" is "0005", "CPU" is "S5P6818", therefore the NanoPi Fire3's kernel dtb file name is "s5p6818-nanopi3-rev05.dtb".<br />
 +
<br />
 +
After the dtb file is confirmed you can reboot your board and run the following command to check if the fb_st7789v module is loaded:
 
<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
+
Here is what you expect to see:<br />
 +
Module                  Size  Used by<br />
 +
fb_st7789v              3315  0<br />
 +
fbtft                  31881  1 fb_st7789v<br />
 +
<br />
 +
 
 +
Or you can run dmesg to check that. In our case after we ran dmesg we found that the SPI LCD was recognized as an "fb1" device:
 
<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.
 
  
====Display Debian GUI on 2.8"LCD====
+
Here is what you expect to see:<br />
Boot your ARM board with Debian and and launch the Debian GUI by running the following commands:<br>
+
[    6.728000] fb_st7789v: module is from the staging directory, the quality is unknown, you have been warned.<br />
After Debian is loaded clone the matrix code samples:
+
[    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 />
 +
Now as long as you set your system's framebuffer device to fb1 in either Qt or X-Windows you will see output in your LCD.
 +
 
 +
====Launch Lubuntu Desktop on 2.8"LCD====
 +
On lubuntu desktop run the following commands: <br />
 +
Firstly remove the armsoc configuration file:
 
<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:
+
Secondly create a new configuration file /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:
+
Here is its content:
 
<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>
+
After reboot you will see the following GUI:<br />
[[File:fbtft-debian.png|frameless|600px|fbtft-debian]]
+
[[File:s5pxx18-lubuntu-spi2.8tft.png|frameless|600px|s5pxx18-lubuntu-spi2.8tft.png]]<br />
 +
A touch panel is currently not supported yet. You need to use a mouse and keyboard to operate.
  
After calibration is done you will see the following system information:
+
====Run Qt Application on 2.8"LCD====
 +
Open a terminal in friendly-core and run the following commands to start a Qt demo:
 
<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>
+
Here is a Qt demo:<br />
 +
[[File:S5pxx18-friendlycore-spi2.8tft.png|frameless|600px|s5pxx18-lubuntu-spi2.8tft.png]]<br />
 +
A touch panel is currently not supported yet. You need to use a mouse and keyboard to operate.
 +
 
 +
==Update Log==
 +
===Dec-15-2017===
 +
* Released English version

Latest revision as of 02:26, 21 December 2018

1 S5P4418/S5P6818

The following steps only apply to Kernel Linux-4.4. We took the NanoPi Fire3 as an example. Run the following commands to initialize FriendlyElec's 2.8" SPI LCD. These commands need to be run only once.

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

Note: the "s5p6818-nanopi3-rev05.dtb" file is the kernel dtb file for the NanoPi Fire3. For another board you need to check its system's "/sys/devices/platform/board/info" file to figure out its dtb file.:

cat /sys/devices/platform/board/info

Here is the info file's content for the NanoPi Fire3:
Hardware  : NANOPI3
Revision  : 0005
Serial  : fa6818dba7110739
The "Hardware" here is "NANOPI3", "Revision" is "0005", "CPU" is "S5P6818", therefore the NanoPi Fire3's kernel dtb file name is "s5p6818-nanopi3-rev05.dtb".

After the dtb file is confirmed you can reboot your board and run the following command to check if the fb_st7789v module is loaded:

lsmod

Here is what you expect to see:
Module Size Used by
fb_st7789v 3315 0
fbtft 31881 1 fb_st7789v

Or you can run dmesg to check that. In our case after we ran dmesg we found that the SPI LCD was recognized as an "fb1" device:

dmesg | grep fb_st7789v

Here is what you expect to see:
[ 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
Now as long as you set your system's framebuffer device to fb1 in either Qt or X-Windows you will see output in your LCD.

1.1 Launch Lubuntu Desktop on 2.8"LCD

On lubuntu desktop run the following commands:
Firstly remove the armsoc configuration file:

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

Secondly create a new configuration file /etc/X11/xorg.conf:

sudo vi /etc/X11/xorg.conf

Here is its content:

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

After reboot you will see the following GUI:
s5pxx18-lubuntu-spi2.8tft.png
A touch panel is currently not supported yet. You need to use a mouse and keyboard to operate.

1.2 Run Qt Application on 2.8"LCD

Open a terminal in friendly-core and run the following commands to start a Qt demo:

. 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

Here is a Qt demo:
s5pxx18-lubuntu-spi2.8tft.png
A touch panel is currently not supported yet. You need to use a mouse and keyboard to operate.

2 Update Log

2.1 Dec-15-2017

  • Released English version