The Arduino Command Line Interface (CLI)

The Arduino folks just came out with the Arduino Command Line Interface (CLI) :

A while back, I wrote about the  Arduino-Builder which is what the Arduino IDE invokes behind the scenes to compile the sketch. (That post is here.) Now, with the Arduino Command Line Interface, everything that can be done from the IDE can now be done on the command line.

The Arduino Command Line Interface can be downloaded from here. By the way, it is also written in the Go language.

I downloaded the file for my system (Linux 64 bit):

curl http://downloads.arduino.cc/arduino-cli/arduino-cli-0.2.0-alpha.preview-linux64.tar.bz2 -o arduino-cli.bz2

Extracted it:

tar -xvf arduino-cli.bz2

and moved it to an easier name:

mv arduino-cli-linux64 arduino-cli

I tried it out and got it working OK for the BluePill but had to make some changes to the boards.txt configuration file.

Here is how I got it working for both the Arduino Uno and  the BluePill (STM32F103C8T6):

Create these directories first (the are needed and not created if they don’t exist):

mkdir $HOME/Arduino
mkdir $HOME/.arduino15

Create a basic config file since it will need to be modified to add the BluePill info:

./arduino-cli config dump >.cli-config.yml

Edit the .cli-config.yml and add these lines at the end:

board_manager:
additional_urls:
- http://dan.drown.org/stm32duino/package_STM32duino_index.json

Next, create a basic test sketch (and optionally edit it):

./arduino-cli sketch new tests

Next, create the index json files via:

./arduino-cli core update-index

Optionally look and see what boards are available to install:

./arduino-cli core search stm

Then install the stm32duino files for the BluePill:

./arduino-cli core install stm32duino:STM32F1

Optionally install the core files for the Arduino Uno (etc.):

./arduino-cli core install arduino:avr

You can see a list of the installed boards via:

./arduino-cli board listall

If you try and compile the test sketch now via:

./arduino-cli compile -v -b stm32duino:STM32F1:genericSTM32F103C $HOME/Arduino/test

You will see a bunch of errors, so you will need to edit the boards.txt file:

vi $HOME/.arduino15/packages/stm32duino/hardware/STM32F1/2018.7.2/boards.txt

To eliminate the errors, change some of the genericSTM32F103C lines with  the string genericSTM32F103C.menu….build. in them to just genericSTM32F103C.build. lines. Make sure there are no duplicates. (The .menu. lines are for selections in the Arduino IDE.)

Once all the correct options are fixed in the boards.txt config file, the sketch should compile fine via:

./arduino-cli compile -v -b stm32duino:STM32F1:genericSTM32F103C $HOME/Arduino/test

To see if the arduino-cli recognizes your attached BluePill (or other Arduino), run:

./arduino-cli board list

To upload the sketch:

./arduino-cli upload -p /dev/ttyACM0 --fqbn stm32duino:STM32F1:genericSTM32F103C $HOME/Arduino/test

Libraries can be found with a search:

./arduino-cli lib search ethernet

And installed via:

./arduino-cli lib install "UIPEthernet"

……………………….

At no time did my fingers leave the keyboard… I like the cli !

Leave a Reply

Your email address will not be published.