How do I fit a new sensor on driver orin?

Hardware platform: jetson-agx-orin-xavier-devkit
It is ready to transplant a new sensor support. The current imx185 sensor driver supported by the development board is changed to imx565. i2 can read and write sensor registers normally and also detect vide0 devices.When collecting data through v4l2, the kernel will print error logs:

Debugging information can be obtained by trace:
kworker/0:13-221 [000] … 1756.206716: rtcpu_nvcsi_intr: tstamp:55762160442 class:GLOBAL type:PHY_INTR0 phy:0 cil:1 st:0 vc:0 status:0x00000044
kworker/0:13-221 [000] … 1756.206716: rtcpu_nvcsi_intr: tstamp:55762160984 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000048
kworker/0:13-221 [000] … 1756.206716: rtcpu_nvcsi_intr: tstamp:55762160984 class:GLOBAL type:PHY_INTR0 phy:0 cil:1 st:0 vc:0 status:0x00000044
kworker/0:13-221 [000] … 1756.206717: rtcpu_nvcsi_intr: tstamp:55762161520 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000048
kworker/0:13-221 [000] … 1756.206717: rtcpu_nvcsi_intr: tstamp:55762161520 class:GLOBAL type:PHY_INTR0 phy:0 cil:1 st:0 vc:0 status:0x00000044
kworker/0:13-221 [000] … 1756.206718: rtcpu_nvcsi_intr: tstamp:55762162063 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000048
kworker/0:13-221 [000] … 1756.206718: rtcpu_nvcsi_intr: tstamp:55762162063 class:GLOBAL type:PHY_INTR0 phy:0 cil:1 st:0 vc:0 status:0x00000044
kworker/0:13-221 [000] … 1756.206718: rtcpu_nvcsi_intr: tstamp:55762162605 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000048
kworker/0:13-221 [000] … 1756.206719: rtcpu_nvcsi_intr: tstamp:55762162605 class:GLOBAL type:PHY_INTR0 phy:0 cil:1 st:0 vc:0 status:0x00000044
kworker/0:13-221 [000] … 1756.206719: rtcpu_nvcsi_intr: tstamp:55762163143 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000048
kworker/0:13-221 [000] … 1756.206719: rtcpu_nvcsi_intr: tstamp:55762163519 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000048

Your topic was posted in the wrong category. I am moving this to the Jetson AGX Orin forum for visibility.

hello 1508723374,

there shows the failure with PHY interrupts, the error code 0x44 indicate there’re more than one bit error has detected on data-lane; the error code 0x48 it shows there’s failure with the LP sequence.

for the sensor bring-up, could you please check Applications Using V4L2 IOCTL Directly by using V4L2 IOCTL to verify basic camera functionality?

furthermore,
since you’re based-on IMX185 to develop your IMX565 sensor driver. could you please also check Sensor Pixel Clock session to review the clock settings in order to avoid potential issues.

I refer to Applications Using V4L2 IOCTL Directly and use the following command:

v4l2-ctl --set-fmt-video=width=3840,height=2160,pixelformat=RG12 --stream-mmap --set-ctrl=sensor_mode=0 --stream-count=10000 -d /dev/video0 --stream-to=185.raw
The mistakes haven’t changed.
This is the IMX565 device tree configuration:

				mode0 {/*mode IMX185_MODE_3840X2160_CROP_20FPS*/
					mclk_khz = "37125";
					num_lanes = "4";  
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					dynamic_pixel_bit_depth = "12";
					csi_pixel_bit_depth = "12";
					mode_type = "bayer";
					pixel_phase = "rggb";

					active_w = "3840";
					active_h = "2160";
					readout_orientation = "0";
					line_length = "4096";
					inherent_gain = "1";
					mclk_multiplier = "2";
					pix_clk_hz = "245760000";

					gain_factor = "10";
					min_gain_val = "0"; /* 0dB */
					max_gain_val = "480"; /* 48dB */
					step_gain_val = "3"; /* 0.3 */
					default_gain = "0";
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					framerate_factor = "1000000";
					min_framerate = "1500000"; /* 1.5 */
					max_framerate = "20000000"; /* 20 */
					step_framerate = "1";
					default_framerate= "20000000";
					exposure_factor = "1000000";
					min_exp_time = "30"; /* us */
					max_exp_time = "660000"; /* us */
					step_exp_time = "1";
					default_exp_time = "33334";/* us */
					embedded_metadata_height = "1";
				};
