• Stars
    star
    316
  • Rank 129,762 (Top 3 %)
  • Language
    C
  • Created about 10 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command line Teensy Loader

Teensy Loader - Command Line Version

The Teensy Loader is available in a command line version for advanced users who want to automate programming, typically using a Makefile. For most uses, the graphical version in Automatic Mode is much easier.

http://www.pjrc.com/teensy/loader_cli.html

Compiling From Source

The command line version is provided as source code for most platforms. To compile, you must have gcc or mingw installed. Edit the Makefile to select your operating system, then just type "make". If you have a BSD compatible make, replace "Makefile" with "Makefile.bsd". Version 2.0 has been tested on Ubuntu 9.04, Mac OS-X 10.5, Windows XP, FreeBSD 8.0, OpenBSD (20-Jan-2010 snapshot), and NetBSD 5.0.1. All versions of NT-based Windows with USB support (2000 and later) are believed to work.

On Ubuntu, you may need to install "libusb-dev" to compile.

sudo apt-get install libusb-dev

Other Linux systems may require other package installation to compile.

Usage and Command Line Options

A typical usage from the command line may look like this:

teensy_loader_cli --mcu=mk20dx256 -w blink_slow_Teensy32.hex

Required command line parameters:

--mcu=<MCU> : Specify Processor. You must specify the target processor. This syntax is the same as used by gcc, which makes integrating with your Makefile easier, we also now support passing in a logical name. Valid options are:
--mcu=TEENSY2           Teensy 2.0
--mcu=TEENSY2PP         Teensy++ 2.0
--mcu=TEENSYLC          Teensy LC
--mcu=TEENSY30          Teensy 3.0
--mcu=TEENSY31          Teensy 3.1
--mcu=TEENSY32          Teensy 3.2
--mcu=TEENSY35          Teensy 3.5
--mcu=TEENSY36          Teensy 3.6
--mcu=TEENSY40          Teensy 4.0
--mcu=TEENSY41          Teensy 4.1
--mcu=TEENSY_MICROMOD   MicroMod Teensy
--mcu=imxrt1062         Teensy 4.0
--mcu=mk66fx1m0         Teensy 3.6
--mcu=mk64fx512         Teensy 3.5
--mcu=mk20dx256         Teensy 3.2 & 3.1
--mcu=mk20dx128         Teensy 3.0
--mcu=mkl26z64          Teensy LC
--mcu=at90usb1286       Teensy++ 2.0
--mcu=atmega32u4        Teensy 2.0
--mcu=at90usb646        Teensy++ 1.0
--mcu=at90usb162        Teensy 1.0

Caution: HEX files compiled with USB support must be compiled for the correct chip. If you load a file built for a different chip, often it will hang while trying to initialize the on-chip USB controller (each chip has a different PLL-based clock generator). On some PCs, this can "confuse" your USB port and a cold reboot may be required to restore USB functionality. When a Teensy has been programmed with such incorrect code, the reset button must be held down BEFORE the USB cable is connected, and then released only after the USB cable is fully connected.

Optional command line parameters:

-w : Wait for device to appear. When the pushbuttons has not been pressed and HalfKay may not be running yet, this option makes teensy_loader_cli wait. It is safe to use this when HalfKay is already running. The hex file is read before waiting to verify it exists, and again immediately after the device is detected.

-r : Use hard reboot if device not online. Perform a hard reset using a second Teensy 2.0 running this rebooter code, with pin C7 connected to the reset pin on your main Teensy. While this requires using a second board, it allows a Makefile to fully automate reprogramming your Teensy. This method is recommended for fully automated usage, such as Travis CI with PlatformIO. No manual button press is required!

-s : Use soft reboot (Linux only) if device not online. Perform a soft reset request by searching for any Teensy running USB Serial code built by Teensyduino. A request to reboot is transmitted to the first device found.

-n : No reboot after programming. After programming the hex file, do not reboot. HalfKay remains running. This option may be useful if you wish to program the code but do not intend for it to run until the Teensy is installed inside a system with its I/O pins connected.

-v : Verbose output. Normally teensy_loader_cli prints only error messages if any operation fails. This enables verbose output, which can help with troubleshooting, or simply show you more status information.

System Specific Setup

Linux requires UDEV rules for non-root users.

https://www.pjrc.com/teensy/00-teensy.rules

FreeBSD requires a device configuration file for non-root users.

OpenBSD's make is incompatible with most AVR makefiles. Use "pkg_add -r gmake", and then compile code with "gmake all" to obtain the .hex file.

