Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Arduino command line tool

License

NotificationsYou must be signed in to change notification settings

arduino/arduino-cli

 
 

Repository files navigation

Tests passingNightly buildcodecov

arduino-cli is an all-in-one solution that provides builder,boards/library manager, uploader, discovery and many other tools neededto use any Arduino compatible board and platforms.

This software is currently under active development: anything can changeat any time, API and UI must be considered unstable until we release version1.0.0.

How to contribute

Contributions are welcome!

Please read the documentHow to contribute whichwill guide you through how to build the source code, run the tests, andcontribute your changes to the project.

✨ Thanks to all ourcontributors! ✨

How to install

Get the latest version

You have several options to install the latest version of the ArduinoCLI on your system.

Install via Homebrew (macOS/Linux)

The Arduino CLI is available as a Homebrew formula since version0.5.0:

brew updatebrew install arduino-cli

Use the install script

The easiest way to get the latest version ofarduino-cli on anysupported platform is using theinstall.sh script:

curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh

The script will installarduino-cli at$PWD/bin, if you want totarget a different directory, for example~/local/bin, set theBINDIR environment variable like this:

curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/local/bin sh

Download the latest packages

You can download the latest version of the pre-built binaries for the supportedplatforms from therelease pageor following the links in the following table. Once downloaded, extract thebinaryarduino-cli into a directory which is in yourPATH.

LinuxLinux 32 bitLinux 64 bit
Linux ARMLinux ARM 32 bitLinux ARM 64 bit
WindowsWindows 32 bitWindows 64 bit
Mac OSX Mac OSX
Deprecation notice: links in the formhttp://downloads.arduino.cc/arduino-cli/arduino-cli-latest-<platform>.tar.bz2won’t be further updated. That URL will provide the version0.3.7-alpha.preview, regardless of further releases.

Get a nightly build

These builds are generated everyday at 01:00 GMT from themaster branch andshould be considered unstable. In order to get the latest nightly buildavailable for the supported platform, use the following links:

LinuxNightly Linux 32 bitNightly Linux 64 bit
Linux ARMNightly Linux ARM 32 bitNightly Linux ARM 64 bit
WindowsNightly Windows 32 bitNightly Windows 64 bit
Mac OSX Nightly Mac OSX

These links return a302: Found response, redirecting to latestgenerated builds by replacinglatest with the latest available builddate, using the format YYYYMMDD (i.e for 2019/Aug/06latest isreplaced with20190806 )

Checksums for the nightly builds are available athttps://downloads.arduino.cc/arduino-cli/nightly/nightly-<DATE>-checksums.txt

Once downloaded, extract the executablearduino-cli into a directorywhich is in yourPATH.

Build from source

If you’re familiar with Golang or if you want to contribute to theproject, you will probably build thearduino-cli locally with yourGo compiler. Please refer to thecontributing docfor setup instructions.

If you don’t have a working Golang environment or if you want to buildarduino-cli targeting different platforms, you can use Docker to geta binary directly from sources. From the project folder run:

docker run -v $PWD:/arduino-cli -w /arduino-cli -e PACKAGE_NAME_PREFIX='snapshot' arduino/arduino-cli:builder-1 goreleaser --rm-dist --snapshot --skip-publish

Once the build is over, you will find a./dist/ folder containingthe packages built out of the current source tree.

How to use

Despite there's no feature parity at the moment, Arduino CLI provides many ofthe features you can find in the Arduino IDE, let's see some examples.

Create a configuration file

Arduino CLI doesn't strictly require a configuration file to work because thecommand line interface provides any possible functionality. However, having onecan spare you a lot of typing when issuing a command, so let's create itright ahead with:

$arduino-cli config initConfig file written: /home/luca/.arduino15/arduino-cli.yaml

If you inspectarduino-cli.yaml contents, you'll find out the availableoptions with their respective default values.

Create a new sketch

To create a new sketch namedMyFirstSketch in the current directory, runthe following command:

$arduino-cli sketch new MyFirstSketchSketch created in: /home/luca/MyFirstSketch

A sketch is a folder containing assets like source files and libraries; thenew command creates for you a .ino file calledMyFirstSketch.inocontaining Arduino boilerplate code:

$cat$HOME/MyFirstSketch/MyFirstSketch.inovoid setup() {}void loop() {}

At this point you can use your favourite file editor or IDE to open thefile$HOME/MyFirstSketch/MyFirstSketch.ino and change the code like this:

