Skip to content

Commit

Permalink
Merge branch 'fix/usb-serial-jtag-hangs-on-init_v5.3' into 'release/v…
Browse files Browse the repository at this point in the history
…5.3'

fix(console): USB Serial JTAG freezes when input received before the driver is installed (v5.3)

See merge request espressif/esp-idf!31820
  • Loading branch information
ESP-Marius committed Jul 25, 2024
2 parents a2d2f30 + 2a24cc2 commit 6c52686
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/console/linenoise/linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,9 @@ int linenoiseProbe(void) {
if (cb < 0) {
continue;
}
if (read_bytes == 0 && c != '\x1b') {
/* invalid response */
break;
if (read_bytes == 0 && c != ESC) {
/* invalid response, try again until the timeout triggers */
continue;
}
read_bytes += cb;
}
Expand Down
12 changes: 8 additions & 4 deletions components/esp_driver_usb_serial_jtag/src/usb_serial_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,14 @@ esp_err_t usb_serial_jtag_driver_install(usb_serial_jtag_driver_config_t *usb_se
usb_serial_jtag_ll_phy_set_defaults(); // External PHY not supported. Set default values.
#endif // USB_WRAP_LL_EXT_PHY_SUPPORTED

usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY |
USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY |
USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);
// Note: DO NOT clear the interrupt status bits here. The output routine needs
// USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY set because it needs the ISR to trigger
// as soon as data is sent; the input routine needs the status to retrieve any
// data that is still in the FIFOs.

// We only enable the RX interrupt; we'll enable the TX one when we actually
// have anything to send.
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);

err = esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0, usb_serial_jtag_isr_handler_default, NULL, &p_usb_serial_jtag_obj->intr_handle);
if (err != ESP_OK) {
Expand Down

0 comments on commit 6c52686

Please sign in to comment.