On Macintosh OS-X 10.8, Casey Rodarmor shared this tip:

I recently had a little trouble getting the teensy cli loader working on Mac OSX 10.8. Apple moved the location of the SDKs around, so that they now reside inside of the xcode app itself. This is the line in the makefile that got it working for me: SDK ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk

Makefile Integration

You can use teensy_loader_cli from your Makefile, to autoamtically program your freshly compiled code. Here is an example:

# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
        @echo
        @echo $(MSG_FLASH) $@
        $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@
        teensy_loader_cli --mcu=$(MCU) -w -v $@

Make requires the white space before any command to be a tab character (not 8 spaces), so please make sure you use tab.

If you connect a second Teensy using the rebootor code, add the "-r" option and your code will always be programmed automaticallly without having to manually press the reset button!

Scott Bronson contributed a Makefile patch to allow "make program" to work for the blinky example.

PlatformIO Integration

Platformio includes support for loading via teensy_loader.

Errata

Compiling on Mac OS-X 10.6 may require adding "-mmacosx-version-min=10.5" to the Makefile. Thanks to Morgan Sutherland for reporting this.

$(CC) $(CFLAGS) -DUSE_APPLE_IOKIT -isysroot $(SDK) -o teensy_loader_cli teensy_loader_cli.c -Wl,-syslibroot,$(SDK) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5

More Repositories

1

Time

Time library for Arduino
C++
1,238
star
2

Audio

Teensy Audio Library
C++
955
star
3

OneWire

Library for Dallas/Maxim 1-Wire Chips
C++
542
star
4

Encoder

Quadrature Encoder Library for Arduino
C++
489
star
5

cores

Teensy Core Libraries for Arduino
C
474
star
6

TimerOne

TimerOne Library with optimization and expanded hardware support
C++
438
star
7

CapacitiveSensor

Detect touch or proximity by capacitve sensing
C++
360
star
8

AltSoftSerial

Software emulated serial using hardware timers for improved compatibility
C++
308
star
9

SerialFlash

Library for using SPI Flash memory with a filesystem-like interface
C++
296
star
10

OctoWS2811

Control thousands of WS2811/2812 LEDs at video refresh speeds
C++
247
star
11

RadioHead

Version of RadioHead library for Teensy boards
C++
237
star
12

ILI9341_t3

Optimized ILI9341 TFT Library
C
224
star
13

XPT2046_Touchscreen

Touchscreen Arduino Library for XPT2046 Touch Controller Chip
C++
208
star
14

USBHost_t36

USB Host Library for Teensy 3.6 and 4.0
C++
166
star
15

TimeAlarms

Time library add-on, schedule alarms to occur at specific dates/times
C++
159
star
16

MahonyAHRS

C++
152
star
17

WS2812Serial

Non-Blocking WS2812 LED Library
C++
137
star
18

FreqCount

Measures the frequency of a signal by counting the number of pulses during a fixed time.
C
136
star
19

PS2Keyboard

PS/2 Keyboard Library for Arduino
C++
132
star
20

DS1307RTC

Use a DS1307 Real Time Clock chip with the Time library
C++
127
star
21

Ethernet

Ethernet library for Teensy (Wiznet W5100 / W5200 / W5500)
C++
125
star
22

SPI

SPI library for Teensy & Arduino IDE
C++
119
star
23

MsTimer2

Run a function using a timer
C++
104
star
24

CoreMark

Benchmark CPU Performance on Arduino Compatible Boards
C
102
star
25

DmxSimple

C++
90
star
26

EEPROM

C++
76
star
27

TimerThree

TimerThree Library with optimization and expanded hardware support
C++
75
star
28

LittleFS

C
71
star
29

Tlc5940

16 channel PWM LED driver based on the Texas Instruments TLC5940 chip.
C
71
star
30

SD

C++
67
star
31

FreqMeasure

Measures the elapsed time during each cycle of an input frequency.
C
64
star
32

MotionCal

Motion Sensor Calibration Tool
C
63
star
33

NXPMotionSense

NXP Motion Sensors for Teensy and Arduino
C++
61
star
34

ILI9341_fonts

Extra fonts for use with ILI9341_t3
C
50
star
35

hid_listen

C
47
star
36

PulsePosition

Multiple High-Res Input & Output PPM Encoded Signal Streams on Teensy 4.x, 3.x & LC
C++
45
star
37

FreqMeasureMulti

Measures the elapsed time during each cycle of up to 8 input frequencies.
C++
34
star
38

ST7735_t3

