Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7df98db

Browse files
pillo79facchinm
authored andcommitted
USB: enable DFU interface and stub
1 parent 1577701 commit 7df98db

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cores/esp32/USB.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
#define USB_WEBUSB_URL "https://espressif.github.io/arduino-esp32/webusb.html"
4848
#endif
4949

50+
#if CFG_TUD_DFU
51+
__attribute__((weak, unused)) uint16_t load_dfu_ota_descriptor(uint8_t * dst, uint8_t * itf) {
52+
return 0;
53+
}
54+
#endif /* CFG_TUD_DFU */
55+
5056
#if CFG_TUD_DFU_RUNTIME
51-
static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
57+
__attribute__((unused)) static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
5258
{
5359
#define DFU_ATTRS (DFU_ATTR_CAN_DOWNLOAD | DFU_ATTR_CAN_UPLOAD | DFU_ATTR_MANIFESTATION_TOLERANT)
5460

@@ -185,7 +191,7 @@ bool ESPUSB::begin(){
185191
.webusb_enabled = webusb_enabled,
186192
.webusb_url = webusb_url.c_str()
187193
};
188-
_started = tinyusb_init(&tinyusb_device_config) == ESP_OK;
194+
_started = tinyusb_init(&tinyusb_device_config) == ESP_OK;
189195
}
190196
return _started;
191197
}
@@ -203,7 +209,9 @@ ESPUSB::operator bool() const
203209
}
204210

205211
bool ESPUSB::enableDFU(){
206-
#if CFG_TUD_DFU_RUNTIME
212+
#if CFG_TUD_DFU
213+
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_DESC_LEN(1), load_dfu_ota_descriptor) == ESP_OK;
214+
#elif CFG_TUD_DFU_RUNTIME
207215
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_RT_DESC_LEN, load_dfu_descriptor) == ESP_OK;
208216
#endif /* CFG_TUD_DFU_RUNTIME */
209217
return false;

0 commit comments

Comments
 (0)