Arduino CLI And IDE now Released - Teensy Supported!

Just spent some time with the new IDE. Looks like it's using pluggable discovery but isn't using pluggable monitor. :(

Sounds about right... I think, guessing at terms and what we are seeing.

So playing with MTP stuff and it does not like SEREMU, thought I would try our version of MTP+Serial, so added it to boards.txt and boards.local.txt and the new item did not show up under
USB type menu...

@mjs513 found an open issue about this: https://github.com/arduino/arduino-cli/issues/1614

So did the work around of delete the folder: C:\Users\<user name>\AppData\Roaming\arduino-ide\
And sure enough it shows up... <Now need to update the code to use it>

But a couple of interesting notes:
a) The added items are not in the order they are defined, they appear to be completely random.
screenshot.jpgscreenshot2.jpg
Which can be annoying as maybe they were defined in what you think is a logical order...

b) The first time you install IDE2 (and in the case the roaming folder is gone, the Arduino startup code nicely goes out and wipes out some of your libraries in your <sketch folder>/libraries

Code:
Downloading LiquidCrystal@1.0.7
Installing LiquidCrystal@1.0.7
Already installed LiquidCrystal@1.0.7
Downloading Keyboard@1.0.3
Installing Keyboard@1.0.3
Already installed Keyboard@1.0.3
Downloading Mouse@1.0.1
Installing Mouse@1.0.1
Already installed Mouse@1.0.1
Downloading Arduino_BuiltIn@1.0.0
Installing Arduino_BuiltIn@1.0.0
Already installed Arduino_BuiltIn@1.0.0
Downloading Ethernet@2.0.0
Installing Ethernet@2.0.0
Already installed Ethernet@2.0.0
Downloading Firmata@2.5.8
Installing Firmata@2.5.8
Already installed Firmata@2.5.8
Downloading Stepper@1.1.3
Installing Stepper@1.1.3
Already installed Stepper@1.1.3
Downloading TFT@1.0.6
Installing TFT@1.0.6
Already installed TFT@1.0.6
Downloading SD@1.2.4
Installing SD@1.2.4
Replacing SD@2.0.0 with SD@1.2.4
Installed SD@1.2.4
Downloading Servo@1.1.8
Installing Servo@1.1.8
Already installed Servo@1.1.8
And in my case it blindly replaced my version of Teensy stuff marked with version 2.0.0 with Old 1.2.4...

So need restore that one... And get back to playing

Side note: I totally dislike the splash screen they put up to try to hide how slow their window is to startup. But especially since it is stuck on top, so it gets in the way if you wish to do other things while it starts up...
 
Last edited:
That item list out of order triggered a similar issue. If you go look at the CPU Speed list its out of order as well
Capture.PNG
 
Maybe it's time to start creating issues on Arduino's IDE 2.0 repository?

https://github.com/arduino/arduino-ide/issues

I tried a few quick searches and didn't see any open issues on the random order of menu items. Maybe it's time to start opening issues with screenshots?


Edit: the lack of pluggable monitor in the IDE is apparently a known issue, so please don't create a duplicate for that problem.

https://github.com/arduino/arduino-ide/issues/769

Just give us the word that we are ready for prime time.

On the serial issue I did find this as an open issue: https://github.com/arduino/arduino-ide/issues/752

EDIT: Lack of a progress bar is there as well: https://github.com/arduino/arduino-ide/issues/575
 
Last edited:
In previous post, I mentioned about getting in the MTP+Serial (Thanks @mjs513 )

So now I did update everything to allow this to build, including restoring my github fork version of SD library...

And it built and installed on locked Micromod :D

I could be wrong, but after the upload, where the Teensy USB type changed, that the Arduino IDE lost the whole Tools->Port menu
So quit the IDE and restarted. At first I did not see the port menu, but then I clicked on the drop down in the toolbar and it looked like it showed my board so I selected and then checked again and ports menu was there.

I downloaded again... To make sure...

After download, the Serial Monitor did not work, however when I chose a real Serial port:
screenshot.jpg


Paul - I am hoping that the current display of Ports is a first pass and is still going to be updated...
That is Teensy MicroMod on usb:0/140000/0/1/4 means absolutely nothing to I would think most windows users...
They want to know that it is COM118
screenshot3.jpg

Edit missed putting in screenshot with serial output
 
usb:0/140000/0/1/4 means absolutely nothing to I would think most windows users...

This is a bug in the IDE. According to the Pluggable Discovery Specification, the IDE is supposed to use the contents of the "label" field for the GUI display.

screenshot.png

But the IDE is incorrectly using the "address" field to populate that menu and other parts of the GUI. Probably nobody has noticed it's wrong because the existing serial discovery gives the same info in both fields.

Here is a sample of what teensy-discovery is sending.

screenshot4.png

Please feel free to open an issue on Arduino's github.
 
b) The first time you install IDE2 (and in the case the roaming folder is gone, the Arduino startup code nicely goes out and wipes out some of your libraries in your <sketch folder>/libraries

Code:
Downloading LiquidCrystal@1.0.7
Installing LiquidCrystal@1.0.7
Already installed LiquidCrystal@1.0.7
Downloading Keyboard@1.0.3
Installing Keyboard@1.0.3
Already installed Keyboard@1.0.3
Downloading Mouse@1.0.1
Installing Mouse@1.0.1
Already installed Mouse@1.0.1
Downloading Arduino_BuiltIn@1.0.0
Installing Arduino_BuiltIn@1.0.0
Already installed Arduino_BuiltIn@1.0.0
Downloading Ethernet@2.0.0
Installing Ethernet@2.0.0
Already installed Ethernet@2.0.0
Downloading Firmata@2.5.8
Installing Firmata@2.5.8
Already installed Firmata@2.5.8
Downloading Stepper@1.1.3
Installing Stepper@1.1.3
Already installed Stepper@1.1.3
Downloading TFT@1.0.6
Installing TFT@1.0.6
Already installed TFT@1.0.6
Downloading SD@1.2.4
Installing SD@1.2.4
Replacing SD@2.0.0 with SD@1.2.4
Installed SD@1.2.4
Downloading Servo@1.1.8
Installing Servo@1.1.8
Already installed Servo@1.1.8
And in my case it blindly replaced my version of Teensy stuff marked with version 2.0.0 with Old 1.2.4...

So need restore that one... And get back to playing

Side note: I totally dislike the splash screen they put up to try to hide how slow their window is to startup. But especially since it is stuck on top, so it gets in the way if you wish to do other things while it starts up...

I raised the issue that SD library was replaced: https://github.com/arduino/arduino-ide/issues/798
 
This is a bug in the IDE. According to the Pluggable Discovery Specification, the IDE is supposed to use the contents of the "label" field for the GUI display.

View attachment 27431

But the IDE is incorrectly using the "address" field to populate that menu and other parts of the GUI. Probably nobody has noticed it's wrong because the existing serial discovery gives the same info in both fields.

Here is a sample of what teensy-discovery is sending.

View attachment 27432

Please feel free to open an issue on Arduino's github.
https://github.com/arduino/arduino-ide/issues/800
 
Sounds about right... I think, guessing at terms and what we are seeing.

So playing with MTP stuff and it does not like SEREMU, thought I would try our version of MTP+Serial, so added it to boards.txt and boards.local.txt and the new item did not show up under
USB type menu...

@mjs513 found an open issue about this: https://github.com/arduino/arduino-cli/issues/1614

So did the work around of delete the folder: C:\Users\<user name>\AppData\Roaming\arduino-ide\
And sure enough it shows up... <Now need to update the code to use it>

But a couple of interesting notes:
a) The added items are not in the order they are defined, they appear to be completely random.
View attachment 27425View attachment 27426
Which can be annoying as maybe they were defined in what you think is a logical order...
.....

