4

The resources I've found regarding the Command Line interface seem to be out of date so I was hoping to find someone with experience using it. I'm currently running Arduino 1.5.6-r2 BETA on Windows 8.1 looking to upload code to an Arduino Leonardo.

I'm trying to create a script(Powershell) file that I can just use to upload code without user intervention. The actual upload part using Arduino CLI is just straight not working for me. If my understanding is correct I should have it already due to my version of the Arduino IDE but none of the functionality works so I'm doubting myself.

Source: https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc

This is the command I'm attempting to run from Windows Command Prompt:

C:\Program Files (x86)\Arduino\arduino.exe --board arduino:avr:leonardo --port COM3 --upload C:\Users\Dev\Documents\Arduino\myProject\myProject.ino

Any insight into what I'm missing would be very much appreciated!

EDIT: Additionally, if anyone could provide information regarding the build/upload process which could lead me to a solution from within C# that would be even more amazing.

  • Personally, I'd compile to a hex file (or even read it back out of the board) and use avrdude, rather than rebuilding from source each time, unless doing a fresh build is part of your goal. At any rate, do you get any error output from your attempt? – Chris Stratton Jun 5 '14 at 21:36
  • @ChrisStratton Basically I'll be downloading updated versions of the code via Powershell, so I'm trying to figure out how to then deploy that code without having to manually go through the process using the IDE. If compiling to hex and using avrdude is a simpler solution capable of working for this, that fits my needs as well. – Karoly S Jun 5 '14 at 21:39
3

Turns out that the Ignoring Bad Library Name error that I had been receiving regardless of if I ran Arduino IDE through command line or standalone was the issue. For whatever reason it was blocking the script with a dialog that then failed the upload regardless of if I manually moved through the popup.

Final setup for those looking for this in the future:

Windows 8.1 x64 with Arduino IDE version 1.5.6-r2(I will revert to 1.0.5 and test with that, and report results) using a Leonardo board. Command is as follows:

Working Directory: C:\Program Files (x86)\Arduino

arduino --board arduino:avr:leonardo --port COM14 --upload C:\Users\Dev\Documents\Arduino\sketch_jun06a\sketch_jun06a.ino

EDIT: As promised, I attempted this with version 1.0.5-r2 and was unsuccessful. Potentially a 1.5.+ feature.

1

I recommend you to look into cross-platform tool named PlatformIO. It has support for Windows OS and doesn't require Arduino IDE or any tools.

From Get Started let's install platform and setup environment for your Arduino Leonardo:

Install new development platform

> platformio platforms install atmelavr

Initialize new PlatformIO based project

> cd path\to\empty\directory
> platformio init
# Project has been initialized!
# Please put your source code to `src` directory, external libraries to `lib`
# and setup environments in `platformio.ini` file.
# Then process project with `platformio run` command.

Setup environments in the Project Configuration File platformio.ini

[env:my_leonardo_board]
platform = atmelavr
framework = arduino
board = leonardo

Process the project’s environments

> platformio run --target upload

P.S: What is interesting, this tool allows you to manage libraries via CLI and then you can build Arduino-based source code with single line

#include <%HEADER_FILE_OF_INSTALLED_LIB>
  • 1
    You should point out that you are the author of PlatformIO – Casey Nov 18 '15 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.