Upload problem arduino nano esp32

I just got a arduino nano esp32 board and i tried to use it on platformio ide with espidf framework.
I used the tutorial here:

https://docs.platformio.org/en/stable/tutorials/espressif32/espidf_debugging_unit_testing_analysis.html

It compiles perfectly and after upload successfully with dfu i can find the “mywifissid” wifi, which means the program is also running successfully.

But my problem is, the com port of the board disappered after the upload, and i can not see the ouput from the serial monitor. It only shows:

  • Executing task: C:\Users\Waste.platformio\penv\Scripts\platformio.exe device monitor

— Available ports:
— Enter port index or full name:

And another problem is, when i power off the microcontroller and restart it, the programm disappered. If i reset the microcontroller with the reset button, the programm also disappers.

I would be very grateful if someone can tell me how to solve these problems. Thanks!

Here my platformio.ini:

; PlatformIO Project Configuration File

;

; Build options: build flags, source filter

; Upload options: custom upload port, speed and extra flags

; Library options: dependencies, extra library storages

; Advanced options: extra scripting

;

; Please visit documentation for the other options and examples

; Redirecting...

[env:arduino_nano_esp32]

platform = espressif32

board = arduino_nano_esp32

framework = espidf

upload_protocol = dfu

Same issue on my side :frowning:

Can you upload the exact project files which, when uploaded, make the COM port of the Nano ESP32 disappear?

Here it is:

platformio.ini

[env]
platform = espressif32
framework = espidf
monitor_speed = 115200
; [env:esp32dev]
; board = esp32dev
[env:arduino_nano_esp32]
upload_port = COM13
upload_protocol = dfu
board = arduino_nano_esp32
build_flags = -DCORE_DEBUG_LEVEL=1
-DLOG_LOCAL_LEVEL=ESP_LOG_INFO

code

#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "sdkconfig.h"

static const char *TAG = "example";

static void http_get_task(void *pvParameters)
{
    while(1) 
    {
        vTaskDelay(4000 / portTICK_PERIOD_MS);
        ESP_LOGI(TAG, "... connected");
    }
}

void app_main(void)
{
     ESP_ERROR_CHECK( nvs_flash_init() );
     ESP_ERROR_CHECK(esp_event_loop_create_default());
     xTaskCreate(&http_get_task, "http_get_task", 4096, NULL, 5, NULL);
}

And you configured USB CDC in the menuconfig per this?

After I change ConsoleOutput to USB CDC , I have compile errors:

....platformio/packages/framework-espidf/components/esp_system/port/soc/esp32s3/usb_console.c:69:1: error: static assertion failed: "usb_osglue_*_int is not multicore capable"
   69 | _Static_assert(SOC_CPU_CORES_NUM == 1, "usb_osglue_*_int is not multicore capable");
      | ^~~~~~~~~~~~~~
....platformio/packages/framework-espidf/components/esp_system/port/soc/esp32s3/usb_console.c: In function 'esp_usb_console_read_buf':
....platformio/packages/framework-espidf/components/esp_system/port/soc/esp32s3/usb_console.c:337:10: error: implicit declaration of function 'esp_usb_console_read_available'; did you mean 'esp_usb_console_write_available'? [-Werror=implicit-function-declaration]
  337 |     if (!esp_usb_console_read_available()) {
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |          esp_usb_console_write_available
....platformio/packages/framework-espidf/components/esp_system/port/soc/esp32s3/usb_console.c: At top level:
....platformio/packages/framework-espidf/components/esp_system/port/soc/esp32s3/usb_console.c:365:6: error: conflicting types for 'esp_usb_console_read_available'; 
have '_Bool(void)'
  365 | bool esp_usb_console_read_available(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
....platformio/packages/framework-espidf/components/esp_system/port/soc/esp32s3/usb_console.c:337:10: note: previous implicit declaration of 'esp_usb_console_read_available' with type 'int()'
  337 |     if (!esp_usb_console_read_available()) {
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1.exe: some warnings being treated as errors
*** [.pio\build\arduino_nano_esp32\esp_system\port\soc\esp32s3\usb_console.o] Error 1

There indeed seems to be an open issue about it. Try using the USB_SERIAL_JTAG option instead instead per

Actually, above problem was referenced as solved in ESP-IDF v5.1.

PlatformIO uses 5.1.2 by default and should have that fixed.

Are you sure you have a completely updated platform? You may need to just remove C:\Users\<user>\.platformio\platforms\espressif32* and restart VSCode.

Also set to USB_SERIAL_JTAG => the port became unavailable

And when you additionally add this code in your app_main function?

Are you sure you have a completely updated platform? You may need to just remove C:\Users\<user>\.platformio\platforms\espressif32* and restart VSCode.

Yes, Doesn’t fix it

It works. Thank yoy

Can you additionally check whether this TinyUSB example works? It doesn’t use the USB JTAG controller but the USB OTG controller. Also, ESP_LOGI etc. should work natively with this, not sure with the USB JTAG controller.

It works, but the line printed by ESP_LOGI has invalid chars:
␛[0;32mI (24450) example: log → UART␛[0m

That is actually correct. These are ANSI color codes, green for info logs.

It additionally needs

monitor_raw = yes

in the platformio.ini to display it correctly. (see similiar topic)