PaulStoffregen
Well-known member
I'm still waiting on the Arduino developers to merge this, before I can support Teensy on arduino-cli
https://github.com/arduino/arduino-cli/pull/109
https://github.com/arduino/arduino-cli/pull/109
does this PR implement what you need?
https://github.com/arduino/arduino-cli/pull/217
That's unfortunate. Arduino CLI is the only solution that allows using programmers editors like Sublime, EMeditor, Epsilon etc.
"%arduino%\arduino-builder" -verbose=1 -warnings=more -compile -logger=human -hardware "%arduino%\hardware" -hardware "%LOCALAPPDATA%\Arduino15\packages" -tools "%arduino%\tools-builder" -tools "%arduino%\hardware\tools\avr" -tools "%LOCALAPPDATA%\Arduino15\packages" -built-in-libraries "%arduino%\libraries" -libraries "%libs%" -fqbn=%fqbn% -build-path %temp1% -build-cache "%temp2%" %ino%
board_manager:
additional_urls: ['https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json', 'https://adafruit.github.io/arduino-board-index/package_adafruit_index.json']
daemon:
port: "50051"
directories:
data: /usr/local/lib/arduino <--- NOTE THIS DIRECTORY
downloads: /usr/local/lib/arduino/staging
user: /usr/local/src/arduino
logging:
file: ""
format: text
level: trace
$ mkdir -p /usr/local/lib/arduino/packages/teensy
$ cp -r /usr/local/lib/arduino1.8.13/hardware/teensy /usr/local/lib/arduino/packages/teensy/hardware
$ cp -r /usr/local/lib/arduino1.8.13/hardware/tools /usr/local/lib/arduino/packages/teensy/tools
## Teensy Loader
#tools.teensyloader.cmd.path={runtime.hardware.path}/../tools
tools.teensyloader.cmd.path=/usr/local/lib/arduino/packages/teensy/tools
$ DISPLAY=:0 /usr/local/lib/arduino/packages/teensy/tools/teensy &
$ arduino-cli --config-file "/usr/local/lib/arduino/config.yaml" compile --verbose --log-level trace --fqbn teensy:avr:teensy40 --upload --port /dev/ttyACM1 --build-path /home/andrew/.tmp/arduino-build/Arduino_Teensy4_test_script --build-cache-path /home/andrew/.tmp/arduino-build.cache/Arduino_Teensy4_test_script /home/andrew/Code/arduino/Arduino-Teensy4/Arduino_Teensy4_test_script
If anyone is following this for a workaround until arduino-cli adds support for the `{runtime.hardware.path}` pattern in Teensy's platform.txt, I managed to get arduino-cli to successfully work with Teensyduino with the following steps.
$ cd /path/to/your/teensy_cli_loader
$ ./teensy_loader_cli -v --mcu=imxrt1062 -w /home/andrew/.tmp/arduino-build/Arduino_Teensy4_test_script/......hex
tools.teensyloader.cmd.path=/usr/local/lib/arduino/packages/teensy/tools
tools.teensyloader.upload.params.quiet=
tools.teensyloader.upload.params.verbose=-verbose
tools.teensyloader.upload.pattern="{cmd.path}/teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={cmd.path}" "-board={build.board}" -reboot "-port={serial.port}" "-portlabel={serial.port.label}" "-portprotocol={serial.port.protocol}"
If anyone is following this for a workaround until arduino-cli adds support for the `{runtime.hardware.path}` pattern in Teensy's platform.txt, I managed to get arduino-cli to successfully work with Teensyduino with the following steps.
Note that I did not have the Arduino IDE installed at all, so these steps assume a fresh install of both Arduino IDE 1.8.13 and Teensyduino 1.53. Also these steps were performed on Ubuntu Linux 20.04, but should work in principle anywhere:
- Install Arduino IDE 1.8.13 (I used /usr/local/lib/arduino1.8.13)
- Install Teensyduino 1.53. Select the Arduino IDE install path above when prompted.
- Install arduino-cli. I built from source, and it shouldn't matter where this is installed. What does matter is where the data directory is defined in your arduino-cli YAML configuration file. For example, I use this very simple configuration file, with data directory defined as /usr/local/lib/arduino:
Code:board_manager: additional_urls: ['https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json', 'https://adafruit.github.io/arduino-board-index/package_adafruit_index.json'] daemon: port: "50051" directories: data: /usr/local/lib/arduino <--- NOTE THIS DIRECTORY downloads: /usr/local/lib/arduino/staging user: /usr/local/src/arduino logging: file: "" format: text level: trace
- Copy Teensyduino to arduino-cli data directory. Note that you'll need to do a bit of rearranging. Assuming the above paths are used, the following commands will create the expected directory structure:
Code:$ mkdir -p /usr/local/lib/arduino/packages/teensy $ cp -r /usr/local/lib/arduino1.8.13/hardware/teensy /usr/local/lib/arduino/packages/teensy/hardware $ cp -r /usr/local/lib/arduino1.8.13/hardware/tools /usr/local/lib/arduino/packages/teensy/tools
- Now with toolchain installed, you'll need to make one ugly patch to address the mentioned feature missing from arduino-cli. Open /usr/local/lib/arduino/packages/teensy/hardware/avr/platform.txt, scroll down to the Teensy Loader section, and replace the commented line with a line specifying the hardcoded path to your tools directory:
Code:## Teensy Loader #tools.teensyloader.cmd.path={runtime.hardware.path}/../tools tools.teensyloader.cmd.path=/usr/local/lib/arduino/packages/teensy/tools
- Now, you simply need to open Teensyloader and run arduino-cli to build and upload your sketch. Unfortunately, it seems Teensyloader requires a graphical environment to run, so if you are running this remotely, you'll need to make sure the remote machine has an Xserver running. The following commands include "DISPLAY=:0" to account for this, but isn't necessary if you are running this locally on a machine with a graphical desktop. For example:
Code:$ DISPLAY=:0 /usr/local/lib/arduino/packages/teensy/tools/teensy & $ arduino-cli --config-file "/usr/local/lib/arduino/config.yaml" compile --verbose --log-level trace --fqbn teensy:avr:teensy40 --upload --port /dev/ttyACM1 --build-path /home/andrew/.tmp/arduino-build/Arduino_Teensy4_test_script --build-cache-path /home/andrew/.tmp/arduino-build.cache/Arduino_Teensy4_test_script /home/andrew/Code/arduino/Arduino-Teensy4/Arduino_Teensy4_test_script
Error during build: incorrect FQBN: invalid fqbn: teensy:avr
hey @ardnew thank you very much for the suggestion, it works. I could customize your command to compile for a Teensy3.2
For a full CLI workflow you can remove the `--upload` parameter and upload the `.hex` generated manually using the Teensy CLI loader https://www.pjrc.com/teensy/loader_cli.html (need to be separately installed / compiled)