Bare-metal Programming On The Teensy 3

Teensy

The Teensy 3.x series of boards are amazing pieces of work, with a tiny, breadboard-friendly footprint, an improbable number of IO pins, and a powerful processor, all for under $20. [Karl Lunt] loves nearly all the features of the Teensy 3, except for one: the Arduino IDE. Yes, the most terrible, most popular IDE in existence. To fix this problem, [Karl] set up a bare-metal development environment, and lucky us, he’s chosen to share it with us.

[Karl] is using CodeBench Lite for the compiler, linker, assembler, and all that other GCC fun, but the CodeSourcery suite doesn’t have an IDE. Visual Studio 2008 Express is [Karl]’s environment of choice, but just about every other IDE out there will do the same job. Of course a make utility will be needed, and grabbing the docs for the Freescale K20 microcontroller wouldn’t be a bad idea, either.

The end result is [Karl] being able to develop for the Teensy 3.X with the IDE of his choice. He was able to quickly set up a ‘blink a LED’ program with the new toolchain, although uploading the files to the Teensy does require the Teensy Loader app.

40 thoughts on “Bare-metal Programming On The Teensy 3

  1. The only issue with all ARM’s (Cortex-M*) is that there is no easy, fast ready open source IDE to fit them all. You have some crippled version for every vendor and mos of them doesn’t work on Linux.
    You can setup eclipse IDE but even for experienced person it is at least few hours tweaking to have verything working.

    Closest to one click right now is http://sourceforge.net/projects/gnuarmeclipse. They now support STM32 and KL Freescale family. My preffered way of working on Linux if you need full blown IDE.

  2. Calling that Arduino abortion an IDE is an insult to all other IDEs. I tried it once and man it’s such a pain in the ass. I can’t imagine people actually using it for anything more advanced than three lines of code to blink an LED. MplabX can be a pain in the arse as well sometimes but at least it has some features to compensate.

    1. Most other IDE’s are an insult to people who just want to do some simple stuff and don’t want to spend hours googling how to configure the damn thing – which coincidentally happens to be exactly what the Arduino was designed to do. So, don’t use Arduino if you’re the person who prefers to mess around in the preferences panel of your favorite IDE.

        1. For me it’s an issue of control. I like an IDE for the code features (syntax highlighting, auto complete, etc.). But I don’t like it for setting preferences. I’d rather reference the datasheet and get the rundown on the effects of each peripheral and setting I’m choosing to use on the chip.

          Generally I use Scite or Eclipse for all chip architectures and write my own makefile to compile and flash.

  3. I setup sublime text to be my arduino ide (install package manager, install Stino, tell it where your arduino install lives, DONE) and it absolutly changed my world. I am not a programmer by trade, but using sublime text made EVERYTHING easier and better, and now I use sublime for everything. It is actually the only piece of softwre on my entire computer I paid for, even tho it has an unlimited free trial.

    1. I second that. Was going to comment myself about how well Sublime Text worked for the last time I needed to write some arduino code. I went a step further and also installed Subline-Linter -> lintccp. ( to help diagnose my mistakes )

      I’m just so happy that it suppports the arduino in my native editor, but the arduino plugin ‘stino’ also supports the build environment / serial monitors / uploading / etc on top of all the built-in features of Sublime-Text.

    1. Visual Studio is actually pretty nice to use. Not everything from Microsoft is bad. Yes Windows is kurft loaded mess but Visual Studio is actually pretty nice to use.
      That being said it would have been really nice to see this use Eclipse, NetBeans, KDevelop, Anjuta IDE, or any number of other FOSS multiplatform IDEs.

    2. IMO, Visual Studio is the best IDE I’ve ever used. I have to use both it and Eclipse quite often and every time I start a new .NET project, a feeling of calmness washes over me. I would call it, the .NET framework, and C# the holy trinity: three things Microsoft actually manages to get right.

        1. I’m not an evangelist, I just like what works best. A FOSS IDE as good as Visual Studio would be great, but it doesn’t exist. Not that Eclipse is crap, but it’s an order of magnitude less polished. C# and .NET Framework are actually open standards with open source implementations, but MS has done a good job developing them (with the exception of some .NET crap like WPF and Silverlight).

          What can I say, if you can afford to turn your nose up at good products because you don’t like the company that makes them, all the power to you. I have to write code for a living and I appreciate whatever makes my life easier.

        2. Have you used a modern version? If not then you are just being silly. Really it is a good IDE. Eclipse is also pretty good but VS is really good. I would love to see a FOSS IDE as good but one should not dismiss how good a tool is based on ideology. You may not use it but to dismiss is dumb.

  4. Guys, seriously: The Arduino IDE is limited for a reason and everybody is hitting its limits very fast. But look in the preferences!!! There is an option called “USE EXTERNAL EDITOR”! Check it! Use it! Stop warm up the air with words. It is not necessary! Use what ever editor you feel like and gives you the unicorn stardust you’re looking for and stop the hate. It is PERFECT for beginners. And the ones who have the power of endurance will be able to make the tight switch to a bigger IDE. You are all loosing your minds over this.

    http://jeelabs.org/wp-content/uploads/2012/01/external-edit.png

    1. It’s not just the editor that is shit. It’s also the compiler integration that is hiding warnings&errors from you. It’s the worst possible combination, C and hiding warnings.
      The whole combination is just rigged up for the worst possible errors.

  5. Given how awfully integrated the Teensy is with the Arduino environment, bare metal is the best thing for it, especially if you forgo the awful Teensy bootloader and use DFU mode.

    Teensy2.0++ is the worst dev board I’ve ever spent money on.

      1. I assume he’s some competitor. Or maybe rather incompetent, since many people seem to manage to do plenty with teensy, seems the flaw is magically hovering around his home.

        1. Nether, it worked reliably after a bit of fighting. But the bootloader is a total pain in that it programs the chip even if you only pressed verify, installation of his code is only possible into a downloaded version of Arduino and by running his closed source binary. Then the I/O on the board is documented sporadically about his website so it’s always a pain to find what pins you’re working with. I replaced it with a Leonardo and that’s far nicer for stuff that’s not a 3D printer.

    1. I like my Teensy2++, I did blow away the original bootloader and add a LUFA bootloader, with an activation button.

      I also added the optional 3.3V regulator to the backside of it.

      And I never use the Arduino IDE unless I can’t avoid it.

      No reason to hate it at all. It becomes a great tool.

    1. portability

      if you use a vendor toolkit, you are gonna have a very tough time getting your code to run on another vendor’s toolkit.

      this is really a key issue for projects where you are trying to decide which chip to use and you want to write some code to test performance, etc. and you want to compare how different chips will handle a particular problem

      ALL of the vendors think the universe revolves around them and that everybody should exclusively use their chips to solve every problem. Screw you if you want to take your code to another vendor’s chip. Until they get over their collective neuroses and learn to play together, it’s just going to be a PITA for the rest of us.

      if you keep it generic and use the bare metal toolchains, it’s a lot easier to write code that will run on more than one chip.

    1. Same, except I use Emacs and avr-make. I’m up, running, coding, compiling and transfering the new firmware all within seconds on linux, no configuration or other crap needed.

  6. Pfft. This is called “bare metal programming” nowadays?

    Real programmers use wire jumpers to set address and instruction codes for programming input. Then came the lamers who had hex keyboards and digit-by-digit input. But you wouldn’t call that “bare metal” any more.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.