/**************************************************************************
* I.MX6 Android i2c-tools porting
* 说明:
* 判断I2C总线设备是否存在,每次都去查dmesg,实在是烦了,于是还是移植
* 一个i2c-tools比较好,不用翻那长长内核信息。
*
* 2016-3-31 深圳 南山平山村 曾剑锋
*************************************************************************/ 一、参考资料:
. Android 平台下使用 i2c-tools
http://my.oschina.net/luoly/blog/368881
. 树莓派学习笔记——I2C Tools 学习笔记
http://blog.csdn.net/xukai871105/article/details/15029843
. Linux I2C工具查看配置I2C设备
http://blog.chinaunix.net/uid-26895763-id-3478882.html 二、download:
groeck/i2c-tools:
https://github.com/groeck/i2c-tools 三、Decompress:
zengjf@zengjf:~$ unzip i2c-tools-master.zip
zengjf@zengjf:~$ mv i2c-tools-master ~/myandroid/external/i2c-tools/ 四、cat external/i2c-tools/Android.mk
# external/i2c-tools/Android.mk LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
LOCAL_SRC_FILES :=tools/util.c tools/i2cbusses.c
LOCAL_MODULE := i2c-tools
include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cdetect.c
LOCAL_MODULE:=i2cdetect
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cget.c
LOCAL_MODULE:=i2cget
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cset.c
LOCAL_MODULE:=i2cset
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cdump.c
LOCAL_MODULE:=i2cdump
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE) 五、compile error:
. 现象:
......
PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Solarium.ogg:system/media/audio/ringtones/Solarium.ogg ignored.
No private recovery resources for TARGET_DEVICE sabresd_6dq
make: Entering directory `/home/zengjf/myandroid'
target thumb C: i2c-tools <= /home/zengjf/myandroid/external/i2c-tools//lib/smbus.c
target StaticLib: i2c-tools (out/target/product/sabresd_6dq/obj/STATIC_LIBRARIES/i2c-tools_intermediates/i2c-tools.a)
target thumb C: i2cdetect <= /home/zengjf/myandroid/external/i2c-tools/lib/smbus.c
target thumb C: i2cdetect <= /home/zengjf/myandroid/external/i2c-tools/tools/i2cdetect.c
/home/zengjf/myandroid/external/i2c-tools/tools/i2cdetect.c::: error: 'I2C_FUNC_SMBUS_PEC' undeclared here (not in a function)
make: *** [out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdetect_intermediates/tools/i2cdetect.o] Error
make: Leaving directory `/home/zengjf/myandroid'
. 解决办法:
cat external/i2c-tools/include/i2c/smbus.h
.....
/* Compatibility defines 添加宏声明*/
#ifndef I2C_SMBUS_I2C_BLOCK_BROKEN
#define I2C_SMBUS_I2C_BLOCK_BROKEN I2C_SMBUS_I2C_BLOCK_DATA
#endif
#ifndef I2C_FUNC_SMBUS_PEC
#define I2C_FUNC_SMBUS_PEC I2C_FUNC_SMBUS_HWPEC_CALC
#endif extern __s32 i2c_smbus_access(int file, char read_write, __u8 command,
int size, union i2c_smbus_data *data); extern __s32 i2c_smbus_write_quick(int file, __u8 value);
......
. 正常现象:
No private recovery resources for TARGET_DEVICE sabresd_6dq
make: Entering directory `/home/zengjf/myandroid'
target thumb C: i2cdetect <= /home/zengjf/myandroid/external/i2c-tools/tools/i2cdetect.c
target Executable: i2cdetect (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdetect_intermediates/LINKED/i2cdetect)
target Symbolic: i2cdetect (out/target/product/sabresd_6dq/symbols/system/bin/i2cdetect)
Export includes file: /home/zengjf/myandroid/external/i2c-tools/Android.mk -- out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdetect_intermediates/export_includes
target Strip: i2cdetect (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdetect_intermediates/i2cdetect)
Install: out/target/product/sabresd_6dq/system/bin/i2cdetect
Import includes file: out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cget_intermediates/import_includes
target thumb C: i2cget <= /home/zengjf/myandroid/external/i2c-tools/tools/i2cget.c
target Executable: i2cget (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cget_intermediates/LINKED/i2cget)
target Symbolic: i2cget (out/target/product/sabresd_6dq/symbols/system/bin/i2cget)
Export includes file: /home/zengjf/myandroid/external/i2c-tools/Android.mk -- out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cget_intermediates/export_includes
target Strip: i2cget (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cget_intermediates/i2cget)
Install: out/target/product/sabresd_6dq/system/bin/i2cget
Import includes file: out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cset_intermediates/import_includes
target thumb C: i2cset <= /home/zengjf/myandroid/external/i2c-tools/tools/i2cset.c
target Executable: i2cset (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cset_intermediates/LINKED/i2cset)
target Symbolic: i2cset (out/target/product/sabresd_6dq/symbols/system/bin/i2cset)
Export includes file: /home/zengjf/myandroid/external/i2c-tools/Android.mk -- out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cset_intermediates/export_includes
target Strip: i2cset (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cset_intermediates/i2cset)
Install: out/target/product/sabresd_6dq/system/bin/i2cset
Import includes file: out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdump_intermediates/import_includes
target thumb C: i2cdump <= /home/zengjf/myandroid/external/i2c-tools/tools/i2cdump.c
target Executable: i2cdump (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdump_intermediates/LINKED/i2cdump)
target Symbolic: i2cdump (out/target/product/sabresd_6dq/symbols/system/bin/i2cdump)
Export includes file: /home/zengjf/myandroid/external/i2c-tools/Android.mk -- out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdump_intermediates/export_includes
target Strip: i2cdump (out/target/product/sabresd_6dq/obj/EXECUTABLES/i2cdump_intermediates/i2cdump)
Install: out/target/product/sabresd_6dq/system/bin/i2cdump
make: Leaving directory `/home/zengjf/myandroid'
zengjf@zengjf:~/myandroid$
. adb push <编译出来的可执行程序> /data/local 六、i2cdetect test:
. test1:
|root@android:/data/local # ./i2cdetect -l
i2c- i2c i2c-gpio3 I2C adapter
i2c- i2c imx-i2c I2C adapter
i2c- i2c imx-i2c I2C adapter
i2c- i2c imx-i2c I2C adapter
root@android:/data/local #
. test2:
root@android:/data/local # ./i2cdetect -y -r
a b c d e f
: -- -- -- -- -- -- -- -- -- -- -- -- --
: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
: UU -- -- -- -- UU -- -- -- -- -- -- -- -- -- --
: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
: -- -- -- -- -- -- -- -- 七、i2cget test:
|root@android:/data/local # ./i2cget -y 0x08 0x03
Error: Could not set address to 0x08: Device or resource busy
|root@android:/data/local # ./i2cget -f -y 0x08 0x03
0x21
|root@android:/data/local #

