Change the CSI port

I am working with Jetson ORIN NX 16G with J202 carrier board. I configured the CSI to work with TC358743, and it works fine on one CSI port with the label CAM0.

I want to use it on the other CSI port which has the label CAM1 and it’s not detecting.

Those are m device tree files which they work with the CSI port with the label CAM0:
tegra234-.zip (5.7 KB)

1 Like

hello emadomari40,

please note that, on Orin NX, CSI0 D1 and CSI1 D0 P/N will always been swizzled for P/N.
you should use device tree property, lane_polarity to configure a polarity swap on any lane.
please see-also reference driver (such as IMX219) for property settings.

I have the following config for the dtsi:

port@0 {
						reg = <0>;
						toshiba_tc358743_out1: endpoint {
							/*port-index = <2>;*/
							port-index = <2>; /* CSI B */
							bus-width = <2>; /* Use CSI-B only */
							data-lanes = <1 2>;
							clock-lanes = <0>;
							clock-noncontinuous;
							link-frequencies = /bits/ 64 <297000000>;
							/*link-frequencies = /bits/ 64 <148500000>;*/
							remote-endpoint = <&toshiba_tc358743_csi_in1>;
						};
					};

I used data-lanes = <1 2>; for swizzle the pins.

please see-also [Figure 10-1. CSI 2-Lane Connection Options] in the Jetson Orin NX Series and Orin Nano Series Design Guide for polarity swaps.

I have similar config as IMX219 but still can’t detect my device on CAM1 but can detect MX219 on CAM1:

/*
 * Copyright (c) 2022-2023, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <dt-bindings/media/camera.h>

/ {
	tegra-capture-vi  {
		num-channels = <2>;
		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
				toshiba_tc358743_vi_in0: endpoint {
					port-index = <0>;
					bus-width = <2>;
					remote-endpoint = <&toshiba_tc358743_csi_out0>;
				};
			};
			port@1 {
				reg = <1>;
				toshiba_tc358743_vi_in1: endpoint {
					port-index = <2>;
					bus-width = <2>;
					remote-endpoint = <&toshiba_tc358743_csi_out1>;
				};
			};
		};
	};

	host1x@13e00000 {
		nvcsi@15a00000 {
			num-channels = <2>;
			#address-cells = <1>;
			#size-cells = <0>;
			channel@0 {
				reg = <0>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						toshiba_tc358743_csi_in0: endpoint@0 {
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&toshiba_tc358743_out0>;
						};
					};
					port@1 {
						reg = <1>;
						toshiba_tc358743_csi_out0: endpoint@1 {
							remote-endpoint = <&toshiba_tc358743_vi_in0>;
						};
					};
				};
			};
			channel@1 {
				reg = <1>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						toshiba_tc358743_csi_in1: endpoint@2 {
							port-index = <2>;
							bus-width = <2>;
							remote-endpoint = <&toshiba_tc358743_out1>;
						};
					};
					port@1 {
						reg = <1>;
						toshiba_tc358743_csi_out1: endpoint@3 {
							remote-endpoint = <&toshiba_tc358743_vi_in1>;
						};
					};
				};
			};
		};
	};

	cam_i2cmux {
		i2c@0 {
			tc358743_cam0: toshiba_tc358743_a@0f {
				compatible = "toshiba,tc358743";
				/* I2C device address */
				reg = <0x0f>;

				/* V4L2 device node location */
				devnode = "video0";

				/* Physical dimensions of sensor */
				physical_w = "3.680";
				physical_h = "2.760";

				sensor_model = "tc358743";

				use_sensor_mode_id = "true";

				mode0 { /* IMX219_MODE_3280x2464_21FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "6";

					active_w = "3280";
					active_h = "2464";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "21000000"; /* 21.0 fps */
					step_framerate = "1";
					default_framerate = "21000000"; /* 21.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};
				mode1 { /* IMX219_MODE_3280x1848_28FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "6";

					active_w = "3280";
					active_h = "1848";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "28000000"; /* 28.0 fps */
					step_framerate = "1";
					default_framerate = "28000000"; /* 28.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};
				mode2 { /* IMX219_MODE_1920x1080_30FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "6";

					active_w = "1920";
					active_h = "1080";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "30000000"; /* 30.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 30.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};

				mode3 { /* IMX219_MODE_1640x1232_30FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "6";

					active_w = "1640";
					active_h = "1232";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "30000000"; /* 60.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 60.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};

				mode4 { /* IMX219_MODE_1280x720_60FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "6";

					active_w = "1280";
					active_h = "720";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "60000000"; /* 60.0 fps */
					step_framerate = "1";
					default_framerate = "60000000"; /* 60.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};

				ports {
					#address-cells = <1>;
					#size-cells = <0>;

					port@0 {
						reg = <0>;
						toshiba_tc358743_out0: endpoint {
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&toshiba_tc358743_csi_in0>;
						};
					};
				};
			};
		};
		i2c@1 {
			tc358743_cam1: toshiba_tc358743_c@0f {
				compatible = "toshiba,tc358743";
				/* I2C device address */
				reg = <0x0f>;

				/* V4L2 device node location */
				devnode = "video1";

				/* Physical dimensions of sensor */
				physical_w = "3.680";
				physical_h = "2.760";

				sensor_model = "tc358743";

				use_sensor_mode_id = "true";

				refclk_hz = <27000000>;  // refclk_hz -> regclk

				mode0 { /* IMX219_MODE_3280x2464_21FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_c";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "0";

					active_w = "3280";
					active_h = "2464";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "21000000"; /* 21.0 fps */
					step_framerate = "1";
					default_framerate = "21000000"; /* 21.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};
				mode1 { /* IMX219_MODE_3280x1848_28FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_c";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "0";

					active_w = "3280";
					active_h = "1848";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "28000000"; /* 28.0 fps */
					step_framerate = "1";
					default_framerate = "28000000"; /* 28.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};
				mode2 { /* IMX219_MODE_1920x1080_30FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_c";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "0";

					active_w = "1920";
					active_h = "1080";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "30000000"; /* 30.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 30.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};
				mode3 { /* IMX219_MODE_1640x1232_30FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_c";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "0";

					active_w = "1640";
					active_h = "1232";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "30000000"; /* 60.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 60.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};
				mode4 { /* IMX219_MODE_1280x720_60FPS */
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_c";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					lane_polarity = "0";

					active_w = "1280";
					active_h = "720";
					mode_type = "bayer";
					pixel_phase = "rggb";
					csi_pixel_bit_depth = "10";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "182400000";

					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "2000000"; /* 2.0 fps */
					max_framerate = "60000000"; /* 60.0 fps */
					step_framerate = "1";
					default_framerate = "60000000"; /* 60.0 fps */
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */

					embedded_metadata_height = "2";
				};

				ports {
					#address-cells = <1>;
					#size-cells = <0>;

					port@0 {
						reg = <0>;
						toshiba_tc358743_out1: endpoint {
							status = "okay";
							/*port-index = <2>;*/
							port-index = <2>; /* CSI B */
							bus-width = <2>; /* Use CSI-B only */
							/*lane_polarity = "6"; */
							/*  data-lanes = <2 1>; */ 
							clock-lanes = <0>;
							clock-noncontinuous;
							link-frequencies = /bits/ 64 <297000000>;
							/*link-frequencies = /bits/ 64 <148500000>;*/
							remote-endpoint = <&toshiba_tc358743_csi_in1>;
						};
					};
				};
			};
		};
	};
};

