UART-Rx-Tx (Serial and Serial0) and Native USB (HWCDC and USBCDC) monitor capture

Hi,
Assuming I would figure it out by myself and forgetting to ask at the right moment (previous posts), I now came to the realization that I have no clue, how to display information delivered either to USBSerial (HWCDC) or Serial (USBCDC or HWCDC) when they are associated to the Native USB interface (setting ARDUINO_USB_CDC_ON_BOOT and ARDUINO_USB_MODE) despite having read several USBCDC related posts (22).
Seems to me it is in part solved at the VSC level, opening a second window like in the capture I attach, of a video that sivar2311 linked me, in one of his multiple answers to my posts, but for sure it must include something CDC related.
In that capture, both monitor windows are related one to port COM4 and the other to port COM15, and in the code Serial and Serial0 are used (ARDUINO_USB_CDC_ON_BOOT = 1 & ARDUINO_USB_MODE = 0).

;                                         -----------------------------
;                                        |     KIT's PHYSICAL PORT     |
;   -------------------------------------|-----------------------------|
;  |  ARDUINO_USB_CDC_ON_BOOT | USB_MODE |      UART      |    USB     |
;  |                          |          |    (RX/TX)     |  (native)  |
;  |--------------------------|----------|----------------|------------|
;  |            0             |    0     | Serial         |  n/a       |
;  |                          |          | HardwareSerial |            |
;  |--------------------------|----------|----------------|------------|
;  |            0             |    1     | Serial         |  USBSerial |
;  |                          |          | HardwareSerial |  HWCDC     |
;  |--------------------------|----------|----------------|------------|
;  |            1             |    0     | Serial0        |  Serial    |
;  |                          |          | HardwareSerial |  USBCDC    |
;  |--------------------------|----------|----------------|------------|
;  |            1             |    1     | Serial0        |  Serial    |
;  |                          |          | HardwareSerial |  HWCDC     |
;   -------------------------------------------------------------------

In some of my previous cases things got printed anyway (fooled mysel maybe) because PIO’s Serial Monitor was in mode “Auto” (and discovered a COM port by itself) and I forgot to unplug the second cable connected to the UART connector, so I got maybe the false impression (maybe even having the wrong Serialx object in the code) that I was getting printf’s anyway.

In my setup a terminal has only these options:
imagen

And in that capture with the double window setup it looks like:

imagen

I tried to find a way to customize that window, but all the available tabs, when doing a right click (PROBLEMS, OUTPUT, DEBUG CONSOLE, TERMINAL, PORTS) where already checked (visible) and SERIAL MONITOR was not available in the list. I know how to move a tiled tab into a separate window, but I still have only a single Serial Monitor (tiled or in a sepparate window) and if I am not mistaken, only attached to HardwareSerial.

To boil it down to a simple phrase, if I have only one cable connected to the USB native port (and having a COM port available at interface 0) it seems I have never been able to display any printf regardles to what Serial objet I was printing. Obviously pointing monitor_port to that interface port. But I imagine if you are using two cables in platformio.ini you should have two monitor_port settings?

I wish I could put it in a shorter and more clear way.

1 Like

The “Serial Monitor” section is a VS Code extension. I used this to display multiple serial interfaces simultaneously in the video. As far as I know, PlatformIO does not have an option to display multiple serial interfaces at once.

In my case COM4 was the Serial to UART port on the ESP32 dev board and COM15 was the native USB port.

Yes, I understand that:

Your code is printing to Serial and Serial0.
Serial0 is delivering to UART.
Serial is delivering to native USB.
Serial0 is being displayed on the PIO Serial Monitor (I imagine in the INI file you have the monitor_port = [UART COM])

But there are three things I do not understand or do not know how to acomplish:

  1. Could you change monitor_port = [USB interface 0 COM] and get instead the Serial object output on PIO’s Serial Monitor? That is not working for me! I could send you my INI and code if that helps.
  2. How do you open that other window and capture/display what is printed on the Serial object?
  3. Why do you have a “SERIAL MONITOR” tab in the terminal tile and I not. Sounds a bit childish :rofl: but maybe it is related.

