Excluding specific serial ports from auto-detection?

Is it possible to explicitly exclude some specific serial ports from ever being automatically selected as the port that PlatformIO tries to upload the sketch to? My laptop has a built-in 3G card, which creates three serial devices. These are always /dev/ttyACM0, /dev/ttyACM1, and /dev/ttyACM2. PlatformIO always autoselects the first one of these and tries uploading the code there, which obviously doesn’t work.

I don’t want to hard-code the serial port device, as that tends to change around depending on which board I’m using, and some other circumstances. I only want to make sure that none of these three serial ports is ever automatically selected as the port to upload to. Is this possible to configue? I didn’t find anything on this.

1 Like


I have exactly the same situation.
Did you resolved ?



Did the question asked ever get solved i.e.
How to EXCLUDE specific ports from being used by the auto-detect

I’ve got COM1 (true serial com port on motherboard) connected to a scanner and COM3 which is a FTDI USb to serial cable connected to a bench multimeter.

Neither of these will ever be connected to a device for programming so HOW can they be excluded. I’d still like the autodetect any other device that gets plugged in, as windows doesn’t always assign the same com port every time (also I have lots of USB ports, and won’t always have a device plugged in to the same USB port).

Could you file a feature request here Issues · platformio/platformio-core · GitHub ?

I think it makes sense to allow passing quantifiers directly to the upload_port and PlatformIO should resolve them. For example, upload_port = vid:10c4 pid:"ea[67][013]". Will this solve your issue?

I realised that the parameter allows wildcards to INCLUDE ports, but how for example can you write COM9 and COM11 and COM13 but not COM1 and COM3.

I’ve just been checking wildcard syntax, and wondered if it is possible to use the NOT qualifier like this
upload_port = COM[!13]

This would solve my issue for now, but longer term it would be more useful to be able to control what the autoscan ports feature looks at, rather that scanning everything or just the port specified.

I’ve just created a new feature request. Please follow it