Arduino now has an officially supported command-line interface. The project, called arduino-cli, is the first time that the official toolchain has departed from the Java-based editor known as the Arduino IDE. You can see the official announcement video below.
Obviously this isn’t a new idea. Platform IO and other command-line driven tools exist. But official support means even if you don’t want to use the command line yourself, this should open up a path to integrate the Arduino build process to other IDEs more easily.
The code is open source, but they do mention in their official announcement that you can license it for commercial use. We assume that would mean if you wanted to build it into a product, not just provide an interface to it. This seems like something Arduino expects, because a lot of the command line tools can produce json which is a fair way to send information to another application for parsing.
The command line interface doesn’t just build a sketch. You can do things like install and manage libraries. For example, to create a new sketch:
arduino-cli sketch new HackadayPgm
You can update the installed platforms, list the connected boards, and search for board support:
arduino-cli core update-index arduino-cli board list arduino-cli core search mkr1000
If you don’t already have the board support, you can install it and verify that it is there:
arduino-cli core install arduino:samd arduino-cli core list
That last step will give you the FQBN or unique name for the core. So to compile and upload you have this mouthful:
arduino-cli compile --fqbn arduino:samd:mkr1000 Arduino/HackadayPgm arduino-cli upload -p /dev/ttyACM0 -fqbn arduino:samd:mkr1000 Arduino/HackadayPgm
Unlike, say, PlatformIO, this is clearly better for building into a tool, even if it is a makefile. We’d like to see a .build.json file or something that allows you to just issue short commands that do the right thing in a working directory. Of course, you could build that with a little shell scripting. Hmm….
It is nice to see the release of an official method and we hope this will lead to more editors being able to handle Arduino seamlessly.
Definite upgrade.
Thanks goodness.
I hope this would produce correct file paths. The arduino-builder script copies the sketch in the /tmp folder and compiles from there. If there is a compile error the path shown is the /tmp/… something, which confuses the IDE (Visual Studio Code).
Finally. If they had it 2 months ago I wouldn’t have wasted a month of frustration dealing with awful esp8266 sdks.
Could you be a littlebit more specific about the problem you ran into?
Working with the EPS8266 under the arduino environment has been super easy if you ask me can’t see how loosing the GUI and having an CLI would solve your problems?
Some people either prefers terminal editors or a very specific IDE.
A official CLI IDE implementation means it’s possible to keep it all terminal, or wrap it in a plug in so you can work from your preferred IDE.
I like to be able to assemble my projects by running make in the command line. As a rule, I believe that builds should be headless. Other than that, I don’t have problems with Arduino as platform. In fact, now that it has cli, it has become officially awesome.
Jesus Christ I have a twin
My name is Jacob not Jesus.
Awesome! This should make it much easier to remote update arduinos hanging off a raspberry pi or similar small linux computer (not that it’s terrible hard to use avrdude manually, but still)
Would be great to see a decent Arduino makefile template.
Or an Arduino plugin for Atom.
Like https://github.com/sudar/Arduino-Makefile, you mean?
Would be nice if someone made a comparison with Arduino Makefile https://github.com/sudar/Arduino-Makefile
yeah , sure , I will , the official one works.
This CLI is more powerful than a Makefile. It handles the conversion from .ino to c++ and all the dependencies through the same steps as the Arduino IDE so it produces the best results.. including managing dependencies (using clang etc) , some of the makefiles out there do this in a simplified fashion and do not produce the same results
Arduino is just like PHP, but for microcontrollers now.
Advanced support for something so crappy is interesting.
It’s so crappy that millions of people are using it and are very happy with it…
Not only that, but it makes arrogant Marks unhappy. What can be better than that?
I never really understood the philosophy behind this flavor of hating-on people. Surely however arrogant he was, you topped it in your very response! If you value your opinion so much, why don’t you also value his? You didn’t say anything more than him.
Riight.
It’s not my only language, but PHP (and some decent frameworks) helped put a second storey on our house, and Arduinos (and the Arduino port to ESP8266) are fun and very effective for many things. (and the Visual Micro plugin for Visual Studio gets you a better IDE for Arduino, when you’re ready for it)
If that’s crappy, I’m up for more crappy. The new Arduino CLI is good news.
This is no upgrade. A real upgrade would have been to use VS Code as the IDE.
Platform IO… But yeah, that’s a little “above my paygrade” for many…
Microsoft has an Arduino plugin for VS Code already. It works surprisingly well.
With this tool you can create plugins for any IDE, if you want to use VSCode you can. MS has already a plugin for Arduino but with this CLI it can be made much lighter and faster
I have been using the VisualMicro extension for Visual Studio for years. It works really well and includes intellisense and works with other extensions such as syntax highlighting, brace matching, and more. The free version does everything you would need, but I gladly registered it. Some of the best $30 I ever spent.
now all i need is an extension for emacs to use it. (back in the olden days emacs had a reputation as a resource hog, but compared to more modern programs, it’s quite svelte)
The old “Eight Megabytes And Constantly Swapping” joke seems quaint nowadays, with my Eclipse IDE instance currently at 672 MB.
emacs was a resource hog before the IDEs added features. When they were just visual file browsers, and had less features than emacs, so then emacs was a resource hog. But by the time IDEs added things like telling you what variables you have available and putting them in a drop-down dialog, they were already using way way more resources.
Emacs can do lots of things because the programming interface is generic, but a default install doesn’t do a lot of things. People talk about the “kitchen sink” merely because a directory full of user-supplied scripts is included with the distribution, without any notice paid to the fact that they’re not even loaded unless the user seeks them out. Nor is notice paid to the fact that the entire set of scripts is smaller than the “examples” folder that other software packages might include.
That said, as an emacs user using avr-gcc I don’t bother to even use the gcc support. It is so trivially easy to switch to a different virtual desktop with a bunch of cli interfaces waiting, and just run the commands there. I would imagine emacs users who want to use the arduino libraries would do the same in most cases.
…I thought the CLI for Arduino was just makefile, gcc, and a collection of avr/atmel flash tools. Maybe things have changed, but some time ago all it did was some horribly mangled way of copy-pasting all of your project code into one file (in a not-really-user-defined order), and then putting that single c file into GCC, in a very vanilla, obvious build order. And then it’d paste in #include “Arduino.h” for you on top of your big copy-pasted code file.
In modern versions, you can include C files which will behave appropriately, but all the INO files still behave in this insane way. I don’t think there is any sane situation where you’d want to do or encourage this behavior, even (especially?) in beginners – makes you wonder if the Arduino had any idea what they were doing, especially back then. It’s things like this that have made me wish a platform a little better thought out than the Arduino were adopted by the hobby community.
I guess with all the custom bootloaders and MCUs Arduino supports now, the CLI is possibly useful now, though I’d imagine all it’s doing is calling a bunch of manufacturer or open source tools which almost always already have CLI support.
| the hobby community.
Don’t we largely exist because of, not in spite of, what Wiring/Arduino has done? We tend to do what is effective within the scope of what we know and what we can learn without needing to be SMEs. If you give us better tools that we can adapt to without starting over, we typically do. The adoption of ESP boards over the Uno is a shining example.
Nope. Hobbyists have always been and will always be. Arduino used the AVR microcontrollers because they were already popular with hobbyists and already had a toolchain they could copy and rename. :)
Pull Arduino from the mix and the hobbyist community is 1/20th the size it is. Again: “largely.”
Is this a ‘new’ cli, or just a modification of the existing one? I seem to remember being able to call ‘arduino’ (not ‘arduino-cli’) with options from the command line to get it to compile and upload (although there didn’t seem to be a way of stating the output name for the compiled binary). Was that something else?
The Arduino IDE has had a CLI for years:
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc
The Arduino IDE’s CLI does allow you to set the output path and filename. For example:
arduino –verify –board arduino:avr:uno –pref build.path=somepath –pref build.project_name=somefilename examples/01.Basics/Blink/Blink.ino
that’s very helpful, thanks.
It’s a brand new tool written in GO that ties together all the tools we’ve built in the last few years. Invoking the Java ide from the command line was a temporary solution but it’s very slow and resource intensive.
My stab into the guessing cloud: someone at Arduino realised that for rational and sensible QA a clean and stable “remote control” aka “scriptable CLI” or the like is a MUST. Now it’s here and public…
Welcome to the pro-league! :-)
I’ve had this for years on my Linux box.
Sharing would have been caring.
If you mean the Arduino IDE CLI, everyone has had it for years:
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc
anybody know if there is an option to specify the output filename of the compiled bin file? (I’d like to batch compile a series of .ino files to a series of compiled files).
This is great news! An arduino cli build system is the sort of thing that the Arduino guys should’ve worked on a long time ago, instead of wasting their time and ours showcasing overpriced useless FPGA boards.
Wasting your time? You sound like we’re some government agency forcing you to stay informed with everything we do… I don’t think the Vidor is overpriced, it has a lot of stuff on it, it’s helping a lot of people get familiar with FPGAs…
Well, you wasted my time by replying to him.
If you’re involved in a project, it is really much much much much much much much much better not respond to comments like this in stories about your project. If you value people talking about your project, and you darn well should if you’re promoting it, then you should let them talk and not complain about it.
You’re the most biased possible commentator when you’re responding to comments voiced in the 3rd person with ones voiced in the 1st person. If you think somebody said something negative, and you can’t respond without being defensive or taking a swipe at them, or getting political, then just don’t respond. Even if a comment is 100% negative, your response should be 100% positive, or else you shouldn’t even engage it. Because they have every right to a negative opinion, and you do your project no favors by arguing with them. People might think your decisions were less good for them than other decisions you might have made, and that is normal. They’re not wrong to care about their own needs, and that should be obvious if you’re saying that you thought your choices did meet your own needs. No reason for negativity there, even in the presence of a complaint.
Finally! This is excellent!
This is great news. I just got I to the Arduino project and after seeing how basict the official IDE is I tried out platform.io which is good but I’m also a programmer and it took over my editor.
Personally I think the folks are Arduino should fort something like Atom or Brackets and take advantage of those communities. Especially since some boards are using python or node.js
I need makefile (or ninja) or rake (ruby make look at brew program on mac os x)
There are Makefiles available.
I always use a Rakefile too, I just use it to wrap the make commands and provide a generated menu.
That way, the Rakefile doesn’t have to care about what tools you’re using, it is just running the cli commands for you.
Hi all ! Using arduino-cli what is the command to install a nodemcu board? I’m pretty new on arduino and have just used its IDE for basic programming, so I really need a help on this. Thanks in advance.