diff --git a/components/tinyusb_dfu/CMakeLists.txt b/components/tinyusb_dfu/CMakeLists.txt index 6f4ad66..35fde67 100644 --- a/components/tinyusb_dfu/CMakeLists.txt +++ b/components/tinyusb_dfu/CMakeLists.txt @@ -49,6 +49,7 @@ if(CONFIG_TINYUSB_DFU) "${tusb_idf}/tinyusb/src/class/midi/midi_device.c" "${tusb_idf}/tinyusb/src/class/msc/msc_device.c" "${tusb_idf}/tinyusb/src/class/vendor/vendor_device.c" + "${tusb_idf}/tinyusb/src/class/dfu/dfu_rt_device.c" "${tusb_idf}/tinyusb/src/common/tusb_fifo.c" "${tusb_idf}/tinyusb/src/device/usbd_control.c" "${tusb_idf}/tinyusb/src/device/usbd.c" diff --git a/components/tinyusb_dfu/additions/include/tinyusb_types.h b/components/tinyusb_dfu/additions/include/tinyusb_types.h index 0f226f3..1b3eb66 100644 --- a/components/tinyusb_dfu/additions/include/tinyusb_types.h +++ b/components/tinyusb_dfu/additions/include/tinyusb_types.h @@ -19,7 +19,7 @@ extern "C" { #endif #define USB_ESPRESSIF_VID 0x303A -#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 7 +#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 8 typedef enum{ TINYUSB_USBDEV_0, diff --git a/components/tinyusb_dfu/additions/include/tusb_config.h b/components/tinyusb_dfu/additions/include/tusb_config.h index 943aad6..0aa0c3a 100644 --- a/components/tinyusb_dfu/additions/include/tusb_config.h +++ b/components/tinyusb_dfu/additions/include/tusb_config.h @@ -91,6 +91,7 @@ extern "C" { #define CFG_TUD_HID CONFIG_TINYUSB_DFU_HID_ENABLED #define CFG_TUD_MIDI CONFIG_TINYUSB_DFU_MIDI_ENABLED #define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_DFU_CUSTOM_CLASS_ENABLED +#define CFG_TUD_DFU_RUNTIME 1 #ifdef __cplusplus } diff --git a/components/tinyusb_dfu/additions/include_private/descriptors_control.h b/components/tinyusb_dfu/additions/include_private/descriptors_control.h index 461ffa8..abdc794 100644 --- a/components/tinyusb_dfu/additions/include_private/descriptors_control.h +++ b/components/tinyusb_dfu/additions/include_private/descriptors_control.h @@ -52,12 +52,13 @@ enum { ITF_NUM_HID, # endif + ITF_NUM_DFU_RT, ITF_NUM_TOTAL }; enum { TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN + - CFG_TUD_HID * TUD_HID_DESC_LEN + CFG_TUD_HID * TUD_HID_DESC_LEN + TUD_DFU_RT_DESC_LEN }; bool tusb_desc_set; diff --git a/components/tinyusb_dfu/additions/src/descriptors_control.c b/components/tinyusb_dfu/additions/src/descriptors_control.c index d7fbf0b..ebbc6bc 100644 --- a/components/tinyusb_dfu/additions/src/descriptors_control.c +++ b/components/tinyusb_dfu/additions/src/descriptors_control.c @@ -14,6 +14,7 @@ #include "esp_log.h" #include "descriptors_control.h" +#include "class/dfu/dfu_rt_device.h" static const char *TAG = "tusb_desc"; static tusb_desc_device_t s_descriptor; @@ -41,8 +42,11 @@ uint8_t const desc_configuration[] = { # endif # if CFG_TUD_HID // Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval - TUD_HID_DESCRIPTOR(ITF_NUM_HID, 6, HID_PROTOCOL_NONE, sizeof(desc_hid_report), 0x84, 16, 10) + TUD_HID_DESCRIPTOR(ITF_NUM_HID, 6, HID_PROTOCOL_NONE, sizeof(desc_hid_report), 0x84, 16, 10), # endif + + // Interface number, string index, attributes, detach timeout, transfer size */ + TUD_DFU_RT_DESCRIPTOR(ITF_NUM_DFU_RT, 7, 0x0d, 1000, 4096), }; // ============================================================================= diff --git a/components/tinyusb_dfu/additions/src/usb_descriptors.c b/components/tinyusb_dfu/additions/src/usb_descriptors.c index 31f0fc5..0dde6dc 100644 --- a/components/tinyusb_dfu/additions/src/usb_descriptors.c +++ b/components/tinyusb_dfu/additions/src/usb_descriptors.c @@ -56,7 +56,8 @@ tusb_desc_strarray_device_t descriptor_str_tinyusb = { "123456", // 3: Serials, should use chip ID "TinyUSB CDC", // 4: CDC Interface "TinyUSB MSC", // 5: MSC Interface - "TinyUSB HID" // 6: HID + "TinyUSB HID", // 6: HID + "TinyUSB DFU RT" // 7: DFU RT }; /* End of TinyUSB default */ @@ -121,10 +122,10 @@ tusb_desc_strarray_device_t descriptor_str_kconfig = { #endif #if CONFIG_TINYUSB_DFU_HID_ENABLED - CONFIG_TINYUSB_DFU_DESC_HID_STRING // 6: HIDs + CONFIG_TINYUSB_DFU_DESC_HID_STRING, // 6: HIDs #else "", #endif - + "DFU (runtime mode)" // 7: DFU RT }; /* End of Kconfig driven Descriptor */