Arduino-cli - Teesnsy - Notes - Questions - Documentation

Sorry, if not the appropriate place (CLI vs IDE) and if all of this has been discussed.
But I thought I would mention a few things here while I am experimenting. And thought I would write down a few notes here, as to not forget and on the rare occasion, it might be of some use to a few others.

Installing it - Is it already installed as part of the IDE? Quick search did not find arduino-cli when I search the daily build zip file (Windows 11 in this case).

So went to: arduino/arduino-cli: Arduino command line tool (github.com) Clicked on the latest release on the right hand side of screen. And made sure add the location to the Path.

Compiling
Doing the command: arduino-cli --help
Gives you a clue to use the compile: compile Compiles Arduino sketches.

Likewise, the help on that command helps some:

C:\Users\kurte>arduino-cli compile --help
Compiles Arduino sketches.

Usage:
  arduino-cli compile [flags]

Examples:
  arduino-cli compile -b arduino:avr:uno /home/user/Arduino/MySketch
  arduino-cli compile -b arduino:avr:uno --build-property "build.extra_flags=\"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch
  arduino-cli compile -b arduino:avr:uno --build-property "build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch
  arduino-cli compile -b arduino:avr:uno --build-property build.extra_flags=-DPIN=2 --build-property "compiler.cpp.extra_flags=\"-DSSID=\"hello world\"\"" /home/user/Arduino/MySketch


Flags:
      --board-options strings        List of board options separated by commas. Or can be used multiple times for multiple options.
      --build-cache-path string      Builds of 'core.a' are saved into this path to be cached and reused.
      --build-path string            Path where to save compiled files. If omitted, a directory will be created in the default temporary path of your OS.
      --build-property stringArray   Override a build property with a custom value. Can be used multiple times for multiple properties.
      --clean                        Optional, cleanup the build folder and do not use any cached build.
      --discovery-timeout duration   Max time to wait for port discovery, e.g.: 30s, 1m (default 1s)
      --dump-profile                 Create and print a profile configuration from the build.
      --encrypt-key string           The name of the custom encryption key to use to encrypt a binary during the compile process. Used only by the platforms that support it.
  -e, --export-binaries              If set built binaries will be exported to the sketch folder.
  -b, --fqbn string                  Fully Qualified Board Name, e.g.: arduino:avr:uno
  -h, --help                         help for compile
      --keys-keychain string         The path of the dir to search for the custom keys to sign and encrypt a binary. Used only by the platforms that support it.
      --libraries strings            Path to a collection of libraries. Can be used multiple times or entries can be comma separated.
      --library strings              Path to a single library’s root folder. Can be used multiple times or entries can be comma separated.
      --only-compilation-database    Just produce the compilation database, without actually compiling. All build commands are skipped except pre* hooks.
      --optimize-for-debug           Optional, optimize compile output for debugging, rather than for release.
      --output-dir string            Save build artifacts in this directory.
  -p, --port string                  Upload port address, e.g.: COM3 or /dev/ttyACM2
      --preprocess                   Print preprocessed code to stdout instead of compiling.
  -m, --profile string               Sketch profile to use
  -P, --programmer string            Programmer to use, e.g: atmel_ice
  -l, --protocol string              Upload port protocol, e.g: serial
      --quiet                        Optional, suppresses almost every output.
      --show-properties              Show all build properties used instead of compiling.
      --sign-key string              The name of the custom signing key to use to sign a binary during the compile process. Used only by the platforms that support it.
  -u, --upload                       Upload the binary after the compilation.
  -t, --verify                       Verify uploaded binary after the upload.
      --vid-pid string               When specified, VID/PID specific build properties are used, if board supports them.
      --warnings string              Optional, can be: none, default, more, all. Used to tell gcc which warning level to use (-W flag). (default "none")

