Arduino Leonardo/Micro and USB CDC

Hi all,

I’m at my wits end with this. Using PlatformIO core 5.1.1 and the Arduino 3.4.0 platform.
Every time I upload to my two Arduino Micros, whether I set them as Leonardos or Micros, I will loose the USB-CDC (serial port) every time. I have to burn a new bootloader in order to get it to work again. On the regular Arduino IDE it works as one would expect.

I have this in my platformio.ini currently:

[env:leonardo]
platform = atmelavr
board = leonardo
framework = arduino
lib_deps = mheironimus/Joystick@^2.0.7

debug_tool = simavr

build_flags = 
    ; enable USB serial
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D USBCON
; QUIRK: without setting this, no  
; data will be received on the serial USB port
; https://github.com/stm32duino/Arduino_Core_STM32/issues/1193
; monitor_dtr = 1
; optional: set COM port to monitor here if there are multiple
;monitor_port= COM27

But doesn’t seem to matter what I do, it will not give me the serial port.

Thank you for any help in advance

… these are configuration options for the STM32Duino core per docs, that won’t have any effect on the AVR Arduino core.

Does a minimalistic sketch and platformio.ini also cause the device to loose the USB CDC? The sketch must at least do a Serial.begin though. You should also take care if you have a clone Micro board and try the 5V/16MHz or 3.3V/8MHz board definitions accordingly.

[env:micro]
platform = atmelavr
board = sparkfun_promicro8
; OR
;board = sparkfun_promicro16
framework = arduino
#include <Arduino.h>

void setup() { Serial.begin(115200); }
void loop() {}