voidsetup() {pinMode(LED_BUILTIN,OUTPUT);}voidloop() {digitalWrite(LED_BUILTIN,HIGH);delay(1000);digitalWrite(LED_BUILTIN,LOW);delay(1000);}

Connect the board to your PC

The first thing to do upon a fresh install is to update the local cache ofavailable platforms and libraries by running:

$arduino-cli core update-indexUpdating index: package_index.json downloaded

After connecting the board to your PCs by using the USB cable, you should beable to check whether it's been recognized by running:

$arduino-cli board listPort         Type              Board Name              FQBN                 Core/dev/ttyACM1 Serial Port (USB) Arduino/Genuino MKR1000 arduino:samd:mkr1000 arduino:samd

In this example, the MKR1000 board was recognized and from the output of thecommand you see the platform core calledarduino:samd is the one that needsto be installed to make it work.

If you see anUnknown board listed, uploadingshould still work as long as you identify the platform core and use the correctFQBN string. When a board is not detected for whatever reason, you can list allthe supported boards and their FQBN strings by running the following:

$arduino-cli board listall mkrBoard Name              FQBNArduino MKR FOX 1200    arduino:samd:mkrfox1200Arduino MKR GSM 1400    arduino:samd:mkrgsm1400Arduino MKR WAN 1300    arduino:samd:mkrwan1300Arduino MKR WiFi 1010   arduino:samd:mkrwifi1010Arduino MKRZERO         arduino:samd:mkrzeroArduino/Genuino MKR1000 arduino:samd:mkr1000

Install the core for your board

To install thearduino:samd platform core, run the following:

$arduino-cli core install arduino:samdDownloading tools...arduino:arm-none-eabi-gcc@4.8.3-2014q1 downloadedarduino:bossac@1.7.0 downloadedarduino:openocd@0.9.0-arduino6-static downloadedarduino:CMSIS@4.5.0 downloadedarduino:CMSIS-Atmel@1.1.0 downloadedarduino:arduinoOTA@1.2.0 downloadedDownloading cores...arduino:samd@1.6.19 downloadedInstalling tools...Installing platforms...Results:arduino:samd@1.6.19 - Installedarduino:arm-none-eabi-gcc@4.8.3-2014q1 - Installedarduino:bossac@1.7.0 - Installedarduino:openocd@0.9.0-arduino6-static - Installedarduino:CMSIS@4.5.0 - Installedarduino:CMSIS-Atmel@1.1.0 - Installedarduino:arduinoOTA@1.2.0 - Installed

Now verify we have installed the core properly by running:

$arduino-cli core listID              Installed       Latest  Namearduino:samd    1.6.19          1.6.19  Arduino SAMD Boards (32-bits ARM Cortex-M0+)

Great! Now we are ready to compile and upload the sketch.

Adding 3rd party cores

If your board requires 3rd party core packages to work, you can list the URLsto additional package indexes in the Arduino CLI configuration file.

For example, to add the ESP8266 core, edit the configuration file and change theboard_manager settings as follows:

board_manager:additional_urls:    -https://arduino.esp8266.com/stable/package_esp8266com_index.json

From now on, commands supporting custom cores will automatically use theadditional URL from the configuration file:

$arduino-cli core update-indexUpdating index: package_index.json downloadedUpdating index: package_esp8266com_index.json downloadedUpdating index: package_index.json downloaded$arduino-cli core search esp8266ID              Version Nameesp8266:esp8266 2.5.2   esp8266

Alternatively, you can pass a link to the the additional package index file withthe--additional-urls option, that has to be specified every time and for everycommand that operates on a 3rd party platform core, for example:

$arduino-cli  core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.jsonUpdating index: package_esp8266com_index.json downloaded$arduino-cli core search esp8266 --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.jsonID              Version Nameesp8266:esp8266 2.5.2   esp8266

Compile and upload the sketch

To compile the sketch you run thecompile command passing the proper FQBNstring:

$arduino-cli compile --fqbn arduino:samd:mkr1000 MyFirstSketchSketch uses 9600 bytes (3%) of program storage space. Maximum is 262144 bytes.

To upload the sketch to your board, run the following command, this time alsoproviding the serial port where the board is connected:

$arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:samd:mkr1000 MyFirstSketchNo new serial port detected.Atmel SMART device 0x10010005 foundDevice       : ATSAMD21G18AChip ID      : 10010005Version      : v2.0 [Arduino:XYZ] Dec 20 2016 15:36:43Address      : 8192Pages        : 3968Page Size    : 64 bytesTotal Size   : 248KBPlanes       : 1Lock Regions : 16Locked       : noneSecurity     : falseBoot Flash   : trueBOD          : trueBOR          : trueArduino      : FAST_CHIP_ERASEArduino      : FAST_MULTI_PAGE_WRITEArduino      : CAN_CHECKSUM_MEMORY_BUFFERErase flashdone in 0.784 secondsWrite 9856 bytes to flash (154 pages)[==============================] 100% (154/154 pages)done in 0.069 secondsVerify 9856 bytes of flash with checksum.Verify successfuldone in 0.009 secondsCPU reset.

Add libraries

If you need to add more functionalities to your sketch, chances are some of thelibraries available in the Arduino ecosystem already provide what you need.For example, if you need a debouncing strategy to better handle button inputs,you can try searching for thedebouncer keyword:

$arduino-cli lib search debouncer  Name: "Debouncer"    Author: hideakitai    Maintainer: hideakitai    Sentence: Debounce library for Arduino    Paragraph: Debounce library for Arduino    Website: https://github.com/hideakitai    Category: Timing    Architecture: *    Types: Contributed    Versions: [0.1.0]  Name: "FTDebouncer"    Author: Ubi de Feo    Maintainer: Ubi de Feo, Sebastian Hunkeler    Sentence: An efficient, low footprint, fast pin debouncing library for Arduino    Paragraph: This pin state supervisor manages debouncing of buttons and handles transitions between LOW and HIGH state, calling a function and notifying your code of which pin has been activated or deactivated.    Website: https://github.com/ubidefeo/FTDebouncer    Category: Uncategorized    Architecture: *    Types: Contributed    Versions: [1.3.0]  Name: "SoftTimer"    Author: Balazs Kelemen <prampec+arduino@gmail.com>    Maintainer: Balazs Kelemen <prampec+arduino@gmail.com>    Sentence: SoftTimer is a lightweight pseudo multitasking solution for Arduino.    Paragraph: SoftTimer enables higher level Arduino programing, yet easy to use, and lightweight. You are often faced with the problem that you need to do multiple tasks at the same time. In SoftTimer, the programmer creates Tasks that runs periodically. This library comes with a collection of handy tools like blinker, pwm, debouncer.    Website: https://github.com/prampec/arduino-softtimer    Category: Timing    Architecture: *    Types: Contributed    Versions: [3.0.0, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.5, 3.2.0]

Our favourite isFTDebouncer, can install it by running:

$arduino-cli lib install FTDebouncer  FTDebouncer depends on FTDebouncer@1.3.0  Downloading FTDebouncer@1.3.0...  FTDebouncer@1.3.0 downloaded  Installing FTDebouncer@1.3.0...  Installed FTDebouncer@1.3.0

Getting help

arduino-cli is a container of commands and each command has its owndedicated help text that can be shown with thehelp command like this:

$arduino-clihelp core  Arduino Core operations.  Usage:    arduino-cli core [command]  Examples:    ./arduino-cli core update-index  Available Commands:    download     Downloads one or more cores and corresponding tool dependencies.    install      Installs one or more cores and corresponding tool dependencies.    list         Shows the list of installed platforms.    search       Search for a core in the package index.    uninstall    Uninstalls one or more cores and corresponding tool dependencies if no more used.    update-index Updates the index of cores.    upgrade      Upgrades one or all installed platforms to the latest version.  Flags:    -h, --help   help for core  Global Flags:        --additional-urls strings   Additional URLs for the board manager.        --config-file string        The custom config file (if not specified the default will be used).        --format string             The output format, can be [text|json]. (default "text")        --log-file string           Path to the file where logs will be written.        --log-format string         The output format for the logs, can be [text|json].        --log-level string          Messages with this level and above will be logged.    -v, --verbose                   Print the logs on the standard output.  Use "arduino-cli core [command] --help" for more information about a command.

Troubleshooting

Arduino Uno/Mega/Duemilanove is not detected when yourunarduino-cli board list

Possible causes:

  • Your board is a cheaper clone, or
  • It mounts a USB2Serial converter like FT232 or CH320: these chipsalways reports the same USB VID/PID to the operating system, so theonly thing that we know is that the board mounts that specificUSB2Serial chip, but we don’t know which board is.
What's the FQBN string?

For a deeper understanding of how FQBN works, you should understandArduino Hardware specification. You can find more information in thisarduino/Arduino wikipage

Using the gRPC interface

Theclient_example folder contains a sampleprogram that shows how to use gRPC interface of the CLI.


[8]ページ先頭

©2009-2025 Movatter.jp