Side note: I totally dislike the splash screen they put up to try to hide how slow their window is to startup. But especially since it is stuck on top, so it gets in the way if you wish to do other things while it starts up...

https://github.com/arduino/arduino-ide/issues/801
 
Here's a quick recap, where we're at today... for anyone else who wants to give this new software a try.

Arduino CLI seems to be working pretty well, but with the caveat that uploading is done by running the GUI-based Teensy Loader. Packages are available for Windows, MacOS and Linux x86_64. If you *really* need another Linux arch, just ask. True headless mode is planned, but we're waiting on an IDE update, specifically issue 790, before we can reliably detect whether upload should be done headless or with the GUI.

Arduino IDE 2.0-rc3 isn't really usable for Teensy at this point. The main thing to be done is reporting issues, which is an awesome way to contribute to the Arduino & Teensy community. Hopefully the new 2.0 IDE will become more usable with 2.0-rc4 as the Arduino developers fix the issues we've already reported.

To use Arduino CLI, download the nightly build from this page. When you extract, it's just a single executable file. Put it somewhere like /usr/local/bin on Linux or MacOS, or edit your PATH environment variable so it runs when you type "arduino-cli" on the command line.

The first step is to run "config init" like this:

Code:
./arduino-cli config init

or on Windows....

Code:
arduino-cli.exe config init

