diff --git a/components/usb/esp_usbh_cdc/Kconfig b/components/usb/esp_usbh_cdc/Kconfig index 3fb23abf0..d2c644027 100644 --- a/components/usb/esp_usbh_cdc/Kconfig +++ b/components/usb/esp_usbh_cdc/Kconfig @@ -1,5 +1,10 @@ menu "USB Host CDC" - + config CDC_GET_DEVICE_DESC + bool "Get device descriptor during emum" + default y + config CDC_GET_CONFIG_DESC + bool "Get config descriptor during emum" + default y config CDC_SEND_DTE_ACTIVE bool "Set control line state during init" default y @@ -15,6 +20,10 @@ menu "USB Host CDC" default 5 help usb task base priority, usb task = base + 2, cdc task = base + 1 + config CTRL_TRANSFER_DATA_MAX_BYTES + int "Max control transfer data size (Bytes)" + range 64 2048 + default 256 config CDC_BULK_IN_URB_NUM int "cdc bulk_in urb num" default 2 diff --git a/components/usb/esp_usbh_cdc/esp_usbh_cdc.c b/components/usb/esp_usbh_cdc/esp_usbh_cdc.c index 582d9daa0..d0fda18a0 100644 --- a/components/usb/esp_usbh_cdc/esp_usbh_cdc.c +++ b/components/usb/esp_usbh_cdc/esp_usbh_cdc.c @@ -30,6 +30,7 @@ #include "hcd.h" #include "usb/usb_types_stack.h" #include "usb_private.h" +#include "usb/usb_helpers.h" #include "esp_private/usb_phy.h" #include "esp_usbh_cdc.h" @@ -47,12 +48,15 @@ static const char *TAG = "USB_HCDC"; #define USB_PORT_NUM 1 //Default port number #define USB_DEVICE_ADDR 1 //Default CDC device address +#define USB_ENUM_CONFIG_INDEX 0 //Index of the first configuration of the device +#define USB_ENUM_SHORT_DESC_REQ_LEN 8 //Number of bytes to request when getting a short descriptor (just enough to get bMaxPacketSize0 or wTotalLength) #define USB_DEVICE_CONFIG 1 //Default CDC device configuration #define USB_EP_CTRL_DEFAULT_MPS 64 //Default MPS(max payload size) of Endpoint 0 #define CDC_EVENT_QUEUE_LEN 16 #define DATA_EVENT_QUEUE_LEN 32 -#define CTRL_TRANSFER_DATA_MAX_BYTES 256 //Just assume that will only IN/OUT 256 bytes in ctrl pipe +#define CTRL_TRANSFER_DATA_MAX_BYTES CONFIG_CTRL_TRANSFER_DATA_MAX_BYTES //Just assume that will only IN/OUT 256 bytes in ctrl pipe #define TIMEOUT_USB_RINGBUF_MS 200 //Timeout for Ring Buffer push +#define TIMEOUT_USB_CTRL_XFER_MS 5000 //Timeout for USB control transfer #define USB_TASK_BASE_PRIORITY CONFIG_USB_TASK_BASE_PRIORITY @@ -674,6 +678,90 @@ static esp_err_t _default_pipe_event_wait_until(hcd_pipe_handle_t expected_pipe_ /*------------------------------------------------ USB Control Process Code ----------------------------------------------------*/ +#ifdef CONFIG_CDC_GET_DEVICE_DESC +static esp_err_t _usb_get_dev_desc(hcd_pipe_handle_t pipe_handle, usb_device_desc_t *device_desc) +{ + CDC_CHECK(pipe_handle != NULL, "pipe_handle can't be NULL", ESP_ERR_INVALID_ARG); + //malloc URB for default control + urb_t *urb_ctrl = _usb_urb_alloc(0, sizeof(usb_setup_packet_t) + CTRL_TRANSFER_DATA_MAX_BYTES, NULL); + CDC_CHECK(urb_ctrl != NULL, "alloc urb failed", ESP_ERR_NO_MEM); + urb_t *urb_done = NULL; + ESP_LOGI(TAG, "get device desc"); + USB_SETUP_PACKET_INIT_GET_DEVICE_DESC((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer); + urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + usb_round_up_to_mps(sizeof(usb_device_desc_t), USB_EP_CTRL_DEFAULT_MPS); + esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); + CDC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); + CDC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); + urb_done = hcd_urb_dequeue(pipe_handle); + CDC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); + CDC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); + CDC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + sizeof(usb_device_desc_t)), "urb status: data overflow", free_urb_); + ESP_LOGI(TAG, "get device desc, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); + usb_device_desc_t *dev_desc = (usb_device_desc_t *)(urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); + if (device_desc != NULL ) *device_desc = *dev_desc; + usb_print_device_descriptor(dev_desc); + goto free_urb_; + +flush_urb_: + _usb_pipe_flush(pipe_handle, 1); +free_urb_: + _usb_urb_free(urb_ctrl); + return ret; +} +#endif + +#ifdef CONFIG_CDC_GET_CONFIG_DESC +static esp_err_t _usb_get_config_desc(hcd_pipe_handle_t pipe_handle, usb_config_desc_t **config_desc) +{ + (void)config_desc; + CDC_CHECK(pipe_handle != NULL, "pipe_handle can't be NULL", ESP_ERR_INVALID_ARG); + //malloc URB for default control + urb_t *urb_ctrl = _usb_urb_alloc(0, sizeof(usb_setup_packet_t) + CTRL_TRANSFER_DATA_MAX_BYTES, NULL); + CDC_CHECK(urb_ctrl != NULL, "alloc urb failed", ESP_ERR_NO_MEM); + urb_t *urb_done = NULL; + ESP_LOGI(TAG, "get short config desc"); + USB_SETUP_PACKET_INIT_GET_CONFIG_DESC((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer, USB_ENUM_CONFIG_INDEX, USB_ENUM_SHORT_DESC_REQ_LEN); + urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + usb_round_up_to_mps(sizeof(usb_config_desc_t), USB_EP_CTRL_DEFAULT_MPS); + esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); + CDC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); + CDC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); + urb_done = hcd_urb_dequeue(pipe_handle); + CDC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); + CDC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); + CDC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + sizeof(usb_config_desc_t)), "urb status: data overflow", free_urb_); + ESP_LOGI(TAG, "get config desc, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); + usb_config_desc_t *cfg_desc = (usb_config_desc_t *)(urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); + uint16_t full_config_length = cfg_desc->wTotalLength; + if (cfg_desc->wTotalLength > CTRL_TRANSFER_DATA_MAX_BYTES) { + ESP_LOGE(TAG, "Configuration descriptor larger than control transfer max length"); + goto free_urb_; + } + ESP_LOGI(TAG, "get full config desc"); + USB_SETUP_PACKET_INIT_GET_CONFIG_DESC((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer, USB_ENUM_CONFIG_INDEX, full_config_length); + urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + usb_round_up_to_mps(full_config_length, USB_EP_CTRL_DEFAULT_MPS); + ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); + CDC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); + CDC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); + urb_done = hcd_urb_dequeue(pipe_handle); + CDC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); + CDC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); + CDC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + full_config_length), "urb status: data overflow", free_urb_); + ESP_LOGI(TAG, "get full config desc, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); + cfg_desc = (usb_config_desc_t *)(urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); + usb_print_config_descriptor(cfg_desc, NULL); + goto free_urb_; + +flush_urb_: + _usb_pipe_flush(pipe_handle, 1); +free_urb_: + _usb_urb_free(urb_ctrl); + return ret; +} +#endif + static esp_err_t _usb_set_device_addr(hcd_pipe_handle_t pipe_handle, uint8_t dev_addr) { CDC_CHECK(pipe_handle != NULL, "pipe_handle can't be NULL", ESP_ERR_INVALID_ARG); @@ -688,7 +776,7 @@ static esp_err_t _usb_set_device_addr(hcd_pipe_handle_t pipe_handle, uint8_t dev ESP_LOGI(TAG, "Set Device Addr = %u", dev_addr); esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); CDC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); CDC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_t *urb_done = hcd_urb_dequeue(pipe_handle); CDC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -721,7 +809,7 @@ static esp_err_t _usb_set_device_config(hcd_pipe_handle_t pipe_handle, uint16_t ESP_LOGI(TAG, "Set Device Configuration = %u", configuration); esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); CDC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); CDC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_t *urb_done = hcd_urb_dequeue(pipe_handle); CDC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -750,7 +838,7 @@ static esp_err_t _usb_set_device_line_state(hcd_pipe_handle_t pipe_handle, bool ESP_LOGI(TAG, "Set Device Line State: dtr %d, rts %d", dtr, rts); esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); CDC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, portMAX_DELAY); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); CDC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_t *urb_done = hcd_urb_dequeue(pipe_handle); CDC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -1073,6 +1161,14 @@ static void _usb_processing_task(void *arg) ret = _usb_set_device_addr(pipe_hdl_dflt, USB_DEVICE_ADDR); CDC_CHECK_GOTO(ESP_OK == ret, "Set device address failed", usb_driver_reset_); +#ifdef CONFIG_CDC_GET_DEVICE_DESC + ret = _usb_get_dev_desc(pipe_hdl_dflt, NULL); + CDC_CHECK_GOTO(ESP_OK == ret, "Get device descriptor failed", usb_driver_reset_); +#endif +#ifdef CONFIG_CDC_GET_CONFIG_DESC + ret = _usb_get_config_desc(pipe_hdl_dflt, NULL); + CDC_CHECK_GOTO(ESP_OK == ret, "Get config descriptor failed", usb_driver_reset_); +#endif _update_device_state(CDC_DEVICE_STATE_ADDRESS); ret = _usb_set_device_config(pipe_hdl_dflt, USB_DEVICE_CONFIG); CDC_CHECK_GOTO(ESP_OK == ret, "Set device configuration failed", usb_driver_reset_); diff --git a/components/usb/uvc_stream/CMakeLists.txt b/components/usb/uvc_stream/CMakeLists.txt index 1e48b3d8c..6e497f1f8 100644 --- a/components/usb/uvc_stream/CMakeLists.txt +++ b/components/usb/uvc_stream/CMakeLists.txt @@ -21,7 +21,7 @@ endif() #ESP-IDF USB component HCD level API default to private now, #to use uvc_stream, related API must manually set to public. -idf_component_register(SRCS uvc_stream.c +idf_component_register(SRCS uvc_stream.c descriptor.c INCLUDE_DIRS "include" "${IDF_PATH}/components/usb/private_include" EMBED_FILES ${embed_files} REQUIRES usb) diff --git a/components/usb/uvc_stream/Kconfig b/components/usb/uvc_stream/Kconfig index 6bfbab474..b64ed1fd4 100644 --- a/components/usb/uvc_stream/Kconfig +++ b/components/usb/uvc_stream/Kconfig @@ -1,11 +1,27 @@ menu "UVC Stream" + config CTRL_TRANSFER_DATA_MAX_BYTES + int "Max control transfer data size (Bytes)" + range 64 2048 + default 600 + config UVC_GET_DEVICE_DESC + bool "Get camera device descriptor during emum" + default y + config UVC_GET_CONFIG_DESC + bool "Get camera config descriptor during emum" + default y + config UVC_PRINT_DESC_VERBOSE + bool "Print camera more descriptor info" + default n + config UVC_PRINT_PROBE_RESULT + bool "Print video cur probe result" + default y config SOURCE_SIMULATE bool "Enable Simulate Pictures From Flash" - default false + default n config TRIGGER_PIN bool "Enable Trigger Pin For Debug" - default false + default n endmenu \ No newline at end of file diff --git a/components/usb/uvc_stream/descriptor.c b/components/usb/uvc_stream/descriptor.c new file mode 100644 index 000000000..ac3e2bf67 --- /dev/null +++ b/components/usb/uvc_stream/descriptor.c @@ -0,0 +1,287 @@ +// Copyright 2016-2022 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License + +#include +#include +#include + +#include "esp_log.h" +#include "usb/usb_host.h" +#include "usb/usb_types_ch9.h" + +typedef enum { + CS_INTERFACE_DESC = 0x24, + CS_ENDPOINT_DESC = 0x25, +} descriptor_types_t; + +typedef enum { + SC_VIDEOCONTROL = 1, + SC_VIDEOSTREAMING = 2, +} interface_sub_class_t; + +static interface_sub_class_t interface_sub_class = SC_VIDEOCONTROL; + +typedef enum { + VC_HEADER = 0x01, + VC_INPUT_TERMINAL = 0x02, + VC_OUTPUT_TERMINAL = 0x03, + VC_SELECTOR_UNIT = 0x04, + VC_PROCESSING_UNIT = 0x05, + VS_FORMAT_MJPEG = 0x06, + VS_FRAME_MJPEG = 0x07, + VS_STILL_FRAME = 0x03, + VS_COLORFORMAT = 0x0D, +} descriptor_subtypes_t; + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bDescriptorSubtype; +} desc_header_t; + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bFirstInterface; + uint8_t bInterfaceCount; + uint8_t bFunctionClass; + uint8_t bFunctionSubClass; + uint8_t bFunctionProtocol; + uint8_t iFunction; +} USB_DESC_ATTR ifc_assoc_desc_t; + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bDescriptorSubType; + uint16_t bcdUVC; + uint16_t wTotalLength; + uint32_t dwClockFrequency; + uint8_t bFunctionProtocol; + uint8_t bInCollection; + uint8_t baInterfaceNr; +} USB_DESC_ATTR vc_interface_desc_t; + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bDescriptorSubType; + uint8_t bNumFormats; + uint16_t wTotalLength; + uint8_t bEndpointAddress; + uint8_t bFunctionProtocol; + uint8_t bmInfo; + uint8_t bTerminalLink; + uint8_t bStillCaptureMethod; + uint8_t bTriggerSupport; + uint8_t bTriggerUsage; + uint8_t bControlSize; + uint8_t bmaControls; +} USB_DESC_ATTR vs_interface_desc_t; + + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bDescriptorSubType; + uint16_t wMaxTransferSize; +} USB_DESC_ATTR class_specific_endpoint_desc_t; + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bDescriptorSubType; + uint8_t bFormatIndex; + uint8_t bNumFrameDescriptors; + uint8_t bmFlags; + uint8_t bDefaultFrameIndex; + uint8_t bAspectRatioX; + uint8_t bAspectRatioY; + uint8_t bmInterlaceFlags; + uint8_t bCopyProtect; +} USB_DESC_ATTR vs_format_desc_t; + +typedef struct { + uint8_t bLength; + uint8_t bDescriptorType; + uint8_t bDescriptorSubType; + uint8_t bFrameIndex; + uint8_t bmCapabilities; + uint16_t wWidth; + uint16_t wHeigh; + uint32_t dwMinBitRate; + uint32_t dwMaxBitRate; + uint32_t dwMaxVideoFrameBufSize; + uint32_t dwDefaultFrameInterval; + uint8_t bFrameIntervalType; + union { + uint32_t dwFrameInterval; + struct { + uint32_t dwMinFrameInterval; + uint32_t dwMaxFrameInterval; + uint32_t dwFrameIntervalStep; + }; + }; +} USB_DESC_ATTR vs_frame_desc_t; + + +static void print_class_header_desc(const uint8_t *buff) +{ + if (interface_sub_class == SC_VIDEOCONTROL) { + const vc_interface_desc_t *desc = (const vc_interface_desc_t *) buff; +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\t*** Class-specific VC Interface Descriptor ***\n"); + printf("\tbLength 0x%x\n", desc->bLength); + printf("\tbDescriptorType 0x%x\n", desc->bDescriptorType); + printf("\tbDescriptorSubType %u\n", desc->bDescriptorSubType); +#endif + printf("\tbcdUVC %x\n", desc->bcdUVC); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\twTotalLength %u\n", desc->wTotalLength); + printf("\tdwClockFrequency %u\n", desc->dwClockFrequency); + printf("\tbFunctionProtocol %u\n", desc->bFunctionProtocol); + printf("\tbInCollection %u\n", desc->bInCollection); + printf("\tbaInterfaceNr %u\n", desc->baInterfaceNr); +#endif + } else if (interface_sub_class == SC_VIDEOSTREAMING) { + const vs_interface_desc_t *desc = (const vs_interface_desc_t *) buff; + printf("\t*** Class-specific VS Interface Descriptor ***\n"); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tbLength 0x%x\n", desc->bLength); + printf("\tbDescriptorType 0x%x\n", desc->bDescriptorType); + printf("\tbDescriptorSubType %u\n", desc->bDescriptorSubType); +#endif + printf("\tbNumFormats %x\n", desc->bNumFormats); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\twTotalLength %u\n", desc->wTotalLength); + printf("\tbEndpointAddress %u\n", desc->bEndpointAddress); + printf("\tbFunctionProtocol %u\n", desc->bFunctionProtocol); + printf("\tbmInfo 0x%x\n", desc->bmInfo); + printf("\tbTerminalLink %u\n", desc->bTerminalLink); + printf("\tbStillCaptureMethod %u\n", desc->bStillCaptureMethod); + printf("\tbTriggerSupport %u\n", desc->bTriggerSupport); + printf("\tbTriggerUsage %u\n", desc->bTriggerUsage); + printf("\tbControlSize %u\n", desc->bControlSize); + printf("\tbmaControls 0x%x\n", desc->bmaControls); +#endif + } +} + +static void print_vs_format_mjpeg_desc(const uint8_t *buff) +{ + const vs_format_desc_t *desc = (const vs_format_desc_t *) buff; + printf("\t*** VS Format MJPEG Descriptor ***\n"); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tbLength 0x%x\n", desc->bLength); + printf("\tbDescriptorType 0x%x\n", desc->bDescriptorType); + printf("\tbDescriptorSubType 0x%x\n", desc->bDescriptorSubType); +#endif + printf("\tbFormatIndex 0x%x\n", desc->bFormatIndex); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tbNumFrameDescriptors %u\n", desc->bNumFrameDescriptors); + printf("\tbmFlags 0x%x\n", desc->bmFlags); +#endif + printf("\tbDefaultFrameIndex %u\n", desc->bDefaultFrameIndex); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tbAspectRatioX %u\n", desc->bAspectRatioX); + printf("\tbAspectRatioY %u\n", desc->bAspectRatioY); + printf("\tbmInterlaceFlags 0x%x\n", desc->bmInterlaceFlags); + printf("\tbCopyProtect %u\n", desc->bCopyProtect); +#endif +} + +static void print_vs_frame_mjpeg_desc(const uint8_t *buff) +{ + // Copy to local buffer due to potential misalignment issues. + uint32_t raw_desc[25]; + uint32_t desc_size = ((const vs_frame_desc_t *)buff)->bLength; + memcpy(raw_desc, buff, desc_size); + + const vs_frame_desc_t *desc = (const vs_frame_desc_t *) raw_desc; + printf("\t*** VS MJPEG Frame Descriptor ***\n"); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tbLength 0x%x\n", desc->bLength); + printf("\tbDescriptorType 0x%x\n", desc->bDescriptorType); + printf("\tbDescriptorSubType 0x%x\n", desc->bDescriptorSubType); +#endif + printf("\tbFrameIndex 0x%x\n", desc->bFrameIndex); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tbmCapabilities 0x%x\n", desc->bmCapabilities); +#endif + printf("\twWidth %u\n", desc->wWidth); + printf("\twHeigh %u\n", desc->wHeigh); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tdwMinBitRate %u\n", desc->dwMinBitRate); + printf("\tdwMaxBitRate %u\n", desc->dwMaxBitRate); +#endif + printf("\tdwMaxVideoFrameBufSize %u\n", desc->dwMaxVideoFrameBufSize); +#ifdef CONFIG_UVC_PRINT_DESC_VERBOSE + printf("\tdwDefaultFrameInterval %u\n", desc->dwDefaultFrameInterval); + printf("\tbFrameIntervalType %u\n", desc->bFrameIntervalType); +#endif + + if (desc->bFrameIntervalType == 0) { + // Continuous Frame Intervals + printf("\tdwMinFrameInterval %u\n", desc->dwMinFrameInterval); + printf("\tdwMaxFrameInterval %u\n", desc->dwMaxFrameInterval); + printf("\tdwFrameIntervalStep %u\n", desc->dwFrameIntervalStep); + } else { + // Discrete Frame Intervals + size_t num_of_intervals = (desc->bLength - 26) / 4; + uint32_t *interval = (uint32_t *)&desc->dwFrameInterval; + for (int i = 0; i < num_of_intervals; ++i) { + printf("\tFrameInterval[%d] %u\n", i, interval[i]); + } + } +} + + +static void print_class_specific_desc(const uint8_t *buff) +{ + desc_header_t *header = (desc_header_t *)buff; + + switch (header->bDescriptorSubtype) { + case VC_HEADER: + print_class_header_desc(buff); + break; + case VS_FORMAT_MJPEG: + if (interface_sub_class == SC_VIDEOCONTROL) { + printf("\t*** Extension Unit Descriptor unsupported, skipping... ***\n");; + interface_sub_class = SC_VIDEOSTREAMING; + return; + } + print_vs_format_mjpeg_desc(buff); + interface_sub_class = SC_VIDEOCONTROL; + break; + case VS_FRAME_MJPEG: + print_vs_frame_mjpeg_desc(buff); + break; + default: + break; + } +} + +void _print_uvc_class_descriptors_cb(const usb_standard_desc_t *desc) +{ + const uint8_t *buff = (uint8_t *)desc; + desc_header_t *header = (desc_header_t *)desc; + + switch (header->bDescriptorType) { + case CS_INTERFACE_DESC: + print_class_specific_desc(buff); + break; + default: + break; + } +} diff --git a/components/usb/uvc_stream/uvc_stream.c b/components/usb/uvc_stream/uvc_stream.c index 6e694be5c..6d71e292f 100644 --- a/components/usb/uvc_stream/uvc_stream.c +++ b/components/usb/uvc_stream/uvc_stream.c @@ -29,6 +29,8 @@ #include "hal/usbh_ll.h" #include "hcd.h" #include "usb/usb_types_stack.h" +#include "usb/usb_helpers.h" +#include "esp_private/usb_phy.h" #include "usb_private.h" #include "esp_log.h" #include "uvc_stream.h" @@ -53,14 +55,17 @@ const char *TAG = "UVC_STREAM"; */ #define USB_PORT_NUM 1 //Default port number #define USB_DEVICE_ADDR 1 //Default UVC device address +#define USB_ENUM_CONFIG_INDEX 0 //Index of the first configuration of the device +#define USB_ENUM_SHORT_DESC_REQ_LEN 8 //Number of bytes to request when getting a short descriptor (just enough to get bMaxPacketSize0 or wTotalLength) #define USB_EP_CTRL_DEFAULT_MPS 64 //Default MPS(max payload size) of Endpoint 0 #define USB_EP_ISOC_MAX_MPS 512 //Max MPS ESP32-S2/S3 can handle -#define CTRL_TRANSFER_DATA_MAX_BYTES 256 //Max data length assumed in control transfer +#define CTRL_TRANSFER_DATA_MAX_BYTES CONFIG_CTRL_TRANSFER_DATA_MAX_BYTES //Max data length assumed in control transfer #define NUM_ISOC_STREAM_URBS 4 //Number of isochronous stream URBS created for continuous enqueue #define NUM_PACKETS_PER_URB_URB 5 //Number of packets in each isochronous stream URB #define UVC_EVENT_QUEUE_LEN 30 //UVC event queue length #define FRAME_MAX_INTERVAL 2000000 //Specified in 100 ns units, General max frame interval (5 FPS) #define FRAME_MIN_INTERVAL 333333 //General min frame interval (30 FPS) +#define TIMEOUT_USB_CTRL_XFER_MS 5000 //Timeout for USB control transfer /** * @brief Task for USB I/O request and payload processing, @@ -803,6 +808,90 @@ static esp_err_t _default_pipe_event_wait_until(hcd_pipe_handle_t expected_pipe_ } /*------------------------------------------------ USB Control Process Code ----------------------------------------------------*/ +#ifdef CONFIG_UVC_GET_DEVICE_DESC +static esp_err_t _usb_get_dev_desc(hcd_pipe_handle_t pipe_handle, usb_device_desc_t *device_desc) +{ + UVC_CHECK(pipe_handle != NULL, "pipe_handle can't be NULL", ESP_ERR_INVALID_ARG); + //malloc URB for default control + urb_t *urb_ctrl = _usb_urb_alloc(0, sizeof(usb_setup_packet_t) + CTRL_TRANSFER_DATA_MAX_BYTES, NULL); + UVC_CHECK(urb_ctrl != NULL, "alloc urb failed", ESP_ERR_NO_MEM); + urb_t *urb_done = NULL; + ESP_LOGI(TAG, "get device desc"); + USB_SETUP_PACKET_INIT_GET_DEVICE_DESC((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer); + urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + usb_round_up_to_mps(sizeof(usb_device_desc_t), USB_EP_CTRL_DEFAULT_MPS); + esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); + UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); + UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); + urb_done = hcd_urb_dequeue(pipe_handle); + UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); + UVC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); + UVC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + sizeof(usb_device_desc_t)), "urb status: data overflow", free_urb_); + ESP_LOGI(TAG, "get device desc, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); + usb_device_desc_t *dev_desc = (usb_device_desc_t *)(urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); + if (device_desc != NULL ) *device_desc = *dev_desc; + usb_print_device_descriptor(dev_desc); + goto free_urb_; + +flush_urb_: + _usb_pipe_flush(pipe_handle, 1); +free_urb_: + _usb_urb_free(urb_ctrl); + return ret; +} +#endif + +#ifdef CONFIG_UVC_GET_CONFIG_DESC +extern void _print_uvc_class_descriptors_cb(const usb_standard_desc_t *desc); +static esp_err_t _usb_get_config_desc(hcd_pipe_handle_t pipe_handle, usb_config_desc_t **config_desc) +{ + (void)config_desc; + UVC_CHECK(pipe_handle != NULL, "pipe_handle can't be NULL", ESP_ERR_INVALID_ARG); + //malloc URB for default control + urb_t *urb_ctrl = _usb_urb_alloc(0, sizeof(usb_setup_packet_t) + CTRL_TRANSFER_DATA_MAX_BYTES, NULL); + UVC_CHECK(urb_ctrl != NULL, "alloc urb failed", ESP_ERR_NO_MEM); + urb_t *urb_done = NULL; + ESP_LOGI(TAG, "get short config desc"); + USB_SETUP_PACKET_INIT_GET_CONFIG_DESC((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer, USB_ENUM_CONFIG_INDEX, USB_ENUM_SHORT_DESC_REQ_LEN); + urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + usb_round_up_to_mps(sizeof(usb_config_desc_t), USB_EP_CTRL_DEFAULT_MPS); + esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); + UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); + UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); + urb_done = hcd_urb_dequeue(pipe_handle); + UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); + UVC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); + UVC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + sizeof(usb_config_desc_t)), "urb status: data overflow", free_urb_); + ESP_LOGI(TAG, "get config desc, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); + usb_config_desc_t *cfg_desc = (usb_config_desc_t *)(urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); + uint16_t full_config_length = cfg_desc->wTotalLength; + if (cfg_desc->wTotalLength > CTRL_TRANSFER_DATA_MAX_BYTES) { + ESP_LOGE(TAG, "Configuration descriptor larger than control transfer max length"); + goto free_urb_; + } + ESP_LOGI(TAG, "get full config desc"); + USB_SETUP_PACKET_INIT_GET_CONFIG_DESC((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer, USB_ENUM_CONFIG_INDEX, full_config_length); + urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + usb_round_up_to_mps(full_config_length, USB_EP_CTRL_DEFAULT_MPS); + ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); + UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); + UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); + urb_done = hcd_urb_dequeue(pipe_handle); + UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); + UVC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); + UVC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + full_config_length), "urb status: data overflow", free_urb_); + ESP_LOGI(TAG, "get full config desc, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); + cfg_desc = (usb_config_desc_t *)(urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); + usb_print_config_descriptor(cfg_desc, _print_uvc_class_descriptors_cb); + goto free_urb_; + +flush_urb_: + _usb_pipe_flush(pipe_handle, 1); +free_urb_: + _usb_urb_free(urb_ctrl); + return ret; +} +#endif static esp_err_t _usb_set_device_addr(hcd_pipe_handle_t pipe_handle, uint8_t dev_addr) { @@ -818,7 +907,7 @@ static esp_err_t _usb_set_device_addr(hcd_pipe_handle_t pipe_handle, uint8_t dev ESP_LOGI(TAG, "Set Device Addr = %u", dev_addr); esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_t *urb_done = hcd_urb_dequeue(pipe_handle); UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -851,7 +940,7 @@ static esp_err_t _usb_set_device_config(hcd_pipe_handle_t pipe_handle, uint16_t ESP_LOGI(TAG, "Set Device Configuration = %u", configuration); esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_t *urb_done = hcd_urb_dequeue(pipe_handle); UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -880,7 +969,7 @@ static esp_err_t _usb_set_device_interface(hcd_pipe_handle_t pipe_handle, uint16 ESP_LOGI(TAG, "Set Device Interface = %u, Alt = %u", interface, interface_alt); esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_t *urb_done = hcd_urb_dequeue(pipe_handle); UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -910,7 +999,7 @@ static esp_err_t _uvc_vs_commit_control(hcd_pipe_handle_t pipe_handle, uvc_strea urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + ((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer)->wLength; esp_err_t ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_done = hcd_urb_dequeue(pipe_handle); UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -922,14 +1011,16 @@ static esp_err_t _uvc_vs_commit_control(hcd_pipe_handle_t pipe_handle, uvc_strea urb_ctrl->transfer.num_bytes = USB_EP_CTRL_DEFAULT_MPS; //IN should be integer multiple of MPS ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_done = hcd_urb_dequeue(pipe_handle); UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); UVC_CHECK_GOTO(USB_TRANSFER_STATUS_COMPLETED == urb_done->transfer.status, "urb status: not complete", free_urb_); - UVC_CHECK_GOTO((urb_done->transfer.actual_num_bytes >= ((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer)->wLength), "urb status: data overflow", free_urb_); + UVC_CHECK_GOTO((urb_done->transfer.actual_num_bytes <= sizeof(usb_setup_packet_t) + ((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer)->wLength), "urb status: data overflow", free_urb_); _buf_to_uvc_stream_ctrl((urb_done->transfer.data_buffer + sizeof(usb_setup_packet_t)), ((usb_setup_packet_t *)urb_done->transfer.data_buffer)->wLength, ctrl_probed); +#ifdef CONFIG_UVC_PRINT_PROBE_RESULT _uvc_stream_ctrl_printf(stdout, ctrl_probed); +#endif ESP_LOGI(TAG, "GET_CUR Probe Done, actual_num_bytes:%d", urb_done->transfer.actual_num_bytes); ESP_LOGI(TAG, "SET_CUR COMMIT"); @@ -938,7 +1029,7 @@ static esp_err_t _uvc_vs_commit_control(hcd_pipe_handle_t pipe_handle, uvc_strea urb_ctrl->transfer.num_bytes = sizeof(usb_setup_packet_t) + ((usb_setup_packet_t *)urb_ctrl->transfer.data_buffer)->wLength; ret = hcd_urb_enqueue(pipe_handle, urb_ctrl); UVC_CHECK_GOTO(ESP_OK == ret, "urb enqueue failed", free_urb_); - ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(500)); + ret = _default_pipe_event_wait_until(pipe_handle, HCD_PIPE_EVENT_URB_DONE, pdMS_TO_TICKS(TIMEOUT_USB_CTRL_XFER_MS)); UVC_CHECK_GOTO(ESP_OK == ret, "urb event error", flush_urb_); urb_done = hcd_urb_dequeue(pipe_handle); UVC_CHECK_GOTO(urb_done == urb_ctrl, "urb status: not same", free_urb_); @@ -1336,6 +1427,14 @@ static void _usb_processing_task(void *arg) // UVC enum process ret = _usb_set_device_addr(pipe_hdl_dflt, uvc_dev->dev_addr); UVC_CHECK_GOTO(ESP_OK == ret, "Set device address failed", usb_driver_reset_); +#ifdef CONFIG_UVC_GET_DEVICE_DESC + ret = _usb_get_dev_desc(pipe_hdl_dflt, NULL); + UVC_CHECK_GOTO(ESP_OK == ret, "Get device descriptor failed", usb_driver_reset_); +#endif +#ifdef CONFIG_UVC_GET_CONFIG_DESC + ret = _usb_get_config_desc(pipe_hdl_dflt, NULL); + UVC_CHECK_GOTO(ESP_OK == ret, "Get config descriptor failed", usb_driver_reset_); +#endif ret = _usb_set_device_config(pipe_hdl_dflt, uvc_dev->configuration); UVC_CHECK_GOTO(ESP_OK == ret, "Set device configuration failed", usb_driver_reset_); ret = _uvc_vs_commit_control(pipe_hdl_dflt, &uvc_dev->ctrl_set, &uvc_dev->ctrl_probed); diff --git a/examples/usb/host/usb_camera_lcd_display/main/Kconfig.projbuild b/examples/usb/host/usb_camera_lcd_display/main/Kconfig.projbuild index 720b3c0a3..82b69b90f 100644 --- a/examples/usb/host/usb_camera_lcd_display/main/Kconfig.projbuild +++ b/examples/usb/host/usb_camera_lcd_display/main/Kconfig.projbuild @@ -2,7 +2,7 @@ menu "USB Camera Demo" config USE_PSRAM bool "Use Psram As Picture Buffer" - default false + default n choice DEVELOP_BOARD prompt "Develop Board" @@ -40,6 +40,6 @@ menu "USB Camera Demo" config BOOT_ANIMATION depends on SIZE_320_240 bool "enable boot animation" - default false + default n endmenu \ No newline at end of file diff --git a/examples/usb/host/usb_camera_sd_card/main/Kconfig.projbuild b/examples/usb/host/usb_camera_sd_card/main/Kconfig.projbuild index a47757b03..0b12c43da 100644 --- a/examples/usb/host/usb_camera_sd_card/main/Kconfig.projbuild +++ b/examples/usb/host/usb_camera_sd_card/main/Kconfig.projbuild @@ -2,7 +2,7 @@ menu "USB Camera Demo" config USE_PSRAM bool "Use Psram As Picture Buffer" - default false + default n choice PIC_SIZE prompt "Picture Size" diff --git a/examples/usb/host/usb_camera_wifi_transfer/main/Kconfig.projbuild b/examples/usb/host/usb_camera_wifi_transfer/main/Kconfig.projbuild index b236ab745..580c864e9 100644 --- a/examples/usb/host/usb_camera_wifi_transfer/main/Kconfig.projbuild +++ b/examples/usb/host/usb_camera_wifi_transfer/main/Kconfig.projbuild @@ -2,7 +2,7 @@ menu "USB Camera Demo" config USE_PSRAM bool "Use Psram As Picture Buffer" - default true + default y choice PIC_SIZE prompt "Picture Size" diff --git a/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults b/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults index db0095417..004e1c142 100644 --- a/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults +++ b/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults @@ -2,122 +2,23 @@ # # FreeRTOS # -CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096 -CONFIG_FREERTOS_USE_TRACE_FACILITY=y -CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y -CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER=y +CONFIG_FREERTOS_HZ=1000 # # Compiler options # -# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set CONFIG_COMPILER_OPTIMIZATION_PERF=y -# CONFIG_COMPILER_OPTIMIZATION_NONE is not set CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set -# CONFIG_COMPILER_CXX_EXCEPTIONS is not set -# CONFIG_COMPILER_CXX_RTTI is not set CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y -# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set -# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set -# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set -# CONFIG_COMPILER_DUMP_RTL_FILES is not set -# end of Compiler options - -# -# Serial flasher config -# -CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 -# CONFIG_ESPTOOLPY_NO_STUB is not set -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y -# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set -# CONFIG_ESPTOOLPY_FLASHMODE_DIO is not set -# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set -CONFIG_ESPTOOLPY_FLASHMODE="dio" -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ="80m" -# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="4MB" -CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y -CONFIG_ESPTOOLPY_BEFORE_RESET=y -# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" -CONFIG_ESPTOOLPY_AFTER_RESET=y -# CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" -# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -# end of Serial flasher config # # ESP32S2-specific # -# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_80 is not set -# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_160 is not set CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ=240 - -# -# Task watch dog -# -CONFIG_TASK_WDT=y -CONFIG_TASK_WDT_TIMEOUT_S=15 -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y - CONFIG_ESP32S2_SPIRAM_SUPPORT=y - -# -# SPI RAM config -# CONFIG_SPIRAM_TYPE_AUTO=y -# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=-1 - -# -# PSRAM clock and cs IO for ESP32S2 -# -CONFIG_DEFAULT_PSRAM_CLK_IO=30 -CONFIG_DEFAULT_PSRAM_CS_IO=26 -# end of PSRAM clock and cs IO for ESP32S2 - -# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set -# CONFIG_SPIRAM_RODATA is not set -CONFIG_SPIRAM_SPEED_80M=y -# CONFIG_SPIRAM_SPEED_40M is not set -# CONFIG_SPIRAM_SPEED_26M is not set -# CONFIG_SPIRAM_SPEED_20M is not set -CONFIG_SPIRAM=y -CONFIG_SPIRAM_BOOT_INIT=y -# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set -# CONFIG_SPIRAM_USE_MEMMAP is not set -# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set -CONFIG_SPIRAM_USE_MALLOC=y -CONFIG_SPIRAM_MEMTEST=y -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=122880 # end of SPI RAM config # diff --git a/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults.esp32s3 b/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults.esp32s3 index b2070cdd6..24d7d2801 100644 --- a/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults.esp32s3 +++ b/examples/usb/host/usb_camera_wifi_transfer/sdkconfig.defaults.esp32s3 @@ -1,169 +1,14 @@ -# -# FreeRTOS -# -# CONFIG_FREERTOS_UNICORE is not set -CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_CORETIMER_0=y -# CONFIG_FREERTOS_CORETIMER_1 is not set -CONFIG_FREERTOS_HZ=1000 -CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set -CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y -# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set -CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 -CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y -# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set -# CONFIG_FREERTOS_ASSERT_DISABLE is not set -CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 -CONFIG_FREERTOS_ISR_STACKSIZE=1536 -# CONFIG_FREERTOS_LEGACY_HOOKS is not set -CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 -CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set -CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096 -CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 -CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 -CONFIG_FREERTOS_USE_TRACE_FACILITY=y -CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y -# CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is not set -CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y -CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER=y -# CONFIG_FREERTOS_RUN_TIME_STATS_USING_CPU_CLK is not set -CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y -# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set -CONFIG_FREERTOS_DEBUG_OCDAWARE=y -# end of FreeRTOS - - -# -# Compiler options -# -# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -CONFIG_COMPILER_OPTIMIZATION_PERF=y -# CONFIG_COMPILER_OPTIMIZATION_NONE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set -# CONFIG_COMPILER_CXX_EXCEPTIONS is not set -# CONFIG_COMPILER_CXX_RTTI is not set -CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y -# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set -# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set -# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set -# CONFIG_COMPILER_DUMP_RTL_FILES is not set -# end of Compiler options - -# -# Serial flasher config -# -CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 -# CONFIG_ESPTOOLPY_NO_STUB is not set -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y -# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set -# CONFIG_ESPTOOLPY_FLASHMODE_DIO is not set -# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set -CONFIG_ESPTOOLPY_FLASHMODE="dio" -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ="80m" -# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="4MB" -CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y -CONFIG_ESPTOOLPY_BEFORE_RESET=y -# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" -CONFIG_ESPTOOLPY_AFTER_RESET=y -# CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" -# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -# end of Serial flasher config - # # ESP32S3-Specific # -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160 is not set CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 -# -# Select Screen Controller -# -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9341=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9486=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9806=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_NT35510=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_RM68120=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1351=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7789=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7796=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1306=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1307=y -CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1322=y - -# -# Task watch dog -# -CONFIG_TASK_WDT=y -CONFIG_TASK_WDT_TIMEOUT_S=15 -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y - -CONFIG_ESP32S3_SPIRAM_SUPPORT=y - # # SPI RAM config # -CONFIG_SPIRAM_TYPE_AUTO=y -# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set -CONFIG_SPIRAM_SIZE=-1 - -# -# PSRAM Clock and CS IO for ESP32S3 -# -CONFIG_DEFAULT_PSRAM_CLK_IO=30 -CONFIG_DEFAULT_PSRAM_CS_IO=26 -# end of PSRAM Clock and CS IO for ESP32S3 - -# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set -# CONFIG_SPIRAM_RODATA is not set -CONFIG_SPIRAM_SPEED_80M=y -# CONFIG_SPIRAM_SPEED_40M is not set -# CONFIG_SPIRAM_SPEED_26M is not set -# CONFIG_SPIRAM_SPEED_20M is not set -CONFIG_SPIRAM=y -CONFIG_SPIRAM_BOOT_INIT=y -# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set -# CONFIG_SPIRAM_USE_MEMMAP is not set -# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set -CONFIG_SPIRAM_USE_MALLOC=y -CONFIG_SPIRAM_MEMTEST=y -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=2048 -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 +CONFIG_ESP32S3_SPIRAM_SUPPORT=y +CONFIG_SPIRAM_MODE_OCT=y # end of SPI RAM config #