I have an issue where the serial port disappears after the Portenta starts executing code.
I am unable to load a program, unless I double click the reset button. At that point the COM port appears in Device Manager and the Arduino IDE (COM 9 in my case).
Program compiles and uploads OK, but the moment it starts running, the COM port disappears, and windows has a message that the last device plugged in was not recognized or is malfunctioning.
the program runs OK on the H7 (just a blink light program for now).
However there is no port in Device Manager or the IDE. The serial monitor will not work, as no port exists to connect to the H7.
If I double click the blue reset button to go into bootloader mode, the serial port reappears.
The tricky thing about the boards with native USB capability like the Arduino Portenta H7 is the USB code that creates the CDC serial port is running on the same microcontroller as your sketch. This means your sketch code can break the USB code, or stop it from running. When that happens, it no longer presents a port.
Sometimes this is normal and expected behavior for your sketch. In other case, it is caused by a bug. With the boards like the Portenta that run the Mbed OS core, you may see the LED do a 4X long, 4X short blink pattern to indicate that something in the sketch has crashed Mbed OS
As you found, the board can easily be recovered by pressing the reset button twice. However, if you don't upload a new sketch, or upload some other problematic sketch, the problem will persist. In this case of a multi-core board, even if you upload a perfectly working sketch to the M4 core, the sketch on the M7 core can still cause the loss of the serial port.
What happens if you upload a basic sketch to the M7 core?
For example:
void setup() {}
void loop() {}
(note that the program on the M4 core won't run with this particular sketch, since it doesn't boot)
My code was blinking the RED LED, so when the MBED had crashed, and the LED was blinking, I though the code was actually running. Once being pointed to the fact that the RED LED was actually an SOS blink (by in0), I figured out the problem - I had cut and pasted the code from another project, and added the blink LED code, but did not remove a line that was accessing the I2C (and I had deleted the Wire.begin in the setup).