Problem using I2C on mangOH green

I am trying to use the I2C interface on the mangOH green using a wp7603. I can open the i2c-4 file and send ioctl commands, but whenever I try to write I get this error:

Error code 107: Transport endpoint is not connected

Here is my code:

int main()
{
    int i2c_fd = open("/dev/i2c-4", O_RDWR);
    cout << "fd: " << i2c_fd << endl;

    while (true)
    {
        if (ioctl(i2c_fd, I2C_SLAVE_FORCE, 0x5a) < 0)
        {
            cout << "Error with ioctl call: " << errno << " " << strerror(errno) << endl;
        }
        else
        {
            if (write(i2c_fd, "asdf", 4) < 0)
            {
                cout << "Error with write call: " << errno << " " << strerror(errno) << endl;
            }
        }
        sleep(1);
    }
}

Which always spits out this output:

fd: 3
Error with write call: 107 Transport endpoint is not connected
Error with write call: 107 Transport endpoint is not connected
Error with write call: 107 Transport endpoint is not connected

At which point I just kill it…

From the hardware side, I have tried it while connected to a slave device, not connected, connected to a Logic Analyzer, with and without pullup resistors, but at no point did I see any activity on the bus.

Am I doing something wrong or missing some configuration with the I2C bus? i2c-4 is the only file I see in /sys/class/i2c-dev, is there another device I should be using?

Where is the I2C device physically connected to your system? Is it in an IoT slot? What does ls -l /dev/i2c* show?

The device is plugged into IoT slot 0. Results:

root@swi-mdm9x28:~# ls -l /dev/i2c*
crw-rw---- 1 root root 89, 4 Jan 1 1970 /dev/i2c-4

We haven’t tested the mangOH SDEF against the wp76xx yet. I expect that some part of the mangoh kernel module is failing.

Hi @apadin, did you manage to fix the problem with i2c communication? I have a very similar issue as you had.

@wsialex: Which device are you trying to communicate with?

I’m trying to communicate with a F-RAM (FM24CL04B-G) on a custom made board with WP7607. I have made these changes to mdm9607-wp76xx.dtsi:
Before

&i2c_4 {
	/* reduce bus frequency as a workaround for MCU ROM boot loader */
	qcom,clk-freq-out = <100000>;

	/* Increase clock high width from 3.4ns to 4.6ns to meet I2C spec */
	qcom,fs-clk-div = <100>;
	qcom,high-time-clk-div = <86>;
	status = "ok";
};

After

&i2c_4 {
	/* reduce bus frequency as a workaround for MCU ROM boot loader */
	qcom,clk-freq-out = <100000>;

	/* Increase clock high width from 3.4ns to 4.6ns to meet I2C spec */
	qcom,fs-clk-div = <100>;
	qcom,high-time-clk-div = <86>;
	status = "ok";

	fram: fram@50 {
        compatible = "at,24c04";
        reg = <0x50>;
    };
};

No changes was needed in kernel config as at24.c driver is already included.

I have tried writing and reading from it with dd if=testdata of=/sys/devices/78b8000.i2c/i2c-4/4-0050/eeprom bs=1 count=8 skip=0 seek=64, which outputs

dd: writing '/sys/devices/78b8000.i2c/i2c-4/4-0050/eeprom': Connection timed out** **1+0 records in** **0+0 records out

ls -l /dev/i2c* outputs

crw-rw----    1 root     root       89,   4 Jan 27  1970 /dev/i2c-4

i2cdetect -y -r 4 outputs

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 05 06 07 -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: UU UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

are there any other configurations needed for i2c? I haven’t yet looked at the bus with a logic analyzer or a scope but will try that today.

Update: when looking at the physical bus with a logic analyzer I saw communication. However, in our design there is a level-shifter from 1.8V to 3.3V which had a bad soldering which explained my issue. So in other words it seems like I have a HW issue.