Super-easy Teensy 3.1 Development Tools on Ubuntu

I’ve been playing with Arduino and other small embedded controller prototyping systems in anticipation of a few cool projects I’m considering. The Arduino tool chain is very easy to set up on Ubuntu; basically one apt-get command will do it, installing the IDE, compiler, download tools, example programs, and everything. I’ve built and run several Arduino example sketches on a Duemillanove and a Bare Bones Board that I had lying around.

Another appealing controller family is the Teensy series, which has both AVR and ARM variants. I had picked up a couple of the ARM boards (Teensy 3.1 and Teensy LC) at Maker Faire and wanted to try them out. They can be used within the Arduino IDE but only if you have certain combinations of Arduino and Teensy software versions, and the Arduino version provided in the Ubuntu repo is not compatible. I could have built the Arduino tools from source but I really didn’t want to mess with the perfectly functional version that Ubuntu installed. So I started looking into setting up a pure ARM cross tool chain and writing code directly for the Freescale processor on the Teensy boards.

I couldn’t find anyone who had done this on Ubuntu using the stock Ubuntu packages for GCC and friends, but I found a good description by Karl Lunt of how he set up the tool chain on Windows: Bare-metal Teensy 3.x Development. Karl also had gathered the essential header files from Freescale, added the necessary C run time start code and linker script, and created a few useful library functions and demo programs, and of course, a Makefile. It only took a few tweaks to combine Karl’s files, standard Ubuntu packages, and the Teensy download tool into a working cross-developement tool set.

Here’s how you can do it:

# Install the ARM compiler from Ubuntu:
sudo apt-get install binutils-arm-none-eabi gcc-arm-none-eabi

# Install the Teensy download/reboot utility
case `uname -i` in
*_64) f=teensy.64bit.gz;;
*) f=teensy.gz;;
esac
wget http://pjrc.com/teensy/$f
mkdir -p $HOME/bin
gunzip <$f >$HOME/bin/teensy
chmod a+rx $HOME/bin/teensy
rm $f
wget http://www.pjrc.com/teensy/49-teensy.rules
sudo mv 49-teensy.rules /etc/udev/rules.d

# Download Karl Lunt's archive of Teensy headers and support code:
wget http://www.seanet.com/~karllunt/Teensy3xlib.zip
mkdir teensy
unzip -d teensy Teensy3xlib.zip
rm Teensy3xlib.zip
sed -i s/mk20d7/MK20D7/ teensy/include/common.h

# Download Karl Lunt's "blinky" demo program:
wget http://www.seanet.com/~karllunt/Teensy3x.zip
unzip Teensy3x.zip blinky.c
rm Teensy3x.zip

# Download my tuned-for-Linux Makefile:
wget http://www.omnicron.com/~ford/teensy/Makefile

# That's it!
echo 'Now run "make"'

You can find the above steps in a ready-to-run script here.

Of course, you can copy and modify the Makefile to build your own projects.

My next step will be to try to add Teensy LC support.

Tags: , , , , ,

Comments are closed.