Page 1 of 1

I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 1:02 am
by mamor
Hello:
I have a Compute Module 3 (CM3L) that use i2c-0 to connect to the Sony IMX219. Here are some questions:
1. Is it possible to connect several slave devices on the same i2c line (i2c-0) as the camera? My tests show that the camera (Sony IMX219) periodically outputs data on the same i2c line (i2c-0) as the other slave devices, thus causing a hang in our system.
2. If the camera (Sony IMX219) cannot share the same bus with other device(s), how can I then move the camera (Sony IMX219) to i2c-1 in software instead?

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 7:16 am
by 6by9
mamor wrote:
Wed Apr 17, 2019 1:02 am
Hello:
I have a Compute Module 3 (CM3L) that use i2c-0 to connect to the Sony IMX219. Here are some questions:
1. Is it possible to connect several slave devices on the same i2c line (i2c-0) as the camera? My tests show that the camera (Sony IMX219) periodically outputs data on the same i2c line (i2c-0) as the other slave devices, thus causing a hang in our system.
Not really. The camera module is normally controlled over i2c by the videocore vpu, not the arm. There is no arbitration between the two processors, therefore accessing the peripheral from both at the same time causes issues. This is the reason the dtparam is i2c_vc (vc for videocore).
No i2c slave ever randomly emits data, but the vpu will be sending it commands.
2. If the camera (Sony IMX219) cannot share the same bus with other device(s), how can I then move the camera (Sony IMX219) to i2c-1 in software instead?
Yes, you can amend dt-blob.bin to use i2c_port 1 on different gpios. The information required to do that is on the same page about configuring the camera for use on a cm.

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 7:20 pm
by mamor
Thank you so much! So here is my dts file for changing the camera to i2c-1 (SDA=2, SCL=3) I highlighted my changes.
Would the change below be ok?
/dts-v1/;

