Skip to main content

Jetson Stream Freezes or Shows Frame Corruption

When to use this article​

On NVIDIA Jetson platforms, a UVC camera stream may freeze, stop after several frames, or show frame corruption when streaming high-resolution or high-bandwidth video.

Why this happens​

The issue can be caused by insufficient UVC transfer buffers in the uvcvideo kernel driver.

The solution is to rebuild the uvcvideo kernel module with larger UVC_URBS and UVC_MAX_PACKETS values, then replace the module on the Jetson system.

caution

The following steps replace a Linux kernel module on the target system. Build and install the module on the same Jetson device and JetPack/L4T version where the camera will be used.

Tested JetPack releases​

We verified this solution on JetPack 6.2.x. For other JetPack versions, use the same procedure but download the BSP source package that matches the Jetson Linux/L4T version installed on the target device.

JetPack versionL4T versionBSP source package
JetPack 6.2R36.4.3https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v4.3/sources/public_sources.tbz2
JetPack 6.2.1R36.4.4https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v4.4/sources/public_sources.tbz2

For other JetPack/L4T versions, go to the NVIDIA Jetson Linux Archive, open the page for the matching Jetson Linux release, and download Sources > Driver Package (BSP) Sources.

Rebuild and install the uvcvideo module​

  1. Check the JetPack/L4T version.
$ cat /etc/nv_tegra_release
  1. Install build dependencies.
$ sudo apt-get update
$ sudo apt-get install -y libssl-dev build-essential pkg-config libncurses-dev lbzip2
  1. Download and extract the NVIDIA kernel source.

Replace <BSP_SOURCE_URL> with the BSP source URL that matches your L4T version.

$ mkdir -p ~/uvc_driver/build_dir
$ cd ~/uvc_driver
$ wget "<BSP_SOURCE_URL>" -O public_sources.tbz2
$ tar -xf public_sources.tbz2
$ cd Linux_for_Tegra/source/
$ tar -xf kernel_src.tbz2
$ cd kernel/kernel-jammy-src/
  1. Update the UVC driver buffer settings.
$ sed -i -e '/#define DRIVER_VERSION/ s/"\(.*\)"/"\1-tn1"/' drivers/media/usb/uvc/uvcvideo.h
$ sed -i -e 's/#define UVC_URBS.*/#define UVC_URBS 1000/' drivers/media/usb/uvc/uvcvideo.h
$ sed -i -e 's/#define UVC_MAX_PACKETS.*/#define UVC_MAX_PACKETS 64/' drivers/media/usb/uvc/uvcvideo.h
  1. Prepare the kernel build configuration.
$ if [ -f /proc/config.gz ]; then \
zcat /proc/config.gz > ~/uvc_driver/build_dir/.config; \
else \
cp /boot/config-$(uname -r) ~/uvc_driver/build_dir/.config; \
fi
$ make ARCH=arm64 O=~/uvc_driver/build_dir olddefconfig
$ make ARCH=arm64 O=~/uvc_driver/build_dir modules_prepare
  1. Build the UVC driver module.
$ make ARCH=arm64 O=~/uvc_driver/build_dir M=$PWD/drivers/media/usb/uvc modules

After the build completes, the new module should be available at:

drivers/media/usb/uvc/uvcvideo.ko
  1. Back up the original module and install the rebuilt module.

Make sure the camera application is stopped before replacing the driver.

$ sudo cp -av /lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/uvcvideo.ko \
/lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/uvcvideo.ko.backup
$ sudo install -m 0644 drivers/media/usb/uvc/uvcvideo.ko \
/lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/uvcvideo.ko
$ sudo depmod -a
$ sudo reboot

Check the result​

After reboot, confirm that the installed uvcvideo module version includes the -tn1 suffix.

$ modinfo /lib/modules/$(uname -r)/kernel/drivers/media/usb/uvc/uvcvideo.ko | grep '^version:'
version: 1.1.1-tn1

Then run a camera streaming test again:

$ v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=100

References​