Ov5640 Camera Sensor Bringup on Orin NX,

Hello Nvidia Team,

We are using Orin NX (16 GB) module + avermedia d131 kit with ov5640 camera sensor.

& facing difficulty while bringing it up.

Driver used : /drivers/media/i2c/ov5640.c (in kernel-source.)

Device Tree :

include “avt-p3767-0000-p1310-0000-d131ox.dtsi”

/ {
capture_vi_base: tegra-capture-vi {
num-channels = <1>;
ports {
#address-cells = <1>;
#size-cells = <0>;
status = “okay”;

        ov5640_vi_port0: port@0 {
			reg = <0>;
			status = "okay";
			ov5640_vi_in0: endpoint {
				status = "okay";
				port-index = <0>;
				bus-width = <2>;
				remote-endpoint = <&ov5640_csi_out0>;
			};
		};
	    
	};
};


host1x@13e00000 {	
	csi_base: nvcsi@15a00000 {
		num-channels = <1>;
		#address-cells = <1>;
		#size-cells = <0>;
		status = "okay";
		csi_chan0: channel@0 {
			reg = <0>;
			status = "okay";
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					status = "okay";
					ov5640_csi_in0: endpoint@0 {
						status = "okay";
						port-index = <0>;
						bus-width = <2>;
						remote-endpoint = <&ov5640_out0>;
					};
				};
				port@1 {
					reg = <1>;
					status = "okay";
					ov5640_csi_out0: endpoint@1 {
						status = "okay";
						remote-endpoint = <&ov5640_vi_in0>;
					};
				};
			};
		};

	};
};

i2c@c240000 {
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;	
	ov5640_mipi: ov5640_mipi@3c {
	    compatible = "ovti,ov5640";
	    reg = <0x3c>;
	    devnode = "video0";
	    physical_w = "3.680";
	    physical_h = "2.760";
	    sensor_model = "ov5640";
                use_sensor_mode_id = "false";
		clocks = <&bpmp_clks TEGRA234_CLK_EXTPERIPH4>, <&bpmp_clks TEGRA234_CLK_PLLP_OUT0>;
		clock-names = "xclk", "pllp_grtba";
		powerdown-gpios =  <&tegra_main_gpio TEGRA234_MAIN_GPIO(Q, 5) GPIO_ACTIVE_HIGH>;
		reset-gpios = <&tegra_main_gpio TEGRA234_MAIN_GPIO(AC, 6) GPIO_ACTIVE_HIGH>;
		status = "okay";
		
		mode0 { /* OV5640_MODE_1920x1080_30FPS */
					mclk_khz = "27000";
					num_lanes = "2";
					lane_polarity = "6";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					active_w = "1920";
					active_h = "1080";
					pixel_phase = "uyvy";
					mode_type = "yuv";
					csi_pixel_bit_depth = "16";
					readout_orientation = "0";
					line_length = "2200";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "207000000";
					gain_factor = "100";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "0"; /* 1.00x */
					max_gain_val = "540"; /* 10.66x */
					step_gain_val = "6";
					default_gain = "0"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "15000000"; /* 2.0 fps */
					max_framerate = "30000000"; /* 30.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 30.0 fps */
					min_exp_time = "1070"; /* us */
					max_exp_time = "33245"; /* us */
					step_exp_time = "55";
					default_exp_time = "2495"; /* us */
					embedded_metadata_height = "0";
				};

		mode1 { /* OV5640_MODE_1920x1080_30FPS */
					mclk_khz = "27000";
					num_lanes = "2";
					lane_polarity = "6";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					active_w = "1920";
					active_h = "1080";
					//pixel_t = "uyvy";
					pixel_phase = "uyvy";
					mode_type = "yuv";
					csi_pixel_bit_depth = "16";
					readout_orientation = "0";
					line_length = "2200";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "207000000";
					gain_factor = "100";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "0"; /* 1.00x */
					max_gain_val = "540"; /* 10.66x */
					step_gain_val = "6";
					default_gain = "0"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "15000000"; /* 2.0 fps */
					max_framerate = "15000000"; /* 30.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 30.0 fps */
					min_exp_time = "1070"; /* us */
					max_exp_time = "33245"; /* us */
					step_exp_time = "55";
					default_exp_time = "2495"; /* us */
					embedded_metadata_height = "0";
					
				};
				
		mode2 { /* OV5640_MODE_720P_1280x720 */
					mclk_khz = "27000";
					num_lanes = "2";
					lane_polarity = "6";
					tegra_sinterface = "serial_a";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					active_w = "1280";
					active_h = "720";
					//pixel_t = "uyvy";
					pixel_phase = "uyvy";
					mode_type = "yuv";
					csi_pixel_bit_depth = "16";
					readout_orientation = "0";
					line_length = "2200";
					inherent_gain = "1";
					mclk_multiplier = "9.33";
					pix_clk_hz = "207000000";
					gain_factor = "100";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "0"; /* 1.00x */
					max_gain_val = "540"; /* 10.66x */
					step_gain_val = "6";
					default_gain = "0"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					min_framerate = "15000000"; /* 2.0 fps */
					max_framerate = "15000000"; /* 30.0 fps */
					step_framerate = "1";
					default_framerate = "30000000"; /* 30.0 fps */
					min_exp_time = "1070"; /* us */
					max_exp_time = "33245"; /* us */
					step_exp_time = "55";
					default_exp_time = "2495"; /* us */
					embedded_metadata_height = "0";
				};

	
		   ports {
			  #address-cells = <1>;
			  #size-cells = <0>;
			  port@0 {
				   reg = <0>;
				   ov5640_out0: endpoint {
							status = "okay";
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&ov5640_csi_in0>;
						};
				  };
		   };
	};
	
	

};

}

