Why rebuild for changes like upload_port?

It seems that if I change anything in platformio.ini, and I press the upload button, it rebuilds the whole project. I could understand it if the change is something that can change the build configuration or something, but it seems that miscellaneous things that should not affect the binary also triggers rebuilding, such as the upload_port (IP address of the OTA target).

Can’t it be smarter and NOT rebuild the whole thing if the changes to the platformio.ini does not change the binary?

1 Like

There are edge cases which affect compilation, e.g., you can engineer a script that takes the upload_port value and makes it available to the firmware code as a macro, based on which the firmware can choose to have an entirely different behavior (How could the main.cpp read the parameters at platformio.ini? - #3 by maxgerhardt), and hence the safe choice is to always fully recompile.

I would like to reanimate this, as I have an increasing number of devices with identical firmware that need to be updated one by one - hence the firmware is built again and again.

I would love to see an alternative option like upload_port_no_rebuild_on_change=... or such that has the desired functionality, but will make clear what happens when is used.

1 Like

@miq19, have you considered not specifying the port in platformio.ini and set it instead in the status bar or VSCode?

This is what I do, and the status bar is typically set to ‘auto’ which works when I have a single device connected or I set it manually to a specific port if needed. E.g., for ESP32:

Also, if what you want is just to flash a number of devices, you can write a shell script that will do it for you, without doing any build. E.g. for ESP32:

1 Like

@zapta Thanks for your advice. Both are referring to a physical upload_port rather the OTA IP address or DNS name I was referring to. But the second with the script is worthwhile to be examined. With the proper esptool parameters this may work for me.

I will need to find out what parameters PlatformIO is supplying to esptool.

Update: the modification of the status line port does not work for me, it will result in the same build-upload cycle.

I think in this case a upload-without-build should work on the CLI: Upload Latest build without a Compile/Link - #4 by ivankravets

Thanks, will give that a try soon! :+1: