myzr_soft 发表于 2020-5-9 16:36:09

i2ctools编译移植



主机平台: UBUNTU14.04
硬件平台:明远智睿MY-IMX6-EK200
内核版本 :linux-4.1.15
交叉编译链:arm-poky-linux-gnueabi-gcc


1.下载i2ctolols压缩包并在虚拟机中进行解压:
$ tar xvf i2c-tools-3.1.1.tar.bz2


2.修改Makefile配置
$ cd i2c-tools-3.1.1/
$ vi Makefile
   CC =arm-poky-linux-gnueabi-gcc
   LDFLAGS +=-static

3.配置交叉编译工具
$ source /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

4.编译
$ make

5.测试
将tools目录下生产的可执行文件移到开发板中
添加可执行权限:
# chmod +x i2cdetect i2cdump i2cget i2cset

列出所有I2C设备总线:
# ./i2cdetect -l
i2c-1      i2c               21a4000.i2c                           I2C adapter
i2c-0      i2c               21a0000.i2c                           I2C adapter


扫描I2C总线设备:
# ./i2cdetect -y 0
   0123456789abcdef
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU
70: -- -- -- -- -- -- -- --                        



列出设备的寄存器值:i2cdump

写寄存器值:i2cset

读寄存器值:i2cget
页: [1]
查看完整版本: i2ctools编译移植