PlatformIO will recompile your project upon every change of the platformio.ini.
You might be able to do something against that with three things:
Remove the upload_port directive in the platformio.ini. PlatformIO will try to auto-detect the correct board. If you only ever have one dev-board connected to your computer, this should always work.
Create two environments which contain the two possible upload ports. This only works if the upload ports are entirely predictable. Then make sure to press “Upload” in the correct environment within the project tasks window of VSCode. Example:
I guess I really am looking for the build process to ignore the port selected.
I am probably not using the correct terminology here but…normally when I have had a successful build I make a small program change and the build process uses some archived info and is quick. Generally when I change the port I would also change some small part of the program. So I want the build to implement the program change but still use the archived core.
My PC is so underpowered it would make a lot of difference.
Perhaps it’s to do with the fact that platformio seems to discard all cached .o files when the platformio.ini file is changed - or at least that’s what I’ve seemed to notice, someone more familiar with the codebase could probably say whether that’s true or not. gcc will use cached object files for all translation units that haven’t changed IIRC.
I say in that case that the command line tool is probably your easiest way around that - you just specify the COM port with --upload-port.
Otherwise, as long as you use the same USB port and same device, I rarely have issues with the port changing so you could try and keep the same device plugged into the same ports?