I'm not entirely sure the "headless" options for Teensy are truely headless (CI Woes)

I'm not entirely sure the "headless" options for Teensy are truely headless (CI Woes)

I'm messing around with https://github.com/nektos/act trying to set up some sort of continuous integration for my project with github actions.

The problem is, I seem to be running into problems caused by teensy (I'm hoping once the good Mr. Stoffregen completes arduino cli integration this won't be a problem any more) - specifically in 2 ways:
  1. Installing TeensyduinoInstall.linux64, using the `--dir=` command line parameter, I get this error: "error while loading shared libraries: libXft.so.2: cannot open shared object file: No such file or directory" - so I need to install libxft2 first, prior to installing teensyduino. I'm a bit rusty on my Linux knowledge, but I believe this is related to needing a graphical user frontend? It's not a showstopping problem, as I can install the library and work around it, but it's still frustrating.
  2. However, this problem currently has me stumped - When I compile my project, using the arduino ide and the --verify command line arg, I believe it fails because teensyduino (specifically something called teensy_post_compile) is trying to open teensy-loader. This actually happens locally on my Windows machine too, just day to day use of the arduino IDE, teensy loader opens regardless of whether I clicked verify or upload.

Is there any way to suppress teeny loader and stop it from being opened automatically by the arduino ide when compiling for teensy?
 
I am also running into this problem. What specifically needs edited in platform.txt to disable this operation?
 
I am also running into this problem. What specifically needs edited in platform.txt to disable this operation?
I am not sure "Which" problem you are running into, but you might look into trying
Arduino-cli

https://arduino.github.io/arduino-cli/0.29/installation/
There are now board setups for Arduino IDE 2.0 which should work with this.
I did a compile only and did not specify all of the options yet like USB type
But the compile does go through:
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

I don't remember if the upload was setup yet to work headless or not. Will have to play later
 
teensy_post_compile is supposed to detect Arduino CLI doing a verify only (no upload) and not run Teensy Loader.

It's only been tested briefly and only on Linux.


Edit: and Kurt tested on Windows in the message just before I wrote this...
 
Last edited:
Tried it again with Arduino CLI version 0.29 running from a terminal on Ubuntu 20.04.

screenshot.png

Seems to work fine. Does not launch Teensy Loader or anything else GUI-based.

Only "compile" (useful for CI) is supported headless. There is no headless upload (yet).
 
Should mention Kurt's test used Teensy platform version 0.58.3 (the latest beta) and my test used 1.57.2 (latest stable).

When this thread was started nearly 1 year ago, version 1.56.0 was the latest. Editing platform.txt was necessary back then. But that is no longer needed. In recent versions, teensy_post_compile supports headless compile for CI usage.

For headless compile, simply run Arduino CLI as shown in msg #4 or msg #6.
 
Should mention Kurt's test used Teensy platform version 0.58.3 (the latest beta) and my test used 1.57.2 (latest stable).

When this thread was started nearly 1 year ago, version 1.56.0 was the latest. Editing platform.txt was necessary back then. But that is no longer needed. In recent versions, teensy_post_compile supports headless compile for CI usage.

For headless compile, simply run Arduino CLI as shown in msg #4 or msg #6.

Thought I would mention, I now have installed the CLI on an RPI4 running Ubuntu64

What sometimes is unclear is what does it mean to say running headless ?


That is: I often times had an RPI that I could plug in the monitor/keyboard/mouse, but most of the time I did not.

And I setup to use a PuTTy (or KiTTy) window from my PC, like I just did:
Code:
kurte@kurte-rpi4:~/Arduino/Blink_Text$ arduino-cli compile  -b teensy:avr:teensyMM -v
Using board 'teensyMM' from platform in folder: /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3
Using core 'teensy4' from platform in folder: /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3
Detecting libraries used...
/home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4 /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/sketch/Blink_Text.ino.cpp -o /dev/null
Generating function prototypes...
/home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4 /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/sketch/Blink_Text.ino.cpp -o /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/preproc/ctags_target_for_gcc_minus_e.cpp
/home/kurte/.arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/precompile_helper /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4 /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685 /home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-g++ -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4 /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/pch/Arduino.h -o /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/pch/Arduino.h.gch
/home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-g++ -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/pch -I/home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4 /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/sketch/Blink_Text.ino.cpp -o /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/sketch/Blink_Text.ino.cpp.o
Compiling libraries...
Compiling core...
/home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-g++ -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/pch -I/home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4 /home/kurte/.arduino15/packages/teensy/hardware/avr/0.58.3/cores/teensy4/AudioStream.cpp -o /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/core/AudioStream.cpp.o

