Personal tools

Difference between revisions of "How to enable support for FT5x06 Multi-Touch Controller on VisionSOM-6ULL"

From SomLabs Wiki

Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{PageHeader|How to enable support for FT5x06 Multi-Touch Controller on VisionSOM-6ULL}}
 
{{PageHeader|How to enable support for FT5x06 Multi-Touch Controller on VisionSOM-6ULL}}
 +
__FORCETOC__
 
== Prerequisites ==
 
== Prerequisites ==
 
This tutorial based on Debian 9.2 image for VisionSOM-6ULL module. Please visit [[How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Linux]] or [[How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Windows]] for more detailed instruction how to create a bootable microSD card.
 
This tutorial based on Debian 9.2 image for VisionSOM-6ULL module. Please visit [[How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Linux]] or [[How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Windows]] for more detailed instruction how to create a bootable microSD card.
Line 5: Line 6:
 
To enable support for LCD-TFT display, please download and apply enable-tft-lcd.patch for somlabs-visionsom-6ull.dts device tree file:
 
To enable support for LCD-TFT display, please download and apply enable-tft-lcd.patch for somlabs-visionsom-6ull.dts device tree file:
  
<pre>wget http://wiki.somlabs.com/images/c/cd/Enable-tft-lcd.zip
+
root@ubuntu:~# '''wget http://wiki.somlabs.com/images/c/cd/Enable-tft-lcd.zip'''
unzip Enable-tft-lcd.zip
+
root@ubuntu:~# '''unzip Enable-tft-lcd.zip'''
patch /home/developer/source/somlabs-dts-1.0/somlabs-visionsom-6ull.dts ./enable-tft-lcd.patch</pre>
+
root@ubuntu:~# '''patch /home/developer/source/somlabs-dts-1.0/somlabs-visionsom-6ull.dts ./enable-tft-lcd.patch'''
 
   
 
   
 
For more info how to customize, build and upload Device Tree file, please visit [[How to customize Debian 9.2 device tree]].
 
For more info how to customize, build and upload Device Tree file, please visit [[How to customize Debian 9.2 device tree]].
Line 13: Line 14:
 
== Enabling support for FT5x06 Multi-Touch Controller ==
 
== Enabling support for FT5x06 Multi-Touch Controller ==
  
