espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.25k stars 7.19k forks source link

Configuration descriptor larger than control transfer max length (IDFGH-8401) #9868

Open nopnop2002 opened 1 year ago

nopnop2002 commented 1 year ago

Answers checklist.

IDF version.

ESP-IDF v5.1-dev-862-g09f7589ef2-dirty

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

No response

Development Kit.

A board using Ai-Thinker's ESP-S3-12K

Power Supply used.

USB

What is the expected behavior?

I tried this example. https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/uvc

With This USB camera(SANWA) it works fine.

$ sudo v4l2-ctl --all
Driver Info:
        Driver name      : uvcvideo
        Card type        : USB 2.0 Camera: USB Camera
        Bus info         : usb-0000:00:1d.0-1.2
        Driver version   : 5.15.53
        Capabilities     : 0x84a00001
                Video Capture
                Metadata Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : uvcvideo
        Model            : USB 2.0 Camera: USB Camera
        Serial           :
        Bus info         : usb-0000:00:1d.0-1.2
        Media version    : 5.15.53
        Hardware revision: 0x00000000 (0)
        Driver version   : 5.15.53
Interface Info:
        ID               : 0x03000002
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : USB 2.0 Camera: USB Camera
        Function         : V4L2 I/O
        Flags         : default
        Pad 0x01000007   : 0: Sink
          Link 0x02000010: from remote pad 0x100000a of entity 'Extension 4': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 640/480
        Pixel Format      : 'YUYV' (YUYV 4:2:2)
        Field             : None
        Bytes per Line    : 1280
        Size Image        : 614400
        Colorspace        : Default
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             :
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 640, Height 480
        Default     : Left 0, Top 0, Width 640, Height 480
        Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 25.000 (25/1)
        Read buffers     : 0
                     brightness 0x00980900 (int)    : min=-64 max=128 step=1 default=112 value=112
                       contrast 0x00980901 (int)    : min=0 max=64 step=1 default=34 value=34
                     saturation 0x00980902 (int)    : min=1 max=128 step=1 default=57 value=57
                            hue 0x00980903 (int)    : min=-8 max=8 step=1 default=0 value=0
                          gamma 0x00980910 (int)    : min=0 max=8 step=1 default=4 value=4
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1
                                0: Disabled
                                1: 50 Hz
                                2: 60 Hz
                      sharpness 0x0098091b (int)    : min=0 max=6 step=1 default=4 value=4
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
                                1: Manual Mode
                                3: Aperture Priority Mode
              exposure_absolute 0x009a0902 (int)    : min=1 max=5000 step=1 default=625 value=625 flags=inactive
         exposure_auto_priority 0x009a0903 (bool)   : default=0 value=1

However, Using the Logitech C615 I get the following error:

E (2502) HUB: Configuration descriptor larger than control transfer max length
E (2502) HUB: Stage failed: CHECK_SHORT_CONFIG_DESC
$ sudo v4l2-ctl --all
Driver Info:
        Driver name      : uvcvideo
        Card type        : HD Webcam C615
        Bus info         : usb-0000:00:1d.0-1.2
        Driver version   : 5.15.53
        Capabilities     : 0x84a00001
                Video Capture
                Metadata Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : uvcvideo
        Model            : HD Webcam C615
        Serial           : 205F2260
        Bus info         : usb-0000:00:1d.0-1.2
        Media version    : 5.15.53
        Hardware revision: 0x00000011 (17)
        Driver version   : 5.15.53
