espflash icon indicating copy to clipboard operation
espflash copied to clipboard

ESP-IDF basic console example misbehaves when run with espflash --monitor

Open mykmelez opened this issue 3 years ago • 1 comments

When I use idf_monitor.py to run the ESP-IDF 4.4.1 basic console example app on my ESP32-S3-DevKitC-1 (connected to my Mac M1 via the devkit's USB-to-UART port), it works as expected, prompting me to enter a command, echoing what I type, and processing the command when I press return:

> idf_monitor.py --port /dev/cu.usbserial-10 build/console.elf
…
Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
esp32s3> help
…

However, when I use espflash 1.5.1 to run it, it doesn't print the esp32s3> prompt until I press return, doesn't echo what I type until I press return, and warns me after the first keypress, "Your terminal application does not support escape sequences. Line editing and history features are disabled."

> espflash --monitor build/console.elf
Serial port: /dev/tty.usbserial-10
Connecting...
…
Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.

Your terminal application does not support escape sequences.
Line editing and history features are disabled.
On Windows, try using Putty instead.
esp32s3> help
…

It does at least process commands, however. When I use espmonitor 0.7.0 to run the app, it doesn't even do that, it just warns me about my terminal and then hangs, not accepting any input nor printing any output:

> espmonitor /dev/cu.usbserial-10    
…
Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.

Your terminal application does not support escape sequences.
Line editing and history features are disabled.
On Windows, try using Putty instead.

Note: if I try to run the app via the devkit's USB port instead of the USB-to-UART port, then all three tools fail. In that case, both idf_monitor.py and espmonitor warn me about my terminal and fail to accept input/print output, while espflash --monitor times out:

> espflash --monitor build/console.elf                       
Serial port: /dev/tty.usbmodem101
Connecting...
…
Error: espflash::timeout

  × Communication error while flashing device
  ╰─▶ Timeout while running WriteReg command

In general, I would expect espflash --monitor (and espmonitor, for that matter) to behave like idf_monitor.py and successfully run the app with its expected behavior.

It isn't clear if this is an issue in espflash, espmonitor, serialport-rs, or some combination (and perhaps even including ESP-IDF itself, given the idf_monitor.py behavior with the USB port). I'm submitting it here first, but I'm happy to redirect or submit additional issues elsewhere if appropriate.

mykmelez avatar May 16 '22 23:05 mykmelez

Sorry for not updating this issue, kind of slipped my mind.

I did spend some time looking into this a couple months ago and unfortunately was not able to come up with a solution or even find an obvious problem in the code. We will be making some pretty major changes to the serial monitor portion of the application pretty soon, so I'm hoping to dig into this again when that happens.

jessebraham avatar Sep 28 '22 16:09 jessebraham

Hi! Would you mind testing the issue with latest changes of main? There have been several major changes since the issue was open.

SergioGasquez avatar Dec 12 '23 10:12 SergioGasquez

Closing the issue due to inactivity, feel free to reopen the issue if it persists or reappears

SergioGasquez avatar Jan 25 '24 14:01 SergioGasquez