It will create a arduino-cli.yaml config file and tell you the full pathname. Edit that file and add "https://www.pjrc.com/teensy/td_156/package_teensy_index.json". It should look like this:

Code:
board_manager:
  additional_urls: [
    https://www.pjrc.com/teensy/td_156/package_teensy_index.json
  ]

After editing, run "arduino-cli config dump". You should see something similar to this:

screenshot3.png

To install Teensy's files, run "arduino-cli core install teensy:avr". Today the package version is 1.56.1. Once it's installed, you can run commands like "arduino-cli board list" and it should probably detect Teensy, even when running in non-Serial modes. You can compile, upload, monitor (even in Teensy's non-Serial modes).

Just remember, today upload always runs the GUI-based Teensy Loader, so if running on Linux you need a full desktop environment. But if you've been wanting to use Arduino CLI for scripts or other automation, hopefully now you can begin to move forward. An update to run fully headless will be coming, once Arduino updates fix those issues mentioned above.
 
Last edited:
Here's a quick recap, where we're at today... for anyone else who wants to give this new software a try.

Arduino CLI seems to be working pretty well, but with the caveat that uploading is done by running the GUI-based Teensy Loader. Packages are available for Windows, MacOS and Linux x86_64. If you *really* need another Linux arch, just ask. True headless mode is planned, but we're waiting on an IDE update, specifically issue 790, before we can reliably detect whether upload should be done headless or with the GUI.

Arduino IDE 2.0-rc3 isn't really usable for Teensy at this point. The main thing to be done is reporting issues, which is an awesome way to contribute to the Arduino & Teensy community. Hopefully the new 2.0 IDE will become more usable with 2.0-rc4 as the Arduino developers fix the issues we've already reported.

To use Arduino CLI, download the nightly build from this page. When you extract, it's just a single executable file. Put it somewhere like /usr/local/bin on Linux or MacOS, or edit your PATH environment variable so it runs when you type "arduino-cli" on the command line.

The first step is to run "config init" like this:
...
or on Windows....

Code:
arduino-cli.exe config init

...

Running as Admin (Win 11) I get:
Code:
arduino-cli config init
[B]Access is denied.[/B]

I run that or with no params and cannot copy that file (same error) or, have it exec even double clicking GUI Explorer?

In the GUI I checked properties and it is not marked as 'Blocked' and attributes are only "A": Archive bit it set.

Very Odd.
Also Odd after installing a prior RC3_Jan28 - I cannot get that folder to delete now that I installed yesterday's Feb01 version.

I already added the PJRC json string using the GUI
 
Ok, I've compiled and uploaded packages for both 32 and 64 bit ARM.

Please let me know if this works when you try it?

It works! Thank you for the quick update!
Code:
$ arduino-cli board list
Port Protocol Type          Board Name   FQBN                 Core      
USB  teensy   Teensy Ports  Teensy 4.1   teensy:avr:teensy41  teensy:avr

$ arduino-cli compile --fqbn teensy:avr:teensy41 Blink
Opening Teensy Loader...
teensy_size: Memory Usage on Teensy 4.1:
teensy_size:   FLASH: code:9580, data:3992, headers:8952   free for files:8103940
teensy_size:    RAM1: variables:4512, code:6912, padding:25856   free for local variables:487008
teensy_size:    RAM2: variables:12384  free for malloc/new:511904

However, the toolchain still evokes the GUI-based Teensy Loader, so I have to run it on an LXDE desktop. If there is a way to get the hex file from arduino-cli, we can go headless by using teensy_loader_cli for uploading.

Update: The hex file can be found in a sub dir of /tmp (often with a name of arduino-sketch-*). It works with teensy_loader_cli:
Code:
$ arduino-cli compile --fqbn teensy:avr:teensy41 Blink
Opening Teensy Loader...
Unable find Teensy Loader.  (p)  Is the Teensy Loader application running?
quit

Error during build: exit status 1

[U][B](You got the above message when attempting without a GUI environment. Nevertheless, the sketch was still compiled and you can find the binaries inside /tmp.)[/B][/U]

$ cd /tmp/arduino-sketch-<some ID>

$ teensy_loader_cli --mcu=TEENSY41 -w Blink.ino.hex

The location of the temporary hex file may vary depending on your system.

Edit 2: The error message
Code:
Opening Teensy Loader...
Unable find Teensy Loader.  (p)  Is the Teensy Loader application running?
quit

Error during build: exit status 1
reminds me of the one I got when I tried to use {Arduino}/hardware/teensy/avr/cores/teensy4/Makefile. I wonder if it is because the toolchain for arduino-cli also uses teensy_post_compile?
 
Last edited:
The location of the temporary hex file may vary depending on your system.

To avoid scrambling for the hex file, I've learned that we can use the --build-path option to set where the compiled files are saved. Besides, to suppress teensy_post_compile, we can comment out the postbuild hook in {Arduino}/packages/teensy/hardware/avr/1.56.1/platform.txt as follows:
Code:
#recipe.hooks.postbuild.1.pattern="{teensytools.path}teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={teensytools.path}" "-board={build.board}"

Now there is no more error message:
Code:
$ arduino-cli compile --build-path build --fqbn teensy:avr:teensy41 Blink
teensy_size: Memory Usage on Teensy 4.1:
teensy_size:   FLASH: code:9564, data:3992, headers:8968   free for files:8103940
teensy_size:    RAM1: variables:4512, code:6896, padding:25872   free for local variables:487008
teensy_size:    RAM2: variables:12384  free for malloc/new:511904

$ teensy_loader_cli --mcu=TEENSY41 -wv build/Blink.ino.hex
Teensy Loader, Command Line, Version 2.2
Read "build/Blink.ino.hex": 22528 bytes, 0.3% usage
Waiting for Teensy device...
 (hint: press the reset button)
Found HalfKay Bootloader
Read "build/Blink.ino.hex": 22528 bytes, 0.3% usage
Programming...................
Booting

This is my first endeavor to use Arduino and Teensy tools in a headless setup without maintaining Makefiles. There are likely more elegant ways to do this, perhaps at least after the IDE update as Paul mentioned.
 
To avoid scrambling for the hex file, I've learned that we can use the --build-path option to set where the compiled files are saved. Besides, to suppress teensy_post_compile, we can comment out the postbuild hook in {Arduino}/packages/teensy/hardware/avr/1.56.1/platform.txt as follows:
Code:
#recipe.hooks.postbuild.1.pattern="{teensytools.path}teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={teensytools.path}" "-board={build.board}"


This is my first endeavor to use Arduino and Teensy tools in a headless setup without maintaining Makefiles. There are likely more elegant ways to do this, perhaps at least after the IDE update as Paul mentioned.

It will be good when we can go fully headless. It has been awhile since I have done remote building for Teensy connected to RPI, I often built in on my PC, then would use winscp to transfer the hex file to the RPI, where I would then run command line teensy loader to program the teensy...

At one point I had it sort of automated, where I hacked the protocol.txt and added another menu item, like update using: ... And then used a command line file transfer to copy it to a known location on the RPI, where I had a batch script running looking for a file to be updated and if so, it updated the teensy... Actually it was probably mentioned in this thread, back when I opened it.

I have since lost all of those scripts. Will be interesting to try out something like that again with the arduino-cli...
 
Paul - first thanks for the recap, especially for some of the tidbits of how to use the arduino-cli.
Here's a quick recap, where we're at today... for anyone else who wants to give this new software a try.
Arduino IDE 2.0-rc3 isn't really usable for Teensy at this point. The main thing to be done is reporting issues, which is an awesome way to contribute to the Arduino & Teensy community. Hopefully the new 2.0 IDE will become more usable with 2.0-rc4 as the Arduino developers fix the issues we've already reported.

But I also sort of a glutton for punishment, so I have continued to play with the IDE 2 some more, to see if there are other things that need to get fixed and the like:

Note: I am using the daily builds of the IDE (On windows machine I have 0201 and on Ubuntu 0202... Have not looked at MAC for a day or two...

There are lots of things that would be great to be expanded upon, but there are also some nice things as well... Note So far neither the new one nor the older one will take over for using external editors, as neither of them appear setup to allow me to edit Libraries or core code...

But it was nice to have some extended editing capabilities, like: today when on the why Serial.print is different than write, I wanted to edit the sources and change like 4 or 5 lines in a row, and I simply clicked on Mouse button 3? (wheel on MS mouse) and column selected the word print, and then typed write and all 4 or 5 lines were updated, like I do in sublime text.

I also included my MemoryDumpLibrary and it was nice to be able to start typing: the name of function and it showed me the declaration of the function....

So again showing some progress....

Note: Their Serial monitor does not yet support the Teensy plug in Serial Monitor, but if your type includes Serial, than you can get it to show the output in it's internal Serial Monitor Pane.
There are a few issues, like if you cut and paste out of the monitor, to lets say here.. It loses the CR's... Was going to report, but there is an existing issue...

Thought I would play some more with MTP stuff, so thought I would build our WIP picture viewer, with the MTP+Serial which is not yet a supported USB type, but brought the modifications into
the system and found that the stuff in boards.local.txt (or changes to boards.txt) did not show up in the menus...

Covered indirectly in the bug report: https://github.com/arduino/arduino-cli/issues/1614 @mjs513 found this existing issue)
So did the work around and it downloaded the libraries again... Again overwriting my version of SD library...
Restored it.

And now the MTP Disk Serial - was in the list. Warning the USB types menu is in sort of a random order (@mjs513 reported that on)

Long story short, with this was able to build this now on both Windows and Ubuntu.

Runs on Windows 10... The Windows File Explorer window opens on it (I choose that earlier as default action), and I have to screw around at times and tell it again that it is the USB serial port not the other teensy port and I can then see the Serial Monitor output...

On Ubuntu It builds, my tft is updated and I can see the Terminal window output if I choose ttyACM0... And sometimes I can see the Files on the SDCard in a Files window on Ubuntu, but not I don't think as MTP, maybe PTP (as Icon shows up as camera...) Other times does not show up at all..

Not sure why yet, but that is more for a different forum thread.
 
I got it to work on my Mac but there were problems.

Just editing the yaml config file to add the additional_urls entry did nothing. The core install command said it could not find teensy. I tried the url for esp32 and that didn't work either so I think this does not work in the Mac version or I am missing something.

Arduino-cli seems to use the same backend packages in the same directories as the classic Arduino app so I used the Arduino 1.18.19 app and installed the json file using its board manager. Interestingly I can now program the teensy with that app now so I no longer need a separate Teensyduino. :)

After installing that way the teensy boards appeared in 'arduino-cli board listall' and I could use a teensy FQBN to directly program the teensy with arduino-cli. Success.

There are some issues: I get this message

Error initializing instance: discovery not found: teensy:teensy-discovery

on most commands even though they go on to work fine.

The 'arduino-cli board list' command crashes

Error detecting boards: Error getting board list: [listing ports from discovery builtin:mdns-discovery: command failed: mdns lookup error: write udp6 [::]:60016->[ff02::fb]:5353: sendto: no route to host]

without outputting anything but I think that is a problem with the Mac version of arduino-cli and nothing to do with your stuff. I reverted to the stable 20.2 version and that crashed too.

Getting command line support with Teensy is a big deal for me, and I have been waiting a long time for this day, so thanks for your great work here.
 
But I also sort of a glutton for punishment, so I have continued to play with the IDE 2 some more

Really glad you're giving a try and opening github issues. Looks like the Arduino developers really are working on this stuff and good constructive feedback is the path to making the new IDE work well.

I too opened an issue today, and asked Cristian about extending Pluggable Discovery (on an old closed issue) to create arduino-cli infrastructure which might someday pave the way for the new toolbar's drop-down menu to configure the menu options as well as the board & port.
 
@KurtE - @PaulStoffregen

Had a bit of time today so took a look at something I noticed the other day. If you do a File -> Examples and look down the list you will see a blank line above say Teensy MicroMod - if you hightlight that line you get a list of sketches.
Capture.PNG
Turns out those are all files that belong to libraries that don't have a library.properties file associated with them. EasyTransfer was one so I added this library.properties file:
Code:
name=EasyTransfer
version=1.7
author=Bill Porter
maintainer=Bill Porter
sentence=Transfer data between Arduinos over serial connection.
paragraph=The purpose of this library is to make it easy for the everyday Arduino user working on projects with multiple Arduinos communicating with each other and sharing data over Serial connections.
category=Data
url=https://github.com/madsci1016/Arduino-EasyTransfer/tree/master/EasyTransfer
architectures=*
and it now shows on the main library examples list.

Not sure if this is what you would consider a bug or something they want everyone to go to.

UPDATE 1; Well here is definitely a issue. After creating library.properties if I click on the example it fails to open
 
I did find a similar issue regarding library format 1.0 vs 1.5 so I added on to that Issue since it was still open: https://github.com/arduino/arduino-ide/issues/40. It was assigned back in Nov of 2021. Lets see what happens.

@KurtE - @PaulStoffregen.

I did get a response from per1234 regarding the issue. The issue with Incorrect handling of Legacy format libraries by the library is universal to all boards.

However, the reason the EasyTransfer examples do not open any more is because they use the .pde file extension instead of the .ino extension, see https://github.com/arduino/arduino-ide/issues/518. Looks like any libraries that use .pde as an extension need to be updated to .ino's.

Update 1. Just changed all file extensions to .ino's from .pde's and now they open in the IDE.
 
I reinstalled on another Mac and figured out why 'core install' did not work yesterday. You have to do a 'core update-index' after editing the yaml to add the new board json. Then 'core install' was successful.

I also don't get the 'teensy:teensy-discovery' warnings on this machine.

So everything is working fine. Good job.
 
Back
Top