PlatformIO Community

Just Upload build without recompile nor scan dependencies

Hi, first post in this comunity and recently discovering PIO. (came from Arduino IDE), Hope this helps anyone else than me, as I saw this question/issue around in many forums:

Issue: Upload button in toolbar checks for changes for recompiling and scans dependencies, but you know the already made .bin/hex files are ok because you just compiled them.

Expected behaviour: just want to upload quickly, I have so many boards to upload and don’t want to wait slow checks, skip those checks and just call upload command, I also don’t want to use another program for uploads.

Actual Solution: Upload Latest build without a Compile/Link
But it has a drawback, that if it can’t upload (eg. it doesn’t find com port or device was not responding), the compiled bin/hex will be erased, how anoying!

New Solution: use command platformio run -t nobuild -t upload --disable-auto-clean
note: COM port should be selected in platformio.ini or specified with -p COMx

Better Solution: Add previous command as a custom task so you don’t have to write the command every time. How? Click Terminal > Run Task… and click on the gear of option PlatformIO: Upload to configure a custom task, it will create/open .vscode/task.json there add the following task lines:

        {
            "type": "shell",
            "command": "platformio run -t nobuild -t upload --disable-auto-clean",
            "problemMatcher": [
                "$platformio"
            ],
            "label": "Upload No Build",
            "options": {
                "env": {"PATH": "{PATH to}/.platformio/penv/Scripts"}
            }
        }

In Label, you can put whatever you want this task to be called, and it will appear in Terminal > Run Task…
The options PATH is only required if platformio is not added to your system environment variables/path, {PATH to} should be replaced accordingly to your system where pio/platformio binaries are located, in Windows is usually in your C:/user folder, Linux should be ~ or home

Example task.json file if you have some other custom tasks (I have a useful Device List to show available COM ports):

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "command": "platformio run -t nobuild -t upload --disable-auto-clean",
            "problemMatcher": [
                "$platformio"
            ],
            "label": "Upload No Build",
            "options": {
                "env": {"PATH": "C:/Users/Axel/.platformio/penv/Scripts"}
            }
        }
        {
            "type": "shell",
            "command": "platformio device list",
            "problemMatcher": [
                "$platformio"
            ],
            "label": "Device List",
            "options": {
                "env": {"PATH": "C:/Users/Axel/.platformio/penv/Scripts"}
            }
        }   
     ]
}

Best Solution Would be to change the upload button or add a new button as a custom command in PIO toolbar, but as far as I have read the only easily customizable button is build.

1 Like