[Beijing Xunwei] i.MX6ULL Terminator Linux capacitive touch screen experimental operation test

1 Compile the driver

Create a Makefile file, the content is basically the same as the previous experiment, you need to modify the value of obj-m to ft5426.o, the specific content is as follows:

KERNELDIR := /home/topeet/kernel/linux-imx-rel_imx_4.1.15_2.1.0_ga
CURRENT_PATH := $(shell pwd)
obj-m := ft5426.o

build: kernel_modules

kernel_modules: 
        $(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) modules
clean:
        $(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) clean

First, we enter two commands in the terminal (set two environment variables):

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-

Then execute the "make" command to compile, compile and complete the production ft5426.ko driver module file.

2 Run the test

Compile the device tree file, use the new device tree file to start the development board, and then copy and compile the produced ft5426.ko driver module file to the lib/modules/4.1.15 directory of the development board root file system (check the development board root file system There is no "/lib/modules/4.1.15" directory, if you don’t have it, you need to create it yourself. The development board uses the busybox file system provided in the CD data, and the CD data "i.MX6UL Terminator CD data\08 _Development board system image\03_file system image\01_Busybox file system" directory). Use the following command to load the module:

depmod
modprobe ft5426

When the driver module is loaded successfully, there is a message as shown in Figure 2.1:
Insert picture description here

Figure 2.1

After the driver is loaded successfully, the /dev/input/eventn device file will be generated. For example, this touch screen is shown in Figure 2.2:
Insert picture description here

Figure 2.2

The event4 device file is the file corresponding to the touch screen. Of course, the file names may be different.
Use the command to view the event4 file:
hexdump /dev/input/event4
use a finger to touch the screen and lift up, there will be information output, as shown in Figure 2.3:
Insert picture description here

Figure 2.3

It shows that the touch screen driver is working normally.

3 Add the driver to the kernel

Earlier we compiled the touch screen driver into a module file, and every time the system is started, the driver module needs to be manually loaded, which is very inconvenient. When our device driver is successfully debugged, we usually compile the driver directly into the kernel, so that the driver will be automatically loaded after the kernel is started. In this section, let's take a look at how to add the ft5426.c driver file to the Linux kernel.
1. Put the driver file in the appropriate directory. The
successfully tested driver file must first be placed in the appropriate directory of the Linux kernel. At this time, we can refer to the directory where the driver files of similar devices are stored, such as touch screen driver files, which we can find in drivers The /input/touchscreen directory is all touch-related driver files, so we put the ft5426.c driver file in this directory.
2. After modifying the corresponding Makefile and
putting the ft5426.c driver file in the drivers/input/touchscreen directory, you need to modify the Makefile in this directory and add the following content: the
obj-y += ft5426.o
addition is complete as shown:
Insert picture description here

Figure 3.1

After the modification is completed, recompile the Linux kernel, and then use the new zImage image to start the development board. After the driver is successfully added, it will be printed as shown in Figure 3.2:
Insert picture description here

Figure 3.2

You can use the following command to view the corresponding event time: the
cat /proc/bus/input/devices
results are as follows:
Insert picture description here

Figure 3.3

You can see that ft5426 ​​corresponds to the /dev/input/event1 device file, and then use the following command to check whether the driver is working properly: The
hexdump /dev/input/event1
result is shown in Figure 3.4:
Insert picture description here

Figure 3.4

It shows that the ft5426 ​​driver is working normally.

Insert picture description here

Guess you like

Origin blog.csdn.net/BeiJingXunWei/article/details/112800078