USB descriptor get corrupted

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ptphucbk
Level 1
Level 1
5 replies posted First reply posted First question asked

Hi everyone,

I'm debugging a camera firmware which is developped based on this: https://www.cypress.com/documentation/application-notes/an75779-how-implement-image-sensor-interface...

The cypress camera works fine except that seldomly during video streaming the camera somehow stops and when I check usb desctiption with lsusb -v, I saw that its descriptor is corrupted. And in dmesg I saw:

 

 

 

[ 8720.318320] usb 1-1.4: new high-speed USB device number 28 using xhci-hcd
[ 8720.419525] usb 1-1.4: config 1 contains an unexpected descriptor of type 0x1, skipping
[ 8720.419534] usb 1-1.4: config 1 has an invalid descriptor of length 1, skipping remainder of the config
[ 8720.419540] usb 1-1.4: config 1 has 1 interface, different from the descriptor's value: 2
[ 8720.419548] usb 1-1.4: config 1 interface 0 altsetting 0 has 0 endpoint descriptors, different from the interface descriptor's value: 1
[ 8720.420738] usb 1-1.4: config 1 has an invalid descriptor of length 1, skipping remainder of the config
[ 8720.420747] usb 1-1.4: config 1 has 0 interfaces, different from the descriptor's value: 2
[ 8720.423854] uvcvideo: Found UVC 1.00 device _v1.4.0 (04b4:00f8)
[ 8720.423873] uvcvideo: No valid video chain found.
[ 8720.423919] usb 1-1.4: Unsupported device

 

 

 

 Is there anyone has the same problem ?

Thank you very much

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

As per this link, the LIBUSB_TRANSFER_ERROR error is seen when short packets are received if LIBUSB_TRANSFER_SHORT_NOT_OK flag is set. Not using this flag might resolve the problem

Please confirm if this is the case for the error.

Please let me know if you can get the UART debug prints on the custom board. Also, let me know if you could stream using guvcview app.

Regards,
Rashi

View solution in original post

0 Likes
9 Replies
ptphucbk
Level 1
Level 1
5 replies posted First reply posted First question asked

Here is the good description of USB:

 

Bus 001 Device 029: ID 04b4:00f8 Cypress Semiconductor Corp.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x04b4 Cypress Semiconductor Corp.
idProduct 0x00f8
bcdDevice 0.00
iManufacturer 1 Innovplus̐_v1.4
iProduct 2 _v1.4.0
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 205
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
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.00
wTotalLength 80
dwClockFrequency 48.000000MHz
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 12
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
Warning: Descriptor too short
bUnitID 2
bSourceID 1
wMaxMultiplier 16384
bControlSize 3
bmControls 0x0000020a
Contrast
Saturation
Gain
iProcessing 0
bmVideoStandards 0x1c
PAL - 625/50
SECAM - 625/50
NTSC - 625/50
VideoControl Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 3
guidExtensionCode {ffffffff-ffff-ffff-ffff-ffffffffffff}
bNumControl 0
bNrPins 1
baSourceID( 0) 2
bControlSize 3
bmControls( 0) 0x00
bmControls( 1) 0x00
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 8
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 41
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 1
guidFormat {59382020-0000-1000-8000-00aa00389b71}
bBitsPerPixel 16
bDefaultFrameIndex 1
bAspectRatioX 8
bAspectRatioY 6
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 0x03
Still image supported
Fixed frame-rate
wWidth 640
wHeight 480
dwMinBitRate 832000000
dwMaxBitRate 832000000
dwMaxVideoFrameBufferSize 614400
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 1
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 0x0000641e
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)

0 Likes
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

Please share the UART debug prints for us to know the reason why the streaming stopped.

Is the good description of USB seen when the device enumerates with the UVC firmware programmed? Or is it sometimes seen when the streaming stops

Please let me know which booting mode is used. And is the board with FX3 a custom board ?

Regards,
Rashi
0 Likes

Hi @Rashi_Vatsa,

Thank you for your answer. Unfortunately I don't have the debug messages from cypress while the problem happened.

It's quite random the problem and I suspect that it comes from libuvc that I used to get camera images instead of the camera's firmware itself.

I will get back to you as soon as I have more information. I just want to ask what is the recommended way to communicate with camera in a linux system: use v4l2 or libuvc ?

Thank you very much.

0 Likes
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

I just want to ask what is the recommended way to communicate with camera in a linux system: use v4l2 or libuvc ?

