How do I use the Arduino IDE to upload the last compiled code? I don't want to have to wait 2 minutes to upload compiled code when there are no changes. It's a big codebase, where I frequently make one or two small changes and have some issue with my MCU or USB cables. Frequently the controller on my boards are damaged due to some overcurrent issue because of the high-heat nature of 3D printing. Having to wait an extra 2-5 minutes every time I experiment with this is unacceptable.
Obviously, there is a keyboard shortcut to do this that I'm unaware of, because otherwise this would add hours to development.
Please tell me how I can get the Arduino IDE to just 'upload without compiling' my sketch.
-
What version of the Arduino IDE are you using? It used to be rubbish, but later versions have better caching of compiled code. Alternatively UECIDE has far better caching than the Arduino IDE and recompilation is a lot faster because of that.Majenko– Majenko2019年09月17日 20:55:13 +00:00Commented Sep 17, 2019 at 20:55
-
you can find the compile bin file in your temp folder, then use a different upload tool (or OTA) to send it out.dandavis– dandavis2019年09月18日 05:32:21 +00:00Commented Sep 18, 2019 at 5:32
-
@Majenko: the link above to UECIDE doesn't seem to point to where it is supposed to point; maybe replace with github.com/UECIDE/UECIDE ?ocrdu– ocrdu2024年01月24日 22:58:06 +00:00Commented Jan 24, 2024 at 22:58
2 Answers 2
You can upload hex file to your board from command line without Arduino IDE.
To get the hex file, use in Arduino IDE in menu the command "Export compiled binary". It will save the hex file next to the ino file.
I assume your board in printer has AVR MCU. Then you can use avrdude from command line to upload the hex file again and again without any compilation.
The avrdude command on Windows is (if started from the sketch's folder):
%LOCALAPPDATA%\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/bin/avrdude -C%LOCALAPPDATA%\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM11 -b115200 -D -Uflash:w:Blink.ino.hex:i
The command line is for the Blink sketch and for AVC boards package 1.6.21
This is what I have done. In the arduino IDE settings panel, turn on the "Show verbose output during compile and upload". This way whenever you are doing verify and upload you can see all the command that Arduino has performed. Now after you hit Verify or Upload it, you can copy the last command before the upload, such as
"/Users/fang/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/Users/fang/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 "-P/dev/cu.usbmodem21101" -b57600 -D "-Uflash:w:/private/var/folders/xb/4609zdjx4tn3bv_6jh2nym_r0000gn/T/arduino/sketches/7972D54945A751059BF3114D2057C2B6/sketch_aug4c.ino.hex:i"
Now, when you need to upload without compiling again, just paste this line to the Terminal, it'll do the rest for you. Essentially you can see Arduino IDE is just a wrapper around these commands.
Update:
I also found another way which is kinda of different but more effective. If you happen to use Visual Studio Code, you can also try the PlatformIO plugin which can compile and upload code separately, I wrote an article about it here, https://windmaomao.medium.com/use-platformio-to-write-arduino-code-3c957c4e58b5