Annoying re-compile


I hope I am in the right place and this question is not a repeat or too trivial.

I compile OK for a nodeMCU. Upload fails as I have specified the wrong port in platformio.ini. So I correct the port. The thing then recompiles…which takes a while.

Can this behaviour be changed?

I know I can autodetect but often I have more than one board attached.

Thank you.

PlatformIO will recompile your project upon every change of the platformio.ini.

You might be able to do something against that with three things:

  1. 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.
  2. 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:
[env] ;global settings for all environments
platform = espressif8266
board = nodemcuv2
framework = arduino
monitor_speed = 115200 ; other options..

upload_port = COM3
monitor_port = COM3

upload_port = COM5
monitor_port = COM5
  1. If possible, use wildcard expressions as shown in docs.


Thank you for the reply and suggestions.

However, as I said, I often do have multiple target boards connected.

Under Windows ports are about as predictable, not to say stable, as an unstable thing. Like nailing jelly (jello) to a tree, as they say.

So I guess I will have to live with it. Maybe the default re-complie could be made to ignore port enumeration and speed changes?

What about using -t nobuild?

E.g. platformio run -t upload -t nobuild --upload-port COMxx will try reuploading with the previously compiled binary.

It doesn’t seem to be documented anywhere but I recently discovered it and it has been super useful.


Thank you that.

I shall look into it.

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?

Looking into the platformio source code, it seems there is a flag --disable-auto-clean:
pio run --disable-auto-clean
That worked for me.