When loading module for ov5640 , we are getting kernel trace as below.

tegra_channel_s_ctrl+0x1c4/0x21c
__v4l2_ctrl_handler_setup+0x10c/0x134
v4l2_ctrl_handler_setup+0x30/0x6c
tegra_channel_init_subdevices+0x2a4/0x7ac
tegra_vi_graph_notify_complete+0x2f4/0x690
v4l2_async_notifier_try_complete+0x78/0x84
v4l2_async_register_subdev+0x168/0x1b0
v4l2_async_register_subdev_sensor_common+0x78/0xf0
ov5640_probe+0x68c/0x78c [ov5640]
i2c_device_probe+0x120/0x300
really_probe+0xf8/0x4b0
driver_probe_device+0x60/0xbc
device_driver_attach+0xc0/0xcc
__driver_attach+0x94/0x120
bus_for_each_dev+0x84/0xe0
driver_attach+0x34/0x40
bus_add_driver+0x10c/0x1ec
driver_register+0x7c/0x124
i2c_register_driver+0x54/0xd0
ov5640_i2c_driver_init+0x28/0x1000 [ov5640]
do_one_initcall+0x54/0x2e0
do_init_module+0x50/0x240

Kernel panic seems to be occurend by kernel-source/nvidia/drivers/media/platform/tegra/camera/vi/channel.c [ line :1335].

case TEGRA_CAMERA_CID_VI_PREFERRED_STRIDE:
                  chan->preferred_stride = ctrl->val;
                  tegra_channel_update_format(chan, chan->format.width,
                                chan->format.height,
                                chan->format.pixelformat,
                                &chan->fmtinfo->bpp,
                                chan->preferred_stride);

Could anyone please let us know the reason behind kernel panic when inserting ov5640.ko driver.

Thanks & Regards,
Kaushal Dekivadia

May need to break down to tegra_channel_update_format() to figure out which line which value cause the panic.

Thanks

Hi Shane,

Thanks for your response.

Kernel oops (Null pointer dereference ) is happening at the same line when call is made to tegra_channel_update_format.

Thanks & Regards,
Kaushal Dekivadia

Please trace into the tegra_channel_update_format() figure the NULL point to find solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.