Teensy 3.x Optimized Version of Adafruit_ST7735 (1.8 inch TFT Display)
C
32
star
39

X-Plane_Plugin

TeensyControls Plugin for X-Plane Flight Simulator
C
31
star
40

MakerFaire2017

Monolith Synth
C++
24
star
41

Bridge

Communicate between Teensy & Raspberry Pi - similar to Arduino Yun
Arduino
24
star
42

RSA_signature_speed

Simple CPU speed benchmark
C
24
star
43

ARM-Toolchain

Shell
23
star
44

PWMServo

Control RC Servo motors with interrupt-resilient PWM
C++
23
star
45

Teensyduino_Examples

Examples for Teensyduino, installed into Arduino's File > Examples > Teensy menu
C++
22
star
46

teensy41_psram_memtest

C++
21
star
47

teensy41_extram

C
20
star
48

Wire

Wire library used on Teensy boards
C++
20
star
49

LedDisplay

Print text to an Avago HCMS-29xx LED display
C++
19
star
50

FrequencyTimer2

Create a zero jitter frequency output, and run your own function on each period.
C++
19
star
51

teensy41_ethernet

C
15
star
52

CryptoAccel

Assembly
15
star
53

TouchGuitar

Arduino
13
star
54

arm_math

C
11
star
55

k66_ethernet

Experiments with K66 Ethernet
Arduino
10
star
56

USB-Serial-Print-Speed-Test

How many lines/second can your Arduino print to the serial monitor?
C++
10
star
57

AVR_DTMF

Efficient 8 bit AVR-based DTMF Decoding
C
10
star
58

Tectonic_Pitch_Shift

C++
9
star
59

FreqCountMany

Measure 10 frequencies with Teensy 4.0 & 4.1
C++
9
star
60

ARM_Toolchain_2014q1_Source

GCC ARM Toolchain Source - for running Arduino on Raspberry Pi
Shell
9
star
61

secure_plugin

Teensy 4 Security plugin for Arduino IDE
Java
8
star
62

SoundfontDecoder

Python
8
star
63

ST7789_t3

C++
7
star
64

Arduino-1.8.9-Teensyduino

Java
7
star
65

ht1632c

Objective-C
7
star
66

Arduino-1.8.5-Teensyduino

C
7
star
67

TopOctaveGenerator

C++
6
star
68

Verify_All_Arduino_Libraries

Perl
6
star
69

teensy_size

C
6
star
70

Arduino-1.8.13-Teensyduino

Java
5
star
71

Arduino-examples-for-Teensyduino

The slightly modified examples for Teensyduino
Arduino
5
star
72

TalkieKeyboards

Five 104-key keyboards trigger speaking 520 words
C
5
star
73

LargeSamplePlayer

C++
5
star
74

Arduino-1.6.0-Teensyduino

C
5
star
75

USB_Tester

C++
5
star
76

hab_tests

C
5
star
77

teardown2018

LED Visualization Shown at Teardown 2018 Hardware Conference
C++
5
star
78

Arduino-1.8.19-Teensyduino

Java
4
star
79

timecode_now

C
4
star
80

Arduino-1.8.8-Teensyduino

Java
4
star
81

Arduino-1.8.10-Teensyduino

Java
4
star
82

Lighting_Controller

C++
4
star
83

SerialDiscovery_JSON

C
4
star
84

Phazerville-Screen-Capture

C++
4
star
85

Arduino-1.8.7-Teensyduino

Java
3
star
86

MyFault

C
3
star
87

Arduino-1.8.12-Teensyduino

Java
3
star
88

ARM_Toolchain_2016q3_Source

Shell
3
star
89

precompile_helper

Help arduino-builder to generate a precompiled Arduino.h header, to speed up compiling Arduino sketches
C
3
star
90

Arduino-1.6.4-Teensyduino

C
3
star
91

AudioWorkshop2015

Audio Workshop at Hackaday Supercon 2015
3
star
92

antplus

Stand-alone Ant Plus code from Michael McElligott
C++
3
star
93

Arduino-1.8.14-Teensyduino

Java
3
star
94

Video_Start_Button

C
2
star
95

Noritake_VFD_CUY

Noritake_VFD_CUY: C++ code library and demo files
C++
2
star
96

Arduino_Dev_List_Topics

2
star
97

Servo

C++
2
star
98

Magnetometers_Test

Simple Magnetometer Testing
C++
2
star
99

StepperPulse

Experiments with DMA to efficiently generate stepper pulse & direction
Arduino
2
star
100

Arduino-1.6.12-Teensyduino

C
2
star