[Beijing Xunwei] i.MX6ULL Terminator Linux I2C driver experimental running test

1 Compile the driver

A Makefile is required as the driver test program in the previous chapter, but the value of obj-m is changed to ap3216c_iic.o. The contents of the Makefile are as follows:

KERNELDIR := /home/topeet/kernel/linux-imx-rel_imx_4.1.15_2.1.0_ga
CURRENT_PATH := $(shell pwd)
obj-m := ap3216c_iic.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 the module, and the compilation is complete to generate the ap3216c_iic.ko module file.

2 Compile the application test program

Enter the following command to compile the application test program: After the
arm-linux-gnueabihf-gcc -o ap3216c_test ap3216c_test.c
compilation is complete, the ap3216c_test executable file will be generated.

3 Run the test

Start the development board and copy the compiled ap3216c_iic.ko module file and ap3216c_test application to the /lib/modules/4.1.15 directory (check whether there is "/lib/modules/4.1.15" in the root file system of the development board Directory, if you don’t have one, 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). Enter the following command to load the module:

depmod
modprobe ap3216c_iic

When the driver module is loaded, an error indicating that the device is busy may appear, because the ap3216c driver may be compiled into the Linux kernel by default. You can first comment out the ap3216c configuration in the kernel configuration, and temporarily use the module to test.
The driver module is successfully loaded. Use the ap3216c_test application test program to test. The command is as follows: The
./ap3216c_test /dev/ap3216c &
test program will continuously read data from AP3216C and output it to the terminal. The result is as follows:
Insert picture description here

Figure 3.1

Uninstall the module using the following command:
rmmod ap3216c_iic

Insert picture description here

Guess you like

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