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 amount 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.

 

Comments

  1. nah! says:

    doesnt the teensy side already have tutorals and recomendations for c/c++ compilers ?

  2. Spock says:

    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.

  3. sneakypoo says:

    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.

    • James says:

      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.

      • I can set a new project in AvrStudio6 in 10 seconds, just click new project, select the correct micro, select that it is a gcc c project, create, done..

        • Mike Szczys says:

          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.

  4. anickle says:

    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.

    • Darjeed says:

      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.

  5. Whatnot says:

    Dismisses the arduino IDE, then turns to microsoft stuff as an alternative… Pfff

    • Lwatcdr says:

      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.

    • lja says:

      Visual Studio is actually one of the best damn IDE’s out there.

    • vpoko says:

      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.

      • Whatnot says:

        Propriety MS stuff seems to be your secret lover.
        May I suggest late night chats on skype about it, I’m sure gates will make some time for you.

        • vpoko says:

          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.

        • Lwatcdr says:

          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.

        • Yarr says:

          Aww, it’s okay, I’m sure mom will let you out of the basement some day, Whatnot. Don’t get bitter.

  6. Indyaner says:

    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

    • daid303 says:

      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.

  7. Bracken says:

    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.

    • wretch says:

      What’s wrong with the Teensy2.0++?

      • Whatnot says:

        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.

        • bigglespip says:

          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.

          • Whatnot says:

            Well bigglespip’s critique seems rational with a foundation and so seems valid. but is he the same person as Bracken?

    • frank26080115 says:

      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.

  8. In general, what’s the difference between a bare metal toolchain and one that installs with the chip vendors’ software? Ex. TI code composer for DSPs, or launchpad, Microchip’s mplabx, etc.

    • F says:

      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.

    • volt says:

      I guess bare-metal sounds more hard-core and bad-ass.

  9. Trui says:

    I prefer vim and make.

  10. Tom says:

    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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,020 other followers