...

/home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.elf /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.eep
/home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-objcopy -O ihex -R .eeprom /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.elf /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.hex
/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/teensy_secure encrypthex TEENSY_MICROMOD /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.hex
encrypting 53248 bytes to /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.ehex
/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/teensy_post_compile -file=Blink_Text.ino -path=/tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685 -tools=/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/ -board=TEENSY_MICROMOD
/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/stdout_redirect /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.sym /home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-objdump -t -C /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.elf
/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/teensy_size /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.elf
Memory Usage on Teensy MicroMod:
  FLASH: code:45836, data:7064, headers:8536   free for files:16453636
   RAM1: variables:8672, code:44128, padding:21408   free for local variables:450080
   RAM2: variables:12384  free for malloc/new:511904
/home/kurte/.arduino15/packages/teensy/tools/teensy-tools/0.58.3/stdout_redirect /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.lst /home/kurte/.arduino15/packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/bin/arm-none-eabi-objdump -d -S -C /tmp/arduino-sketch-8FC37326E183E4BF9056A623E5369685/Blink_Text.ino.elf
I then tried to upload. It failed
Code:
kurte@kurte-rpi4:~/Arduino/Blink_Text$ arduino-cli upload -p usb1/1-1/1-1.2
Opening Teensy Loader...
Unable find Teensy Loader.  (p)  Is the Teensy Loader application running?
quitError during Upload: Failed uploading: uploading error: exit status 1

I then went and logged into the RPI with mouse and keyboard, and then went back to PC:
Code:
kurte@kurte-rpi4:~/Arduino/Blink_Text$ arduino-cli upload -p usb1/1-1/1-1.2
Opening Teensy Loader...
But I noticed the Teensy app was then loaded and shown on the display.

EDIT - did not appear to upload in this case.
I remember some stuff about this up on the Arduino-cli project issues:
https://github.com/arduino/arduino-cli/issues/700

I know parts of it were done, but not sure if they implemented, the Environment variable for CLI version, that you can check against.

Also wondering how hard it would be to update boards.txt/platform.txt to maybe have another upload option?
Like Upload Using: (Teensy, TeensyLoaderCLI), and let people choose which one to use?
 
Last edited:
If one uses putty to remote connect, it's important to specify if one will use cli only, or one will use graphics. A standard ssh connection is cli only. To have x11 graphics one needs $ssh -X. For graphics and super user privileges one uses $ssh -Y. The case is important. Lower case option will not work.

Perhaps the program in question called a program with graphics display. This is not allowed under a simple ssh connection. The graphics program will be blocked.
 
Headless upload is not (yet) supported.

Headless compile does work. This is the feature used by most CI tests.

"Headless" means text-only command line (or automated script) usage, not requiring or using any GUI. It is pretty awesome that X11 can do remote graphics, but it in this context "Headless" means text only which is suitable to usage from scripts that typical CI systems use.
 
Thanks Paul,

But with the CLI and teensy_loader_cli - people can now do the updates of a teensy on a headless connection.
Which is great.

I just updated a Teensy micromod connected to RPI 4 over kitty.

I am still experimenting on figuring out different things and how to specify build things.

My last build was: kurte@kurte-rpi4:~$ arduino-cli compile -b teensy:avr:teensyMM --build-property="build.usbtype=USB_MTPDISK_SERIAL" -e ~/github/mtp_tft_picture_view -v --clean

Which succeeded in changing the USB type from Serial to MTPDISK_SERIAL
In changing the USB type, I needed to add --clean as without it, it used the last cached build for serial and the link failed, not having the USB MTP stuff compiled in.

the -e (--export-binaries) - did not appear to copy the binaries to the sketch folder

But was able to do: kurte@kurte-rpi4:/tmp/arduino-sketch-DF8D89D8A69FE2F3B0B8F109B8081E93$ teensy_loader_cli --mcu=TEENSY_MICROMOD -w mtp_tft_picture_view.ino.hex
And press the program button on the Teensy and now it is running that sketch.
 
Since you all made me curious about using the cli I decided to see if I could figure out whats going on since I never used it before. @KurtE's example in post #11 really help as an example.

