currupted frames from AR1820 USB camera

I am getting corrupted frames from 18MP AR1820 USB3 camera most of the time at all resolutions. Less frequent at low res. This is Bayer camera, I am using V4L2_PIX_FMT_YUYV to get raw buffers. The problem happens in USB stack. Not reproducible on Windows or Linux x86 host (Ubuntu 14.04 LTS). Here is TX1 kernel log for bad case.

Error message: uvcvideo: Dropping payload (out of sync).

Log:
[ 217.892415] uvcvideo: uvc_v4l2_open
[ 217.898270] hub 2-0:1.0: state 7 ports 4 chg 0000 evt 0004
[ 217.921056] usb 2-2: usb auto-resume
[ 217.981219] usb 2-2: finish resume
[ 217.986588] usb 2-2: disable remote wakeup, status 2
[ 217.993110] hub 2-2:1.0: hub_resume
[ 217.999208] hub 2-2:1.0: port 4: status 0263 change 0000
[ 218.006017] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0010
[ 218.013419] usb 2-2.4: usb auto-resume
[ 218.045552] hub 2-0:1.0: state 7 ports 4 chg 0000 evt 0004
[ 218.052567] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0010
[ 218.063221] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0010
[ 218.071343] usb 2-2.4: finish resume
[ 218.076901] usb 2-2.4: disable remote wakeup, status 2
[ 218.083492] uvcvideo: Resuming interface 0
[ 218.088975] uvcvideo: Resuming interface 1
[ 218.095959] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCAP) [ 218.101030] hub 2-2:1.0: resume on port 4, status 0
[ 218.114635] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCAP)
[ 218.120975] uvcvideo: uvc_v4l2_ioctl(VIDIOC_G_FMT)
[ 218.126996] uvcvideo: uvc_v4l2_ioctl(VIDIOC_G_PARM)
[ 218.133137] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FMT)
[ 218.139325] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
[ 218.146120] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
[ 218.153163] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
[ 218.159753] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
[ 218.166294] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FMT)
[ 218.172216] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCAP)
[ 218.178085] uvcvideo: uvc_v4l2_ioctl(VIDIOC_G_INPUT)
[ 218.183852] compat_ioctl32: unknown ioctl ‘V’, dir=3, #26 (0xc050561a)
[ 218.191616] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCTRL)
[ 218.197545] uvcvideo: uvc_v4l2_ioctl(VIDIOC_TRY_FMT)
[ 218.203277] uvcvideo: Trying format 0x56595559 (YUYV): 4912x3684.
[ 218.210080] uvcvideo: Using default frame interval 33333.3 us (30.0 fps).
[ 218.219175] uvcvideo: uvc_v4l2_ioctl(VIDIOC_S_FMT)
[ 218.224740] uvcvideo: Trying format 0x56595559 (YUYV): 4912x3684.
[ 218.231560] uvcvideo: Using default frame interval 33333.3 us (30.0 fps).
[ 218.240494] uvcvideo: uvc_v4l2_ioctl(VIDIOC_G_PARM)
[ 218.247837] uvcvideo: uvc_v4l2_ioctl(VIDIOC_REQBUFS)
[ 218.294901] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYBUF)
[ 218.302667] uvcvideo: uvc_v4l2_mmap
[ 218.312884] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYBUF)
[ 218.320514] uvcvideo: uvc_v4l2_mmap
[ 218.330250] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 218.337529] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 218.344732] uvcvideo: uvc_v4l2_ioctl(VIDIOC_STREAMON)
[ 218.353597] uvcvideo: Allocated 5 URB buffers of 32x1024 bytes each.
[ 218.361607] uvcvideo: uvc_v4l2_ioctl(VIDIOC_S_CTRL)
[ 218.370180] uvcvideo: uvc_v4l2_ioctl(VIDIOC_S_CTRL) [ 218.372763] uvcvideo: Non-zero status (-71) in video completion handler.
[ 218.384063] uvcvideo: uvc_v4l2_poll
[ 218.388930] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 218.396610] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 218.404108] uvcvideo: uvc_v4l2_poll
[ 218.409609] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 218.417216] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 218.424775] uvcvideo: uvc_v4l2_poll
[ 219.430983] uvcvideo: frame 1 stats: 0/0/152 packets, 0/0/152 pts (!early initial), 151/152 scr, last pts/stc/sof 2958699444/2956444583/145
[ 219.446690] uvcvideo: Frame complete (FID bit toggled).
[ 219.453555] uvcvideo: frame 2 stats: 0/0/1 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 219.453681] uvcvideo: uvc_v4l2_poll
[ 219.453737] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 219.453763] uvcvideo: LI-AR1820: PTS 2958699444 y 2343.632156 SOF 2343.632156 (x1 2144457530 x2 2145228787 y1 145620992 y2 147652608 SOF offset 60)
[ 219.453776] uvcvideo: LI-AR1820: SOF 2343.632156 y 1117581369 ts 219.011802 buf ts 218.784557 (x1 145883136/690/174 x2 147914752/721/205 y1 1000000000 y2 1030986616)
[ 219.453799] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 219.453818] uvcvideo: uvc_v4l2_poll
[ 219.527337] uvcvideo: Frame complete (EOF found).
[ 219.533989] uvcvideo: frame 3 stats: 0/0/1 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 219.534075] uvcvideo: uvc_v4l2_poll
[ 219.534097] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 219.534113] uvcvideo: LI-AR1820: PTS 0 y 56053.748779 SOF 56053.748779 (x1 808189678 x2 808960935 y1 145620992 y2 147652608 SOF offset 60)
[ 219.534124] uvcvideo: LI-AR1820: SOF 54005.748779 y 52757393290 ts 270.651613 buf ts 219.556137 (x1 145883136/690/174 x2 147914752/721/205 y1 1000000000 y2 1030986616)
[ 219.534302] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 219.534315] uvcvideo: uvc_v4l2_poll
[ 220.673121] uvcvideo: Frame complete (EOF found).
[ 220.681743] uvcvideo: uvc_v4l2_poll
[ 220.689202] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 220.695659] uvcvideo: LI-AR1820: PTS 2995544361 y 3973.255447 SOF 3973.255447 (x1 2151754130 x2 3448017554 y1 260440064 y2 275251200 SOF offset 60)
[ 220.711987] uvcvideo: LI-AR1820: SOF 3973.255447 y 998694193 ts 220.648288 buf ts 219.640079 (x1 260898816/397/1926 x2 281083904/449/104 y1 1000000000 y2 1051931788)
[ 220.731611] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 220.737856] uvcvideo: uvc_v4l2_poll
[ 221.118362] uvcvideo: frame 4 stats: 0/0/188 packets, 1/49/188 pts (!early initial), 187/188 scr, last pts/stc/sof 2995544361/1110971/44
[ 221.341031] uvcvideo: Frame complete (EOF found).
[ 221.347383] uvcvideo: uvc_v4l2_poll
[ 221.352333] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 221.358566] uvcvideo: LI-AR1820: PTS 1111903 y 2151.341079 SOF 2151.341079 (x1 2163707446 x2 2164487607 y1 183238656 y2 185270272 SOF offset 60)
[ 221.374344] uvcvideo: LI-AR1820: SOF 2151.341079 y 271153273 ts 220.609474 buf ts 221.162855 (x1 188612608/1086/748 x2 190644224/1117/779 y1 1000000000 y2 1031093334)
[ 221.394129] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 221.400290] uvcvideo: uvc_v4l2_poll
[ 221.793498] uvcvideo: frame 5 stats: 0/0/471 packets, 0/0/471 pts (!early initial), 470/471 scr, last pts/stc/sof 1111903/18122785/719
[ 223.402078] uvcvideo: uvc_v4l2_poll
[ 223.407268] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[ 224.271582] uvcvideo: Frame complete (overflow).
[ 224.277788] uvcvideo: Frame complete (overflow).
[ 224.283946] uvcvideo: Dropping payload (out of sync).
[ 224.283983] uvcvideo: LI-AR1820: PTS 29570632 y 1235.160400 SOF 1235.160400 (x1 2209101019 x2 2209882313 y1 241172480 y2 243204096 SOF offset 60)
[ 224.283992] uvcvideo: LI-AR1820: SOF 3283.160400 y 521017176 ts 223.790341 buf ts 221.838951 (x1 246480896/1969/1632 x2 248512512/2000/1663 y1 1000000000 y2 1031074167)
[ 224.327210] uvcvideo: Dropping payload (out of sync).
[ 224.334039] uvcvideo: Dropping payload (out of sync).
[ 224.341291] uvcvideo: Dropping payload (out of sync).
[ 224.347928] uvcvideo: Dropping payload (out of sync).
[ 224.355129] uvcvideo: Dropping payload (out of sync).
[ 224.361888] uvcvideo: Dropping payload (out of sync).
[ 224.368741] uvcvideo: Dropping payload (out of sync).
[ 224.375357] uvcvideo: Dropping payload (out of sync).
[ 224.382082] uvcvideo: Dropping payload (out of sync).
[ 224.388614] uvcvideo: Dropping payload (out of sync).
[ 224.395384] uvcvideo: Dropping payload (out of sync).
[ 224.401923] uvcvideo: Dropping payload (out of sync).
[ 224.408438] uvcvideo: Dropping payload (out of sync).
[ 225.844270] uvcvideo: Dropping payload (out of sync).
[ 225.850610] uvcvideo: Dropping payload (out of sync).
[ 225.857025] uvcvideo: Dropping payload (out of sync).
[ 225.863193] uvcvideo: Dropping payload (out of sync).
[ 225.869569] uvcvideo: Dropping payload (out of sync).
[ 225.875647] uvcvideo: Dropping payload (out of sync).
[ 225.881910] uvcvideo: Dropping payload (out of sync).
[ 225.887964] uvcvideo: Dropping payload (out of sync).
[ 225.894077] uvcvideo: Dropping payload (out of sync).
[ 225.900083] uvcvideo: Dropping payload (out of sync).
[ 225.906087] uvcvideo: Dropping payload (out of sync).
[ 225.912072] uvcvideo: Dropping payload (out of sync).
[ 225.917995] uvcvideo: Dropping payload (out of sync).
[ 225.923967] uvcvideo: Dropping payload (out of sync).
[ 225.929649] uvcvideo: Dropping payload (out of sync).
[ 225.935564] uvcvideo: Dropping payload (out of sync).
[ 225.941040] uvcvideo: Dropping payload (out of sync).
[ 225.946826] uvcvideo: Dropping payload (out of sync).
[ 225.952289] uvcvideo: Dropping payload (out of sync).
[ 225.958188] uvcvideo: Dropping payload (out of sync).
[ 225.963618] uvcvideo: Dropping payload (out of sync).
[ 225.969439] uvcvideo: Dropping payload (out of sync).
[ 225.974835] uvcvideo: Dropping payload (out of sync).
[ 225.980688] uvcvideo: Dropping payload (out of sync).
[ 226.004641] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[ 226.009782] uvcvideo: uvc_v4l2_ioctl(VIDIOC_STREAMOFF)
[ 226.025809] uvcvideo: uvc_v4l2_release
[ 228.041129] uvcvideo: Suspending interface 1
[ 228.045867] uvcvideo: Suspending interface 0
[ 228.050844] usb 2-2.4: usb auto-suspend, wakeup 0
[ 228.572151] hub 2-2:1.0: hub_suspend
[ 228.578006] tegra-xhci tegra-xhci: tegra_xhci_process_mbox_message data_in 0x0
[ 228.587697] tegra-xhci tegra-xhci: t210_disable_lfps_detector port 1
[ 228.596023] tegra-xhci tegra-xhci: t210_lfps_detector: misc_pad_ctl1 @5a0 = 0x10142080
[ 228.609760] tegra-xhci tegra-xhci: tegra_xhci_process_mbox_message data_in 0x0
[ 228.611149] usb 2-2: usb auto-suspend, wakeup 1
[ 228.625003] tegra-xhci tegra-xhci: t210_enable_lfps_detector port 1
[ 228.633366] tegra-xhci tegra-xhci: t210_lfps_detector: misc_pad_ctl1 @5a0 = 0x10000080

