I2C Slave

Hi,

I have to use the Jetson Nano like an I2C Slave device.

I found a topic what I followed and I have build a custom image, after image flashing I don’t see any i2c slave devices (ie.: /dev/slave-i2c-0) what I’d to use in a c++ qt app.

My modifications:

  1. Enabled these configs:
    CONFIG_I2C_TEGRA_SLAVE=y
    CONFIG_I2C_SLAVE_EEPROM=y

  2. Modified the kernel device-tree:
    the dts file: Linux_for_Tegra/sources/hardware/nvidia/platform/t18x/quill/kernel-
    dts/tegra186-quill-p3310-1000-a00-00-base.dts
    what I added this file:
    i2c@7000c000 {
    compatible = “nvidia,tegra210-i2c-slave”;
    eeprom@64 {
    reg = <0x64>;
    compatible=“slave-24c02”;
    status = “okay”;
    };
    };

Could you please check from the list above if there are any missing settings?

Thanks, BR
Labi

Could you have a check the /proc/device-tree to check the context have include your modification.

Yes I could:

	i2c@7000c000 {
            compatible = "nvidia,tegra210-i2c-slave";
            clocks = <0x26 0xc 0x26 0xf3>;
            resets = <0x26 0xc>;
            clock-names = "div-clk", "parent";
            status = "okay";
            #address-cells = <0x1>;
            interrupts = <0x0 0x26 0x4>;
            #size-cells = <0x0>;
            dma-names = "rx", "tx";
            phandle = <0xb0>;
            reg = <0x0 0x7000c000 0x0 0x100>;
            iommus = <0x30 0xe>;
            clock-frequency = <0x61a80>;
            dmas = <0x51 0x15 0x51 0x15>;
            reset-names = "i2c";
            linux,phandle = <0xb0>;

            eeprom@64 {
                    compatible = "slave-24c02";
                    status = "okay";
                    reg = <0x64>;
            };

            temp-sensor@4c {
                    compatible = "ti,tmp451";
                    extended-rage = <0x1>;
                    sensor-name = "tegra";
                    supported-hwrev = <0x1>;
                    #thermal-sensor-cells = <0x1>;
                    offset = <0x0>;
                    conv-rate = <0x6>;
                    status = "disabled";
                    interrupt-parent = <0x5b>;
                    temp-alert-gpio = <0x5b 0xbc 0x0>;
                    interrupts = <0xbc 0x8>;
                    phandle = <0x121>;
                    vdd-supply = <0x3b>;
                    reg = <0x4c>;
                    linux,phandle = <0x121>;

                    ext {
                            shutdown-limit = <0x69>;
                    };

                    loc {
                            shutdown-limit = <0x78>;
                    };
            };
    };

Could you suggest to me a working sample or method for a c++ implementation ?

I think once Nano already configure as slave mode you have connect to a host device to communicate with it.

I tried the communication with I2C master and it is working well.

But the issue is that I’d like to handle the incoming data from the host device in a c++ application.
Do you have any suggestion for that?

Maybe below link can be reference.

If I understand correctly this stackoverflow.com article is about i2c master read&write implementation in c++ (with fake device)

But I need i2c slave implementation.

Do you have any reference for that?

Do you like i2c slave user space APP implementation on Nano?
Sorry, I don’t have this kind of experience.

Yes, I would like to use the I2C Slave function, so I’m interested in what I2C master sends to me.

Is there anybody you can escalate my issue?

Based on the module’s description it supports the I2C Slave, but there are no available descriptions, references or documentation for usage. How can I use it if I do not receive any help?

Looks like there’s no user space LIBs for this, however you can implement by kernel space API like i2c_slave_recv()/i2c_slave_send()

https://android.googlesource.com/kernel/tegra/+/android-tegra-flounder-3.10-lollipop-release/include/linux/i2c-slave.h

I found the working solution:

Your backend simulates an EEPROM on the connected I2C bus. Its memory contents can be accessed from userspace via this file located in sysfs:

/sys/bus/i2c/devices//slave-eeprom