Adv7280m - Kernel crash when capture from video0 over v4l2

Hi bros,

I’m using adv7280m csi 1 lane with jetson nano. Below is my device tree porting from imx219
Please help me fix it, be lost many time to resolve problem :(

/*
 * Copyright (c) 2018-2019, 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>
#include <dt-bindings/platform/t210/t210.h>

/ {
	host1x {
		vi_base: vi {
			num-channels = <1>;
            status = "okay";
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
                status = "okay";
				vi_port0: port@0 {
                    status = "okay";
					reg = <0>;
					rbpcv2_imx219_vi_in0: endpoint {
                        status = "okay";
						port-index = <0>;
						bus-width = <1>;
						remote-endpoint = <&rbpcv2_imx219_csi_out0>;
					};
				};
			};
		};

		csi_base: nvcsi {
			num-channels = <1>;
            status = "okay";
			#address-cells = <1>;
			#size-cells = <0>;
			csi_chan0: channel@0 {
                status = "okay";
				reg = <0>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					csi_chan0_port0: port@0 {
                        status = "okay";
						reg = <0>;
						rbpcv2_imx219_csi_in0: endpoint@0 {
							port-index = <0>;
							bus-width = <1>;
							remote-endpoint = <&rbpcv2_imx219_out0>;
						};
					};
					csi_chan0_port1: port@1 {
                        status = "okay";
						reg = <1>;
						rbpcv2_imx219_csi_out0: endpoint@1 {
							remote-endpoint = <&rbpcv2_imx219_vi_in0>;
						};
					};
				};
			};
		};

		i2c@546c0000 {
			imx219_single_cam0: rbpcv2_imx219_a@10 {
				compatible = "adi,adv7280-m";
				/* I2C device address */
				reg = <0x21>;

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

				/* Physical dimensions of sensor */
                physical_w = "4.713";
                physical_h = "3.494";

				sensor_model = "adv7280-m";

				use_sensor_mode_id = "false";
				
				mode0{
					mclk_khz = "24000";
					num_lanes = "1";
					mclk_multiplier = "2";
					pix_clk_hz = "74250000";
				};

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

					port@0 {
						reg = <0>;
						rbpcv2_imx219_out0: endpoint {
                            status = "okay";
							port-index = <0>;
							bus-width = <1>;
							remote-endpoint = <&rbpcv2_imx219_csi_in0>;
						};
					};
				};
			};
		};
    };

	lens_imx219@RBPCV2 {
		min_focus_distance = "0.0";
		hyper_focal = "0.0";
		focal_length = "3.04";
		f_number = "2.0";
		aperture = "0.0";
	};
};

/ {
	tcp: 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 = <1>;
		max_lane_speed = <1500000>;
		min_bits_per_pixel = <10>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		max_pixel_rate = <240000>;
		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 {
			cam_module0: module0 {
				badge = "porg_front_RBPCV2";
				position = "front";
				orientation = "1";
				cam_module0_drivernode0: drivernode0 {
					pcl_id = "v4l2_sensor";
					devname = "adv7280 6-0021";
					proc-device-tree = "/proc/device-tree/cam_i2cmux/i2c@1/rbpcv2_imx219_e@10";
				};
				cam_module0_drivernode1: drivernode1 {
					pcl_id = "v4l2_lens";
					proc-device-tree = "/proc/device-tree/lens_imx219@RBPCV2/";
				};
			};
		};
	};
};

When i capture without mode0: have signal on data output, not have clock. Error:

video4linux video0: frame start syncpt timeout!0

When i capture with mode0 on device tree, kernel crash :