>> We have seen customers using guvcview application which is compatible with V4L2 driver. As the problem is seen with libuvc you can try using V4L2 with guvcview to narrow down the problem

Regards,
Rashi

Hi, I've been debugging libuvc and I saw that 

the camera's stream is started with:
 
libusb_fill_bulk_transfer ( transfer, strmh->devh->usb_devh,
          format_desc->parent->bEndpointAddress,
          strmh->transfer_bufs[transfer_id],
          strmh->cur_ctrl.dwMaxPayloadTransferSize, _uvc_stream_callback,
          ( void* ) strmh, 5000 );
 
The call-back function _uvc_stream_callback is called everytime a libusb_transfer is received. However transfer's status can be LIBUSB_TRANSFER_ERROR.
 
Do you happen to have this problem ?
 
Here is the file that has those codes: https://github.com/libuvc/libuvc/blob/master/src/stream.c
 
Thank you very much 
 
0 Likes
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

As per this link, the LIBUSB_TRANSFER_ERROR error is seen when short packets are received if LIBUSB_TRANSFER_SHORT_NOT_OK flag is set. Not using this flag might resolve the problem

Please confirm if this is the case for the error.

Please let me know if you can get the UART debug prints on the custom board. Also, let me know if you could stream using guvcview app.

Regards,
Rashi
0 Likes

Hi, 

Thank you for your answer.

I tried to force 

transfer->flags = LIBUSB_TRANSFER_ADD_ZERO_PACKET;
 
Not sure it this is the right way to do. However I still got 
LIBUSB_TRANSFER_ERROR.
transfer = libusb_alloc_transfer(0);
transfer->flags = LIBUSB_TRANSFER_ADD_ZERO_PACKET;
strmh->transfers[transfer_id] = transfer;
strmh->transfer_bufs[transfer_id] = malloc (
strmh->cur_ctrl.dwMaxPayloadTransferSize );
libusb_fill_bulk_transfer ( transfer, strmh->devh->usb_devh,
format_desc->parent->bEndpointAddress,
strmh->transfer_bufs[transfer_id],
strmh->cur_ctrl.dwMaxPayloadTransferSize, _uvc_stream_callback,
( void* ) strmh, 5000 );

Please let me know if you can get the UART debug prints on the custom board. Also, let me know if you could stream using guvcview app.


I haven't been able to get UART debug for now. guvcview seems to works. I activated LIBUSB_DEBUG=3 ang get this message:

libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=16

The messages around it are:

[device.c:1617] begin uvc_close
[device.c:909] begin uvc_release_if
[device.c:910/uvc_release_if] releasing interface 0
[device.c:1800] begin _uvc_status_callback
[device.c:1778] begin uvc_process_status_xfer
[device.c:1793] end uvc_process_status_xfer
[device.c:929/uvc_release_if] reattached kernel driver to interface 0
[device.c:938] end uvc_release_if (0)
libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=16
[device.c:1825/_uvc_status_callback] libusb_submit_transfer() = -1
[device.c:1827] end _uvc_status_callback
[device.c:852] begin uvc_unref_device
[device.c:860] end uvc_unref_device
[device.c:1595] begin uvc_free_devh
[device.c:421] begin uvc_free_device_info
[device.c:474] end uvc_free_device_info
[device.c:1605] end uvc_free_devh
[device.c:1643] end uvc_close
[device.c:852] begin uvc_unref_device
[device.c:860] end uvc_unref_device
[device.c:138] begin uvc_find_device
[device.c:600] begin uvc_get_device_list
[device.c:675/uvc_get_device_list] non-UVC: 0
[device.c:836] begin uvc_ref_device
[device.c:841] end uvc_ref_device
[device.c:673/uvc_get_device_list]     UVC: 1
[device.c:675/uvc_get_device_list] non-UVC: 2
[device.c:675/uvc_get_device_list] non-UVC: 3
[device.c:675/uvc_get_device_list] non-UVC: 4
[device.c:683] end uvc_get_device_list (0)
[device.c:496] begin uvc_get_device_descriptor
[device.c:538] end uvc_get_device_descriptor (0)
[device.c:550] begin uvc_free_device_descriptor
[device.c:563] end uvc_free_device_descriptor
[device.c:836] begin uvc_ref_device
[device.c:841] end uvc_ref_device
[device.c:699] begin uvc_free_device_list
[device.c:852] begin uvc_unref_device
[device.c:860] end uvc_unref_device
[device.c:709] end uvc_free_device_list
[device.c:171] end uvc_find_device (0)
[device.c:281] begin uvc_open
[device.c:284/uvc_open] libusb_open() = 0
[device.c:836] begin uvc_ref_device
[device.c:841] end uvc_ref_device
[device.c:374] begin uvc_get_device_info
[device.c:953] begin uvc_scan_control
[device.c:496] begin uvc_get_device_descriptor
[device.c:538] end uvc_get_device_descriptor (0)
[device.c:550] begin uvc_free_device_descriptor
[device.c:563] end uvc_free_device_descriptor
[device.c:1174] begin uvc_parse_vc
[device.c:1019] begin uvc_parse_vc_header
[device.c:1222] begin uvc_scan_streaming
[device.c:1537] begin uvc_parse_vs
[device.c:1259] begin uvc_parse_vs_input_header
[device.c:1265] end uvc_parse_vs_input_header (0)
[device.c:1586] end uvc_parse_vs (0)
[device.c:1537] begin uvc_parse_vs
[device.c:1276] begin uvc_parse_vs_format_uncompressed
[device.c:1295] end uvc_parse_vs_format_uncompressed (0)
[device.c:1586] end uvc_parse_vs (0)
[device.c:1537] begin uvc_parse_vs
[device.c:1423] begin uvc_parse_vs_frame_uncompressed
[device.c:1458] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1586] end uvc_parse_vs (0)
[device.c:1248] end uvc_scan_streaming (0)
[device.c:1049] end uvc_parse_vc_header (0)
[device.c:1205] end uvc_parse_vc (0)
[device.c:1174] begin uvc_parse_vc
[device.c:1063] begin uvc_parse_vc_input_terminal
[device.c:1084] end uvc_parse_vc_input_terminal (0)
[device.c:1205] end uvc_parse_vc (0)
[device.c:1174] begin uvc_parse_vc
[device.c:1098] begin uvc_parse_vc_processing_unit
[device.c:1109] end uvc_parse_vc_processing_unit (0)
[device.c:1205] end uvc_parse_vc (0)
[device.c:1174] begin uvc_parse_vc
[device.c:1145] begin uvc_parse_vc_extension_unit
[device.c:1159] end uvc_parse_vc_extension_unit (0)
[device.c:1205] end uvc_parse_vc (0)
[device.c:1174] begin uvc_parse_vc
[device.c:1205] end uvc_parse_vc (0)
[device.c:1005] end uvc_scan_control (0)
[device.c:399] end uvc_get_device_info (0)
[device.c:302/uvc_open] claiming control interface 0
[device.c:873] begin uvc_claim_if
[device.c:886/uvc_claim_if] claiming interface 0
[device.c:895] end uvc_claim_if (0)
[device.c:326/uvc_open] libusb_submit_transfer() = 0
[device.c:343] end uvc_open (0)
[stream.c:474] begin uvc_get_stream_ctrl_format_size
[stream.c:494/uvc_get_stream_ctrl_format_size] claiming streaming interface 1
[device.c:873] begin uvc_claim_if
[device.c:886/uvc_claim_if] claiming interface 1
[device.c:895] end uvc_claim_if (0)
[stream.c:533] end uvc_get_stream_ctrl_format_size (0)

 

I will keep debugging libuvc for now. Thank you very much for your repies

0 Likes
ptphucbk
Level 1
Level 1
5 replies posted First reply posted First question asked

 And here is the corrupted one:

Bus 001 Device 004: ID 04b4:00f8 Cypress Semiconductor Corp.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x04b4 Cypress Semiconductor Corp.
idProduct 0x00f8
bcdDevice 0.00
iManufacturer 1 (error)
iProduct 2 _v1?_.0
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 205
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
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 0
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 0
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.00
wTotalLength 80
dwClockFrequency 48.000000MHz
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 27648
wOcularFocalLength 732
bControlSize 1
bmControls 0x00000001
Scanning Mode
junk at descriptor end: 12 24
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 0x00160f05
(Missing must-be-set LPM bit!)
buf[0] = 2
Device Status: 0x0000
(Bus Powered)

 

0 Likes
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

Please let me know if you can try using some other Host application compatible to libuvc. 

As the video streaming works with guvcview, it doesn't seem that the problem is on the device side

Regards,
Rashi
0 Likes