tegra-camera-platform {
		compatible = "nvidia, tegra-camera-platform";
		/**
		* Physical settings to calculate max ISO BW
		*
		* num_csi_lanes = <>;
		* Total number of CSI lanes when all cameras are active
		*
		* max_lane_speed = <>;
		* Max lane speed in Kbit/s
		*
		* min_bits_per_pixel = <>;
		* Min bits per pixel
		*
		* vi_peak_byte_per_pixel = <>;
		* Max byte per pixel for the VI ISO case
		*
		* vi_bw_margin_pct = <>;
		* Vi bandwidth margin in percentage
		*
		* max_pixel_rate = <>;
		* Max pixel rate in Kpixel/s for the ISP ISO case
		*
		* isp_peak_byte_per_pixel = <>;
		* Max byte per pixel for the ISP ISO case
		*
		* isp_bw_margin_pct = <>;
		* Isp bandwidth margin in percentage
		*/
		num_csi_lanes = <4>;
		max_lane_speed = <1500000>;
		min_bits_per_pixel = <12>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		isp_peak_byte_per_pixel = <5>;
		isp_bw_margin_pct = <25>;

		/**
		 * The general guideline for naming badge_info contains 3 parts, and is as follows,
		 * The first part is the camera_board_id for the module; if the module is in a FFD
		 * platform, then use the platform name for this part.
		 * The second part contains the position of the module, ex. "rear" or "front".
		 * The third part contains the last 6 characters of a part number which is found
		 * in the module's specsheet from the vender.
		 */
		modules {
			module0 {
				badge = "imx185_bottom_liimx185";
				position = "bottom";
				orientation = "0";
				drivernode0 {
					/* Declare PCL support driver (classically known as guid)  */
					pcl_id = "v4l2_sensor";
					/* Driver v4l2 device name */
					devname = "imx185 30-001a";
					/* Declare the device-tree hierarchy to driver instance */
					proc-device-tree = "/proc/device-tree/i2c@3180000/imx185_a@1a";
				};
			};
		};
	};

hello 1508723374,

since you’re based-on IMX185 to develop your IMX565 sensor driver.
had you also update the compatible property as identical string with IMX565 sensor driver?
for example,