You’ll probably want to provide “lsusb -t” output. If you run lsusb with no arguments you’ll also see an ID, and can print verbose USB info (where ####:#### are numbers of ID from plain lsusb) for the specific device via:

lsusb -d '####:####' -vvv
# lsusb -d '2a0b:00ed' -vvv

Bus 002 Device 004: ID 2a0b:00ed
[ 4943.257858] hub 2-0:1.0: state 7 ports 4 chg 0000 evt 0004
[ 4943.283103] usb 2-2: usb auto-resume
[ 4943.343102] usb 2-2: finish resume
[ 4943.347169] usb 2-2: disable remote wakeup, status 2
[ 4943.353383] hub 2-2:1.0: hub_resume
[ 4943.358776] hub 2-2:1.0: port 2: status 0263 change 0000
[ 4943.367340] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0000
[ 4943.367897] usb 2-2.2: usb auto-resume
[ 4943.376755] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0004
[ 4943.387105] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0004
[ 4943.403155] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0004
[ 4943.419122] hub 2-2:1.0: state 7 ports 4 chg 0000 evt 0004
[ 4943.425162] usb 2-2.2: finish resume
[ 4943.429364] usb 2-2.2: disable remote wakeup, status 2
Device Descriptor:
  bLength                18
  bDescriptorType  [ 4943.443181] hub 2-2:1.0: resume on port 2, status 0
       1
  bcdUSB               3.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0         9
  idVendor           0x2a0b
  idProduct          0x00ed
  bcdDevice            0.00
  iManufacturer           1 Leopard Imaging
  iProduct                2 LI-AR1820
  iSerial                 3 0000000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          278
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              224mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass         14 Video
      bFunctionSubClass       3 Video Interface Collection
      bFunctionProtocol       0
      iFunction               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass        14 Video
      bInterfaceSubClass      1 Video Control
      bInterfaceProtocol      0
      iInterface              0
      VideoControl Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdUVC               1.10
        wTotalLength           81
        dwClockFrequency       25.187500MHz
        bInCollection           1
        baInterfaceNr( 0)       1
      VideoControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Camera Sensor
        bAssocTerminal          0
        iTerminal               0
        wObjectiveFocalLengthMin      0
        wObjectiveFocalLengthMax      0
        wOcularFocalLength            0
        bControlSize                  3
        bmControls           0x00000008
          Exposure Time (Absolute)
      VideoControl Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      5 (PROCESSING_UNIT)
        bUnitID                 2
        bSourceID               1
        wMaxMultiplier      16384
        bControlSize            3
        bmControls     0x00000200
          Gain
        iProcessing             0
        bmVideoStandards     0x 0
      VideoControl Interface Descriptor:
        bLength                28
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 3
        guidExtensionCode         {e121e378-acc8-a540-8ac9-75a2a02c74fb}
        bNumControl             1
        bNrPins                 1
        baSourceID( 0)          2
        bControlSize            3
        bmControls( 0)       0xff
        bmControls( 1)       0xff
        bmControls( 2)       0x00
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             4
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               3
        iTerminal               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
        bMaxBurst               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass        14 Video
      bInterfaceSubClass      2 Video Streaming
      bInterfaceProtocol      0
      iInterface              0
      VideoStreaming Interface Descriptor:
        bLength                            14
        bDescriptorType                    36
        bDescriptorSubtype                  1 (INPUT_HEADER)
        bNumFormats                         1
        wTotalLength                      131
        bEndPointAddress                  131
        bmInfo                              0
        bTerminalLink                       4
        bStillCaptureMethod                 1
        bTriggerSupport                     0
        bTriggerUsage                       0
        bControlSize                        1
        bmaControls( 0)                    27
      VideoStreaming Interface Descriptor:
        bLength                            27
        bDescriptorType                    36
        bDescriptorSubtype                  4 (FORMAT_UNCOMPRESSED)
        bFormatIndex                        1
        bNumFrameDescriptors                3
        guidFormat                            {59555932-0000-1000-8000-00aa00389b71}
        bBitsPerPixel                      16
        bDefaultFrameIndex                  1
        bAspectRatioX                      16
        bAspectRatioY                       9
        bmInterlaceFlags                 0x00
          Interlaced stream or variable: No
          Fields per frame: 2 fields
          Field 1 first: No
          Field pattern: Field 1 only
          bCopyProtect                      0
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         1
        bmCapabilities                   0x01
          Still image supported
        wWidth                           1920
        wHeight                          1080
        dwMinBitRate                 20736000
        dwMaxBitRate                 20736000
        dwMaxVideoFrameBufferSize     4147200
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  1
        dwFrameInterval( 0)            333333
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         2
        bmCapabilities                   0x01
          Still image supported
        wWidth                           4912
        wHeight                          3684
        dwMinBitRate                1085748480
        dwMaxBitRate                1085748480
        dwMaxVideoFrameBufferSize    36191616
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  1
        dwFrameInterval( 0)            333333
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         3
        bmCapabilities                   0x01
          Still image supported
        wWidth                           1280
        wHeight                           720
        dwMinBitRate                 55296000
        dwMaxBitRate                 55296000
        dwMaxVideoFrameBufferSize     1843200
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  1
        dwFrameInterval( 0)            333333
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst              15
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength           22
  bNumDeviceCaps          2
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x00000002
      Link Power Management (LPM) Supported
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x000e
      Device can operate at Full Speed (12Mbps)
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   3
      Lowest fully-functional device speed is SuperSpeed (5Gbps)
    bU1DevExitLat           0 micro seconds
    bU2DevExitLat           0 micro seconds
Device Status:     0x0000
  (Bus Powered)

The USB transfer mode is bulk. This would be appropriate for stop motion cameras, but not full motion (full motion would use isochronous). Bulk transfer is essentially stop-and-go, and depends on the camera saving or buffering data while waiting for the ok to continue sending. Is the camera sending individual snapshots, or is it full motion?

If the USB Video Class expects a constant bandwidth available, bulk transfer stops could result in dropping data or buffer overflows/underflows.

The camera use case is stop motion, snapshot mode. I am using standard start/stop streaming V4L2 API for getting frames. Is it supported on TX1?

I don’t know enough about V4L2, but how large is an individual frame? It doesn’t seem likely that USB would have to halt a bulk transfer unless a large amount of data is transferred, or unless something else is competing for USB bandwidth. What I’m curious about, and cannot answer, is whether V4L2 itself has any behavior difference between a bulk transfer device and one with isochronous transfer. Obviously much of V4L2 was designed around full motion devices and thus isochronous behavior. I do not know what would happen within V4L2 if a bulk transfer pauses…speculating, perhaps V4L2 expects isochronous behavior.

One thing to simplify testing is be sure USB autosuspend is disabled:

sudo echo -1 > /sys/module/usbcore/parameters/autosuspend

…if USB is actually going to sleep then all bets are off (USB messages may indicate autosuspend).

This is 18MP sensor. https://www.leopardimaging.com/uploads/LI-USB30-AR1820C_datasheet.pdf. autosuspend was turned off from the beginning.

Would be good to known whether TX1 USB stack supports UVC with bulk transfer mode.

I doubt USB itself would be an issue with bulk versus isochronous modes with any class beneath the protocols. The consumer of the USB data would be more likely to be sensitive to this. Being part of a class within USB means there are probably some standardized functions to be expected, but the application consuming the device does not necessarily have to be aware of USB transfer mode…certainly the commands to access the device would be known to the consuming program.

I can’t say for sure, but at 18MP, it may be possible a single frame of uncompressed color to require being interrupted and restarted in a similar way as a hard drive being read when other USB devices also want to use the USB pipe.

I’m unsure of how to do it, but it seems there is a need to determine if bulk transfer stop/start is losing data, or if it is the end application expecting the data not liking to be interrupted. Or, it could of course be something completely different, but the behavior of the issue decreasing at low resolution tends to increase the odds of this.

DmitriK,

I would like to suggest you below steps to check if this issue can be improved,

  1. Increase TRBS_PER_SEGMENT to 256
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 8820871b..0322430 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1238,7 +1238,7 @@ union xhci_trb {
  * since the command ring is 64-byte aligned.
  * It must also be greater than 16.
  */
-#define TRBS_PER_SEGMENT	64
+#define TRBS_PER_SEGMENT	256
 /* Allow two commands + a link TRB, along with any reserved command TRBs */
 #define MAX_RSVD_CMD_TRBS	(TRBS_PER_SEGMENT - 3)
 #define TRB_SEGMENT_SIZE	(TRBS_PER_SEGMENT*16)
  1. Increase UVC_URBS and UVC_MAX_PACKETS
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index af505fd..e5f36ef 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -112,9 +112,9 @@
 #define DRIVER_VERSION		"1.1.1"
 
 /* Number of isochronous URBs. */
-#define UVC_URBS		5
+#define UVC_URBS		76
 /* Maximum number of packets per URB. */
-#define UVC_MAX_PACKETS		32
+#define UVC_MAX_PACKETS		64
 /* Maximum number of video buffers. */
 #define UVC_MAX_VIDEO_BUFFERS	32
 /* Maximum status buffer size in bytes of interrupt URB. */
  1. Follow http://elinux.org/Jetson/Performance to set cpus run at max rate

I tried this patch to fix my issue with corrupt video from multiple high resolution usb3 cameras but it did not help unfortunately. Do you have any other suggestions?

https://devtalk.nvidia.com/default/topic/936302/jetson-tx1/support-for-multiple-high-resolution-usb-3-0-cameras-/post/4888286/#4888286

hammer00,

Please check if below new xusb fw can help your issue,
https://devtalk.nvidia.com/default/topic/919354/jetson-tx1/usb-3-transfer-failures/post/4899105/#4899105

nVConan,

The patch did not fix the issue also it looks like the patch you mentioned above is for cameras running in isochronous mode is that true? I am getting closer but our cameras are running in bulk mode I can successfully get two cameras to work on a single controller at a rate of 148MB/s each. My understanding is the usb stack limits bulk transfers to 80% of usb3 bandwidth I am still only using 2/3 of that number. I am using a pci card for an additional usb controller I start getting the dropping payload stuff whenever I attempt to access a third camera. I am using the firmware patch as well.

Hi nVConan,

I got it working with kernel from 24.1 release. Notes:

  1. “Increase TRBS_PER_SEGMENT to 256” patch was already in 24.1 kernel

  2. had to add “Increase UVC_URBS and UVC_MAX_PACKETS” patch

  3. setting “set cpus run at max rate” was critical step for getting uncorrupted frames at the beginning after skipping first 3 frames at start.

Like mentioned in previous post I also got it working only with 2 cameras streaming simultaneously (16MP @ 3.3fps, 2 bytes per pixel). Adding 3rd camera brings the frame corruption back. Looks like cameras are fighting for available bandwidth. Cameras are streaming in bulk transfer mode. I think I need to slow-down the readout rate/clock.

Thanks

One thing I wonder about…since this is bulk mode it is expected that the camera uploading an image to the computer would halt if told to do so, and then continue when possible (just like a hard drive). Is the camera also pausing snapping of a new frame when the current frame is not yet uploaded? Either pausing the snap of a new shot or having sufficient buffer would be required to stop overrun at the camera’s buffer…in the case of multiple cameras this would be even more critical that a new frame not be snapped until the buffer in the camera itself is sufficient (if there is no pause in the camera itself then you are back to needing isochronous mode).