# Debug I2C in kernel

Source: [https://docs.qualcomm.com/doc/80-88500-1/topic/43_Debug_I2C_in_kernel.html](https://docs.qualcomm.com/doc/80-88500-1/topic/43_Debug_I2C_in_kernel.html)

## About this task

The following are the debugging steps to ensure that the slave device is powered up and ready to accept I^2^C transfer:

## Procedure

1. Verify and ensure that the I^2^C bus is properly registered with the Linux TTY stack.
        
When all the required information is defined in the code, the I^2^C bus is registered under `/dev/i2c-#`, where the cell-index matches the bus number. Following is an example listing the registered I^2^C buses:

        adb shellCopy to clipboard

        cd /dev/Copy to clipboard

        ls i2c*Copy to clipboard

        root@android:/dev # ls i2c*
        ls i2c*Copy to clipboard

            Sample output:

<samp class="ph systemoutput"> i2c-0 i2c-10 i2c-2</samp>

A sample code for the I^2^C master test from user space is available at: vendor/qcom/proprietary/kernel-tests/i2c-msm/. In the build, the I^2^C binary is available at: /data/kernel-tests/i2c-msm-test.
2. Find the I^2^C master. Following is an example:
        
/sys/kernel/debug/f9928000.i2c # ls /dev/i2c*Copy to clipboard

        ls /dev/i2c*Copy to clipboard

Sample output:

<samp class="ph systemoutput">/dev/i2c-2 </samp>

<samp class="ph systemoutput">/dev/i2c-5 </samp>

<samp class="ph systemoutput">/dev/i2c-6</samp>
3. Ensure that you have execute access on the I2C binary. If you do not have access,
          modify the file attributes of the `i2c-msm-test` binary . 
        
cd /data/kernel-testsCopy to clipboard

        /data/kernel-tests # chmod 777 i2c-msm-testCopy to clipboard

Sample output: <samp class="ph systemoutput">chmod 777 i2c-msm-test</samp>

        /data/kernel-tests # ls -l i2c-msm-testCopy to clipboard

Sample output:

<samp class="ph systemoutput">ls -l i2c-msm-test -rwxrwxrwx root root 22712 2015-06-12 07:07
              i2c-msm-test</samp>
4. Run `i2c-msm-test` to test I^2^C master.
        
The following are some error messages indicating the cause of I^2^C issues:

    - Invalid software configuration
    - Invalid hardware configuration
    - Slave device issues

For more information about `i2c-msm-test`, see the source code at
              vendor/qcom/proprietary/kernel-tests/i2c-msm/i2c-msm-test.c and
            run the command: 

        ./i2c-msm-test --helpCopy to clipboard

**Parent Topic:** [I2C in QUP](https://docs.qualcomm.com/doc/80-88500-1/topic/41_I2C_in_QUP_v3.html)

Last Published: Aug 18, 2023

[Previous Topic
Enable I2C bus in aDSP](https://docs.qualcomm.com/bundle/publicresource/80-88500-1/topics/51_Enable_I2C_bus_in_aDSP.md) [Next Topic
Debug I2C in sensor core](https://docs.qualcomm.com/bundle/publicresource/80-88500-1/topics/52_Debug_I2C_in_sensor_core.md)