Repository navigation
Description
We created a custom device tree overlay for our cameras to use libcamera & CM3+. The most recent kernel update made it so we could not detect any cameras.
We reviewed the code in rpi-6.1.y/arch/arm/boot/dts/overlays and discovered we need to include link-frequency to our custom overlays.
We use i2c_vc and i2c_arm to be our i2c buses for the camera as we don't use the default pins. Also tried using i2c0 & i2c1 as to not enable the mux to no avail.
When we included the link-frequency it didn't just work like it did before. i2c_vc seems to be breaking now.
Now with i2c_vc enabled we can't detect any cameras.
With i2c_vc disabled and i2c_arm=on we are able to detect 1 camera, but we'd really like to detect both.
Previously we used both of these i2c buses without a problem.
When we swap cam0 and cam1 i2c buses it will detect the other camera, but won't take a photo and libcamera hangs forever.
Our .dtsi file is the same as yours - https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/imx708.dtsi commit dbb9efdf61fe1c4459774d69839ea877d25fe743
& our kq_gpio.h is https://github.com/torvalds/linux/blob/master/include/dt-bindings/gpio/gpio.h
Our dts file varies slightly to enable support for 2 cameras.
It is below our relevant portion of /boot/config.txt
/boot/config.txt - with i2c_vc=on & i2c_arm=on I.E. how we used to see 2 cameras
[all]
enable_uart=1
dtparam=i2c_arm=on
dtparam=watchdog=on
dtoverlay=disable-bt
arm_64bit=0
dtparam=i2c_vc=on
dtparam=cam0_reg
dtparam=cam0_reg_gpio=20
dtparam=cam1_reg
dtparam=cam1_reg_gpio=22
#dtoverlay=imx219-st,cam0
#dtoverlay=imx219-st,cam1
dtoverlay=imx708-st,cam0
dtoverlay=imx708-st,cam1
dtoverlay=i2c-rtc-gpio,ds3231,i2c_gpio_sda=4,i2c_gpio_scl=5
Our custom overlay imx708-st.dts
// SPDX-License-Identifier: GPL-2.0-only
// Definitions for IMX708 camera module on VC I2C bus
/dts-v1/;
/plugin/;
// #include <dt-bindings/gpio/gpio.h>
#include "kq_gpio.h"
/{
compatible = "brcm,bcm2835";
clk_frag: fragment@1 {
target = <&cam1_clk>;
__overlay__ {
status = "okay";
clock-frequency = <24000000>;
};
};
reg_frag: fragment@3 {
target = <&cam1_reg>;
cam_reg: __overlay__ {
startup-delay-us = <70000>;
off-on-delay-us = <30000>;
regulator-min-microvolt = <2700000>;
regulator-max-microvolt = <2700000>;
};
};
fragment@4 {
target = <&cam_node>;
__overlay__ {
lens-focus = <&vcm_node>;
};
};
i2c_frag: fragment@100 {
target = <&i2c_vc>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
#include "imx708.dtsi"
};
};
csi_frag: fragment@101 {
target = <&csi0>;
csi: __overlay__ {
status = "okay";
brcm,media-controller;
port {
csi_ep: endpoint {
remote-endpoint = <&cam_endpoint>;
clock-lanes = <0>;
data-lanes = <1 2>;
clock-noncontinuous;
};
};
};
};
__overrides__ {
rotation = <&cam_node>,"rotation:0";
orientation = <&cam_node>,"orientation:0";
media-controller = <&csi>,"brcm,media-controller?";
cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
<&csi_frag>, "target:0=",<&csi0>,
<&clk_frag>, "target:0=",<&cam0_clk>,
<®_frag>, "target:0=",<&cam0_reg>,
<&cam_node>, "clocks:0=",<&cam0_clk>,
<&cam_node>, "VANA1-supply:0=",<&cam0_reg>,
<&vcm_node>, "VDD-supply:0=",<&cam0_reg>;
cam1 = <&i2c_frag>, "target:0=",<&i2c_arm>,
<&csi_frag>, "target:0=",<&csi1>,
<&clk_frag>, "target:0=",<&cam1_clk>,
<®_frag>, "target:0=",<&cam1_reg>,
<&cam_node>, "clocks:0=",<&cam1_clk>,
<&cam_node>, "VANA1-supply:0=",<&cam1_reg>,
<&vcm_node>, "VDD-supply:0=",<&cam1_reg>;
vcm = <&vcm_node>, "status",
<0>, "=4";
link-frequency = <&cam_endpoint>,"link-frequencies#0";
};
};
&cam_node {
status = "okay";
};
&cam_endpoint {
remote-endpoint = <&csi_ep>;
};
&vcm_node {
status = "okay";
};
Activity
naushir commentedon Jul 12, 2023
@6by9 for visibility.
naushir commentedon Jul 12, 2023
Can you share some libcamera/console logs when you start your application to try and determine what happens in this case?
6by9 commentedon Jul 12, 2023
What GPIOs do you use for the I2C?
I suspect you want to use i2c0if as the base BSC0 controller, not i2c0 or i2c_csi_dsi which are the alternate pinmux settings for 0&1 and 28&29 (on a CM3) respectively.
What kernel were you working with before? 5.15 and 6.1 both validate that the link frequency in the imx708 node is present and valid https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/media/i2c/imx708.c#L1856-L1861
6by9 commentedon Jul 12, 2023
Did you swap the from &csi1 to &csi0 (or vice versa) too?
kquinnyst commentedon Jul 12, 2023
pins -
imx708-st.dts with i2cs flipped
Console output
$ libcamera-jpeg --list-cameras$ time libcamera-jpeg -o test.jpgkquinnyst commentedon Jul 12, 2023
Did you swap the from &csi1 to &csi0 (or vice versa) too?
Yes we tried this, but we weren't able to get the other camera visible with either configuration. Perhaps there is a way in which this is possible I can continue to investigate if you think it would be helpful
naushir commentedon Jul 12, 2023
Could you run
LIBCAMERA_LOG_LEVELS=*:0 libcamera-hello -t 0 -nand post the console log output from that?6by9 commentedon Jul 12, 2023
https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/README#L2189-L2199
kquinnyst commentedon Jul 12, 2023
With i2cs still flipped -
$ LIBCAMERA_LOG_LEVELS=*:0 libcamera-hello -t 0 -nkquinnyst commentedon Jul 12, 2023
Yes we dug into the readme as well, we commented out i2c_vc=on and that is the only configuration where we can get a working camera so I think you're on the right track. We used i2c0 (which shouldn't enable the mux), it doesn't work to detect both cameras either
dtoverlay=i2c1,pins_2_3
dtoverlay=i2c0,pins_0_1
and
#dtparam=i2c_arm=on
#dtparam=i2c_vc=on
are equivelant but with dtparam=i2c_vc=on we get no cameras, whereas we can use dtoverlay=i2c0,pins_0_1 we can still get our one camera to connect & take photos (when the i2cs aren't flipped)
6by9 commentedon Jul 12, 2023
Drop back to basic level diagnostics (not libcamera).
Only 0&1 should report as SDA0/SCL0.
i2cdetect -l should report
i2c-1 bcm2835 (i2c@7e804000)andi2c-0 bcm2835 (i2c@7e205000). There should not be entries relating toi2c-22-muxi2c-detect should report the imx708 sensor on address 0x1a, the VCM on address 0x0c, and probably 0x64 as well.
kquinnyst commentedon Jul 12, 2023
i2cs are not flipped for this - relevant code
$ raspi-gpio get$ raspi-gpio set 20,22 op,dhUnknown argument "op,dh"
$ raspi-gpio set 20 op$ raspi-gpio set 22 dh$ raspi-gpio get 0-3,28-29,44-45$ sudo i2cdetect -l$ sudo i2cdetect -y 0sudo i2cdetect -y 1kquinnyst commentedon Jul 12, 2023
$ raspi-gpio set 20 op dh$ raspi-gpio set 22 op dh$ sudo i2cdetect -y 1$ sudo i2cdetect -y 0kquinnyst commentedon Jul 12, 2023
Linux UCSD-ORG04-G 6.1.32-v7+ armv7l GNU/Linux -- not working
Linux UCSD-ORG04-1 6.1.19-v7+ armv7l GNU/Linux -- working (without jiffies update)
imx708-st from working raspberry pi (UCSD-ORG04-1) that sees both cameras (without jiffies update)
relevant /boot/config.txt from working pi before kernel update (without jiffies update)
6by9 commentedon Jul 12, 2023
I presume by "jiffies update" you're referring to raspberrypi/linux#5416, but whatever.
Looking at the history, I'd guess that it's raspberrypi/linux#5428 that is causing you issues.
Both sensors are showing up via i2cdetect, so it's a configuration issue somewhere.
Is there anything useful in the kernel log (
dmesg)?Or in the firmware log from processing device tree (
sudo vcdbg log msg)?If you look in /proc/device-tree, do you find your sensor as (from memory) /proc/device-tree/soc/i2c@..../imx708, or /proc/device-tree/soc/i2c0-mux/i2c@0/imx708
If it's the sensor on i2c-0 (GPIOs 0&1) that isn't loading, then as I've said in #68 (comment) I think you want to use
&i2c0if, not&i2c_vc.The order of the the commands in config.txt will matter if you use dtoverlay=i2c0,pins_0_1, as it updates where the alias for i2c_vc points.
Although I'm now confused as to whether you want the i2c0 mux or not - your "working" configuration still includes
dtparam=i2c_vc=on, and not thedtoverlay=i2c0,pins_0_1that you'd previously mentioned.naushir commentedon Jul 13, 2023
According to your libcamera logs, the device driver had no problems talking to the sensor over I2C. However this bit in the logs:
suggest that Unicam has seen no activity from the sensor while streaming. @6by9 commented earlier in #68 (comment) - have you swapped the CSI2 endpoints around?
kquinnyst commentedon Jul 13, 2023
dmesgsudo vcdbg log msgI guess I just found it interesting that when we use i2c_vc in our updated Pi we don't see any cameras, but with i2c0 we can see one camera on i2c_arm.
ls /proc/device-tree/soc/i2c@7e205000ls /proc/device-tree/soc/i2c@7e804000/How would I use i2c0if instead?
kquinnyst commentedon Jul 13, 2023
Tried this to swap to i2c0if - edited
compiled & rebooted to
$ libcamera-hello --list-camerasNo cameras available!
kquinnyst commentedon Jul 13, 2023
Tried this configuration of i2c0if as well to no avail
No Cameras Detectedkquinnyst commentedon Jul 13, 2023
Swapping CSI endpoints
Code
recompile & reboot
$ libcamera-hello --list-cameras$ time libcamera-jpeg -o test.jpg$ LIBCAMERA_LOG_LEVELS=*:0 libcamera-hello -t 0 -n6by9 commentedon Jul 13, 2023
TBH There's little point in throwing the logs from all your experiments on here.
I have a CM3 set up here to recreate it, and will report back.
6by9 commentedon Jul 13, 2023
So the reason for the breakage is raspberrypi/linux@dbb9efd
The regulators have been renamed based on upstream review and requested changes.
Your overlay therefore doesn't amend the regulator for cam0 appropriately, therefore the sensor doesn't get powered up, and fails to probe.
Amend your overlay overrides to
6by9 commentedon Jul 13, 2023
For reference, my complete overlay is
and nearly your config.txt entries (just the regulator GPIOs changed)
6by9 commentedon Jul 13, 2023
kquinnyst commentedon Jul 13, 2023
Y'all are amazing thank you so much!
libcamera-jpeg --list-cameras