vu@vu:~$ r[   76.996957] Unable to handle kernel read from unreadable memory at virtual address 0000b018
[   77.005385] Mem abort info:
[   77.008221]   ESR = 0x96000005
[   77.011330]   Exception class = DABT (current EL), IL = 32 bits
[   77.017487]   SET = 0, FnV = 0
[   77.020751]   EA = 0, S1PTW = 0
[   77.024081] Data abort info:
[   77.027149]   ISV = 0, ISS = 0x00000005
[   77.031172]   CM = 0, WnR = 0
[   77.034136] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc0f618e000
[   77.040954] [000000000000b018] *pgd=0000000000000000, *pud=0000000000000000
[   77.048016] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   77.053576] Modules linked in: bnep fuse zram overlay spidev nvgpu bluedroid_pm ip_tables x_tables
[   77.062600] CPU: 3 PID: 6983 Comm: vi-output, adv7 Not tainted 4.9.140-tegra #81
[   77.069978] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[   77.075971] task: ffffffc0f7c62a00 task.stack: ffffffc0bc1ec000
[   77.081882] PC is at read_settle_time_from_dt+0x58/0x140
[   77.087183] LR is at csi2_start_streaming+0x48/0x4c0
[   77.092134] pc : [<ffffff8008b408e8>] lr : [<ffffff8008b413c0>] pstate: 20400045
[   77.099512] sp : ffffffc0bc1efbc0
[   77.102816] x29: ffffffc0bc1efbc0 x28: ffffffc0f745a4c8
[   77.108131] x27: 0000000000000158 x26: ffffffc0f7423418
[   77.113443] x25: 0000000006146580 x24: ffffffc0f745a4c8
[   77.118755] x23: 0000000000000000 x22: ffffffc0f7423428
[   77.124065] x21: ffffffc0f954c010 x20: 000000000000b000
[   77.129377] x19: ffffffc0f7423418 x18: 0000000000000000
[   77.134688] x17: 0000000000000001 x16: 0000000000000000
[   77.139999] x15: ffffff800a194080 x14: 0000000000000001
[   77.145309] x13: 0000000000000030 x12: 0000000000000000
[   77.150620] x11: 0000000000000000 x10: 000000005f5e1000
[   77.155932] x9 : ffffffc0f9180018 x8 : 0000000000001340
[   77.161243] x7 : 0000000000000001 x6 : ffffff800a195768
[   77.166553] x5 : 0000000000000000 x4 : 0000000000000000
[   77.171864] x3 : ffffff80094cd2c8 x2 : 0000000000000001
[   77.177177] x1 : 0000000000000000 x0 : 0000000000000158
[   77.182488]
[   77.183973] Process vi-output, adv7 (pid: 6983, stack limit = 0xffffffc0bc1ec000)
[   77.191437] Call trace:
[   77.193879] [<ffffff8008b408e8>] read_settle_time_from_dt+0x58/0x140
[   77.200220] [<ffffff8008b413c0>] csi2_start_streaming+0x48/0x4c0
[   77.206215] [<ffffff8008b400c4>] tegra_csi_s_stream+0xac/0x318
[   77.212036] [<ffffff8008b33f44>] tegra_channel_set_stream+0x1fc/0x4c8
[   77.218463] [<ffffff8008b36ac8>] tegra_channel_enable_stream+0x48/0x60
[   77.224977] [<ffffff8008b38590>] tegra_channel_kthread_capture_start+0x830/0x948
[   77.232359] [<ffffff80080dbee4>] kthread+0xec/0xf0
[   77.237141] [<ffffff8008083850>] ret_from_fork+0x10/0x40
[   77.242443] ---[ end trace c43e33b06d5b56d4 ]---
[  277.095102] Unable to handle kernel read from unreadable memory at virtual address 00000000
[  277.103891] Mem abort info:
[  277.106936]   ESR = 0x96000005
[  277.110153]   Exception class = DABT (current EL), IL = 32 bits
[  277.116167]   SET = 0, FnV = 0
[  277.119294]   EA = 0, S1PTW = 0
[  277.122475] Data abort info:
[  277.125385]   ISV = 0, ISS = 0x00000005
[  277.129229]   CM = 0, WnR = 0
[  277.132189] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc0f41e2000
[  277.139335] [0000000000000000] *pgd=0000000000000000, *pud=0000000000000000
[  277.146460] Internal error: Oops: 96000005 [#2] PREEMPT SMP
[  277.152019] Modules linked in: bnep fuse zram overlay spidev nvgpu bluedroid_pm ip_tables x_tables
[  277.161332] CPU: 0 PID: 6982 Comm: cap_v4l2 Tainted: G      D         4.9.140-tegra #81
[  277.169410] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[  277.175486] task: ffffffc0e9cfb800 task.stack: ffffffc0bc1d8000
[  277.181520] PC is at __ll_sc_atomic_sub_return+0x4/0x20
[  277.186842] LR is at exit_creds+0x2c/0x78
[  277.190925] pc : [<ffffff800845a7a4>] lr : [<ffffff80080def7c>] pstate: 60400045
[  277.198382] sp : ffffffc0bc1dbb30
[  277.201766] x29: ffffffc0bc1dbb30 x28: ffffffc0e9cfb800
[  277.207233] x27: ffffff8008f62000 x26: ffffffc0f78ab018
[  277.212689] x25: ffffffc0c2090ae8 x24: ffffffc0f7454d78
[  277.218134] x23: 0000000000000001 x22: ffffffc0f78ab018
[  277.223582] x21: ffffffc0f7c62a30 x20: 0000000000000000
[  277.229023] x19: ffffffc0f7c62a00 x18: 0000007f7b79ba70
[  277.234472] x17: 0000000000000000 x16: 00000000000000a5
[  277.239921] x15: 0000000000000000 x14: 0000000000000002
[  277.245368] x13: 000000000000270f x12: 0000000000000001
[  277.250810] x11: ffffffc0c2090a80 x10: ffffff800a05bd80
[  277.256257] x9 : ffffffffffffffff x8 : 0000000000000001
[  277.261695] x7 : 000000007f200000 x6 : ffffffc0e1dd02c0
[  277.267138] x5 : 0000000000000800 x4 : 0000000000000000
[  277.272577] x3 : 00000000000000a5 x2 : 0000000000000000
[  277.278017] x1 : 0000000000000000 x0 : 0000000000000001
[  277.283455]
[  277.285026] Process cap_v4l2 (pid: 6982, stack limit = 0xffffffc0bc1d8000)
[  277.291962] Call trace:
[  277.294514] [<ffffff800845a7a4>] __ll_sc_atomic_sub_return+0x4/0x20
[  277.300873] [<ffffff80080b01ac>] __put_task_struct+0x4c/0x140
[  277.306704] [<ffffff80080dca3c>] kthread_stop+0x1e4/0x1e8
[  277.312197] [<ffffff8008b377e0>] vi2_channel_stop_streaming+0xe0/0x660
[  277.318819] [<ffffff8008b308c4>] tegra_channel_stop_streaming+0x34/0x48
[  277.325515] [<ffffff8008b28bd4>] __vb2_queue_cancel+0x34/0x188
[  277.331434] [<ffffff8008b2a0fc>] vb2_core_queue_release+0x2c/0x58
[  277.337609] [<ffffff8008b2c77c>] _vb2_fop_release+0x84/0xa0
[  277.343259] [<ffffff8008b3223c>] tegra_channel_close+0x64/0x140
[  277.349270] [<ffffff8008b05d30>] v4l2_release+0x48/0xa0
[  277.354585] [<ffffff800825fc00>] __fput+0x90/0x1d0
[  277.359460] [<ffffff800825fdb8>] ____fput+0x20/0x30
[  277.364430] [<ffffff80080d9bf4>] task_work_run+0xbc/0xd8
[  277.369826] [<ffffff80080b9674>] do_exit+0x2c4/0xa08
[  277.374876] [<ffffff80080b9e48>] do_group_exit+0x40/0xa8
[  277.380271] [<ffffff80080b9ed0>] __wake_up_parent+0x0/0x40
[  277.385837] [<ffffff80080838c0>] el0_svc_naked+0x34/0x38
[  277.391244] ---[ end trace c43e33b06d5b56d5 ]---

Looks like your dtb lost something.
What does the v4l2-ctl --list-formats-ext show?

Hi ShaneCCC,

This is my output:

vu@vu:~$ v4l2-ctl -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
vu@vu:~$ v4l2-ctl -d /dev/video0 --all
Driver Info (not using libv4l2):
        Driver name   : tegra-video
        Card type     : vi-output, adv7280 6-0021
        Bus info      : platform:54080000.vi:0
        Driver version: 4.9.140
        Capabilities  : 0x84200001
                Video Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps   : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Priority: 2
Video input : 0 (Camera 0: ok)
DV timings:
        Active width: 0
        Active height: 0
        Total width: 0
        Total height: 0
        Frame format: progressive
        Polarities: -vsync -hsync
        Pixelclock: 0 Hz
        Horizontal frontporch: 0
        Horizontal sync: 0
        Horizontal backporch: 0
        Vertical frontporch: 0
        Vertical sync: 0
        Vertical backporch: 0
        Standards:
        Flags:
Format Video Capture:
        Width/Height      : 720/240
        Pixel Format      : 'UYVY'
        Field             : Alternating
        Bytes per Line    : 1472
        Size Image        : 353280
        Colorspace        : SMPTE 170M
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             :

User Controls

                     brightness 0x00980900 (int)    : min=-128 max=127 step=1 default=0 value=0 flags=slider
                       contrast 0x00980901 (int)    : min=0 max=255 step=1 default=128 value=128 flags=slider
                     saturation 0x00980902 (int)    : min=0 max=255 step=1 default=128 value=128 flags=slider
                            hue 0x00980903 (int)    : min=-127 max=128 step=1 default=0 value=0 flags=slider
                 fast_switching 0x00981970 (bool)   : default=0 value=0

Camera Controls

                    bypass_mode 0x009a2064 (intmenu): min=0 max=1 default=0 value=0
                override_enable 0x009a2065 (intmenu): min=0 max=1 default=0 value=0
                   height_align 0x009a2066 (int)    : min=1 max=16 step=1 default=1 value=1
                     size_align 0x009a2067 (intmenu): min=0 max=2 default=0 value=0
               write_isp_format 0x009a2068 (bool)   : default=0 value=0
       sensor_signal_properties 0x009a2069 (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
        sensor_image_properties 0x009a206a (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
      sensor_control_properties 0x009a206b (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
              sensor_dv_timings 0x009a206c (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
               low_latency_mode 0x009a206d (bool)   : default=0 value=0
                   sensor_modes 0x009a2082 (int)    : min=0 max=30 step=1 default=30 value=0 flags=read-only

Enable the debug information in the csi2_fops.c to check if can get more information.

sudo su
echo file csi2_fops.c +p > /sys/kernel/debug/dynamic_debug/control

Hi,

I don’t see any thing from debug console

That’s weird could you check the source of the csi2_fops.c to check the tegra_csi_statu() was called while capture failed.

Hi Shane,

Problem had been resolve via TOPIC