The 7’ LCD-TFT display for SoMLabs module [https://somlabs.com/product/sl-tft7-tp-800-480/ SL-TFT7-TP-800-480] is equipped with a capacitive touch panel controller from [http://wiki.somlabs.com/images/9/9c/FT5x06.pdf FT5x06] series (single-chip capacitive touch panel controller ICs with a built-in 8 bit Micro-controller unit).  A simple driver for the FT5x06 touch controller using I²C is already included in the Linux kernel for SoMLabs module. To enable support for FT5x06 driver, configure kernel with ''menuconfig'' tool (alternatively use ''make xconfig'' or ''make qconfig''):
+
The 7’ LCD-TFT display for SoMLabs module [https://somlabs.com/product/sl-tft7-tp-800-480/ SL-TFT7-TP-800-480] is equipped with a capacitive touch panel controller from [http://wiki.somlabs.com/images/9/9c/FT5x06.pdf FT5x06] series (single-chip capacitive touch panel controller ICs with a built-in 8-bit microcontroller unit).  A simple driver for the FT5x06 touch controller using I²C is already included in the Linux kernel for SoMLabs module. To enable support for FT5x06 driver, configure kernel with ''menuconfig'' tool (alternatively use ''make xconfig'' or ''make qconfig''):
  
<pre>cd linux-sources
+
root@ubuntu:~# '''cd /home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga'''
make ARCH=arm menuconfig
+
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# '''make ARCH=arm menuconfig'''
</pre>
 
  
 
and choose the right driver:
 
and choose the right driver:
Line 37: Line 37:
 
[[File:20180504_img01.png|center|700px]]
 
[[File:20180504_img01.png|center|700px]]
  
After all these options have been selected, save your confguration, exit the ''menuconfig'' tool, build a new kernel image:
+
After all these options have been selected, save your configuration, exit the ''menuconfig'' tool, build a new kernel image:
  
<pre>make ARCH=arm zImage
+
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# '''make ARCH=arm zImage'''
</pre>
 
  
 
and transfer the new kernel images to a microSD:
 
and transfer the new kernel images to a microSD:
  
<pre>sudo mount /dev/sdbX /mnt/sdcard
+
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# '''sudo mount /dev/sdbX /mnt/sdcard'''
cd /mnt/sdcard
+
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# '''cd /mnt/sdcard'''
sudo cp <linuxsources>/arch/arm/boot/zImage boot/
+
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# '''sudo cp <linuxsources>/arch/arm/boot/zImage boot/'''
</pre>
+
 
  
 
In last steps, customize ''Device Tree'' file (''somlabs-visionsom-6ull.dts''). Because FT5x06 is using I²C bus, it is needed to enable I2C controller (I2C2):
 
In last steps, customize ''Device Tree'' file (''somlabs-visionsom-6ull.dts''). Because FT5x06 is using I²C bus, it is needed to enable I2C controller (I2C2):
Line 118: Line 117:
 
To test touchscreen driver, let’s install one of lightweight desktop environment:
 
To test touchscreen driver, let’s install one of lightweight desktop environment:
  
<pre>root@somlabs:~# apt-get update
+
root@somlabs:~# '''apt-get update'''
root@somlabs:~# apt-get install xfce4
+
root@somlabs:~# '''apt-get install xfce4'''
</pre>
 
 
   
 
   
 
To be sure that your SD card has enough space for it, please remember to resize it before installing ''xfce4'' package - more information: [[How to resize Debian 9.2 root partition to fit SD card]].
 
To be sure that your SD card has enough space for it, please remember to resize it before installing ''xfce4'' package - more information: [[How to resize Debian 9.2 root partition to fit SD card]].
Line 126: Line 124:
 
After ''Xfce'' installation we will notice that touchscreen input is rotated according to screen orientation (180°). Because kernel driver for FT5x06 chips doesn’t support additional DT properties like ''touchscreen-inverted-x'', ''touchscreen-inverted-y'' and ''touchscreen-swapped-x-y'', we need to calibrate touchscreen directly in userspace. In Debian – like in most of nowadays Linux distributions – default input device driver is ''libinput'' https://www.freedesktop.org/wiki/Software/libinput/ (as a replacement for ''evdev''). ''Libinput'' uses ''Coordination Transformation Matrix'' (CTM) (https://wiki.ubuntu.com/X/InputCoordinateTransformation) to transform input coordinate (x, y, z) to output coordinate (X, Y, Z). To check current values for CTM, list all input devices:
 
After ''Xfce'' installation we will notice that touchscreen input is rotated according to screen orientation (180°). Because kernel driver for FT5x06 chips doesn’t support additional DT properties like ''touchscreen-inverted-x'', ''touchscreen-inverted-y'' and ''touchscreen-swapped-x-y'', we need to calibrate touchscreen directly in userspace. In Debian – like in most of nowadays Linux distributions – default input device driver is ''libinput'' https://www.freedesktop.org/wiki/Software/libinput/ (as a replacement for ''evdev''). ''Libinput'' uses ''Coordination Transformation Matrix'' (CTM) (https://wiki.ubuntu.com/X/InputCoordinateTransformation) to transform input coordinate (x, y, z) to output coordinate (X, Y, Z). To check current values for CTM, list all input devices:
  
<pre>root@somlabs:~# xinput list
+
root@somlabs:~# '''xinput list'''
</pre>
 
  
 
You will see output like:
 
You will see output like:
Line 143: Line 140:
 
To print the CTM of selected device (in our case it is ''EP0790M09''), run the following command:
 
To print the CTM of selected device (in our case it is ''EP0790M09''), run the following command:
  
<pre>root@somlabs:~# xinput list-props EP0790M09 | grep "Transformation”
+
root@somlabs:~# '''xinput list-props EP0790M09 | grep "Transformation”'''
</pre>
 
  
To change and test transformation matrix (please visit [6] for more info how to use and configure CTM):
+
To change and test transformation matrix (please visit https://wiki.ubuntu.com/X/InputCoordinateTransformation for more info how to use and configure CTM):
  
 
* in case of rotating left (counterclockwise 90°)
 
* in case of rotating left (counterclockwise 90°)
Line 172: Line 168:
  
 
Reboot system and enjoy!
 
Reboot system and enjoy!
 +
 +
== Ready to use image file ==
 +
You can also use a prepared image file.
 +
 +
You need to download the image file:
 +
[http://ftp.somlabs.com/VisionSOM-6ULL/SoMLabs-VisionSOM-6ULL-TP.zip SoMLabs-VisionSOM-6ULL-TP.zip]
 +
 +
Then you need to write the image file to microSD card. More information you can find in manuals: [[How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Linux]] or [[How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Windows]].

Latest revision as of 21:36, 5 September 2018

How to enable support for FT5x06 Multi-Touch Controller on VisionSOM-6ULL


Prerequisites

This tutorial based on Debian 9.2 image for VisionSOM-6ULL module. Please visit How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Linux or How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Windows for more detailed instruction how to create a bootable microSD card.

To enable support for LCD-TFT display, please download and apply enable-tft-lcd.patch for somlabs-visionsom-6ull.dts device tree file:

root@ubuntu:~# wget http://wiki.somlabs.com/images/c/cd/Enable-tft-lcd.zip
root@ubuntu:~# unzip Enable-tft-lcd.zip
root@ubuntu:~# patch /home/developer/source/somlabs-dts-1.0/somlabs-visionsom-6ull.dts ./enable-tft-lcd.patch

For more info how to customize, build and upload Device Tree file, please visit How to customize Debian 9.2 device tree.

Enabling support for FT5x06 Multi-Touch Controller

The 7’ LCD-TFT display for SoMLabs module SL-TFT7-TP-800-480 is equipped with a capacitive touch panel controller from FT5x06 series (single-chip capacitive touch panel controller ICs with a built-in 8-bit microcontroller unit). A simple driver for the FT5x06 touch controller using I²C is already included in the Linux kernel for SoMLabs module. To enable support for FT5x06 driver, configure kernel with menuconfig tool (alternatively use make xconfig or make qconfig):

root@ubuntu:~# cd /home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# make ARCH=arm menuconfig

and choose the right driver:

Device Drivers -->
	Input device support -->
		-*- Generic input layer (needed for keyboard, mouse, ...)
		*** Userland interfaces ***
		 <*>  Event interface
		 < >  Event debugging
		*** Input Device Drivers ***
		 [ ]  Joysticks/Gamepads  --->
		 [ ]  Tablets  --->
		 [*]  Touchscreens  --->
			<*>  EDT FocalTech FT5x06 I2C Touchscreen support


20180504 img01.png

After all these options have been selected, save your configuration, exit the menuconfig tool, build a new kernel image:

root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# make ARCH=arm zImage

and transfer the new kernel images to a microSD:

root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# sudo mount /dev/sdbX /mnt/sdcard
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# cd /mnt/sdcard
root@ubuntu:/home/developer/source/kernel/linux-rel_imx_4.1.15_2.1.0_ga# sudo cp <linuxsources>/arch/arm/boot/zImage boot/


In last steps, customize Device Tree file (somlabs-visionsom-6ull.dts). Because FT5x06 is using I²C bus, it is needed to enable I2C controller (I2C2):

&i2c2 {
	clock_frequency = <100000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c2>;
	status = "okay"
};

In IOMUX section set proper I2C pin definition:

pinctrl_i2c2: i2c2grp {
	fsl,pins = <
		MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0
		MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0
	>;
}

According to Device Tree documentation for FT5x06 chips, add following entry in somlabs-visionsom-6ull.dts file:

&i2c2 {
	clock_frequency = <100000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c2>;
	status = "okay";

	polytouch: edt-ft5x06@38 {
		compatible = "edt,edt-ft5406", "edt,edt-ft5x06";
		reg = <0x38>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_edt_ft5x06>;
		interrupt-parent = <&gpio1>;
		interrupts = <2 0>;

		touchscreen-size-x = <800>;
		touchscreen-size-y = <480>;
	};
};

Where:

  • reg: I2C slave address of the chip (0x38),
  • interrupt-parent: a handle pointing to the interrupt controller serving the interrupt for this chip,
  • interrupts: interrupt specification for the touchdetect interrupt.

Above description also defines two optional properties for Touchscreens:

  • touchscreen-size-x: horizontal resolution of touchscreen (in pixels),
  • touchscreen-size-y: vertical resolution of touchscreen (in pixels).

IOMUX section for touchscreen controller:

pinctrl_edt_ft5x06:edt-ft5x06grp {
	fsl,pins = <
		MX6UL_PAD_GPIO1_IO02__GPIO1_IO02	0x1b0b0
	>;
};

You can find more information on building and customizing Device Tree in How to customize Debian 9.2 device tree tutorial.


Testing and configuring touchscreen with desktop environment - Xfce

To test touchscreen driver, let’s install one of lightweight desktop environment:

root@somlabs:~# apt-get update
root@somlabs:~# apt-get install xfce4

To be sure that your SD card has enough space for it, please remember to resize it before installing xfce4 package - more information: How to resize Debian 9.2 root partition to fit SD card.

After Xfce installation we will notice that touchscreen input is rotated according to screen orientation (180°). Because kernel driver for FT5x06 chips doesn’t support additional DT properties like touchscreen-inverted-x, touchscreen-inverted-y and touchscreen-swapped-x-y, we need to calibrate touchscreen directly in userspace. In Debian – like in most of nowadays Linux distributions – default input device driver is libinput https://www.freedesktop.org/wiki/Software/libinput/ (as a replacement for evdev). Libinput uses Coordination Transformation Matrix (CTM) (https://wiki.ubuntu.com/X/InputCoordinateTransformation) to transform input coordinate (x, y, z) to output coordinate (X, Y, Z). To check current values for CTM, list all input devices:

root@somlabs:~# xinput list

You will see output like:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ USB Optical Mouse                       	id=7	[slave  pointer  (2)]
⎜   ↳ EP0790M09                               	id=9	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ 20cc000.snvs:snvs-powerkey              	id=6	[slave  keyboard (3)]
    ↳ USB2.0 Camera                           	id=8	[slave  keyboard (3)]

To print the CTM of selected device (in our case it is EP0790M09), run the following command:

root@somlabs:~# xinput list-props EP0790M09 | grep "Transformation”

To change and test transformation matrix (please visit https://wiki.ubuntu.com/X/InputCoordinateTransformation for more info how to use and configure CTM):

  • in case of rotating left (counterclockwise 90°)
xinput set-prop EP0790M09 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
  • in case of rotating right (clockwise 90°)
xinput set-prop EP0790M09 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
  • and like in our case - inverting rotate (clockwise 180°)
xinput set-prop EP0790M09 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1

Once we have determined the CTM, modify /usr/share/X11/xorg.conf.d/40-libinput.conf file in the section with "libinput touchscreen catchall" identifier and add new line with TransformationMatrix option:

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
EndSection

Reboot system and enjoy!

Ready to use image file

You can also use a prepared image file.

You need to download the image file: SoMLabs-VisionSOM-6ULL-TP.zip

Then you need to write the image file to microSD card. More information you can find in manuals: How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Linux or How to prepare SD Card with Debian 9.2 for VisionSOM-6ULL on Windows.

NXP Partner ST Partner Renesas Partner