A comprehensive Teensy 3.x/4.x project template for Linux, Windows Subsystem for Linux (WSL), and Windows. Inspired by apmorton/teensy-template referencing the Teensy cores from PaulStoffregen/cores. Configurations for VS Code are included, but not required to use this project template.
After cloning this project you'll need the appropriate tools for your OS to compile and upload your code to your Teensy. You have two options (for WSL you must install Teensyduino for Windows from option 2 regardless of which tools option you choose):
Enables your project to compile standalone, but increases your project size. Run these two Git commands from the terminal within your project:
git remote add tools https://github.com/rspurrell/teensy-template.git
- Then either:
- Linux/WSL:
git subtree add --squash --prefix=tools/ tools linux-tools
- Windows:
git subtree add --squash --prefix=tools/ tools windows-tools
- Linux/WSL:
Consumes a smaller footprint, but has a dependency on having Teensyduino installed to compile.
- Download and extract an Arduino IDE tarball:
wget https://downloads.arduino.cc/arduino-1.8.13-linux64.tar.xz
tar xvf arduino-1.8.13-linux64.tar.xz -C /path/to/parent
- Download and install Teensyduino:
wget https://www.pjrc.com/teensy/td_153/TeensyduinoInstall.linux64
chmod 755 TeensyduinoInstall.linux64
./TeensyduinoInstall.linux64 --dir=/path/to/parent/arduino-1.8.13
- Install the Arduino IDE
- Install Teensyduino for Windows
- Install the Teensy udev rule:
sudo cp 49-teensy.rules /etc/udev/rules.d/
- Unplug your Teensy and plug it back in
Create a convenient shortcut to the Teensy loader executable at %PROGRAMFILES(x86)%\Arduino\hardware\tools\teensy.exe
.
Please note that since there is no USB support in WSL, make upload
will not work.
Install GNU Make for Windows. I highly recommended using the Windows package manager, Chocolately. Once installed, simply type choco install make
on an elevated command line.
- Put your code in
src/main.cpp
and its folder - Put any libraries you need in
libraries
- Set the TEENSY variable in
Makefile
according to your teensy version- You may need to update the
TOOLSPATH
variable depending what you choose for your tools setup
- You may need to update the
- Build your code
make
. Alternatively, usemake TEENSY=**
where**
is your Teensy version [LC
,30
,31
,32
,35
,36
,40
,41
] - Upload your code:
- Linux/Windows:
make upload
(does not work with WSL) - WSL: Using Teensy loader, locate and load the compiled hex file located in your WSL project folder. (eg.
\\wsl$\Ubuntu-20.04\home\rspurrell\workspaces\teensy\teensy-template\bin
)
- Linux/Windows:
- Install the Microsoft C/C++ Extensions
- Open this project folder in VS Code
- Adjust the
toolsPath
andcompilerPath
in.vscode/c_cpp_properties.json
as necessary - Select the configuration matching your Teensy.
Ctrl+Shift+P
and typeSelect a Configuration
- The
cores
sub-folder is agit subtree
of PaulStoffregen/cores - The
linux-tool
andwindows-tools
branches are taken from Teensyduino v1.5.3 - The
src/main.cpp
file is a copy ofteensy4/main.cpp
- The
Makefile
file is a modified copy ofteensy3/Makefile
- The
49-teensy.rules
file is taken from PJRC's udev rules - Inspiration for this template was appropriated from apmorton/teensy-template