<Reused this post for Arduino-CLI updated notes> Also posted on Arduino forum
More recent notes of trying out arduino-cli with teensy support on both Windows and Raspberry PI running ubuntu 64 bits.
Installing it - Is it already installed as part of the IDE?
Yes: It is in the resources/app/node_modules/arduino-ide-extension/build subfolder of the Arduino IDE installation folder.
So my nightly build it is installed at: C:\arduino-ide_nightly\resources\app\node_modules\arduino-ide-extension\build
and released version: C:\Program Files\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build
But: before I knew this, I installed from: [arduino/arduino-cli: Arduino command line tool (github.com)](https://github.com/arduino/arduino-cli) 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:
Code:
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
actually FLA) for a Teensy?
One way to get an idea is to use the command:
Code:
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
Code:
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:
Code:
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
Code:
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)
Updated: the FQBN in this case is far more than just information about the board, it also allows you to specify all of the values for the menu items as part of it.
So the short answer on how to build with USB set to MTP Serial is:
Code:
D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM:usb=serialmtp
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
Which is a lot cleaner than my previous fumbling around solution I tried before this:
Code:
D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM --build-property="build.usbtype=USB_MTPDISK_SERIAL" --clean
Which worked, but I had to manually add --clean as the command did not know directly I changed settings and so the core files were not rebuilt.
Also - was considered a major hack that may or may not work i the future.

But how do you find out about what are the valid FQBN options? That is where the command:
Code:
D:\github\mtp_tft_picture_view>arduino-cli board details -b teensy:avr:teensyMM
Board name: Teensy MicroMod
FQBN: teensy:avr:teensyMM
Board version: 0.58.3
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_158-beta3/teensy-package.tar.bz2
Platform file name: teensy-package.tar.bz2
Platform size (bytes): 33761456
Platform checksum: SHA-256:593b43c860ac16208fc0e506ed2cf1581a52e9cfcb44fca8a0f94a252b9f8095
Required tool: teensy:teensy-tools 0.58.3
Required tool: teensy:teensy-compile 11.3.1-beta2
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
Note: you do not need to specify all of the options, only those which are not the default ones.
Next up Upload:
For my main computer, which in my case is Windows 11, or secondary computers one running Ubuntu (64 bit) or MAC, where I have displays connected, have a few different options:
Do it as part of the compile like:
Code:
D:\github\mtp_tft_picture_view>arduino-cli compile -b teensy:avr:teensyMM:usb=serialmtp --upload -p usb:0/140000/0/8/1/1
Or could do as two steps. Here showing with not building in the sketch directory.
Code:
C:\Users\kurte>arduino-cli compile -b teensy:avr:teensyMM:usb=serialmtp D:\github\mtp_tft_picture_view
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
C:\Users\kurte>arduino-cli upload -p usb:0/140000/0/8/1/1 D:\github\mtp_tft_picture_view
Headless uploads, for example to Raspberry PI over SSH. I am ussing KiTTy (derived from PuTTy)
If you actually running on the RPI using a monitor, keyboard, mouse, you can use all of the same as above.
Currently when building for Teensy boards, headless uploads are not fully supported yet. That is the upload will try to launch the GUI teensy app.
So currently I am using teensly_loader_cli, or may also try TyTools.
To make it easier I thought I would use the --export-binaries
Code:
kurte@kurte-rpi4:~/github/mtp_tft_picture_view$ arduino-cli compile -b teensy:avr:teensyMM:usb=serialmtp --export-binaries
/home/kurte/github/mtp_tft_picture_view/mtp_tft_picture_view.ino:211:17: note: '#pragma message: Display: ST7735_t3 or ST7789_t3'
211 | #pragma message "Display: ST7735_t3 or ST7789_t3"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Memory Usage on Teensy MicroMod:
FLASH: code:171352, data:36368, headers:8340 free for files:16299012
RAM1: variables:106784, code:167544, padding:29064 free for local variables:220896
RAM2: variables:28800 free for malloc/new:495488
Used library Version Path
SPI 1.0 /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/libraries/SPI
SD 2.0.0 /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/libraries/SD
SdFat 2.1.2 /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/libraries/SdFat
MTP_Teensy 1.0.0 /home/kurte/github/mtp_teensy
JPEGDEC 1.2.8 /home/kurte/Arduino/libraries/JPEGDEC
PNGdec 1.0.1 /home/kurte/Arduino/libraries/PNGdec
ST7735_t3 1.0.0 /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/libraries/ST7735_t3
Used platform Version Path
teensy:avr 0.58.3 /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3
kurte@kurte-rpi4:~/github/mtp_tft_picture_view$ ls build/teensy.avr.teensyMM/
mtp_tft_picture_view.ino.eep mtp_tft_picture_view.ino.elf mtp_tft_picture_view.ino.lst
mtp_tft_picture_view.ino.ehex mtp_tft_picture_view.ino.hex mtp_tft_picture_view.ino.sym
As you can see it saves the output files into sub-directory build and subdirectory based off of the main FQBN string.
So was able to program it using the command:
Code:
kurte@kurte-rpi4:~/github/mtp_tft_picture_view$ teensy_loader_cli --mcu=TEENSY_MICROMOD -w build/teensy.avr.teensyMM/mtp_tft_picture_view.ino.hex
kurte@kurte-rpi4:~/github/mtp_tft_picture_view$
Note: In this case I pressed the program button.
And I was also able to program the teensy using the tytools which I downloaded sources from: https://github.com/Koromix/tytools
And built them on the RPI using the instructions given in the Readme file
Code:
Supported firmware formats: elf, ihex.
kurte@kurte-rpi4:~$ tycmd upload ~/github/mtp_tft_picture_view/build/teensy.avr.teensyMM/mtp_tft_picture_view.ino.hex
upload@8493450-Teensy Uploading to board '8493450-Teensy' (Teensy MicroMod)
upload@8493450-Teensy Triggering board reboot
upload@8493450-Teensy Firmware: mtp_tft_picture_view.ino.hex
upload@8493450-Teensy Flash usage: 211 kiB (1.3%)
upload@8493450-Teensy Uploading... 100%
upload@8493450-Teensy Sending reset command (with RTC)
kurte@kurte-rpi4:~$
Hopefully this version of the information is a little easier to understand!