一、下载I2C-tools工具:
最近在移植i2c-tools工具,下载地址:https://i2c.wiki.kernel.org/index.php/I2C_Tools;百度到了wiki中的git地址;
1 git clone git://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git -b i2c-tools-3.1
二、将git下载到external目录下,编写Android.mk,将其打包system.img:
Android.mk内容如下:
1 LOCAL_PATH:= $(call my-dir) 2 3 include $(CLEAR_VARS) 4 5 LOCAL_MODULE_TAGS := optional 6 LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include 7 LOCAL_SRC_FILES := tools/i2cbusses.c tools/util.c 8 LOCAL_MODULE := i2c-tools 9 include $(BUILD_STATIC_LIBRARY) 10 11 include $(CLEAR_VARS) 12 13 LOCAL_MODULE_TAGS := optional 14 LOCAL_SRC_FILES:=tools/i2cdetect.c 15 LOCAL_MODULE:=i2cdetect 16 LOCAL_CPPFLAGS += -DANDROID 17 LOCAL_SHARED_LIBRARIES:=libc 18 LOCAL_STATIC_LIBRARIES := i2c-tools 19 LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include 20 include $(BUILD_EXECUTABLE) 21 22 include $(CLEAR_VARS) 23 24 LOCAL_MODULE_TAGS := optional 25 LOCAL_SRC_FILES:=tools/i2cget.c 26 LOCAL_MODULE:=i2cget 27 LOCAL_CPPFLAGS += -DANDROID 28 LOCAL_SHARED_LIBRARIES:=libc 29 LOCAL_STATIC_LIBRARIES := i2c-tools 30 LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include 31 include $(BUILD_EXECUTABLE) 32 33 include $(CLEAR_VARS) 34 35 LOCAL_MODULE_TAGS := optional 36 LOCAL_SRC_FILES:=tools/i2cset.c 37 LOCAL_MODULE:=i2cset 38 LOCAL_CPPFLAGS += -DANDROID 39 LOCAL_SHARED_LIBRARIES:=libc 40 LOCAL_STATIC_LIBRARIES := i2c-tools 41 LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include 42 include $(BUILD_EXECUTABLE) 43 44 include $(CLEAR_VARS) 45 46 LOCAL_MODULE_TAGS := optional 47 LOCAL_SRC_FILES:=tools/i2cdump.c 48 LOCAL_MODULE:=i2cdump 49 LOCAL_CPPFLAGS += -DANDROID 50 LOCAL_SHARED_LIBRARIES:=libc 51 LOCAL_STATIC_LIBRARIES := i2c-tools 52 LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include 53 include $(BUILD_EXECUTABLE)
然后mm命令编译当前目录,生成到:
make snod编译进板子上的system/bin目录下;
Android下的i2c-tools使用如链接所示,就不提及了;
http://blog.csdn.net/hui872370036/article/details/50379036