PlatformIO Community

Upload Latest build without a Compile/Link

I have seen a couple entries but did not feel it was answered (or maybe I just hoped there was a “new answer”).

I have the situation where I am flashing a bunch of processors (most of them virgin). In my old Visual Studio there was an UPLOAD option which took the most recent build and the current platform and port - and just transferred the code.

As best I can see - this works the same as the Arduino (and others) - of doing a code compile validation and then uploads - it works and is fine - just hoping there is a simple way within the IDE to “just upload”.

I know I can use the HEX file and external program - but was hoping for a simpler solution.

Thanks

I’m not sure what your requirements are. You want an upload button which does not compile the firmware but instantly uploads? (btw, if there are no source code changes, PlatformIO will not recompile a source file and just upload).

If you want a faster upload method then a small custom script which invokes the upload program might be best for you. What board are you using?

1 Like

There’s no just upload whatever was last built option… ) Ignore me… see next post. :man_facepalming:

It comes down to a question of ‘what are you trying to achieve’ … as for me, doing a build without changing code takes a whopping 1.040 seconds … so about 1.5 seconds after me hitting the upload button, PlatformIO will be trying to upload the code, if it hasn’t been changed since the last build. If you needed upload only, that is a bit too specific, and as @maxgerhardt pointed out, is best done with a custom script… which could possibly be just a matter of coping the actual upload command from a ‘verbose upload’ run into a script and running that on demand…

pio run -t nobuild -t upload.

2 Likes

I have multiple reasons to get upload working without compile, but the above command does not seem to work for the Arduino UNO either for local or remote projects.

If I do a normal upload then change the main.cpp and run the above command what gets uploaded is always the new version. Makes sense for the default to always be the latest build however I would really like to be able to use the upload command with a pre-compiled build.

I have looked into advanced scripting but nothing seems to be an easy solution.

If that feature is broken please open an issue at https://github.com/platformio/platformio-core.

No problem logging an issue, just wondering if it works for anyone else? I will do some more testing, perhaps it works for some boards and not others.

You’re right, actually I can’t reproduce this.

I did an Uno project

[env:uno]
platform = atmelavr
board = uno
framework = arduino

with a src\main.cpp of

#include <Arduino.h>

void setup() {
	Serial.begin(115200);
}

void loop() {
	Serial.println("Version 1!");
	delay(1000);
}

Upload to the board an I get

Version 1!
Version 1!

Now change the string to “Version 2” and execute pio run -t nobuild -t upload:

C:\Users\Maxi\Documents\stackoverflow_testing>pio run -t nobuild -t upload
Processing uno (platform: atmelavr; board: uno; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Auto-detected: COM10
Uploading .pio\build\uno\firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file ".pio\build\uno\firmware.hex"
avrdude: writing flash (1640 bytes):

Writing | ################################################## | 100% 0.27s

avrdude: 1640 bytes of flash written
avrdude: verifying flash memory against .pio\build\uno\firmware.hex:
avrdude: load data flash data from input file .pio\build\uno\firmware.hex:
avrdude: input file .pio\build\uno\firmware.hex contains 1640 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.21s

avrdude: verifying ...
avrdude: 1640 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

============================================= [SUCCESS] Took 3.38 seconds =============================================

And then on the serial monitor

C:\Users\Maxi\Documents\stackoverflow_testing>miniterm.py --exit-char=50  COM10 115200
--- Miniterm on COM10  115200,8,N,1 ---
--- Quit: u'2' | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Version 1!
Version 1!

After pio run -t upload

Version 2!
Version 2

So now I’d need you to reproduce this project and compare the results.

1 Like

Thank you so much @maxgerhardt for that complete reply. It works local but not remote for me on Gitpod cloud.

I have been having a few VSCode setup issues (Great on my windows 10 laptop, bad on my windows 10 desktop) so it is really helpful seeing working code. I will file an issue, but only for the remote command. Your code and my own testing shows it works fine for a local VS code build. I am only having problems with my remote build

The following does not work for me running Platformio on a Gitpod Cloud docker github of it here
Open in Gitpod

pio remote run -t nobuild -t upload

.

The following works fine on a local computer running VS Code

pio  run -t nobuild -t upload

So I guess I now need someone with a cloud setup to test if “pio remote run -t nobuild -t upload” works for them.

On second thought I might be able to use 2 local computers to test out a remote build. Back in a bit.

.

So running VS-Code local on a windows machine with

pio account login
pio remote agent start

Then on a ubuntu laptop running VS-Code after changing your code to version 2! (By the way I used 9600 for the serial baud rate)

pio account login
pio remote run -t nobuild -t upload

I get serial output of

Version 2!

So it looks like the problem is with “pio remote run” not just on the Gitpod cloud platform. Can someone else confirm this?

Issue submitted to https://github.com/platformio/platformio-core/issues/3302

1 Like