Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of transplanting and using Tslib under Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is the method of transplanting and using Tslib under Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

54.5 Tslib Migration and use

After the ft5426 touch driver is added successfully, it is found that the touch may not be accurate, so you can use a third-party open source library tslib to debug the touch screen. Let's take a look at how the tslib source code is migrated.

54.5.1 get tslib source code

The tslib source code can be obtained from the official address: https://github.com/libts/tslib. When you open the URL, you can see that the latest version is 1.21.It can be obtained from the official website or from the network disk materials. the data path: i.MX6UL Terminator CD material / 06_Linux driver routines / third-party library source code / tslib-1.21.tar.bz2. After obtaining the tslib source code, copy it to the Ubuntu system and decompress it to get the tslib-1.21 folder.

54.5.2 compiling tslib

After you get the tslib source code, you can compile the tslib source code in the following steps.

1. Modify the user who owns the tslib source code

The tslib-1.21 directory obtained by modification and decompression belongs to the current user. If you do not modify it, you may encounter various problems in later compilation. My current login user name for ubuntu is "topeet", so the modification command is as follows:

The modified sudo chown topeet:topeet tslib-1.21-R is shown in figure 54.5.2.1:

2. Ubuntu tool installation

When compiling tslib, you need to install some files in ubuntu to prevent errors in the process of compiling tslib. The command is as follows:

Sudo apt-get install autoconf

Sudo apt-get install automake

Sudo apt-get install libtool

3. Compile tslib

First create a tslib folder to hold the compilation results. For example, the file path is: / home/topeet/tslib

Then configure and compile tslib using the following command:

Cd tslib-1.21/ enter the tslib source directory

. / configure-host=arm-none-linux-gnueabi-prefix=/home/topeet/tslib

Make / / compilation

Make install / / installation

Note that when using. / configure to configure tslib, the "--host" parameter specifies the compiler, and the specified compiler should use the same compiler as the compiled file system, otherwise it cannot be used normally under the development board. "--prefix" parameter specifies where to install the tslib file after compilation, which must be installed in the "tslib" directory we just created.

After compilation, the tslib directory is shown in figure 54.5.2.2:

Then copy all the files in the tslib directory to the root file system of the development board. If you copy it directly, the symbolic link file cannot be copied, so you can first use the tar command to package it, and then extract it to the root file system. The command is as follows:

Tar-czvf lib.tar.gz * / / package to generate lib.tar.gz package

Tar-xvf lib.tar.gz / extract to the root file directory of the development board

54.5.3 Test tslib

When the compiled tslib is copied to the development board, the command is tested.

1. Configure tslib

Open the / etc/ts.conf file and find the following line:

Module_raw input

Delete the "#" if there is a "#" in front of the above sentence.

Open the / etc/profile file and add the following:

1 export TSLIB_TSDEVICE=/dev/input/event1

2 export TSLIB_CALIBFILE=/etc/pointercal

3 export TSLIB_CONFFILE=/etc/ts.conf

4 export TSLIB_PLUGINDIR=/lib/ts

5 export TSLIB_CONSOLEDEVICE=none

6 export TSLIB_FBDEVICE=/dev/fb0

Line 1, TSLIB_TSDEVICE represents the touch device file, here set to / dev/input/event1, this should be set on a case-by-case basis, if your touch device file is event2 then it should be set to / dev/input/event2, and so on.

Line 2, TSLIB_CALIBFILE represents the calibration file, if the screen calibration, the calibration results are saved in this file, here set the calibration file to / etc/pointercal, this file may not exist, will be automatically generated during calibration.

Line 3, TSLIB_CONFFILE represents the touch configuration file, the file is / etc/ts.conf, which is generated when the tslib is migrated.

On line 4, TSLIB_PLUGINDIR represents the location of the tslib plug-in directory, which is / lib/ts.

Line 5, TSLIB_CONSOLEDEVICE represents the console setting, which is not set here, so it is none.