Global Flags:
      --additional-urls strings   Comma-separated list of additional URLs for the Boards Manager.
      --config-file string        The custom config file (if not specified the default will be used).
      --format string             The output format for the logs, can be: text, json, jsonmini, yaml (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. Valid levels are: trace, debug, info, warn, error, fatal, panic
      --no-color                  Disable colored output.
  -v, --verbose                   Print the logs on the standard output.

So what is the FQBN (yet another TLA :wink: actually FLA) for a Teensy?
One way to get an idea is to use the command:

C:\Users\kurte>arduino-cli board list
Port               Protocol Type         Board Name FQBN                Core
usb:0/140000/0/8/4 teensy   Teensy Ports Teensy 4.0 teensy:avr:teensy40 teensy:avr

So found out both the FQBN and the port name, in this case it was T40 compiled with a USB type that does not include USB Serial. Another run with a Teensy MicroMod

C:\Users\kurte>arduino-cli board list
Port                 Protocol Type              Board Name      FQBN                Core
COM27                serial   Serial Port (USB) Unknown
usb:0/140000/0/8/1/1 teensy   Teensy Ports      Teensy MicroMod teensy:avr:teensyMM teensy:avr

Now how to do I compile a sketch: first attempt (actually probably 10th) :

Note: one of my first attempts failed to find any of the libraries. Turns out the CLI does not look into the same configuration stuff as either IDE... And it was defaulting to default location which is under the onedrive... on my W11 machine. My sketchbook is not there. So fiddled around with it for a while and found:
arduino-cli config init
Then edited the file mentioned and set the correct location.

But now that is working, In this case I changed directory to the location of sketch

D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM
D:\github\mtp_tft_picture_view\mtp_tft_picture_view.ino:18:17: note: '#pragma message: Note Built without MTP support'
   18 | #pragma message "Note Built without MTP support"
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\github\mtp_tft_picture_view\mtp_tft_picture_view.ino:147:17: note: '#pragma message: Display: ILI9341_t3n'
  147 | #pragma message "Display: ILI9341_t3n"
      |                 ^~~~~~~~~~~~~~~~~~~~~~
Memory Usage on Teensy MicroMod:
  FLASH: code:140840, data:33204, headers:8224   free for files:16332804
   RAM1: variables:102080, code:135240, padding:28600   free for local variables:258368
   RAM2: variables:12384  free for malloc/new:511904

Used library        Version Path
SPI                 1.0     C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.58.3\libraries\SPI
SD                  2.0.0   D:\github\SD
SdFat               2.1.2   D:\github\SdFat
JPEGDEC             1.2.8   C:\Users\kurte\Documents\Arduino\libraries\JPEGDEC
PNGdec              1.0.1   C:\Users\kurte\Documents\Arduino\libraries\PNGdec
ILI9341_t3n         1.1.0   D:\github\ili9341_t3n
XPT2046_Touchscreen 1.4     C:\Users\kurte\Documents\Arduino\libraries\XPT2046_Touchscreen

Used platform Version Path
teensy:avr    0.58.3  C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.58.3

How do I define Build Options?
That is how do I Build with using not the default options? The CLI help gave a couple examples of using a larger hammer to replace major settings, but nothing appears to apply (at least to me)

So it built, but not with MTP support, how do I enable it. More fumbling around but finally found:

D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM --build-property="build.usbtype=USB_MTPDISK_SERIAL"
D:\github\mtp_tft_picture_view\mtp_tft_picture_view.ino:147:17: note: '#pragma message: Display: ILI9341_t3n'
  147 | #pragma message "Display: ILI9341_t3n"
      |                 ^~~~~~~~~~~~~~~~~~~~~~
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\AppData\Local\Temp\arduino-sketch-479771791AB690CB5AEED20B64877CBE\libraries\MTP_Teensy\MTP_Teensy.cpp.o: in function `MTP_class::begin()':
C:\Users\kurte\Documents\Arduino\libraries\MTP_Teensy\src/MTP_Teensy.cpp:91: undefined reference to `usb_mtp_rxSize'
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\AppData\Local\Temp\arduino-sketch-479771791AB690CB5AEED20B64877CBE\libraries\MTP_Teensy\MTP_Teensy.cpp.o: in function `MTP_class::receive_bulk(unsigned long)':
C:\Users\kurte\Documents\Arduino\libraries\MTP_Teensy\src/MTP_Teensy.cpp:1593: undefined reference to `usb_mtp_recv'

Which mostly built be link failed. FIgured out, because it did not rebuild the core using the new option. So needed to add the --clean option

D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM --build-property="build.usbtype=USB_MTPDISK_SERIAL" --clean
D:\github\mtp_tft_picture_view\mtp_tft_picture_view.ino:147:17: note: '#pragma message: Display: ILI9341_t3n'
  147 | #pragma message "Display: ILI9341_t3n"
      |                 ^~~~~~~~~~~~~~~~~~~~~~
Memory Usage on Teensy MicroMod:
  FLASH: code:167972, data:36440, headers:8576   free for files:16302084
   RAM1: variables:105632, code:162360, padding:1480   free for local variables:254816
   RAM2: variables:28800  free for malloc/new:495488

Used library        Version Path
SPI                 1.0     C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.58.3\libraries\SPI
SD                  2.0.0   D:\github\SD
SdFat               2.1.2   D:\github\SdFat
MTP_Teensy          1.0.0   D:\github\MTP_Teensy
JPEGDEC             1.2.8   C:\Users\kurte\Documents\Arduino\libraries\JPEGDEC
PNGdec              1.0.1   C:\Users\kurte\Documents\Arduino\libraries\PNGdec
ILI9341_t3n         1.1.0   D:\github\ili9341_t3n
XPT2046_Touchscreen 1.4     C:\Users\kurte\Documents\Arduino\libraries\XPT2046_Touchscreen

Used platform Version Path
teensy:avr    0.58.3  C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.58.3

:smiley:

Next up Upload: More on this later. Where I am mostly interested in the CLI is for remote builds on an RPI, and I wish to this headless.

So far in the case of Teensy builds, headless uploads are not fully supported yet.
So I end up using teensly_loader_cli, but that is another topic.

To make it easier I thought I would use the --export-binaries
When I was first doing this on my Windows 11 machine using KiTTy to talk to RPI, my quick first look I thought the export did not work as I did not see the .hex file in the same directory.

But looking again the files are put into a subfolder

D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM --build-property="build.usbtype=USB_MTPDISK_SERIAL"  --export-binaries
...
D:\github\mtp_tft_picture_view>dir build\teensy.avr.teensyMM
 Volume in drive D is DATA
 Volume Serial Number is 5C92-8524

 Directory of D:\github\mtp_tft_picture_view\build\teensy.avr.teensyMM

12/23/2022  11:50 AM    <DIR>          .
12/23/2022  11:50 AM    <DIR>          ..
12/23/2022  11:50 AM                34 mtp_tft_picture_view.ino.eep
12/23/2022  11:50 AM           525,944 mtp_tft_picture_view.ino.ehex
12/23/2022  11:50 AM         3,166,792 mtp_tft_picture_view.ino.elf
12/23/2022  11:50 AM           599,181 mtp_tft_picture_view.ino.hex
12/23/2022  11:50 AM         4,035,276 mtp_tft_picture_view.ino.lst
12/23/2022  11:50 AM            74,302 mtp_tft_picture_view.ino.sym
               6 File(s)      8,401,529 bytes
               2 Dir(s)  756,272,873,472 bytes free

But on PC was able to upload like:

D:\github\mtp_tft_picture_view>arduino-cli upload -p usb:0/140000/0/8/1/1

Now back to playing

To follow on to the --build-property I mentioned in the first post, the different Teensy boards have several tools sub-menus for different options. These settings are defined in the file boards.txt and used in platform.txt.

I am not sure of how directly some of the stuff mentioned here are reflected in other board types other than Teensy, but they probably also have similar settings and the like.

I am not going to show all of the different ones, like for different keyboards or the like as I don't typically use them, but can fill those in later.

But here are a few: Note I have tried to keep the default one as first in lists

board.usbtype

Probably in most/all boards.

"Serial" -> build.usbtype=USB_SERIAL
"Dual Serial" -> build.usbtype=USB_DUAL_SERIAL
"Triple Serial" -> build.usbtype=USB_TRIPLE_SERIAL
"Keyboard" -> build.usbtype=USB_KEYBOARDONLY
"Keyboard + Touch Screen" -> build.usbtype=USB_TOUCHSCREEN
"Keyboard + Mouse + Touch Screen" -> build.usbtype=USB_HID_TOUCHSCREEN
"Keyboard + Mouse + Joystick" -> build.usbtype=USB_HID
"Serial + Keyboard + Mouse + Joystick	" -> build.usbtype=USB_SERIAL_HID
"MIDI" -> build.usbtype=USB_MIDI
"MIDIx4" -> build.usbtype=USB_MIDI4
"MIDIx16" -> build.usbtype=USB_MIDI16
"Serial + MIDI" -> build.usbtype=USB_MIDI_SERIAL
"Serial + MIDIx4" -> build.usbtype=USB_MIDI4_SERIAL
"Serial + MIDIx16" -> build.usbtype=USB_MIDI16_SERIAL
"Audio" -> build.usbtype=USB_AUDIO
"Serial + MIDI + Audio" -> build.usbtype=USB_MIDI_AUDIO_SERIAL
"Serial + MIDIx16 + Audio" -> build.usbtype=USB_MIDI16_AUDIO_SERIAL
"MTP Disk (Experimental)" -> build.usbtype=USB_MTPDISK
"Serial + MTP Disk (Experimental)" -> build.usbtype=USB_MTPDISK_SERIAL
"Raw HID" -> build.usbtype=USB_RAWHID
"Flight Sim Controls" -> build.usbtype=USB_FLIGHTSIM
"Flight Sim Controls + Joystick" -> build.usbtype=USB_FLIGHTSIM_JOYSTICK

T3.x and LC have a few others.

"No USB" -> build.usbtype=USB_DISABLED
"All of the Above" -> build.usbtype=USB_EVERYTHING

CPU Speed

T4.x

"600 MHz" => build.fcpu=600000000
"1.008 GHz (overclock, cooling req'd)" => build.fcpu=1008000000
"150 MHz" => build.fcpu=150000000
"24 MHz" => build.fcpu=24000000
"396 MHz" => build.fcpu=396000000
"450 MHz" => build.fcpu=450000000
"528 MHz" => build.fcpu=528000000
"720 MHz (overclock)" => build.fcpu=720000000
"816 MHz (overclock)" => build.fcpu=816000000
"912 MHz (overclock, cooling req'd)" => build.fcpu=912000000
"960 MHz (overclock, cooling req'd)" => build.fcpu=960000000

T3.6

"120 MHz" -> build.fcpu=120000000
"144 MHz" -> build.fcpu=144000000
"168 MHz" -> fcpu=16000000
"16 MHz (No USB)" -> build.fcpu=168000000
"180 MHz" -> build.fcpu=180000000
"192 MHz (overclock)" -> build.fcpu=192000000
"216 MHz (overclock)" -> fcpu=2000000
"240 MHz (overclock)" -> build.fcpu=216000000
"24 MHz" -> fcpu=24000000
"256 MHz (overclock)" -> build.fcpu=240000000
"2 MHz (No USB)" -> build.fcpu=256000000
"48 MHz" -> fcpu=4000000
"4 MHz (No USB)" -> fcpu=48000000
"72 MHz" -> fcpu=72000000
"8 MHz (No USB)" -> fcpu=8000000
"96 MHz" -> fcpu=96000000

Teensy 3.5

"120 MHz" -> build.fcpu=120000000
"96 MHz" -> build.fcpu=96000000
"72 MHz" -> build.fcpu=72000000
"48 MHz" -> build.fcpu=48000000
"24 MHz" -> build.fcpu=24000000
"16 MHz (No USB)" -> build.fcpu=16000000
"8 MHz (No USB)" -> build.fcpu=8000000
"4 MHz (No USB)" -> build.fcpu=4000000
"2 MHz (No USB)" -> build.fcpu=2000000
"144 MHz (overclock)" -> build.fcpu=144000000
"168 MHz (overclock)" -> build.fcpu=168000000

Teensy 3.2/3.1

"96 MHz (overclock)" -> build.fcpu=96000000
"72 MHz" -> build.fcpu=72000000
"48 MHz" -> build.fcpu=48000000
"24 MHz" -> build.fcpu=24000000
"16 MHz (No USB)" -> build.fcpu=16000000
"8 MHz (No USB)" -> build.fcpu=8000000
"4 MHz (No USB)" -> build.fcpu=4000000
"2 MHz (No USB)" -> build.fcpu=2000000
"120 MHz (overclock)" -> build.fcpu=120000000
"144 MHz (overclock)" -> build.fcpu=144000000
"168 MHz (overclock)" -> build.fcpu=168000000

Teensy LC

"48 MHz" -> build.fcpu=48000000
"24 MHz" -> build.fcpu=24000000

Optimize
Note: these appear to set two different --build-property settings:

For T4.x the options are:

"Faster" -> build.flags.optimize=-O2 -> build.flags.ldspecs=
"Fast" -> build.flags.optimize=-O1 -> build.flags.ldspecs=
"Fastest" -> build.flags.optimize=-O3 -> build.flags.ldspecs=
"Debug" -> build.flags.optimize=-Og -> build.flags.ldspecs=
"Smallest Code" -> build.flags.optimize=-Os --specs=nano.specs -> build.flags.ldspecs=

For T3.6 probably other T3.x

"Faster" -> build.flags.optimize=-O2 -> build.flags.ldspecs=
"Faster with LTO" -> build.flags.optimize=-O2 -flto -fno-fat-lto-objects -> build.flags.ldspecs=-fuse-linker-plugin
"Fast" -> build.flags.optimize=-O1 -> build.flags.ldspecs=
"Fast with LTO" -> build.flags.optimize=-O1 -flto -fno-fat-lto-objects -> build.flags.ldspecs=-fuse-linker-plugin
"Fastest" -> build.flags.optimize=-O3 -> build.flags.ldspecs=
"Fastest + pure-code" -> build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -> build.flags.ldspecs=
"Fastest with LTO" -> build.flags.optimize=-O3 -flto -fno-fat-lto-objects -> build.flags.ldspecs=-fuse-linker-plugin
"Fastest + pure-code with LTO" -> build.flags.optimize=-O3 -mpure-code -D__PURE_CODE__ -flto -fno-fat-lto-objects -> build.flags.ldspecs=-fuse-linker-plugin
"Debug" -> build.flags.optimize=-Og -> build.flags.ldspecs=
"Debug with LTO" -> build.flags.optimize=-Og -flto -fno-fat-lto-objects -> build.flags.ldspecs=-fuse-linker-plugin
"Smallest Code" -> build.flags.optimize=-Os --specs=nano.specs -> build.flags.ldspecs=
"Smallest Code with LTO" -> build.flags.optimize=-Os -flto -fno-fat-lto-objects --specs=nano.specs -> build.flags.ldspecs=-fuse-linker-plugin

Yes. It is in the resources/app/node_modules/arduino-ide-extension/build subfolder of the Arduino IDE installation folder.

You can use the arduino-cli.exe there directly. I find it more convenient to install a separate copy of Arduino CLI for that purpose.

I strongly recommend against doing it this way. This might work now, but that build.usbtype property is not considered part of the public API of the Teensy boards platform, so this command might stop working as expected the next time you update to a new version of the platform.

The right way to set custom board options is via the FQBN. When you use the minimal FQBN teensy:avr:teensyMM, the default value of all the custom board options are used, but you can specify other settings by expanding the FQBN

The format of the FQBN is like this:

<vendor ID>:<architecture>:<board ID>[:<menu ID>=<option ID>[,<menu ID>=<option ID>]...]

You can learn all the available menu IDs and option IDs for a given board by running the following arduino-cli command:

arduino-cli board details --fqbn <FQBN>

(where <FQBN> is replaced by the fully qualified board name of the board you are using)

For example:

$ arduino-cli board details -b teensy:avr:teensyMM

Board name:                Teensy MicroMod
FQBN:                      teensy:avr:teensyMM
Board version:             1.57.1

Identification properties: modelID=0x26

Package name:              teensy
Package maintainer:        Paul Stoffregen
Package URL:               https://www.pjrc.com/teensy/package_teensy_index.json
Package website:           https://www.pjrc.com/teensy/td_download.html
Package online help:       https://forum.pjrc.com/forum.php

Platform name:             Teensy
Platform category:         Contributed
Platform architecture:     avr
Platform URL:              https://www.pjrc.com/teensy/td_157/teensy-package.tar.bz2
Platform file name:        teensy-package.tar.bz2
Platform size (bytes):     33493974
Platform checksum:         SHA-256:1922c67a3d1261efb085eda1d99f5907936b89cc078f3567825cfc49661141c2

Required tool: teensy:teensy-tools                   1.57.1
Required tool: teensy:teensy-compile                 5.4.1

Option:        USB Type                                     usb
               Serial                                βœ”      usb=serial
               Dual Serial                                  usb=serial2
               Triple Serial                                usb=serial3
               Keyboard                                     usb=keyboard
               Keyboard + Touch Screen                      usb=touch
               Keyboard + Mouse + Touch Screen              usb=hidtouch
               Keyboard + Mouse + Joystick                  usb=hid
               Serial + Keyboard + Mouse + Joystick         usb=serialhid
               MIDI                                         usb=midi
               MIDIx4                                       usb=midi4
               MIDIx16                                      usb=midi16
               Serial + MIDI                                usb=serialmidi
               Serial + MIDIx4                              usb=serialmidi4
               Serial + MIDIx16                             usb=serialmidi16
               Audio                                        usb=audio
               Serial + MIDI + Audio                        usb=serialmidiaudio
               Serial + MIDIx16 + Audio                     usb=serialmidi16audio
               MTP Disk (Experimental)                      usb=mtp
               Serial + MTP Disk (Experimental)             usb=serialmtp
               Raw HID                                      usb=rawhid
               Flight Sim Controls                          usb=flightsim
               Flight Sim Controls + Joystick               usb=flightsimjoystick
Option:        CPU Speed                                    speed
               600 MHz                               βœ”      speed=600
               528 MHz                                      speed=528
               450 MHz                                      speed=450
               396 MHz                                      speed=396
               150 MHz                                      speed=150
               24 MHz                                       speed=24
               720 MHz (overclock)                          speed=720
               816 MHz (overclock)                          speed=816
               912 MHz (overclock, cooling req'd)           speed=912
               960 MHz (overclock, cooling req'd)           speed=960
               1.008 GHz (overclock, cooling req'd)         speed=1008
Option:        Optimize                                     opt
               Faster                                βœ”      opt=o2std
               Fast                                         opt=o1std
               Fastest                                      opt=o3std
               Debug                                        opt=ogstd
               Smallest Code                                opt=osstd
Option:        Keyboard Layout                              keys
               US English                            βœ”      keys=en-us
               Canadian French                              keys=fr-ca
               Canadian Multilingual                        keys=xx-ca
               Czech                                        keys=cz-cz
               Danish                                       keys=da-da
               Finnish                                      keys=fi-fi
               French                                       keys=fr-fr
               French Belgian                               keys=fr-be
               French Swiss                                 keys=fr-ch
               German                                       keys=de-de
               German (Mac)                                 keys=de-dm
               German Swiss                                 keys=de-ch
               Icelandic                                    keys=is-is
               Irish                                        keys=en-ie
               Italian                                      keys=it-it
               Norwegian                                    keys=no-no
               Portuguese                                   keys=pt-pt
               Portuguese Brazilian                         keys=pt-br
               Serbian (Latin Only)                         keys=rs-rs
               Spanish                                      keys=es-es
               Spanish Latin America                        keys=es-mx
               Swedish                                      keys=sv-se
               Turkish (partial)                            keys=tr-tr
               United Kingdom                               keys=en-gb
               US International                             keys=usint
Programmers:   ID                                    Name



A new release of Arduino CLI is available: 0.0.0-git β†’ 0.29.0
https://arduino.github.io/arduino-cli/latest/installation/#latest-packages

per@HAL MINGW64 /e/git/arduino-cli ((0.29.0))
$ ./arduino-cli board details -b teensy:avr:teensyMM
Board name:                Teensy MicroMod
FQBN:                      teensy:avr:teensyMM
Board version:             1.57.1

Identification properties: modelID=0x26

Package name:              teensy
Package maintainer:        Paul Stoffregen
Package URL:               https://www.pjrc.com/teensy/package_teensy_index.json
Package website:           https://www.pjrc.com/teensy/td_download.html
Package online help:       https://forum.pjrc.com/forum.php

Platform name:             Teensy
Platform category:         Contributed
Platform architecture:     avr
Platform URL:              https://www.pjrc.com/teensy/td_157/teensy-package.tar.bz2
Platform file name:        teensy-package.tar.bz2
Platform size (bytes):     33493974
Platform checksum:         SHA-256:1922c67a3d1261efb085eda1d99f5907936b89cc078f3567825cfc49661141c2

Required tool:             teensy:teensy-tools                                 1.57.1

Required tool:             teensy:teensy-compile                               5.4.1

Option:                    USB Type                                                   usb
                           Serial                                              βœ”      usb=serial
                           Dual Serial                                                usb=serial2
                           Triple Serial                                              usb=serial3
                           Keyboard                                                   usb=keyboard
                           Keyboard + Touch Screen                                    usb=touch
                           Keyboard + Mouse + Touch Screen                            usb=hidtouch
                           Keyboard + Mouse + Joystick                                usb=hid
                           Serial + Keyboard + Mouse + Joystick                       usb=serialhid
                           MIDI                                                       usb=midi
                           MIDIx4                                                     usb=midi4
                           MIDIx16                                                    usb=midi16
                           Serial + MIDI                                              usb=serialmidi
                           Serial + MIDIx4                                            usb=serialmidi4
                           Serial + MIDIx16                                           usb=serialmidi16
                           Audio                                                      usb=audio
                           Serial + MIDI + Audio                                      usb=serialmidiaudio
                           Serial + MIDIx16 + Audio                                   usb=serialmidi16audio
                           MTP Disk (Experimental)                                    usb=mtp
                           Serial + MTP Disk (Experimental)                           usb=serialmtp
                           Raw HID                                                    usb=rawhid
                           Flight Sim Controls                                        usb=flightsim
                           Flight Sim Controls + Joystick                             usb=flightsimjoystick
Option:                    CPU Speed                                                  speed
                           600 MHz                                             βœ”      speed=600
                           528 MHz                                                    speed=528
                           450 MHz                                                    speed=450
                           396 MHz                                                    speed=396
                           150 MHz                                                    speed=150
                           24 MHz                                                     speed=24
                           720 MHz (overclock)                                        speed=720
                           816 MHz (overclock)                                        speed=816
                           912 MHz (overclock, cooling req'd)                         speed=912
                           960 MHz (overclock, cooling req'd)                         speed=960
                           1.008 GHz (overclock, cooling req'd)                       speed=1008
Option:                    Optimize                                                   opt
                           Faster                                              βœ”      opt=o2std
                           Fast                                                       opt=o1std
                           Fastest                                                    opt=o3std
                           Debug                                                      opt=ogstd
                           Smallest Code                                              opt=osstd
Option:                    Keyboard Layout                                            keys
                           US English                                          βœ”      keys=en-us
                           Canadian French                                            keys=fr-ca
                           Canadian Multilingual                                      keys=xx-ca
                           Czech                                                      keys=cz-cz
                           Danish                                                     keys=da-da
                           Finnish                                                    keys=fi-fi
                           French                                                     keys=fr-fr
                           French Belgian                                             keys=fr-be
                           French Swiss                                               keys=fr-ch
                           German                                                     keys=de-de
                           German (Mac)                                               keys=de-dm
                           German Swiss                                               keys=de-ch
                           Icelandic                                                  keys=is-is
                           Irish                                                      keys=en-ie
                           Italian                                                    keys=it-it
                           Norwegian                                                  keys=no-no
                           Portuguese                                                 keys=pt-pt
                           Portuguese Brazilian                                       keys=pt-br
                           Serbian (Latin Only)                                       keys=rs-rs
                           Spanish                                                    keys=es-es
                           Spanish Latin America                                      keys=es-mx
                           Swedish                                                    keys=sv-se
                           Turkish (partial)                                          keys=tr-tr
                           United Kingdom                                             keys=en-gb
                           US International                                           keys=usint
Programmers:               Id                                                  Name

Here we can see that the ID for the "USB Type" menu is usb and the ID for the "Serial + MTP Disk (Experimental)" option is serialmtp.

So the full FQBN is:

teensy:avr:teensyMM:usb=serialmtp

So just replace the teensy:avr:teensyMM in your command with teensy:avr:teensyMM:teensy:avr:teensyMM:usb=serialmtp, remove the --build-property flag, and you are set.

--build-property flags are useful for doing more advanced things like inserting additional flags into the compilation commands, but in cases like this where you have a dedicated formal public API provided by the Arduino boards platform author and framework, using that approach instead of setting the custom board option is super hacky.

We have some documenation about this, but feedback such as yours indicates it is insufficient. We are tracking the need to expand the existing documentation of the FQBN format here:

https://github.com/arduino/arduino-cli/issues/355

This will be done automatically when you use the FQBN approach

1 Like

Thanks!

Yes, the documentation was not clear. Would really suggest adding information like this to the help pages as well as the --help.

For example, having one of the examples at the start of: compile --help
that showed setting an option, and comment saying use the board details ...
for a complete list of options would help a lot.

Likewise there is something mentioned about profiles, but nothing suggesting what they are used for... I know I should dig deeper

Thanks again

There is information on build profiles here:

https://arduino.github.io/arduino-cli/latest/sketch-project-file/

1 Like

Thanks again @ptillisch,

Just an FYI - I updated my similar ramblings up on the Teensy forum thread:
Arduino CLI And IDE now Released - Teensy Supported! (pjrc.com)

Suggestions always welcome

I also use the --build-properties option but will try the FQBN method and profiles.

I found at least on Linux it is possible to have something similar to the 1.x IDE portable mode. The following steers arduino-cli away from the default ~/Arduino and ~/.arduino15 directories.

ROOTDIR="${HOME}/your_project"
export ARDUINO_DIRECTORIES_DATA="${ROOTDIR}/data"
export ARDUINO_DIRECTORIES_DOWNLOADS="${ROOTDIR}/downloads"
export ARDUINO_DIRECTORIES_USER="${ROOTDIR}/user"
export LIBDIR="${ARDUINO_DIRECTORIES_USER}/libraries"
mkdir -p ${LIBDIR}

At this point, arduino-cli will install board files and libraries in subdirectories of $ROOTDIR. If there is an easier way to do this, please let me know.

Portable mode is useful if the project does bad but sometimes necessary things like patching board source code files.

You can configure Arduino CLI via environment variables on any operating system.

I think it depends on your use case, but I would definitely consider the alternative of configuring the directories.data. and directories.user paths via the configuration file:

https://arduino.github.io/arduino-cli/latest/configuration/#configuration-file

You can't use environment variables in the configuration file, so it does not provide all the capabilities of the approach of configuring Arduino CLI via environment variables. Whether that is a significant deficiency depends on your use case.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.