/ {
videocore {

pins_cm3 {

pin_config {

[email protected] {
polarity = "active_high";
termination = "pull_down";
startup_state = "inactive";
function = "input";
}; // pin

[email protected] { function = "input"; termination = "pull_up"; }; // CAMERA 0 I2C1 SDA
[email protected] { function = "input"; termination = "pull_up"; }; // CAMERA 0 I2C1 SCL

[email protected] { function = "output"; termination = "pull_down"; startup_state="active"; }; // ADP5585 Reset
[email protected] { function = "output"; termination = "pull_down"; startup_state="active"; }; // ADV7611 Reset
[email protected] { function = "output"; termination = "pull_down"; startup_state="inactive"; }; // TFP410 Reset
[email protected] { function = "output"; termination = "pull_down"; startup_state="active"; }; // Ethernet Reset
[email protected] { function = "output"; termination = "pull_down"; startup_state="active"; }; // Life LED
[email protected] { function = "output"; termination = "pull_down"; startup_state="active"; }; // Deserializer Reset
[email protected] { function = "input"; termination = "pull_up"; }; // PERIPHERAL I2C0 SDA
[email protected] { function = "input"; termination = "pull_up"; }; // PERIPHERAL I2C0 SCL
[email protected] { function = "output"; termination = "no_pulling"; }; // CAMERA 0 LED
[email protected] { function = "output"; termination = "no_pulling";}; // CAMERA PWM
[email protected] { function = "output"; termination = "no_pulling"; startup_state="active"; }; // CAMERA 0 SHUTDOWN
[email protected] { function = "uart0"; termination = "no_pulling"; drive_strength_mA = < 8 >; }; // TX uart0
[email protected] { function = "uart0"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // RX uart0
[email protected] { function = "input"; termination = "pull_up"; }; // SMPS_SCL
[email protected] { function = "input"; termination = "pull_up"; }; // SMPS_SDA
[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CLK
[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CMD
[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D0
[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D1
[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D2
[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D3
[email protected] { function = "input"; termination = "no_pulling"; polarity = "active_low"; }; // Hotplug
[email protected] { function = "output"; termination = "no_pulling"; polarity = "active_low"; }; // EMMC_ENABLE_N
}; // pin_config

pin_defines {
[email protected]_CONTROL_ATTACHED {
type = "external";
number = <0>;
};
[email protected]_ENABLE {
type = "external";
number = <1>;
};
[email protected]_LOW {
type = "absent";
};
[email protected]_DISK_ACTIVITY {
type = "absent";
};
[email protected]_RUN {
type = "absent";
};
[email protected]_SDA {
type = "internal";
number = <46>;
};
[email protected]_SCL {
type = "internal";
number = <47>;
};
[email protected]_CLK {
type = "absent";
};
[email protected]_LPO_CLK {
type = "absent";
};
[email protected]_LIMIT_1A2 {
type = "absent";
};
[email protected]_1V8_SEL {
type = "absent";
};
[email protected] {
type = "absent";
};
[email protected] {
type = "absent";
};
[email protected]_MODE {
type = "absent";
};
[email protected]_CARD_DETECT {
type = "absent";
};
[email protected]_SDA {
type = "absent";
};
[email protected]_SCL {
type = "absent";
};

[email protected]_CAMERAS {
type = "internal";
number = <1>;
};
[email protected]_0_LED {
type = "internal";
number = <5>;
};
[email protected]_0_SHUTDOWN {
type = "internal";
number = <35>;
};
[email protected]_0_UNICAM_PORT {
type = "internal";
number = <0>;
};
pin_defi[email protected]_0_I2C_PORT {
type = "internal";
number = <0>;
};
[email protected]_0_SDA_PIN {
type = "internal";
number = <2>;
};
[email protected]_0_SCL_PIN {
type = "internal";
number = <3>;
};

}; // pin_defines

}; // pins_cm3

};

};

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 7:53 pm
by 6by9
[email protected]_0_I2C_PORT {
Needs to be internal and 1 if you wish it to use i2c-1.

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 9:17 pm
by mamor
6by9 wrote:
Wed Apr 17, 2019 7:53 pm
[email protected]_0_I2C_PORT {
Needs to be internal and 1 if you wish it to use i2c-1.
Thank you!!! This helps us alot and help us proceed with our project.
Btw, what is a 'CAMERA_0_UNICAM_PORT'

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 9:39 pm
by 6by9
mamor wrote:
Wed Apr 17, 2019 9:17 pm
Thank you!!! This helps us alot and help us proceed with our project.
Btw, what is a 'CAMERA_0_UNICAM_PORT'
It selects between using cam0/csi0 or cam1/csi1 for the csi image data.

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Wed Apr 17, 2019 10:21 pm
by mamor
6by9 wrote:
Wed Apr 17, 2019 9:39 pm
mamor wrote:
Wed Apr 17, 2019 9:17 pm
Thank you!!! This helps us alot and help us proceed with our project.
Btw, what is a 'CAMERA_0_UNICAM_PORT'
It selects between using cam0/csi0 or cam1/csi1 for the csi image data.
Thank you! :-)

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Thu Apr 18, 2019 1:59 am
by mamor
6by9 wrote:
Wed Apr 17, 2019 7:16 am
mamor wrote:
Wed Apr 17, 2019 1:02 am
Hello:
I have a Compute Module 3 (CM3L) that use i2c-0 to connect to the Sony IMX219. Here are some questions:
1. Is it possible to connect several slave devices on the same i2c line (i2c-0) as the camera? My tests show that the camera (Sony IMX219) periodically outputs data on the same i2c line (i2c-0) as the other slave devices, thus causing a hang in our system.
Not really. The camera module is normally controlled over i2c by the videocore vpu, not the arm. There is no arbitration between the two processors, therefore accessing the peripheral from both at the same time causes issues. This is the reason the dtparam is i2c_vc (vc for videocore).
No i2c slave ever randomly emits data, but the vpu will be sending it commands.
2. If the camera (Sony IMX219) cannot share the same bus with other device(s), how can I then move the camera (Sony IMX219) to i2c-1 in software instead?
Yes, you can amend dt-blob.bin to use i2c_port 1 on different gpios. The information required to do that is on the same page about configuring the camera for use on a cm.
So, can I still use query the camera (Sony IMX219) registers the ARM I2C (i2c-0) even though the camera (Sony IMX219) i2c-0 is also controlled by the VPU? Granted, they are on the same bus with no other peripherals. Would that be ok?

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Thu Apr 18, 2019 2:00 am
by mamor
mamor wrote:
Thu Apr 18, 2019 1:59 am
6by9 wrote:
Wed Apr 17, 2019 7:16 am
mamor wrote:
Wed Apr 17, 2019 1:02 am
Hello:
I have a Compute Module 3 (CM3L) that use i2c-0 to connect to the Sony IMX219. Here are some questions:
1. Is it possible to connect several slave devices on the same i2c line (i2c-0) as the camera? My tests show that the camera (Sony IMX219) periodically outputs data on the same i2c line (i2c-0) as the other slave devices, thus causing a hang in our system.
Not really. The camera module is normally controlled over i2c by the videocore vpu, not the arm. There is no arbitration between the two processors, therefore accessing the peripheral from both at the same time causes issues. This is the reason the dtparam is i2c_vc (vc for videocore).
No i2c slave ever randomly emits data, but the vpu will be sending it commands.
2. If the camera (Sony IMX219) cannot share the same bus with other device(s), how can I then move the camera (Sony IMX219) to i2c-1 in software instead?
Yes, you can amend dt-blob.bin to use i2c_port 1 on different gpios. The information required to do that is on the same page about configuring the camera for use on a cm.
So, can I still use query the camera (Sony IMX219) registers using the the ARM I2C (i2c-0) even though the camera (Sony IMX219) i2c-0 is also controlled by the VPU? Granted, they are on the same bus with no other peripherals. Would that be ok?

Re: I2C-0: CM3L connected to Sony IMX219 Camera

Posted: Thu Apr 18, 2019 8:24 pm
by mamor
So, besides amending dt-blob.bin, do I need to watch out for anything in the /boot/config.txt file in order to move the camera to i2c-1 besides keeping the 'vc_i2c=on'?