I have not been able so far to see on VSC/PIO what I print to Serial object when having these settings:

build_flags = 
	-DARDUINO_USB_CDC_ON_BOOT=1    ; Serial Monitor on Serial0
    -DARDUINO_USB_MODE=0           ; Serial on USBCDC

This can be set either in the platformio.ini by monitor_port or selected in PlatformIO’s bottom bar.

Regarding your questions:
1: Yes, I could have changed the monitor_port to COM15 (which is connected to the native USB (USBCDC) in my case).
2: That’s the VS Code Extension “Serial Monitor”
3: Because you have not installed the corresponding VS Code Plugin (see answer #2).

Yes please :slight_smile:

This settings will use USBCDC (TinyUSB / Software CDC).
Therefore the COM Port changes when the ESP32 resets after uploading.

Instead of hardcoding the COM port in platformio.ini use the COM port selector in PIO’s bottom bar!:

Click on this Icon and a new window on the top will pop up, which shows you the available ports.

Note: No ESP connected at the time the screenshot was taken

This is my environment.

Device manager COM port section (Only one USB cable, connected to the USB connector of the Kit)
ESP32-S3-DevKitC-1.1 N8R2

imagen

PLATFORMIO.INI file

[env:esp32-s3-devkitc-1-n8r2]
platform = espressif32
board = esp32-s3-devkitc-1-n8r2
framework = arduino
monitor_speed = 115200
upload_port = COM34
monitor_port = COM34
build_flags = 
	-DARDUINO_USB_CDC_ON_BOOT=1    ; Serial Monitor on Serial0
    -DARDUINO_USB_MODE=0           ; Serial on USBCDC
    -DCORE_DEBUG_LEVEL=5

CODE

#include "Arduino.h"
#include <USBCDC.h>

int loop_count = 0;

void setup() {
    Serial.begin(115200);
    Serial0.begin(115200);

    delay(10000);

    Serial.printf( "[USB-CDC]: Starting!\n");
    Serial0.printf("[UART]:    Starting!\n");

    size_t psram_size = esp_spiram_get_size();
    Serial.printf( "[USB-CDC]: PSRAM size: %d bytes\n", psram_size);
    Serial0.printf("[UART]:    PSRAM size: %d bytes\n", psram_size);
}

void loop() {
    loop_count++;
    Serial.printf( "[USB-CDC]: Loop: %d \n", loop_count);
    Serial0.printf("[UART]:    Loop: %d \n", loop_count);
    delay(1000);
}

COMPILE of code

Processing esp32-s3-devkitc-1-n8r2 (platform: espressif32; board: esp32-s3-devkitc-1-n8r2; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n8r2.html
PLATFORM: Espressif 32 (6.7.0) > Espressif ESP32-S3-DevKitC-1-N8R2 (8 MB QD, 2 MB QD PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20016.0 (2.0.16)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\src\main.cpp.o
Building .pio\build\esp32-s3-devkitc-1-n8r2\bootloader.bin
Generating partitions .pio\build\esp32-s3-devkitc-1-n8r2\partitions.bin
esptool.py v4.5.1
Creating esp32s3 image...
Merged 1 ELF section
Successfully created esp32s3 image.
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\FirmwareMSC.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\HWCDC.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\USB.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\USBCDC.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\USBMSC.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-i2c-slave.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-rgb-led.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-tinyusb.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\firmware_msc_fat.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32-s3-devkitc-1-n8r2\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32-s3-devkitc-1-n8r2\libFrameworkArduino.a
Linking .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Retrieving maximum program size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Checking size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.5% (used 31192 bytes from 327680 bytes)
Flash: [=         ]   9.5% (used 317493 bytes from 3342336 bytes)
Building .pio\build\esp32-s3-devkitc-1-n8r2\firmware.bin
esptool.py v4.5.1
Creating esp32s3 image...
Merged 2 ELF sections
Successfully created esp32s3 image.
================================================================================= [SUCCESS] Took 28.25 seconds =================================================================================
 *  Terminal will be reused by tasks, press any key to close it.

UPLOAD of code

Executing task: C:\Users\tmagdahl\.platformio\penv\Scripts\platformio.exe run --target upload 

Processing esp32-s3-devkitc-1-n8r2 (platform: espressif32; board: esp32-s3-devkitc-1-n8r2; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n8r2.html
PLATFORM: Espressif 32 (6.7.0) > Espressif ESP32-S3-DevKitC-1-N8R2 (8 MB QD, 2 MB QD PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20016.0 (2.0.16)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Checking size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.5% (used 31192 bytes from 327680 bytes)
Flash: [=         ]   9.5% (used 317493 bytes from 3342336 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Using manually specified: COM34
Uploading .pio\build\esp32-s3-devkitc-1-n8r2\firmware.bin
esptool.py v4.5.1
Serial port COM34
Connecting...
Chip is ESP32-S3 (revision v0.2)
Features: WiFi, BLE
Crystal is 40MHz
MAC: dc:da:0c:61:9e:3c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0005dfff...
Compressed 15104 bytes to 10430...
Writing at 0x00000000... (100 %)
Wrote 15104 bytes (10430 compressed) at 0x00000000 in 0.2 seconds (effective 558.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.0 seconds (effective 625.4 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 841.1 kbit/s)...
Hash of data verified.
Compressed 317856 bytes to 182694...
Writing at 0x00010000... (8 %)
Writing at 0x0001bcb0... (16 %)
Writing at 0x000243fa... (25 %)
Writing at 0x00029e9c... (33 %)
Writing at 0x0002f45d... (41 %)
Writing at 0x000347b6... (50 %)
Writing at 0x00039af5... (58 %)
Writing at 0x0003fd69... (66 %)
Writing at 0x0004a03e... (75 %)
Writing at 0x00051889... (83 %)
Writing at 0x00056de6... (91 %)
Writing at 0x0005c8a0... (100 %)
Wrote 317856 bytes (182694 compressed) at 0x00010000 in 2.3 seconds (effective 1104.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
================================================================================== [SUCCESS] Took 8.09 seconds ================================================================================== *  Terminal will be reused by tasks, press any key to close it.

SERIAL MONITOR window after 5 minutes (started inmediately after upload finished)

JSON file (just in case something is screwed up inside when I had to redo it). At some moment trying to figure out something I run a command recommended in a blog like “pio upgrade espressif32” or something like that and I lost my JSON file and had to redo it. (esp32-s3-devkitc-1-n8r2.json)

 {
  "build": {
    "arduino": {
      "ldscript": "esp32s3_out.ld",
      "partitions": "default_8MB_devkitc_n8r2.csv",
      "memory_type": "qio_qspi"
    },
    "core": "esp32",
    "extra_flags": [
      "-DARDUINO_ESP32S3_DEV",
      "-DARDUINO_RUNNING_CORE=1",
      "-DARDUINO_EVENT_RUNNING_CORE=1",
      "-DBOARD_HAS_PSRAM"
    ],
    "f_cpu": "240000000L",
    "f_flash": "80000000L",
    "flash_mode": "qio",
    "psram_type": "qio",
    "hwids": [
      [
        "0x303A",
        "0x1001"
      ]
    ],
    "mcu": "esp32s3",
    "variant": "esp32s3"
  },
  "connectivity": [
    "wifi",
    "bluetooth"
  ],
  "debug": {
    "default_tool": "esp-builtin",
    "onboard_tools": [
      "esp-builtin"
    ],
    "openocd_target": "esp32s3.cfg"
  },
  "frameworks": [
    "arduino",
    "espidf"
  ],
  "platforms" : [
    "espressif32"
  ],  
  "name": "Espressif ESP32-S3-DevKitC-1-N8R2 (8 MB QD, 2 MB QD PSRAM)",
  "upload": {
    "flash_size": "8MB",
    "maximum_ram_size": 327680,
    "maximum_size": 8388608,
    "require_upload_port": true,
    "speed": 921600
  },
  "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html",
  "vendor": "Espressif"
}

PRTITION file default_8MB_devkitc_n8r2.csv

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x330000,
app1,     app,  ota_1,   0x340000,0x330000,
spiffs,   data, spiffs,  0x670000,0x180000,
coredump, data, coredump,0x7F0000,0x10000,

Looks like your ESP32 is still in Download-Mode.
Did you reset your ESP after uploading?

In USBCDC Mode (Software / TinyUSB) the “Serial” COM Port will be different form the Upload COM Port when the ESP reboots!

Put your custom board.json files in C:\Users\<username>\.platformio\boards
This will survive platform updates.

Maybe there is something odd now that you mention TinyUSB.
After upload finishes the JTAG port COM34 is not changing to COM36 (TinyUSB) as it happend some days ago. Not sure why it is not happening now.

I did indicated COM34 at the bottom in the PIO bar but the output is still empty

I did it with monitor_port = COM34 still active in the INI file and commented out too, with the same result.

You need to reset your ESP32 manually.
Then you should here the disconnect / connect sound from Windows and the COM Port 36 should become available in the COM Port selector.

By the way: You don’t need to #include <USBCDC.h>.

ESP32 put in upload mode (press and hold BOOT + short press on RESET).
COM12 is the JTAG/Serial (hardware) port

After uploading the sketch and reset of the ESP32:
The TinyUSB Serial (software USBCDC) port comes available on COM13:

Opening PIO’s serial monitor on COM13 shows:

To upload a new sketch, the ESP32 must be put into download-mode again by press & hold BOOT + short press on RESET.
Now COM12 is available for uploading a new sketch…

Due to a bug in Arduino Core 2.x.x (before version 2.0.17) no automatic reset is performed after uploading a new sketch via HWCDC.

This has been fixed with the Arduino core version 2.0.17, which is not yet available in PlatformIO.

If I disconnect the Kit from the PC USB port and reconnect, I go back to TinyUSB COM36.

imagen

If I attempt to upload under this condittion I get an error (I will copy two sequential upload attempts one with upload_port = COM34 in the INI file [obviously fails because it does not exists] and the next one with upload_port = COM36, that does exist)

First UPLOAD on COM34

Executing task: C:\Users\tmagdahl\.platformio\penv\Scripts\platformio.exe run --target upload --upload-port COM34 

Processing esp32-s3-devkitc-1-n8r2 (platform: espressif32; board: esp32-s3-devkitc-1-n8r2; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n8r2.html
PLATFORM: Espressif 32 (6.7.0) > Espressif ESP32-S3-DevKitC-1-N8R2 (8 MB QD, 2 MB QD PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20016.0 (2.0.16)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Checking size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.5% (used 31192 bytes from 327680 bytes)
Flash: [=         ]   9.5% (used 317493 bytes from 3342336 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Using manually specified: COM34
Uploading .pio\build\esp32-s3-devkitc-1-n8r2\firmware.bin
esptool.py v4.5.1
Serial port COM34

A fatal error occurred: Could not open COM34, the port doesn't exist
*** [upload] Error 2
================================================================================== [FAILED] Took 4.00 seconds ==================================================================================

 *  The terminal process "C:\Users\tmagdahl\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--upload-port', 'COM34'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Second UPLOAD attempt on COM36 (TinyUSB). Seems to me that TinyUSB is not good for UPLOAD.

Executing task: C:\Users\tmagdahl\.platformio\penv\Scripts\platformio.exe run --target upload --upload-port COM36 

Processing esp32-s3-devkitc-1-n8r2 (platform: espressif32; board: esp32-s3-devkitc-1-n8r2; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n8r2.html
PLATFORM: Espressif 32 (6.7.0) > Espressif ESP32-S3-DevKitC-1-N8R2 (8 MB QD, 2 MB QD PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20016.0 (2.0.16)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Checking size .pio\build\esp32-s3-devkitc-1-n8r2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.5% (used 31192 bytes from 327680 bytes)
Flash: [=         ]   9.5% (used 317493 bytes from 3342336 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Using manually specified: COM36
Uploading .pio\build\esp32-s3-devkitc-1-n8r2\firmware.bin
esptool.py v4.5.1
Serial port COM36
Connecting......................................

A fatal error occurred: Failed to connect to ESP32-S3: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
*** [upload] Error 2
================================================================================== [FAILED] Took 11.88 seconds ==================================================================================
 *  The terminal process "C:\Users\tmagdahl\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--upload-port', 'COM36'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

If I reset the Kit with its two buttons COM36 (TinyUSB) mutates to COM34 (JTAG Interface 0). Under these condittions UPLOAD works fine. IMHO uploading has never been an issue, after I learned (more than a week ago) that I had to reset the Kit for this to happen.

Now from one of your previous posts I understant I might need to reset the Kit after UPLOAD finishes?, but in such a case in my environment COM34 still stays as COM34 (JTAG Interface 0) and if I open the Serial Monitor nothing is printed (waited more than a minute).

Commenting now to your following post

In your screen captures, COM12 is in my case COM34 (the dropdown list shows JTAG Interface 0).
The screen capture after you UPLOAD and RESET (I am not shouting when using capitals :rofl:)
shows COM13 which I guess is TinyUSB as you describe (the droplist shows COM13 but no mention of TinyUSB) and that would be COM36 in my setup.

But the difference between your setup and mine is that after an upload success and a manual reset, in your case you experience a COM12 to COM13 change (In my septup that would be COM34 to COM36 respectively).
But in my case after an upload success and manual reset my COM34 stays as COM34 which seems to be odd.

Instead of manual resetting after upload I will do the reset by unplugging the USB cable which will make it change from COM34 (your COM12) to COM36 (your COM13). I am writing while I am performing the test.

Now it worked! But the reset I have to do by unplugging the cable.
Yes it changed to COM36 (your COM13) and if I open Serial Monitor I do have output now, but missed a lot of the first prints due to the USB cable disconnect and because the still open Serial Monitor will not reconnect and I have to kill it and launch it again.
Any clue why my manual reset is not behaving the same?
I am not 100% sure but this cable disconnect might generate a big mess when trying to debug?

Well, not sure why, but when I use

build_flags = 
	-DARDUINO_USB_CDC_ON_BOOT=1    ; Serial Monitor on Serial0
    -DARDUINO_USB_MODE=0           ; Serial on USBCDC

DEBUG is not stopping at its default temporary break point, neither at the hard ones I defined in SETUP and LOOP.
But for debug to work (it needs to be able to upload the recompiled code), but even if I can (obviously with external help) get it to debug, if I had to reset the Kit, manually or by disconnecting the USB cable, the debug session will probabbly not be very happy. So it seems it will be impossible to inspect the Serial CDC output while debugging under these terms?

True, as I wrote above!

The TinyUSB interface cannot be used for uploading (and debugging to answer your next question beforehand).

True again, as I wrote above.
The ESP32 is now in upload mode and awaiting new firmware to be uploaded.

True, otherwise the ESP will stay in upload mode.

That’s strange! A single press to RESET should result in a reset of your ESP32 !?
Don’t hold the BOOT Button pressed! Otherwise the ESP32 will again enter upload mode.

In result this is a RESET of the ESP32.

Great! The Serial Monitor (VS Code Extension) offers automatic reconnection:

This will minimize your loss of the first lines.

For some (unknown) reason, my COM13 (TinyUSB) is not shown correctly. It is statet as "USB JTAG/serial debung unit. While running ZADIG this is shown correctly:

As written above, TinyUSB cannot be used for debugging. This is only available via HWUSB (ARDUINO_USB_MODE=1) which will result in a single COM (COM 12 in my case) and shown correctly in Zadig as follow:


Yes, as written above, TinyUSB cannot be used for debugging.

1 Like

Hi,

I am not close to my board right now so I will try it later

The sequence:
Press BOOT / Press RESET / Release RESET / Release BOOT
is to enter UPLOAD mode (move from TinyUSB to JTAG Interface 0)

And in this answer from you I am quoting, the sequence should be:
Press RESET / Release RESET
?

I was doing the BOOT/RESET sequence :crazy_face:.

Regards

Correct

That’s a normal reset to reboot the ESP into application mode.

Thanks again sivar2311 for all the help.
Really appreciate it!