Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB serial jtag console does not take input if enter is being pressed too soon (IDFGH-12989) #13940

Closed
3 tasks done
congyue opened this issue Jun 10, 2024 · 3 comments
Closed
3 tasks done
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally

Comments

@congyue
Copy link

congyue commented Jun 10, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Setup

  • HW: ESP32-S3-DevKitM-1
  • IDF_version: 5.2.2 tag
  • Code: official basic console example
  • The final sdkconfig contains CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y

Expected behavior

The console should work as expected:

esp32s3>
esp32s3> version
IDF Version:v5.2.1-538-g3b8741b172-dirty
Chip info:
	model:ESP32-S3
	cores:2
	feature:/802.11bgn/BLE/External-Flash:4 MB
	revision number:1
esp32s3>

Actual behavior

If developer tries to press enter too soon when the chip is still booting up, then the console won't take input anymore and the console seems frozen. e.g.

esp32s3>
esp32s3> restart
I (14284) cmd_system_commonESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
...
<Keep pressing Enter key while the device is booting>
...
I (214) main_task: Started on CPU0
I (224) main_task: Calling app_main()
I (264) example: Command history enabled

esp32s3> I (774) main_task: Returned from app_main()

<console is frozen>

// The console won't take any input for this boot cycle, I have to power cycle the device from HW
// However, if there is any periodic logging, they will still be printed properly

The impact for this issue would be:

  • Make developer's life harder since we usually use Enter key to test if the console is ready
  • When this issue (console frozen) happens, if someone without context tries to attach USB serial, they may consider the device is hang or not responding, which cause further confusion.

If this is a feature instead of bug, may I know how to disable it? Thanks!
@igrr @mythbuster5

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 10, 2024
@github-actions github-actions bot changed the title USB serial jtag console does not take input if enter is being pressed too soon USB serial jtag console does not take input if enter is being pressed too soon (IDFGH-12989) Jun 10, 2024
@0xjakob
Copy link
Contributor

0xjakob commented Jun 11, 2024

@congyue Thanks for noticing this! I could reproduce this and it looks like a bug. We'll take a look and come back here once we know more about this.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jun 17, 2024
@SoucheSouche
Copy link
Collaborator

Hi @congyue, I seem to have isolated the issue that causes the console to freeze when pressing basically any key too quickly after restart.

The USB Serial JTAG driver is initialized, the interrupt bit for data reception is cleared without checking if data has been received. So any input received before the driver is initialized is basically ignored it seems.

I tried reading data (if any) before clearing the interrupt bit during initialization of the driver and it fixes the issue.

I will keep you updated as I implement the fix properly and submit it for review internally.

@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: In Progress Work is in progress labels Jun 17, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Reviewing Issue is being reviewed labels Jul 1, 2024
espressif-bot pushed a commit that referenced this issue Jul 3, 2024
When data was sent through USB Serial JTAG before the
driver was installed, the bus was malfunctioning. This
was because the interrupt bit for data reception was cleared
regardless of whether data was received or not. Consequently,
usb_serial_jtag_isr_handler_default was not triggered and the
data was never read causing the bus to malfunction.

This commit is modifying usb_serial_jtag_driver_install to
prevent clearing USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT and
USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY thus allowing the callback
usb_serial_jtag_isr_handler_default to trigger for possible data
exchanged prior to the call to usb_serial_jtag_driver_install.

This commit also modified the while logic in linenoiseProbe to
discard any data that doesn't match the expected chaaracter sequences
to prevent random input from interfering with evaluating whether the
terminal supports escape sequences or not.

See #13940
espressif-bot pushed a commit that referenced this issue Jul 4, 2024
When data was sent through USB Serial JTAG before the
driver was installed, the bus was malfunctioning. This
was because the interrupt bit for data reception was cleared
regardless of whether data was received or not. Consequently,
usb_serial_jtag_isr_handler_default was not triggered and the
data was never read causing the bus to malfunction.

This commit is modifying usb_serial_jtag_driver_install to
prevent clearing USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT and
USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY thus allowing the callback
usb_serial_jtag_isr_handler_default to trigger for possible data
exchanged prior to the call to usb_serial_jtag_driver_install.

This commit also modified the while logic in linenoiseProbe to
discard any data that doesn't match the expected chaaracter sequences
to prevent random input from interfering with evaluating whether the
terminal supports escape sequences or not.

See #13940
espressif-bot pushed a commit that referenced this issue Jul 4, 2024
When data was sent through USB Serial JTAG before the
driver was installed, the bus was malfunctioning. This
was because the interrupt bit for data reception was cleared
regardless of whether data was received or not. Consequently,
usb_serial_jtag_isr_handler_default was not triggered and the
data was never read causing the bus to malfunction.

This commit is modifying usb_serial_jtag_driver_install to
prevent clearing USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT and
USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY thus allowing the callback
usb_serial_jtag_isr_handler_default to trigger for possible data
exchanged prior to the call to usb_serial_jtag_driver_install.

This commit also modified the while logic in linenoiseProbe to
discard any data that doesn't match the expected chaaracter sequences
to prevent random input from interfering with evaluating whether the
terminal supports escape sequences or not.

See #13940
@SoucheSouche
Copy link
Collaborator

Closing the issue since it was fixed and merged (see 87b1e45)

espressif-bot pushed a commit that referenced this issue Jul 31, 2024
When data was sent through USB Serial JTAG before the
driver was installed, the bus was malfunctioning. This
was because the interrupt bit for data reception was cleared
regardless of whether data was received or not. Consequently,
usb_serial_jtag_isr_handler_default was not triggered and the
data was never read causing the bus to malfunction.

This commit is modifying usb_serial_jtag_driver_install to
prevent clearing USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT and
USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY thus allowing the callback
usb_serial_jtag_isr_handler_default to trigger for possible data
exchanged prior to the call to usb_serial_jtag_driver_install.

This commit also modified the while logic in linenoiseProbe to
discard any data that doesn't match the expected chaaracter sequences
to prevent random input from interfering with evaluating whether the
terminal supports escape sequences or not.

See #13940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

4 participants