I have Platformio IDE 1.10.0 installed on VSCode (WIN10). Platform is espressif32 V1.11.1, building on a lolin_d32_pro board.
Board flashing’s upload_port auto-detect is working correctly. But the serial monitor’s monitor_port does not auto-detect and instead I have to type in the COMx port.
I tried specifying the COM port with a wildcard in platformio.ino. Like this: monitor_port = COM*
The good news is that this automatically launches the monitor terminal after each flash upload, but it chooses the wrong port for the monitor. For example, the ESP32 board is on COM4, but the monitor_port wildcard is picking COM5.
I have temporarily solved the issue by specifying the exact monitor_port COMx value in platformio.ini. Like this: monitor_port = COM4
This works great for me. After a flash it automatically opens a monitor terminal for my serial debugging. But specifying a fixed COMx is problematic since port usage can vary with the other project members.
I would like to have monitor_port automatically copy the auto-detected COM port found by upload_port. Is this possible (or is there another solution)?
What port does it open when not specifying monitor_port
explicitly?
If monitor_port is not specified in platformio.ini then this is what I see when I open the serial monitor terminal:
--- Available ports:
--- 1: COM1 'Communications Port (COM1)'
--- 2: COM2 'High-Speed USB Serial Port (COM2)'
--- 3: COM3 'High-Speed USB Serial Port (COM3)'
--- 4: COM4 'USB-SERIAL CH340 (COM4)'
--- 5: COM5 'USB Serial Port (COM5)'
--- Enter port index or full name:
My ESP32 is on COM4, so I have to manually enter it to select the monitor port.
As mentioned, if I use the wildcard in platformio.ini, auto-detect chooses COM5.
I’ve continued my experimentation with the USB port problem. I’m seeing some interesting behavior.
I removed the COM5 USB adapter and everything works perfectly; Both upload and serial monitor are correctly auto-detected. So this hinted that maybe the issue was caused by the COM5 device. But if it was only that easy. Read on …
So I installed a random FT232RL USB adapter from a desk drawer. It was assigned COM10. To ensure a clean start I rebooted the PC and launched the VS Code IDE. Now when I choose serial monitor the list looks like this:
--- Available ports:
--- 1: COM1 'Communications Port (COM1)'
--- 2: COM2 'High-Speed USB Serial Port (COM2)'
--- 3: COM3 'High-Speed USB Serial Port (COM3)'
--- 4: COM4 'USB-SERIAL CH340 (COM4)'
--- 5: COM10 'USB Serial Port (COM10)'
--- Enter port index or full name:
Choosing COM4 enables the ESP32’s serial monitor. So at this point it looks like the behavior follows what I saw when the COM5 device was present.
But now when I do a flash upload it auto-detects COM10! I removed the COM10 USB device and flash Upload correctly auto-detects COM4.
As before, any advice is appreciated.
Path of least resistance is probably to go into the Device Manager, open up COM4 (i.e. your ESP32’s CH340 Serial port), assign it to a specific out of the way COM port number, and then lock that in explicitly as your upload and monitor ports.
@pfeerick: Your workaround would be functional, but the build is an open source project. So it’s important to solve this within a default platformio.ini or other common project file in the distribution. This will save other project builders from having to perform special customizations.
I’m beginning to wonder if I’ve uncovered a oddball port detect bug. But I don’t want to needlessly open an issue ticket until I have checked off all the boxes, so to speak.
1 Like
My monitor port and upload port issues are resolved. As follows:
(1) Unlike the Upload port, the Monitor port does not use auto-detection. If only one COMx port has a VID:PID tag in its description then it will be automatically chosen. If more than one are detected then the user must manually choose the port. For now I am using monitor_port = COM4 in my platformio.ini
(2) The incorrectly chosen Upload port was solved by adding an extra_scripts file to platformio.ini. The file contains the USB PIDS / VIDS of my board’s EPS32. Details to this are discussed in the issue ticket mentioned above.