On line 6, TSLIB_FBDEVICE represents the FB device, that is, the screen. According to the actual configuration, my screen file is / dev/fb0, so it is set to / dev/fb0 here.

Restart the development board after it is all configured, and then you can test it.

2. Test tslib

After the development board is restarted, you can calibrate it first, using the following command:

Ts_calibrate

After the calibration is completed, the / etc/pointercal file is generated. If you want to recalibrate, you can delete the / etc/pointercal file directly and re-execute the calibration command.

You can then use the ts_test_mt command to test whether the touchscreen is working properly and whether multi-touch is valid, and execute the following command:

Ts_test_mt

After the command is executed, a test interface opens, as shown in figure 54.5.3.1:

In the figure above, there are three buttons "Drag", "Draw" and "Quit". The functions of these three buttons are as follows:

Drag: drag button. This is the default function. You can see that there is a crosshairs in the middle of the screen. We can drag and drop this cursor by touching the screen. A touch point, a crosshairs, for a five-point capacitive touch screen, if all five fingers are placed on the screen, then there are five cursors, one for each finger.

Draw: draw button, press this button, we can do a simple drawing on the screen, we can use this function to detect whether multi-touch is working properly.

Quit: exit button, exit ts_test_mt test software.

54.6 use the ft5426 driver that comes with the Linux kernel

Many drivers of capacitive touch chips are integrated in the Linux kernel, including the driver of ft5426 that we use. So let's use the ft5426 driver file that comes with the Linux kernel. You need to remove the ft5426.c driver file we added before using it. You only need to modify the drivers/input/touchscreen/Makefile file and delete the following line:

Obj-y + = ft54266.o

The driver file of the ft5426 that comes with the kernel is drivers/input/touchscreen/edt-ft5x06.c.

1. Enable kernel ft5426 driver configuration

To use the driver that comes with the Linux kernel, you need to add the Linux kernel configuration. First, open the graphical configuration interface with the following command:

Make ARCH=arm menuconfig

The configuration path is as follows:

Device Drivers->

Input device support->

Touchscreens->

EDT FocalTech FT5x06 I2C Touchscreen support

The configuration is shown in the figure:

When the configuration is complete, recompile the Linux kernel to generate a zImage image.

2. Modify the device tree file

We want to modify the compatible attribute value edt-ft5x06.c of the ft5426 device node under the device tree according to the compatible attribute in the edt-ft5x06.c file. The list of compatible attributes supported is as follows:

Static const struct of_device_id edt_ft5x06_of_match [] = {

{.clients = "edt,edt-ft5206",}

{.clients = "edt,edt-ft5306",}

{.clients = "edt,edt-ft5406",}

{/ * sentinel * /}

}

As you can see, the compatible attributes supported by the edt-ft5x06.c file by default are only three "edt,edt-ft5206", "edt,edt-ft5306", and "edt,edt-ft5406". We can modify the ft5426 node in the device tree, add a "edt,edt-ft5406" to the value of the compatible attribute, or add one to the edt_ft5x06_of_match table in the edt-ft5x06.c file:

{.clients = "edt,edt-ft5426",}

In a word, match the ft5426 device with the edt-ft5x06.c driver. Here we modify the ft5426 device node under the device tree, as follows

1 ft5426: ft5426@38 {

2 compatible = "edt,edt-ft5426", "edt,edt-ft5406"

3 reg =

4 pinctrl-names = "default"

5 pinctrl-0 =

6 interrupt-parent =

7 interrupts =

8 reset-gpios =

9 interrupt-gpios =

10}

Add a "edt,edt-ft5406" compatibility value to the compatible property.

After the device tree modification is complete, recompile. Then start the development board using the new zImage and dtb device tree files. When the driver is normal, the following startup information is available:

You can then use the following command to view the details of the input device:

Cat / proc/bus/input/devices

The result is shown in the figure:

You can then use the hexdump or ts_test_mt command to test.

This is the end of the introduction of "what is the method of transplanting and using Tslib under Linux". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report