Interface Info:
        ID               : 0x03000002
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : HD Webcam C615
        Function         : V4L2 I/O
        Flags         : default
        Pad 0x01000007   : 0: Sink
          Link 0x02000019: from remote pad 0x100000a of entity 'Extension 5': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 640/480
        Pixel Format      : 'YUYV' (YUYV 4:2:2)
        Field             : None
        Bytes per Line    : 1280
        Size Image        : 614400
        Colorspace        : sRGB
        Transfer Function : Rec. 709
        YCbCr/HSV Encoding: ITU-R 601
        Quantization      : Default (maps to Limited Range)
        Flags             :
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 640, Height 480
        Default     : Left 0, Top 0, Width 640, Height 480
        Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 30.000 (30/1)
        Read buffers     : 0
                     brightness 0x00980900 (int)    : min=0 max=255 step=1 default=128 value=128
                       contrast 0x00980901 (int)    : min=0 max=255 step=1 default=32 value=32
                     saturation 0x00980902 (int)    : min=0 max=255 step=1 default=32 value=32
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
                           gain 0x00980913 (int)    : min=0 max=255 step=1 default=64 value=64
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=2 value=2
                                0: Disabled
                                1: 50 Hz
                                2: 60 Hz
      white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4000 value=4000 flags=inactive
                      sharpness 0x0098091b (int)    : min=0 max=255 step=1 default=22 value=22
         backlight_compensation 0x0098091c (int)    : min=0 max=1 step=1 default=1 value=1
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
                                1: Manual Mode
                                3: Aperture Priority Mode
              exposure_absolute 0x009a0902 (int)    : min=3 max=2047 step=1 default=166 value=166 flags=inactive
         exposure_auto_priority 0x009a0903 (bool)   : default=0 value=1
                   pan_absolute 0x009a0908 (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                  tilt_absolute 0x009a0909 (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                 focus_absolute 0x009a090a (int)    : min=0 max=255 step=17 default=51 value=51 flags=inactive
                     focus_auto 0x009a090c (bool)   : default=1 value=1
                  zoom_absolute 0x009a090d (int)    : min=1 max=5 step=1 default=1 value=1

What is the actual behavior?

Using the Logitech C615 I get the following error:

E (2502) HUB: Configuration descriptor larger than control transfer max length
E (2502) HUB: Stage failed: CHECK_SHORT_CONFIG_DESC

Steps to reproduce.

  1. Connect Logitech C615 to ESP32 Board
  2. Build Firmware

Debug Logs.

CHECK_SHORT_CONFIG_DESC

More Information.

No response

tore-espressif commented 1 year ago

idf.py menuconfig Component config -> USB-OTG -> Largest size (in bytes) of transfers to/from default endpoints

Set the value you need

nopnop2002 commented 1 year ago

@tore-espressif

Thank you for the reply.

Component config -> USB-OTG -> Largest size (in bytes) of transfers to/from default endpoints

I changed this value from 1024 to 4096.

uvc_find_device() is pass. But i get this fail.

Device found
DEVICE CONFIGURATION (046d:082c/2) ---
Status: idle
VideoControl:
        bcdUVC: 0x0100
VideoStreaming(1):
        bEndpointAddress: 129
        Formats:
        UncompressedFormat(1)
                  bits per pixel: 16
                  GUID: 5955593200001000800000aa00389b71 (YUY2)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-4608000
                          max frame size: 38400
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-6082560
                          max frame size: 50688
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
        MJPEGFormat(2)
                  bits per pixel: 0
                  GUID: 4d4a5047000000000000000000000000 (MJPG)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 640x480
                          bit rate: 24576000-147456000
                          max frame size: 614400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-9216000
                          max frame size: 38400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(3)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-12165120
                          max frame size: 50688
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(4)
                          capabilities: 01
                          size: 320x240
                          bit rate: 6144000-36864000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(5)
                          capabilities: 01
                          size: 432x240
                          bit rate: 8294400-49766400
                          max frame size: 207360
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(6)
                          capabilities: 01
                          size: 352x288
                          bit rate: 8110080-48660480
                          max frame size: 202752
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(7)
                          capabilities: 01
                          size: 640x360
                          bit rate: 18432000-110592000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
END DEVICE CONFIGURATION
E (32172) USBH: Dev 1 EP 0 Error
E (32172) Transfer failed: Status 1
E (32172) USBH: Device 1 gone
bmHint: 0001
bFormatIndex: 2
bFrameIndex: 4
dwFrameInterval: 333333
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 61
wCompWindowSize: 0
wDelay: 0
dwMaxVideoFrameSize: 38400
dwMaxPayloadTransferSize: 512
bInterfaceNumber: 3
transfer_status: 1E (32192) example: UVC error: Unknown error

assert failed: app_main main.c:231 (0)

CHECK_SHORT_CONFIG_DESC-2

app_main main.c:231 is

UVC_CHECK( uvc_start_streaming(devh, &ctrl, frame_callback, NULL, 0) );

nopnop2002 commented 1 year ago

I compared it with: https://github.com/libuvc/libuvc

"uvc_get_stream_ctrl_format_size" in esp-idf does not work properly.

Linux

uvc_get_stream_ctrl_format_size format=3 640x480 30fps
bmHint: 0001
bFormatIndex: 1
bFrameIndex: 1
dwFrameInterval: 333333
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 61
wCompWindowSize: 0
wDelay: 0
dwMaxVideoFrameSize: 614400
dwMaxPayloadTransferSize: 3060
bInterfaceNumber: 3
Streaming...
Enabling auto exposure ...
 ... full AE not supported, trying aperture priority mode
 ... enabled aperture priority auto exposure mode
callback! frame_format = 3, width = 640, height = 480, length = 614400, ptr = 12345
callback! frame_format = 3, width = 640, height = 480, length = 614400, ptr = 12345
callback! frame_format = 3, width = 640, height = 480, length = 614400, ptr = 12345
callback! frame_format = 3, width = 640, height = 480, length = 614400, ptr = 12345

ESP-IDF

I (23712) example: uvc_get_stream_ctrl_format_size FORMAT=3 640x480 FPS=15
Negotiating streaming format failed, trying again...
Negotiating streaming format failed, trying again...
Negotiating streaming format failed, trying again...
Negotiating streaming format failed, trying again...
nopnop2002 commented 1 year ago

Mayby libusb_open() issues.

uvc_print_diag() using Linux

DEVICE CONFIGURATION (046d:082c/205F2260) ---
Status: idle
VideoControl:
        bcdUVC: 0x0100
VideoStreaming(1):
        bEndpointAddress: 129
        Formats:
        UncompressedFormat(1)
                  bits per pixel: 16
                  GUID: 5955593200001000800000aa00389b71 (YUY2)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 640x480
                          bit rate: 24576000-147456000
                          max frame size: 614400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-9216000
                          max frame size: 38400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(3)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-12165120
                          max frame size: 50688
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(4)
                          capabilities: 01
                          size: 320x240
                          bit rate: 6144000-36864000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(5)
                          capabilities: 01
                          size: 432x240
                          bit rate: 8294400-49766400
                          max frame size: 207360
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(6)
                          capabilities: 01
                          size: 352x288
                          bit rate: 8110080-48660480
                          max frame size: 202752
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(7)
                          capabilities: 01
                          size: 640x360
                          bit rate: 18432000-110592000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(8)
                          capabilities: 01
                          size: 800x448
                          bit rate: 28672000-172032000
                          max frame size: 716800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(9)
                          capabilities: 01
                          size: 864x480
                          bit rate: 33177600-159252480
                          max frame size: 829440
                          default interval: 1/24
                          interval[0]: 1/24
                          interval[1]: 1/20
                          interval[2]: 1/15
                          interval[3]: 1/10
                          interval[4]: 1/7
                          interval[5]: 1/5
                        FrameDescriptor(10)
                          capabilities: 01
                          size: 1024x576
                          bit rate: 47185920-141557760
                          max frame size: 1179648
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
                        FrameDescriptor(11)
                          capabilities: 01
                          size: 800x600
                          bit rate: 38400000-184320000
                          max frame size: 960000
                          default interval: 1/24
                          interval[0]: 1/24
                          interval[1]: 1/20
                          interval[2]: 1/15
                          interval[3]: 1/10
                          interval[4]: 1/7
                          interval[5]: 1/5
                        FrameDescriptor(12)
                          capabilities: 01
                          size: 960x720
                          bit rate: 55296000-165888000
                          max frame size: 1382400
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
                        FrameDescriptor(13)
                          capabilities: 01
                          size: 1280x720
                          bit rate: 73728000-147456000
                          max frame size: 1843200
                          default interval: 1/10
                          interval[0]: 1/10
                          interval[1]: 1/7
                          interval[2]: 1/5
                        FrameDescriptor(14)
                          capabilities: 01
                          size: 1600x896
                          bit rate: 114688000-172032000
                          max frame size: 2867200
                          default interval: 1/7
                          interval[0]: 1/7
                          interval[1]: 1/5
                        FrameDescriptor(15)
                          capabilities: 01
                          size: 1920x1080
                          bit rate: 165888000-165888000
                          max frame size: 4147200
                          default interval: 1/5
                          interval[0]: 1/5
        MJPEGFormat(2)
                  bits per pixel: 0
                  GUID: 4d4a5047000000000000000000000000 (MJPG)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 640x480
                          bit rate: 24576000-147456000
                          max frame size: 614400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-9216000
                          max frame size: 38400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(3)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-12165120
                          max frame size: 50688
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(4)
                          capabilities: 01
                          size: 320x240
                          bit rate: 6144000-36864000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(5)
                          capabilities: 01
                          size: 432x240
                          bit rate: 8294400-49766400
                          max frame size: 207360
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(6)
                          capabilities: 01
                          size: 352x288
                          bit rate: 8110080-48660480
                          max frame size: 202752
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(7)
                          capabilities: 01
                          size: 640x360
                          bit rate: 18432000-110592000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(8)
                          capabilities: 01
                          size: 800x448
                          bit rate: 28672000-172032000
                          max frame size: 716800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(9)
                          capabilities: 01
                          size: 864x480
                          bit rate: 33177600-199065600
                          max frame size: 829440
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(10)
                          capabilities: 01
                          size: 1024x576
                          bit rate: 47185920-283115520
                          max frame size: 1179648
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(11)
                          capabilities: 01
                          size: 800x600
                          bit rate: 38400000-230400000
                          max frame size: 960000
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(12)
                          capabilities: 01
                          size: 960x720
                          bit rate: 55296000-331776000
                          max frame size: 1382400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(13)
                          capabilities: 01
                          size: 1280x720
                          bit rate: 73728000-442368000
                          max frame size: 1843200
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(14)
                          capabilities: 01
                          size: 1600x896
                          bit rate: 114688000-688128000
                          max frame size: 2867200
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(15)
                          capabilities: 01
                          size: 1920x1080
                          bit rate: 165888000-995328000
                          max frame size: 4147200
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
END DEVICE CONFIGURATION

uvc_print_diag() using ESP-IDF

DEVICE CONFIGURATION (046d:082c/2) ---
Status: idle
VideoControl:
        bcdUVC: 0x0100
VideoStreaming(1):
        bEndpointAddress: 129
        Formats:
        UncompressedFormat(1)
                  bits per pixel: 16
                  GUID: 5955593200001000800000aa00389b71 (YUY2)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-4608000
                          max frame size: 38400
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-6082560
                          max frame size: 50688
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
        MJPEGFormat(2)
                  bits per pixel: 0
                  GUID: 4d4a5047000000000000000000000000 (MJPG)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 640x480
                          bit rate: 24576000-147456000
                          max frame size: 614400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-9216000
                          max frame size: 38400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(3)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-12165120
                          max frame size: 50688
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(4)
                          capabilities: 01
                          size: 320x240
                          bit rate: 6144000-36864000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(5)
                          capabilities: 01
                          size: 432x240
                          bit rate: 8294400-49766400
                          max frame size: 207360
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(6)
                          capabilities: 01
                          size: 352x288
                          bit rate: 8110080-48660480
                          max frame size: 202752
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(7)
                          capabilities: 01
                          size: 640x360
                          bit rate: 18432000-110592000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
END DEVICE CONFIGURATION
tore-espressif commented 6 months ago

@nopnop2002 I'm very sorry for the extra ordinary slow response. As you can see from your logs, the USB camera descriptors differs for HighSpeed (linux) and FullSpeed (esp32-sx).

In latest master branch we merged bunch fixes for USB cameras. Could you try again?

nopnop2002 commented 6 months ago

@tore-espressif

Thank you for your reply. I tried this sample on the latest master branch.

$ idf.py --version
ESP-IDF v5.3-dev-2381-g9f4e8eb0cd

Using the Logitech C615 I get the following error:

I (32429) example: Waiting for USB UVC device connection ...
I (32449) example: Device found
DEVICE CONFIGURATION (046d:082c/2) ---
Status: idle
VideoControl:
        bcdUVC: 0x0100
VideoStreaming(1):
        bEndpointAddress: 129
        Formats:
        UncompressedFormat(1)
                  bits per pixel: 16
                  GUID: 5955593200001000800000aa00389b71 (YUY2)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-4608000
                          max frame size: 38400
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-6082560
                          max frame size: 50688
                          default interval: 1/15
                          interval[0]: 1/15
                          interval[1]: 1/10
                          interval[2]: 1/7
                          interval[3]: 1/5
        MJPEGFormat(2)
                  bits per pixel: 0
                  GUID: 4d4a5047000000000000000000000000 (MJPG)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 01
                          size: 640x480
                          bit rate: 24576000-147456000
                          max frame size: 614400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(2)
                          capabilities: 01
                          size: 160x120
                          bit rate: 1536000-9216000
                          max frame size: 38400
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(3)
                          capabilities: 01
                          size: 176x144
                          bit rate: 2027520-12165120
                          max frame size: 50688
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(4)
                          capabilities: 01
                          size: 320x240
                          bit rate: 6144000-36864000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(5)
                          capabilities: 01
                          size: 432x240
                          bit rate: 8294400-49766400
                          max frame size: 207360
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(6)
                          capabilities: 01
                          size: 352x288
                          bit rate: 8110080-48660480
                          max frame size: 202752
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
                        FrameDescriptor(7)
                          capabilities: 01
                          size: 640x360
                          bit rate: 18432000-110592000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
                          interval[1]: 1/24
                          interval[2]: 1/20
                          interval[3]: 1/15
                          interval[4]: 1/10
                          interval[5]: 1/7
                          interval[6]: 1/5
END DEVICE CONFIGURATION
I (32739) example: Negotiate streaming profile 640x480, fps 15 ...
E (32759) USBH: Dev 1 EP 0 Error
E (32759) Transfer failed: Status 1
E (32759) USBH: Device 1 gone
transfer_status: 1I (32759) example: Negotiation complete.
bmHint: 0001
bFormatIndex: 2
bFrameIndex: 1
dwFrameInterval: 666666
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 61
wCompWindowSize: 0
wDelay: 0
dwMaxVideoFrameSize: 38400
dwMaxPayloadTransferSize: 512
bInterfaceNumber: 3
E (32789) example: UVC error: Unknown error
tore-espressif commented 5 months ago

@nopnop2002 Thanks for the log. Transfer failed: Status 1 on endpoint 0 is really rare. It means that the camera failed to respond on EP0. This usually indicates a problem on the device side (we saw similar behavior with some HighSpeed devices connected to FullSpeed host - such as ESP32-S3)

We'd need a USB trace to see what exactly caused the problem.

The USB Video class will get more attention from us in upcoming weeks/months so I hope we can reproduce and fix on our side

nopnop2002 commented 5 months ago

@tore-espressif

We'd need a USB trace to see what exactly caused the problem.

Please let me know if there is anything I can do.

tore-espressif commented 2 hours ago

In the past 6 months we have tested with a dozen of different USB cameras and we did not see similar error. We can keep this open if someone gets the same error

nopnop2002 commented 44 minutes ago

@tore-espressif

In the past 6 months we have tested with a dozen of different USB cameras and we did not see similar error.

I would like to know the device ID of a USB camera that works properly. We can check the device ID with lsusb.