What I found (for 2.x.x) was: https://arduino.github.io/arduino-cli/0.19/commands/arduino-cli_compile/, at least for the compile options.
Code:
      --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 5s)
  -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
      --libraries strings            List of custom libraries dir paths separated by commas. Or can be used multiple times for multiple libraries dir paths.
      --library strings              List of paths to libraries root folders. Libraries set this way have top priority in case of conflicts. Can be used multiple times for different libraries.
      --only-compilation-database    Just produce the compilation database, without actually compiling.
      --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.
  -P, --programmer string            Optional, use the specified programmer to upload.
  -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.
  -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" and "all". Defaults to "none". Used to tell gcc which warning level to use (-W flag). (default "none")

Interesting enough there are other things you can do with the CLI:
Code:
arduino-cli board - Arduino board commands.
arduino-cli burn-bootloader - Upload the bootloader.
arduino-cli cache - Arduino cache commands.
arduino-cli compile - Compiles Arduino sketches.
arduino-cli completion - Generates completion scripts
arduino-cli config - Arduino configuration commands.
arduino-cli core - Arduino core operations.
arduino-cli daemon - Run as a daemon on port 50051
arduino-cli debug - Debug Arduino sketches.
arduino-cli lib - Arduino commands about libraries.
arduino-cli outdated - Lists cores and libraries that can be upgraded
arduino-cli sketch - Arduino CLI sketch commands.
arduino-cli update - Updates the index of cores and libraries
arduino-cli upgrade - Upgrades installed cores and libraries.
arduino-cli upload - Upload Arduino sketches.
arduino-cli version - Shows version number of Arduino CLI.

Oh and figure out whats FQBN is about: https://arduino.github.io/arduino-cli/0.19/commands/arduino-cli_board_details/

So the question is does this work the same way on Windows as it does in Linux or do I need something else?
 
Windows works the same way.

However, I ran into a simple issue, that it was not finding my libraries. It was defaulting to think my sketchbook was stored under the onedrive folder. I have mostly neutered the onedrive stuff. I do still have it as a way to copy between machines and share, but...

So, I used the: arduino-cli config init
Which generated a file. I then edited the directory name and made things work.
If you wish to see the FQBN and the like for boards you have plugged in, you can do: adruino-cli board list
 
Windows works the same way.

However, I ran into a simple issue, that it was not finding my libraries. It was defaulting to think my sketchbook was stored under the onedrive folder. I have mostly neutered the onedrive stuff. I do still have it as a way to copy between machines and share, but...

So, I used the: arduino-cli config init
Which generated a file. I then edited the directory name and made things work.
If you wish to see the FQBN and the like for boards you have plugged in, you can do: adruino-cli board list

Thanks Kurt will give it a try.
 
UPdate: I am glad I posted up on Arduino as @PerT filled in lots of the blanks, which included some better solutions.

I decide to update the main thread we created for IDE2 and CLI. took over Posting #3 in the thread Arduino CLI And IDE now Released - Teensy Supported! for CLI information.
Sorry in advance for my ramblings and let me know if you have any suggestions on how to clean up the rambling
 
UPdate: I am glad I posted up on Arduino as @PerT filled in lots of the blanks, which included some better solutions.
...

Nice and useful feedback @PerT and info @KurtE. Not looked at anything Headless - TSET hides the IDE for CmdLine from Text editor - but still invokes GUI to select the Teensy for Button free.
TSET likes GUI TyCommander to pick (and remember) Teensy for upload at that time - not sure of a way to ID and pick a Teensy at upload in Headless mode. TyComm CmdLine version can use Ser# IIRC - but that takes knowing and using that.
BTW: The TSET project uses and defines the FQBN string (IDE menu replaced with the batch file prompts to gather info) - so that has carried over from IDE 1.8.x.
Code:
set model=teensy40
set speed=600
set opt=o2std
set usb=serial
set keys=en-us
set fqbn=teensy:avr:%model%:usb=%usb%,speed=%speed%,opt=%opt%,keys=%keys%
 
UPdate: I am glad I posted up on Arduino as @PerT filled in lots of the blanks, which included some better solutions.

I decide to update the main thread we created for IDE2 and CLI. took over Posting #3 in the thread Arduino CLI And IDE now Released - Teensy Supported! for CLI information.
Sorry in advance for my ramblings and let me know if you have any suggestions on how to clean up the rambling

Glad you posted as well. Explanations and example is great - especially for someone who never played with it before.
 
Last edited by a moderator:
Back
Top