/ {
	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 = <10>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		max_pixel_rate = <7500000>;
		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 vendor.
		 */
		modules {
			module0 {
				badge = "jakku_front_TOSHIBA";
				position = "front";
				orientation = "1";
				drivernode0 {
					pcl_id = "v4l2_sensor";
					devname = "tc358743 9-000f";
					proc-device-tree = "/proc/device-tree/cam_i2cmux/i2c@0/toshiba_tc358743_a@0f";
				};
			};
			module1 {
				badge = "jakku_rear_TOSHIBA";
				position = "rear";
				orientation = "1";
				drivernode0 {
					pcl_id = "v4l2_sensor";
					devname = "tc358743 10-000f";
					proc-device-tree = "/proc/device-tree/cam_i2cmux/i2c@1/toshiba_tc358743_c@0f";
				};
			};
		};
	};
};

Should I follow this figure:

So swapping between:

CSI0_D1_N
CSI0_D1_P

and:

CSI1_D0_N
CSI1_D0_P

Please note that I am using 4 lanes not 2

hello emadomari40,

is it a customization carrier board?
FYI, p3768 (Orin Nano DevKit carrier board) can work with 4-lane camera only on Cam0 slot,
we’re not support CSI-B in 4-lane config because of CSI clock limitations.

It p3905 based on a customized carrier board

I am working with TC358743XBG and it supports up to 4 lanes, but work also with 2 lanes

hello emadomari40,

may I double confirm what’s p3905? don’t your works with Orin NX module?

Its Jetson Orin NX (P3767-0000) with Xavier Carrier Board (P3509-0000).

hello emadomari40,

please refer to Jetson Compatibility, and also forum discussion threads, such as… Topic 249961, Topic 276127.
please work with Orin Nano carrier board as we don’t support the setup (i.e. Orin NX + Xavier NX carrier board)

what are the port index of cam1 and cam0?

hello emadomari40,

please refer to [3.2 Camera Connector] from Jetson Orin Nano Developer Kit Carrier Board Specification.
let me re-cap the connectors support as following.

J20: CSI 1 x2 lane
J21: CSI 1 x2 lane or 1 x4 lane

I have moved to a customized carrier board with this connection:

Where:
CSIA is CSI0
CSIB is CSI1

q1) What should the lane polarity value be?
q2) What should the CSI port indes and i2c be?

I have the TC358743 detected on the customized carrier board when I run v4l2 commands:

Screenshot from 2024-08-23 14-13-31 (1)

But when I run the gst command, I get a green screen and the system freezes.

please share the logs,
for instance, please share UART logs, or, you may setup a terminal to keep gathering logs ($ dmesg --follow)

This is the output:

hello emadomari40,

may I know which Jetpack release version you’re working with?
you may check the release tag for confirmation, i.e. $ cat /etc/nv_tegra_release