Port not detected/updated after it changes

You can do both on both ports (uploading and serial monitor).

The flag just defines that the Serial object is of type USBCDC or HWCDC instead of HardwareSerial. See

and