Android I2c-Tools安裝使用說明
阿新 • • 發佈:2018-12-18
將 i2c-tools 程式碼下載到 Android 原始碼的 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/i2cbusses.c tools/util.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)
然後 Android根目錄: . build/envsetup.sh cd external/i2c-tools mm 編譯後在 out/target/product/xxx/system/bin目錄下生成4個可執行程式: i2cdetect i2cdump i2cget i2cset
通過 adb push 之間將編譯生成的4個檔案複製到 Android 平臺的 /system/bin 目錄下。 在 abd pusll 之前,要先將 system 分割槽 remount 成可寫入模式。
adb shell cd system/bin
用i2cdetect檢測有幾組i2c匯流排在系統上:
i2cdetect -l
用i2cdetect檢測掛載在i2c_n總線上器件:
i2cdetect-r -y 0
i2cdetect-r -y 1
...