Problem to upload sketch with Arduino CLI.

I problem to upload a arduino sketch with Arduino CLI tool under Windows 10.
When I use following command to upload

D:\>arduino-cli upload C:\Users\Admin\Documents\Arduino\sketch_aug27a\sketch_aug27a.ino --port COM7 --fqbn arduino:avr:uno

I got this error message

Error during Upload: compiled sketch not found in 
C:\Users\Admin\Documents\Arduino\sketch_aug27a\build\arduino.avr.uno

Can someone help me?

1 Like

Hi @kenne76. Unlike the Arduino IDE and similar tools, Arduino CLI treats compiling and uploading as two separate processes. So you must compile your sketch before uploading it. You can do that as two separate commands (arduino-cli compile, arduino-cli upload):

D:\>arduino-cli compile C:\Users\Admin\Documents\Arduino\sketch_aug27a\sketch_aug27a.ino --fqbn arduino:avr:uno
D:\>arduino-cli upload C:\Users\Admin\Documents\Arduino\sketch_aug27a\sketch_aug27a.ino --port COM7 --fqbn arduino:avr:uno

or you can use arduino-cli compile --upload to compile and upload in a single command:

D:\>arduino-cli compile --upload C:\Users\Admin\Documents\Arduino\sketch_aug27a\sketch_aug27a.ino --port COM7 --fqbn arduino:avr:uno

Having a command that only uploads is convenient if you needed to upload the exact same sketch to multiple Arduino boards. The compilation process takes so time, so doing the same thing with the Arduino IDE would mean waiting for the sketch to be pointlessly recompiled before every upload. Since that's not a very common use case for Arduino users and separating the upload process from the compile process could cause confusion when people alter their code and then forget to compile it again before uploading, this capability was not provided by the designers of the Arduino IDE. However, the Arduino CLI is designed with more advanced users in mind so this "upload only" capability is provided.

If I use this code
arduino-cli compile --upload C:\Users\Admin\Documents\Arduino\sketch_aug27a\sketch_aug27a.ino --port COM7 --fqbn arduino:avr:uno
then I get the following error message
avr-gcc: error: C:\Users\Admin\AppData\Local\Temp\arduino-sketch-CC718361D3264C1E6D21A6417DC24544/core\core.a: No such file or directory
Error during build: exit status 1

How do I solve this problem?

This sort of error could be caused by your antivirus software. Try TEMPORARILY disabling your antivirus for a single compilation to see if the problem goes away, then turn the antivirus back on. If the problem doesn't occur with the antivirus off you will need to adjust the settings of your antivirus to whitelist the appropriate file, folder, or process so it doesn't interfere with compilation.

Please be cautious about working without an antivirus. This is only about temporarily disabling it for a quick test. If you don't feel comfortable doing that, fine. You can try going straight to configuring the antivirus to whitelist the Arduino software.