Getting Error when trying to capture from multiple USB cameras simultaneously

This is a common issue faced in the industry with many USB cameras. You may get errors like Failed to allocate required memory. when tying to capture simultaneously from more than one usb cameras.

The root cause for this issue is that most of the USB cameras requests for more BW than actually required. If the use case is to capture only from 2 USB cameras , it can be done by connecting one of them to USB type-C port since it is internally connected to a seperate instance of USB controller. But if the use case is to capture from more than 2 cameras, you need to modify the UVC driver to override the BW allocation.

The root cause and work around is explained in detail in this blog Multiple UVC cameras on linux

To apply the work around to our SDK, use below steps

  1. Download and install Processor SDK Linux Processor SDK Linux

  2. Get the patch to add bandwidth_cap parameter to uvcvideo kernel module uvcvideo patch

  3. Apply the patch to kernel source in Processor SDK Linux Install path. Please refer to PSDK building kernel

  4. Compile only uvcvideo module using below command

    make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- tisdk_j7-evm_defconfig
    make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- ./drivers/media/usb/uvc/uvcvideo.ko
  5. Copy ./drivers/media/usb/uvc/uvcvideo.ko to evm

  6. Remove uvcvideo module and install modified version using below commands

    rmmmod uvcvideo
    insmod uvcvideo.ko
  7. Set the desired BW cap as shown below

    echo 1200 >  /sys/module/uvcvideo/parameters/bandwidth_cap


The unit of BW here is Bytes/125us, you can estimate the approximate BW requirment by multiplying fps with size/frame