# Debug I2C in sensor core

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

## About this task
If the I^2^C is stuck in the SLPI or aDSP, debug using the memory dump. To
      capture the memory dump, do the following:

## Procedure

1. In the adsp\_proc/core/settings/buses/i2c/config/strait/i2c\_devcfg.c file, change the default configuration from `BUS_ENABLE_RECOVER_ON_TIMEOUT` to `BUS_ENABLE_FATAL_ON_TIMEOUT`.
2. Increase the I^2^C transfer timeout. 
        
For I^2^C, regardless of the data size, each transfer is given a fixed
          timeout value. Currently, the fixed timeout value is 2000 ms. If the data size of the
          sensor component passed into the I^2^C layer is large, the default timeout value
          might not be enough and may cause unexpected termination of the transfer. 
Identify a
            component that needs transfer data in large size and modify the following timeout
            setting accordingly:

        #define MAX_TRANSFER_TIMEOUT 2000 //within i2c_drv.hCopy to clipboard
3. Enable the I^2^C or GPI layer register dump collection.
        
If the transfer gets stuck in the default I^2^C software, the bus recovery
            mechanism is activated after the timeout expires. To debug, force the software to
            collect the I^2^C or GPI layer register dump and error information after the
            timeout expires.

The following configuration in the i2c\_devcfg.c file controls the behavior of the I^2^C driver in this scenario. Choose `recover_state` from the following possible options:

        static plat_device_config i2c_device_config[] =
        {
        .core_base_addr = (uint8 *) QUPV3_CORE_BASE_ADDRESS,
        .core_offset = 0x00080000,
        .qupv3_instance = QUP_SSC,
        …………..
        .recover_state = BUS_ENABLE_RECOVER_ON_TIMEOUT,
        ………………
        },
        typedef enum bus_recovery_feature
        {
        BUS_DISABLE_TIMEOUT //i2c will stuck, no bus recovery mechanism attempted
        BUS_ENABLE_REGDUMP //i2c and gpi register dump will be collected if crash.
        BUS_ENABLE_FATAL_ON_TIMEOUT // device will crash after i2c/gpi register
        dump collected.
        BUS_ENABLE_RECOVER_ON_TIMEOUT // device will activate bus recovery to
        try bring things back to normal.
        BUS_ENABLE_FATAL_ON_TIMEOUT_WITH_REGDUMP // not appliable
        BUS_ENABLE_RECOVER_ON_TIMEOUT_WITH_REGDUMP//not appliable
        
        }bus_recovery_feature;Copy 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
Debug I2C in kernel](https://docs.qualcomm.com/bundle/publicresource/80-88500-1/topics/43_Debug_I2C_in_kernel.md) [Next Topic
QUPs in HLOS](https://docs.qualcomm.com/bundle/publicresource/80-88500-1/topics/53_QUPs_in_HLOS.md)