i2c@3180000 {
    tca9546@70 {
        i2c@0 {
        imx185_a@1a {
            compatible = "sony,imx185"; <== it should also updated.

is this IMX565 sensor actually used the same CSI port as IMX185?
can you also confirm all of the power supply had given correctly?

hello JerryChang
I understand that the compatible field should be just an identifier that associates imx185.c with imx185.dts, and that even if it is not modified, it will not affect my fetching stream. Our adapter board does not use tca9546 in the design, so imx185_a@1a is directly hung under i2c@3180000, as shown in the following:

	i2c@3180000 {
			imx185_a@1a {
				compatible = "sony,imx185";

				reg = <0x1a>;
				devnode = "video0";

At the same time, corresponding modifications have also been made in other files, as follows:
tegra234-p3737-camera-modules.dtsi

	i2c@3180000 {
		imx185_cam0: imx185_a@1a {
			status = "enable";
		};

tegra234-p3737-camera-imx185-overlay.dts

	fragment@10 {
		//// target = <&liimx185_csi_in0>;
		target-path = "/host1x@13e00000/nvcsi@15a00000/channel@0/ports/port@0/endpoint@0";
		board_config {
			odm-data = "enable-imx185";
			sw-modules = "kernel";
		};
		__overlay__ {
			status = "okay";
			port-index = <0>;
			bus-width = <4>;
			/// remote-endpoint = <&liimx185_imx185_out0>;
			remote-endpoint = "/i2c@3180000/imx185_a@1a/ports/port@0/endpoint";
		};
	};
	fragment@11 {
		//// target = <&csi_chan0_port1>;
		target-path = "/host1x@13e00000/nvcsi@15a00000/channel@0/ports/port@1";
		board_config {
			odm-data = "enable-imx185";
			sw-modules = "kernel";
		};
		__overlay__ {
			status = "okay";
		};
	};

tegra234-p3737-0000-camera-imx185-a00.dtsi

/ {
	gpio@2200000 {
		camera-control-output-low {
			gpio-hog;
			output-low;
			gpios = <CAM0_RST_L 0>;
			label = "cam0-rst";
		};
	};

	i2c@3180000 {
		imx185_a@1a {
			/* Define any required hw resources needed by driver */
			/* ie. clocks, io pins, power sources */
			clocks = <&bpmp_clks TEGRA234_CLK_EXTPERIPH1>,
						<&bpmp_clks TEGRA234_CLK_EXTPERIPH1>;
			clock-names = "extperiph1", "pllp_grtba";
			mclk = "extperiph1";
			reset-gpios = <&tegra_main_gpio CAM0_RST_L GPIO_ACTIVE_HIGH>;
		};
	};
};

not really… please refer to developer guide, Device Properties.

BTW,
system level clock configurations were based-on device tree settings.
for bring-up purpose. you may execute below commands to boost all the VI/CSI/ISP clocks to avoid some clock related issue.
for example,

sudo su
echo 1 > /sys/kernel/debug/bpmp/debug/clk/vi/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/isp/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/nvcsi/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/emc/mrq_rate_locked
cat /sys/kernel/debug/bpmp/debug/clk/vi/max_rate |tee /sys/kernel/debug/bpmp/debug/clk/vi/rate
cat /sys/kernel/debug/bpmp/debug/clk/isp/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/isp/rate
cat /sys/kernel/debug/bpmp/debug/clk/nvcsi/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/nvcsi/rate
cat /sys/kernel/debug/bpmp/debug/clk/emc/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/emc/rate

I reworked the driver and device tree, replacing all references to imx185 with imx565. Use the command line you gave to increase the clock rate, still no change, the error is as follows:


What I am confused about is that if the kernel connects sonsor, CSI and VI, how can the binding relationship between them determine that the binding is correct?
image

device topology looks correct… Sensor → CSI → VI.
may I also know what’s the latest VI tracing logs? are you still seeing the same PHY interrupts with 0x44?

  • It seems a little different:
     kworker/3:2-157     [003] ....   305.246004: rtcpu_nvcsi_intr: tstamp:10424999305 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246004: rtcpu_nvcsi_intr: tstamp:10424999659 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246005: rtcpu_nvcsi_intr: tstamp:10425000013 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246005: rtcpu_nvcsi_intr: tstamp:10425000363 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246005: rtcpu_nvcsi_intr: tstamp:10425000715 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246006: rtcpu_nvcsi_intr: tstamp:10425001066 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246006: rtcpu_nvcsi_intr: tstamp:10425001415 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246006: rtcpu_nvcsi_intr: tstamp:10425001766 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246007: rtcpu_nvcsi_intr: tstamp:10425002119 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246009: rtcpu_nvcsi_intr: tstamp:10425002470 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008

hello 1508723374,

it’s LP sequence error detected on data lane. this usually an issue on sensor side.
note,
there’s sequence, LP11->LP01->LP00->LP11. when moving from LP to HS. the settle time determine how many cscil clock cycles to wait after LP00.

hence…
you may configure cil_settletime, it’s the property to tune the transition time from LP to HS mode.
please see-also developer guide for more details of cil_settletime property.

hello JerryChang, Sorry for replying so late.
By changing the cil_settletime parameter to 120, the situation didn’t settle, and the same error message was reported:

 [003] ....   305.246004: rtcpu_nvcsi_intr: tstamp:10424999305 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246004: rtcpu_nvcsi_intr: tstamp:10424999659 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246005: rtcpu_nvcsi_intr: tstamp:10425000013 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246005: rtcpu_nvcsi_intr: tstamp:10425000363 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008

It is worth noting that these two problems were discovered during the debugging process:

Use this command:v4l2-compliance -d /dev/video0

  • I don’t know if these two phenomena will help you find the problem,Thanks!

I refer to another post Camera DTSI endpoint error - Jetson & Embedded Systems / Jetson AGX Xavier - NVIDIA Developer Forums, which has similar problems to mine, I decompiled my device tree rice, and did not find any problematic resistance, please help me look at it.

liimx185_imx185_out0 = "/i2c@3180000/imx185_a@1a/ports/port@0/endpoint";
liimx185_csi_in0 = "/host1x@13e00000/nvcsi@15a00000/channel@0/ports/port@0/endpoint@0";
liimx185_csi_out0 = "/host1x@13e00000/nvcsi@15a00000/channel@0/ports/port@1/endpoint@1";
liimx185_vi_in0 = "/tegra-capture-vi/ports/port@0/endpoint";
imx185_cam0 = "/i2c@3180000/imx185_a@1a";

extracted_proc.dts (522.8 KB)

hello 1508723374,

(1) can you obtain correct sensor format dumps by… $ v4l2-ctl -d /dev/video0 --list-formats-ext
(2) you may ignore the test failure of VIDIOC_G/S_PARAM in compliance test.
(3) however, please dig into the sensor driver to examine the test item for buffer ioctls. it should be root cause of your issue.

hello JerryChang,
According to the command line output you give( format looks okay):
image
This is based on the official imx185 driver. How can I modify it to test the buffer ioctls.
nv_imx185.c (21.7 KB)
imx185_mode_tbls.h (19.7 KB)

hello 1508723374,

these vb2_ioctl_xxx() functions are simple helper functions that you can use in your struct v4l2_file_operations, struct v4l2_ioctl_ops and struct vb2_ops.
that failure might be calling filehandle to do queuing operation is prohibited.

What do I have to do to enable this file handle. Or if this error will affect my ability to get a video stream. That is, whether the following error information is related to this error:

     kworker/3:2-157     [003] ....   305.246004: rtcpu_nvcsi_intr: tstamp:10424999659 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008
     kworker/3:2-157     [003] ....   305.246005: rtcpu_nvcsi_intr: tstamp:10425000013 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000008

as mentioned in previous comment #14. this usually an issue on sensor hardware side.

I found the problem, and it’s not your mipi signal problem.