Announcing the New Arduino Command Line Interface

Build Arduino code from the command line and Makefiles

Alasdair Allan
6 years ago

Every so often a piece of technology can become a lever that lets people move the world, just a little bit. The Arduino has become one of those levers. But strangely enough, the real power of the Arduino system isn’t the hardware. Instead it’s the Arduino development environment. While there are many other boards out there offering similar functionality, the Arduino perhaps best succeeded at wrapping the hard to use and messy details of microcontroller programming away from the user, and that was mostly thanks to the IDE.

However, the way we work with boards is changing, and Arduino has had to change with it. While they introduced Arduino Create—a modern, flexible, and perhaps most importantly web-based, tool chain—two years ago, the announcement today of the new Arduino Command Line Interface (CLI) is probably equally important.

While the new web-based build system was vital in keeping Arduino up to date with the way makers and educators use hardware, the announcement of an official command line interface is vital for professional developers.

“The Arduino team has been working hard to support the needs of our professional developer community. Many of you requested a way to use our tools in Makefiles, and wanted Arduino IDE features available via a fast, clean, command line interface.”

If you’re building not just a single project but uploading code to hundreds, or sometimes even thousands, of boards you need reliable tools. However it’s also vital that these tools are scriptable, and fully automatable, and the graphical Arduino development environment wasn’t that. While there have always been ways around it, until today there hasn’t been an officially supported, command line interface.

The new command line tool will let you create, modify and upload sketches, add libraries, and install project dependencies. It also has the option for JSON output for easy parsing by other programs.

$ arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:samd:mkr1000 Arduino/MyFirstSketch
No new serial port detected.
Atmel SMART device 0x10010005 found
Device       : ATSAMD21G18A
Chip ID      : 10010005
Version      : v2.0 [Arduino:XYZ] Dec 20 2016 15:36:43
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : none
Security     : false
Boot Flash   : true
BOD          : true
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
done in 0.784 seconds

Write 9856 bytes to flash (154 pages)
[==============================] 100% (154/154 pages)
done in 0.069 seconds

Verify 9856 bytes of flash with checksum.
Verify successful
done in 0.009 seconds
CPU reset.

Although today’s release is an alpha release, the new tools work on both ARM and Intel architectures, and preview binaries for Linux (64-bit, 32-bit, and ARM), macOS, and Windows are available to download.

More information on today’s release can be found on the Arduino blog, and in the documentation associated with the project’s GitHub repo.

Alasdair Allan
Scientist, author, hacker, maker, and journalist. Building, breaking, and writing. For hire. You can reach me at 📫 alasdair@babilim.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles