Jetson Orin Nano CSI-2 stream becomes corrupted after running for a while

Hi everyone,

I am working with a Jetson Orin Nano 8GB running JetPack/L4T 36.4.0

Problem

Initially, the captured image/data is correct. However, after running for some time:

  • The image becomes corrupted/noisy.
  • Captured frames can become misaligned/corrupted.
  • Eventually, the CSI capture stream may stop.

Dmesg

After the stream starts failing, I repeatedly get the following messages:

[  503.015287] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  503.015316] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  503.017090] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  508.135236] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  508.135266] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  508.137102] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  513.255001] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  513.255033] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  513.256806] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  518.374840] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  518.374867] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  518.376450] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  523.494485] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  523.494516] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  523.496036] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  528.614529] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  528.614556] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  528.616292] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  533.734346] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  533.734377] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  533.736216] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  538.854234] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  538.854263] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  538.856394] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel
[  543.973804] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 5000 ms
[  543.973829] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[  543.975562] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel

V4L2 trace

I also captured the V4L2 trace using the kernel tracing interface.

The trace shows that the captured buffers are being returned with the ERROR flag:

cap dqbuf: 0 seq:   1116 bytesused: 4147200 ts: 605.431340 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1117 bytesused: 4147200 ts: 605.447998 delta: 16.658 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1118 bytesused: 4147200 ts: 605.464655 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1119 bytesused: 4147200 ts: 605.481312 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1120 bytesused: 4147200 ts: 605.497970 delta: 16.658 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1121 bytesused: 4147200 ts: 605.514627 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1122 bytesused: 4147200 ts: 605.531285 delta: 16.658 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1123 bytesused: 4147200 ts: 605.547942 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1124 bytesused: 4147200 ts: 605.564615 delta: 16.673 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1125 bytesused: 4147200 ts: 605.647902 delta: 83.287 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1126 bytesused: 4147200 ts: 605.681293 delta: 33.391 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1127 bytesused: 4147200 ts: 605.714593 delta: 33.300 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1128 bytesused: 4147200 ts: 605.797804 delta: 83.211 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1129 bytesused: 4147200 ts: 605.814477 delta: 16.673 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1130 bytesused: 4147200 ts: 605.897764 delta: 83.287 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1131 bytesused: 4147200 ts: 605.981067 delta: 83.303 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1132 bytesused: 4147200 ts: 606.081012 delta: 99.945 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1133 bytesused: 4147200 ts: 606.280871 delta: 199.859 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1134 bytesused: 4147200 ts: 606.297543 delta: 16.672 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1135 bytesused: 4147200 ts: 606.330858 delta: 33.315 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1136 bytesused: 4147200 ts: 606.480791 delta: 149.933 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1137 bytesused: 4147200 ts: 606.514121 delta: 33.330 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1138 bytesused: 4147200 ts: 606.597378 delta: 83.257 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1139 bytesused: 4147200 ts: 606.714011 delta: 116.633 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1140 bytesused: 4147200 ts: 606.730668 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1141 bytesused: 4147200 ts: 606.830598 delta: 99.930 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1142 bytesused: 4147200 ts: 606.847255 delta: 16.657 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:   1143 bytesused: 4147200 ts: 606.913870 delta: 66.615 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:   1144 bytesused: 4147200 ts: 607.197032 delta: 283.162 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:   1145 bytesused: 4147200 ts: 607.363622 delta: 166.590 ms (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:   1146 bytesused: 4147200 ts: 607.480209 delta: 116.587 ms (error, ts-monotonic, ts-src-eof)

Initially, the frame interval is approximately 16.67 ms, which is consistent with 60 FPS.

After some time, however, the frame intervals become highly irregular

My main question is:

What is the most likely root cause of this issue, and what should I check or change to fix it?

Thank you for your advice.

  1. Check without video encoder.
gst-launch-1.0 -e v4l2src device=/dev/video0 ! 'video/x-raw,format=YUY2,width=1920,height=1080,framerate=60/1' ! xvimagesink -ev
gst-launch-1.0 nvv4l2camerasrc device= /dev/video0 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, framerate=(fraction)60/1' ! nvvidconv ! nv3dsink -e
  1. Boost the clocks to try.
sudo jetson_clocks
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

Thank you for your response. I tested the NVCSI clock separately.

When I run:

echo 1 > /sys/kernel/debug/bpmp/debug/clk/nvcsi/mrq_rate_locked

the image corruption issue no longer occurs.

The NVCSI clock rate is then:

214300000 Hz

I also observed that without locking NVCSI, when I start the camera capture, the NVCSI clock rate drops, and the image corruption starts to occur. So it seems the issue is related to the NVCSI clock being dynamically reduced during camera capture.

Could you please explain:

  1. Why does the NVCSI clock rate drop when the camera starts capturing?
  2. Can this be fixed in the Device Tree / driver / build configuration, so the setting is persistent after reboot and does not require manually writing to mrq_rate_locked?

The NVCSI/VI clocks acquire the clocks depend on the pix_clk_hz.

You can adjust it to fix the problem or just boost the clocks as WAR.

Thanks

Thanks for the explanation.

My setup uses 2 CSI-2 lanes at 1350 Mbps/lane with YUV422 16-bit.

I calculated:

pix_clk_hz = (1350 × 2) / 16 = 168.75 MHz

However, even after adjusting pix_clk_hz around this value, the NVCSI/VI errors still occur. Could you please confirm whether this calculation and the resulting pix_clk_hz = 168,750,000 Hz are correct for my setup?

Also, are there any other Device Tree parameters that can affect the NVCSI clock rate?

Thanks.

Does your device tree have serdes_pix_clk_hz?

Since my per-lane frequency is 1.350 Gbps (which is less than 1.5 Gbps), I am not using the serdes_pix_clk_hz parameter. Is this correct?

You can increase extra 10% to 20% to acquire more NVCSI/VI bandwidth to try.

Thanks

Thanks for the suggestion. I increased it by 20% (from 168.75MHz to 202.5MHz), but the issue still persists. Instead of the noisy image I had before, the output now just turns completely black or green.

Suppose modifying the pix_clk_hz impace the settle time calculation.

You can set the cil_settletime manually instead of 0 for auto calculation.

Reference to below for the settle time calculation.

I also tried lowering the MIPI clock/data rate from the FPGA to 1 Gbps/lane and recalculated the cil_settletime based on the recommended formula.

For 1 Gbps/lane, I calculated:

  • UI = 0.5 ns
  • lp_clock_period = 1 / 408 MHz = 2.45098 ns
  • The calculated valid range for cil_settletime is approximately 35.9 ~ 61.2.
  • I chose cil_settletime = 49, which is approximately the middle of the valid range.

However, changing pix_clk_hz from 125 MHz to 180 MHz did not resolve the issue.

At the same time, I observed that the NVCSI clock was only around 40 MHz when checking:

cat /sys/kernel/debug/bpmp/debug/clk/nvcsi/rate

I then manually increased the NVCSI clock and locked it. When the NVCSI clock reached around 100 MHz, the camera started working normally.

Do you have any idea?

You can check the ../drivers/video/tegra/camera/tegra_camera_platform.c for calculation.

Thank you. I found the calculate_and_set_device_clock() function in tegra_camera_platform.c.

I have a question about how the CSI clock is actually calculated here. In the HWTYPE_CSI case, I see:

nr = max_depth * final_pr * overhead;
dr = bus_width * 100;
clk_rate = (nr + dr) / dr;

Could you clarify where the values of overhead and bus_width come from, and how they are determined?

For max_depth, is it derived from the camera device-tree property csi_pixel_bit_depth?

Also, how does pix_clk_hz relate to active_pixel_rate / phy_pixel_rate used as final_pr in this calculation?

For my current configuration, the actual NVCSI clock is around 401,812,500 Hz, while pix_clk_hz= 160,000,000 Hz

I would like to understand the exact calculation of the NVCSI clock so I can determine whether the clock is being set too low for my MIPI data rate.

Could you point me to where bus_width, overhead, and max_pixel_depth are initialized or calculated?

Most of them are from the device tree.

You can print them to debug.

Thanks

I noticed that bus_width is set to 64 in the CSI clock calculation:

dr = bus_width * 100;

I checked the driver and found that it is defined as:

#define CSI_BUS_WIDTH 64

Can I reduce this value, for example from 64 to 32, to increase the calculated NVCSI clock? Would changing this value have any side effects?

Suppose no side effect. Do you print them to confirm?

Yes. I printed the values to confirm.

After setting CSI_BUS_WIDTH from 64 to 32, I got:

CSI: lane_speed=0, lane_num=4, overhead=100, max_depth=16, bus_width=32
CSI: nr=256000000000, dr=3200
CSI: clk_rate=80000001

With CSI_BUS_WIDTH = 64, the calculated clk_rate was 40000001.

So reducing bus_width from 64 to 32 approximately doubles the calculated CSI clock from 40 MHz to 80 MHz.

Could the root cause be that the CSI/NVCSI clock is too low for the MIPI data rate? The same device tree works stably on TX2 NX with JetPack 4.6.2. Are there any differences in CSI clock calculation or requirements between TX2 NX and Orin Nano?

Yes, the TX2 is too old to tell if any different.

Suppose you can boost the clocks to modify the calculation in tegra_camera_platform.c for your case.