This is a cache of https://discuss.96boards.org/t/building-i2c-tools-for-aosp-on-hikey-960/5163. It is a snapshot of the page at 2024-10-31T09:35:49.256+0000.
Building i2c-tools for AOSP on Hikey 960 - HiKey 960 - <strong>96Boards</strong> Forum

Building i2c-tools for AOSP on Hikey 960

I have started driver development for a capacitive I2C touch panel for HiKey 960. As I’m pretty new to Linux driver development, I want to make a start with using i2c-tools, to verify my device hardware is connected properly. Unfortunately I can’t build i2c-tools for AOSP. I have followed the step outlined in the 1st answer of this post:

I end up with numerous error: undefined reference to 'i2c_smbus_**** errors.

Is there any step I’m missing to build this tool for Hikey 960? Thanks

I’m using the 3.1 branch from here:
https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/log/?h=i2c-tools-3.1

Put it in external/i2c-tools and add this Android.mk to it;
(note: Despite a similar overall look, this makefile is NOT the same as the one in your link, which WILL NOT WORK)

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional
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 := optional
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 := optional
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 := optional
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 := optional
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)

omg @doitright you livin’up to your name once again. thanks a bunch!

Hi,

Can you enlist all the steps to build i2c tools for mediatek x20 development board? Thanks.

Can you enlist all the steps to build i2c tools for mediatek x20 development board? Thanks.

Did you try these steps already and found it didn’t work for you? Or are you
just worried that the X20 Android port is too old for these instructions
to work.