Skip to content

Commit 5833d07

Browse files
committed
fix(cdc): Disable SOF interrupt and CDC reset on begin()
1 parent 5de054b commit 5833d07

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

cores/esp32/HWCDC.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,20 @@ static void hw_cdc_isr_handler(void *arg) {
134134
connected = false;
135135
}
136136

137-
if (usbjtag_intr_status & USB_SERIAL_JTAG_INTR_SOF) {
138-
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF);
139-
lastSOF_ms = millis();
140-
}
137+
// SOF ISR is causing esptool to be unable to upload firmware to the board
138+
// if (usbjtag_intr_status & USB_SERIAL_JTAG_INTR_SOF) {
139+
// usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF);
140+
// lastSOF_ms = millis();
141+
// }
141142

142143
if (xTaskWoken == pdTRUE) {
143144
portYIELD_FROM_ISR();
144145
}
145146
}
146147

147148
inline bool HWCDC::isPlugged(void) {
148-
return (lastSOF_ms + SOF_TIMEOUT) >= millis();
149+
// SOF ISR is causing esptool to be unable to upload firmware to the board
150+
return true;//(lastSOF_ms + SOF_TIMEOUT) >= millis();
149151
}
150152

151153
bool HWCDC::isCDC_Connected() {
@@ -309,8 +311,9 @@ void HWCDC::begin(unsigned long baud) {
309311
}
310312

311313
// the HW Serial pins needs to be first deinited in order to allow `if(Serial)` to work :-(
312-
deinit(NULL);
313-
delay(10); // USB Host has to enumerate it again
314+
// But this is also causing terminal to hang, so they are disabled
315+
// deinit(NULL);
316+
// delay(10); // USB Host has to enumerate it again
314317

315318
// Peripheral Manager setting for USB D+ D- pins
316319
uint8_t pin = USB_DM_GPIO_NUM;
@@ -332,9 +335,11 @@ void HWCDC::begin(unsigned long baud) {
332335
// Enable USB pad function
333336
USB_SERIAL_JTAG.conf0.usb_pad_enable = 1;
334337
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
335-
usb_serial_jtag_ll_ena_intr_mask(
336-
USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET | USB_SERIAL_JTAG_INTR_SOF
337-
);
338+
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET);
339+
// SOF ISR is causing esptool to be unable to upload firmware to the board
340+
// usb_serial_jtag_ll_ena_intr_mask(
341+
// USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET | USB_SERIAL_JTAG_INTR_SOF
342+
// );
338343
if (!intr_handle && esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0, hw_cdc_isr_handler, NULL, &intr_handle) != ESP_OK) {
339344
isr_log_e("HW USB CDC failed to init interrupts");
340345
end();

0 commit comments

Comments
 (0)