RAW8 MIPI CSI capture issue

I am currently porting a camera driver for Jetson Orin NX the camera outputs RAW8 monochrome video, I have added RAW8 support in tegracam and seem to almost be able to capture something.
I use CSI3 (2 lane CSI input) to capture the data with this command:
v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=GREY --stream-mmap --stream-count=1 -d /dev/video0 --stream-to=/tmp/test.raw
The issue is there seem to be a problem decoding frames as I have the following errors in dmesg:
[ 692.401474] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256
[ 692.418144] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256
[ 692.434817] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256
This is the mode i use :

mode0 {
	mclk_khz = "24000";

	num_lanes = "2";
	pix_clk_hz = "44000000";
	csi_pixel_bit_depth = "8";
	tegra_sinterface = "serial_c";
	phy_mode = "DPHY";

	active_w = "640";
	active_h = "480";
	line_length = "1464";
	pixel_t = "y8";
	horz_front_porch = "412";
	horz_back_porch = "412";

	lane_polarity = "0";

	gain_factor = "10";
	min_gain_val = "0";             /* 0dB */
	max_gain_val = "480";           /* 48dB */
	step_gain_val = "3";            /* 0.3 */
	default_gain = "0";
	framerate_factor = "1000000";
	default_framerate = "60000000";
	min_framerate = "9000000";
	max_framerate = "90000000";     /* 30 */
	step_framerate = "1000000";
	omin_exp_time = "30";            /* us */
	max_exp_time = "660000";        /* us */
	step_exp_time = "10";
	default_exp_time = "33334";     /* us */
	exposure_factor = "1";
	/*cil_settletime = "0";*/
	/*embedded_metadata_height = "10";*/

};

I modified the following files:

--- a/drivers/media/platform/tegra/camera/camera_common.c
+++ b/drivers/media/platform/tegra/camera/camera_common.c
@@ -129,6 +129,11 @@ static const struct camera_common_colorfmt camera_common_color_fmts[] = {
 		V4L2_COLORSPACE_SRGB,
 		V4L2_PIX_FMT_VYUY,
 	},
+	{
+		MEDIA_BUS_FMT_Y8_1X8,
+		V4L2_COLORSPACE_RAW,
+		V4L2_PIX_FMT_GREY,
+	},
 };
 
 struct camera_common_csi_io_pad_ctx {
@@ -667,7 +672,8 @@ int camera_common_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
 
 verify_code:
 	mf->field = V4L2_FIELD_NONE;
-	mf->colorspace = V4L2_COLORSPACE_SRGB;
+	//mf->colorspace = V4L2_COLORSPACE_SRGB;
 	mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
 	mf->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
 	mf->quantization = V4L2_QUANTIZATION_DEFAULT;
--- a/drivers/media/platform/tegra/camera/sensor_common.c
+++ b/drivers/media/platform/tegra/camera/sensor_common.c
@@ -267,6 +267,8 @@ static int extract_pixel_format(
 		*format = V4L2_PIX_FMT_UYVY;
 	else if (strncmp(pixel_t, "yuv_vyuy16", size) == 0)
 		*format = V4L2_PIX_FMT_VYUY;
+	else if (strncmp(pixel_t, "grey_y8", size) == 0)
+		*format = V4L2_PIX_FMT_GREY;
 	else {
 		pr_err("%s: Need to extend format%s\n", __func__, pixel_t);
 		return -EINVAL;
--- a/drivers/media/platform/tegra/camera/vi/vi5_formats.h
+++ b/drivers/media/platform/tegra/camera/vi/vi5_formats.h
@@ -82,6 +82,8 @@ static const struct tegra_video_format vi5_video_formats[] = {
 	/* RAW 7: TODO */
 
 	/* RAW 8 */
+	TEGRA_VIDEO_FORMAT(RAW8, 8, Y8_1X8, 1, 1, T_R8, RAW8, GREY, "Greyscale 8"),
+
 	TEGRA_VIDEO_FORMAT(RAW8, 8, SRGGB8_1X8, 1, 1, T_R8,
 				RAW8, SRGGB8, "RGRG.. GBGB.."),
 	TEGRA_VIDEO_FORMAT(RAW8, 8, SGRBG8_1X8, 1, 1, T_R8,

Is there something Im missing ? How can I get more logs from the CSI interface ?

*** Please note that this reply is generated by LLM automatically ***

Based on the provided context, it appears that you are experiencing issues with capturing and decoding frames from a camera connected to the Jetson Orin NX using the CSI interface. The camera outputs RAW8 monochrome video, and you have added RAW8 support in tegracam.

To troubleshoot the issue, let’s break down the information provided:

  1. CSI Interface: The Jetson Orin NX supports the CSI interface, which is used for camera capture. The CSI interface is a high-speed interface that can capture data from multiple cameras simultaneously.
  2. RAW8 Support: You have added RAW8 support in tegracam, which suggests that the camera driver is capable of handling RAW8 monochrome video.
  3. CSI3 2-lane CSI Input: You are using CSI3 with a 2-lane CSI input to capture the data. This configuration is supported by the Jetson Orin NX.
  4. Error Messages: The error messages in dmesg indicate that there is a problem decoding frames. This could be due to a variety of reasons, including incorrect configuration, hardware issues, or software bugs.

To get more logs from the CSI interface, you can try the following:

  1. Enable Debug Logging: You can enable debug logging for the CSI interface by adding the following line to the kernel command line: csi.debug=1. This will enable debug logging for the CSI interface, which can provide more detailed information about the capture process.
  2. Use the nvgstcapture Application: The nvgstcapture application is a tool that can be used to capture and display video from the CSI interface. You can use this application to test the camera capture and see if the issue is specific to your application or if it’s a general issue with the CSI interface.
  3. Check the Camera Configuration: Make sure that the camera configuration is correct. Check the camera’s datasheet to ensure that the configuration you are using is supported.
  4. Check the CSI Interface Configuration: Make sure that the CSI interface configuration is correct. Check the Jetson Orin NX documentation to ensure that the configuration you are using is supported.

In comparison to the supported cameras listed in the context, the Logitech C920 is a USB 2.0 camera that is validated on Jetson platforms running Jetson Linux with USB 2.0 ports. However, your camera is connected to the CSI interface, which is a different interface than the USB 2.0 interface used by the Logitech C920.

To summarize, to troubleshoot the issue, you can try enabling debug logging for the CSI interface, using the nvgstcapture application, checking the camera configuration, and checking the CSI interface configuration. If the issue persists, you may want to consider seeking further assistance from NVIDIA or the camera manufacturer.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Hello @y3bu3 V4l2 also have a camera trace where you can get more info about your error. You can enable it with:

sudo modprobe rtcpu_debug

echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
echo 3 > /sys/kernel/debug/camrtc/log-level
echo 1 > /sys/kernel/debug/tracing/events/camera_common/enable
echo > /sys/kernel/debug/tracing/trace
cat /sys/kernel/debug/tracing/trace

You can read more about debug camera on this wiki:

Additional based on your jetpack you can also use the debug fw

Best Regards,

Isaac Barrios
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

Looks like pixel long line error. It could be the sensor output size more than the driver reported.

Thanks

[  692.434817] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256