I.MX6 Android i2c-tools porting的更多相关文章

  1. I.MX6 Android U-blox miniPCI 4G porting

    /************************************************************************** * I.MX6 Android U-blox m ...

  2. I.MX6 Android Linux shell MMPF0100 i2c 设置数据

    #!/system/bin/busybox ash # # I.MX6 Android Linux shell MMPF0100 i2c 设置数据 # 说明: # 本文主要记录通过shell脚本来设置 ...

  3. I.MX6 Android iperf3 porting failed

    /***************************************************************************** * I.MX6 Android iperf ...

  4. I.MX6 Android Linux shell MMPF0100 i2c 获取数据

    #!/system/bin/busybox ash # # I.MX6 Android Linux shell MMPF0100 i2c 获取数据 # 说明: # 本文主要记录通过shell脚本来获取 ...

  5. 在android下使用i2c tools

    在android使用i2c tools访问i2c,很方便,可以在https://launchpad.net/ubuntu/+source/i2c-tools 下载最新的i2c tools. 把i2c- ...

  6. I.MX6 HUAWEI MU609 3G porting

    /*************************************************************************** * I.MX6 HUAWEI MU609 3G ...

  7. I.MX6 Android 5.1.1 下载、编译

    /************************************************************************* * I.MX6 Android 5.1.1 下载. ...

  8. I.MX6 android mkuserimg.sh

    /************************************************************************** * I.MX6 android mkuserim ...

  9. Android SDK Tools Platform-tools Build-tools

    (1)Android SDK (Android SDK主安装包,包含SDK Manager.AVD Manager.工具包tools,释放后的根文件夹为android-sdk-windows): re ...

随机推荐

  1. AWK 介绍

    一.模式和动作 awk脚本是由模式和操作组成的:pattern {action} pattern与{action}两者是可选的.如果没有模式,则action应用到全部记录,如果没有action,则输出 ...

  2. IEtester不靠谱

    对于刚刚学习前端的人来说,IEtester无疑是个测试神器, 刚开始用的时候,真有种如获至宝的兴奋. 然而,随着你学习的深入,你会慢慢地发现这个东西不太靠谱,而且会觉得没必要用它.为什么这么说呢? 首 ...

  3. 外部表查询时出现ORA-29913和ORA-29400错误

    create table t_ext_tab(id char(1),name char(6)) organization external( type oracle_loader default di ...

  4. Oracle中正则表达式的使用

    Oracle10开始支持正则表达式. ORACLE中的支持正则表达式的函数主要有下面四个: 1. REGEXP_LIKE :          与LIKE的功能相似 2. REGEXP_INSTR : ...

  5. redis缓存的安装和使用

    Redis介绍    Redis本质上一个Key/Value数据库,与Memcached类似的NoSQL型数据库,但是他的数据可以持久化的保存在磁盘上,解决了服务重启后数据不丢失的问题,他的值可以是s ...

  6. (转载)Cocos2dx-OpenGL ES 2.0教程:你的第一个三角形(1)

    前言 在本系列教程中,我会以当下最流行的2D引擎Cocos2D-X为基础,介绍OpenGL ES 2.0的一些基本用法.本系列教程的宗旨是OpenGL扫盲,让大家在使用Cocos2D-X过程中,知其然 ...

  7. WCF入门教程一[什么是WCF]--转载只为学习收藏

    一.概述 Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,可以翻译为Windows通讯接口,它是.NET框架的一部分.由 .NE ...

  8. 指针 取地址& 解引用 *

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtAAAACNCAIAAAARutrLAAAgAElEQVR4nOydd3wcxd3/R13uvdsUY2

  9. Scala中的Extractor

    Scala中使用unapply方法可以实现三种extractor(另外使用unapplySeq也可以实现extractor) def unapply(object: S): Option[(T1, . ...

  10. poj 3440 Coin Toss 概率问题

    这题主要是推导数学公式!!! 将概率问题转化为圆心所在的面积! 代码如下: #include<iostream> #include<stdio.h> #include<a ...