ESP32S3 esp-idf: Platformio serial monitor not working on USB CDC interface

Hi,

I am using native USB CDC interface on GPIO19 and GPIO20 on ESP32S3 to flash and monitor my application. Flashing works, application is running correctly, however launching the Plaformio Serial monitor does not display the serial output, I am only getting:

--- Terminal on COM4 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time   
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

Suprisingly, without re-flashing if I launch the ESP-IDF Serial Monitor in VSCode I can see the serial output:

I (26) boot: ESP-IDF v5.1.2 2nd stage bootloader
I (27) boot: compile time Nov 21 2023 20:32:33
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (33) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
etc..

Is there anything I am missing here, maybe a buid_flag or something?

Here is my platformio.ini:

[platformio]
default_envs = main

[env]
platform = espressif32
board = esp32s3box
framework = espidf
platform_packages = framework-espidf
upload_speed = 921600
monitor_speed = 115200
monitor_raw = true
board_build.partitions = partitions.csv

[env:main]
build_flags =
    -Wall

Either you’re on the wrong monitor_port = ... setting or you need to assert the (virtual) DTR signal using monitor_dtr = 1 (or 0 if inverted) in the platformio.ini.

1 Like

Monitor port I am sure is correct, both Platformio and ESP-IDF serial monitor are using COM4.
I tried both monitor_dtr = 1 and monitor_dtr = 1 and no serail output.

--- forcing DTR active
--- Terminal on COM4 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time   
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

I noticed that ESP-IDF serial monitor is able to trigger a reset while Platformio Serial monitor is not able to. I am not sure if this is the issue.

Found something new, using monitor_dtr = 0 works but only if I do a Reset before opening the monitor, then the output is as shown below.
If I close the monitor and try to re-open it does not show the output (unless I reset the device and open the monitor again).

--- forcing DTR inactive
--- Terminal on COM4 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time   
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40378fa6
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x1750
load:0x403c9700,len:0x4
load:0x403c9704,len:0xc00
load:0x403cc700,len:0x2e04
entry 0x403c9908
I (26) boot: ESP-IDF v5.1.2 2nd stage bootloader
I (27) boot: compile time Nov 21 2023 20:32:33  
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (33) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode       : DIO  
I (43) boot.esp32s3: SPI Flash Size : 2MB 

I accepted the solution.
It works, the only draw back is that launching the Serial Monitor only resets the board the first run of the ESP32 program. If I close and launch Serial monitor again it does not reset the board. however good part is it still displays output messages.
I think having a reset after every launch of Serial monitor is a matter of taste. Thanks for yur support!