Unfortunately although I have a good deal of experience with the Portenta H7 Arduino board that is the brains of the Portenta Machine Control, I don't have any experience with the Portenta Machine Control control itself and don't have access to this hardware.
The tricky thing about the boards with native USB capability like the 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, the board no longer produces a serial port. This can be caused by a bug in the sketch code (e.g., dividing by zero), or as an expected result (e.g., putting the microcontroller to sleep).
This can be unexpected to those who previously mainly worked with the boards like Uno and Mega with a dedicated USB chip that can never be affected by the sketch code.
The missing port makes it so you can't upload normally any more. However, the situation is really not so bad because there is an independent program called the bootloader in a separate section of memory from your sketch, and that program has its own USB CDC code. So even if the sketch is completely broken, you only need to activate the bootloader to get a port back and be able to upload.
On the Portenta H7 board, that is done by the following procedure:
- Connect the Portenta H7 board to your computer with the USB cable.
- Press and release the reset button on the board.
- Wait for the green LED near the USB socket on the board to turn on.
It does this almost immediately, but you do need to wait for it.
- While the green LED is still on (it only stays on for one second so you need to be somewhat quick), press and release the reset button again.
The green LED should now start pulsing. If not, repeat the process in case you didn't get the timing quite right.
After that, the board should produce a serial port. Once you have activated the bootloader, the board remains in the bootloader mode until an upload is completed or the board is reset or power cycled.
If you once again upload the same sketch that caused the loss of the serial port, it is likely this will happen again. If the loss of the port is unexpected, this means that you still need to evaluate the code to try to find out what is causing it, but at least once you know the recovery technique this is not a dead end situation.
Unfortunately I'm not sure of the behavior of the Portenta Machine Control related to this double reset technique and I didn't find any information about it in the documentation. The Portenta H7 inside is no different from using a standalone bare Portenta H7 board, but the electrical interface (reset button and LED) between the Portenta Machine Control hardware and the Portenta H7 board inside might result in differences in behavior that I am not aware of.
Another thing to consider is that the sketch program interfering with the USB CDC functionality is only one possible cause of the "no port" symptom. There are other common causes of this symptom:
- Using a charge-only, damaged, or defective USB cable.
- Permanent physical damage to the hardware.
If the problem is the USB cable, it can be solved by using a different cable. Make sure it is fully inserted into the jack on the Portenta Machine Control and your computer.
If the problem is physical hardware damage then it is usually not easily repairable and the solution is to replace the hardware.
I'm sorry I'm not able to provide more effective assistance for this specific hardware. You can contact Arduino technical support, who are better equipped to support Portenta Machine Control users:
https://www.arduino.cc/en/contact-us