i2c-tools under Android

Published on May 27, 2011

Archived Notice

This article has been archived and may contain broken links, photos and out-of-date information. If you have any questions, please Contact Us.

While working with a multi-touch display under Android recently, I had some questions about what data was being received from the touch screen, which is connected to our Nitrogen53 board over i2c.

My early debug steps involved instrumenting the kernel, but I really wanted the quicker cycle time of the i2c-tools package. It turns out that this was trivially easy to do. The i2c-tools package is very clean and the Android build system makes generating a makefile simple.

I simply copied my source tree into hardware/i2c-tools-3.0.2, added the following Android.mk, and it worked! The following is the content of Android.mk that I came up with by a quick scan of the Makefile.

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)