How to Program an AT90USB1286/Teensylu/Printrboard with Arduino and USBtinyISP

My first step in loading Marlin RepRap firmware into the Printrboard is to get Arduino to play nicely with it.  The method I am going to describe in this article for programming a Printrboard with Arduino will work with the Teensylu or any other device that uses the AT90USB1286 and has an ICSP connector.   The programmer we are going to use is a USBtinyISP or compatible. Since the AT90USB1286 isn’t officially supported by Arduino, it takes a bit of setting up to get things working properly.

I first looked at the instructions on Teensylu’s page in the RepRap wiki, but found them very confusing, and I didn’t like the idea of having to send the HEX file to the MCU using an external utility instead of doing everything within the Arduino IDE. So, I set out to streamline the process and document it as I went.  If you follow my method below, you’ll be able to compile and download your firmware all within the Arduino IDE.

Step 1: Download and install Teensyduino

Teensyduino was created by PJRC for their Teensy line of boards.  Teensy is a great alternative to Arduino if you want an ultra compact board with built in USB.  The Teensy++ happens to also use the AT90USB1286, so it’s compatible w/ Printrboard/Teensylu.  Follow PJRC’s instructions for installation from the download link.

If you only plan to program for RepRap, you don’t need to install any of the libraries.  On Windows, you will be prompted to install the serial driver. Select yes.  You don’t have to worry when Windows complains that the driver is unsigned… it’s just an INF file to tell Windows to use one of its own built-in drivers.

Step 2: Modify Teensyduino Configuration for use with USBtinyISP

Download at90usb1286txt.zip.

Navigate to where your Arduino files are located.  On my computer, I have them in d:\arduino-0022.  We will call this <arduinofolder>.  Now, find the subfolder where the Teensyduino library was installed:

<arduinofolder>\hardware\teensy

If you are in the correct folder, you should already see a boards.txt and a subfolder called core in there.  Drop the files from at90usb1286txt.zip into that folder, overwriting the existing boards.txt.  You should see something like this:

If you don’t plan to develop with any of PJRC’s Teensy or Teensy++ boards, you can keep them from showing up in your Arduino menu by copying boards.txt.nopjrc over boards.txt.

Now, when you start Arduino, you should see some new configurations in the Tools->Board menu.  The important ones are:

[usbtinyisp]AT90USB1286
[usbtinyisp]Teensylu/Printrboard
[BootloaderCDC]AT90USB1286
[BootloaderCDC]Teensylu/Printrboard

To use a USBtinyISP programmer, select either [usbtinyisp]AT90USB1286 or [usbtinyisp]Teensylu/Printrboard. The only difference between the two configurations is that I took the extra useless options out to make things simpler when programming Teensylu/Printrboard.  The Teensylu/Printrboard option is the same as the AT90USB1286 option with USB Type = Serial and CPU Speed = 16MHz.

At this point, you can plug in your USBtinyISP and into your AT90USB1286/Teensylu/Printrboard and start programming!

So what are the [BootloaderCDC] configurations for?  They allow you to download sketches into your target board directly through a USB connection to your host, without the USBtinyISP programmer.  See my next article for details on how to do that.

Update 20140909: I have uploaded a copy of Arduino 1.0.5-r2 for Windows to github, which is already modified to work with the AT90usb1286, so you don’t have to modify it as above. Simply go to https://github.com/lincomatic/arduino-1.0.5-r2-at90usb1286 and click the Download Zip button, and then extract the contents to your PC. My distribution also supports the USBasp in addition to the USBtinyISP.

There are 21 Comments to "How to Program an AT90USB1286/Teensylu/Printrboard with Arduino and USBtinyISP"

  • [...] menu, and select the COM port associated with your Printrboard’s bootloader. SeeLincomatic’s How to Program an AT90USB1286/Teensylu/Printrboard with Arduino article for help configuring [...]

  • [...] for this post goes to Lincomatic. I’m posting my methods and what I did to get my board working. I also think having this [...]

  • Redd says:

    hey, so after we tried uploading to the printrboard using the arduino022 compiler ..the program compiles however it takes a long time to upload and doesnt return any success or error ..it isnt even able to upload a simple blink program…any help would be appreciated

    • lincomatic says:

      Is the CDC Bootloader installed on your Printrboard? After it’s installed, you also have to set the jumper to boot into the bootloader before you can load your code into the Printrboard. See the “Booting into the Bootloader” section of my bootloaders article for details. There’s also a step by step write up in the RepRap wiki.

      • Mto says:

        Thanks for the post. I’ve used USBTiny to load CDC and was able to recover my printrboard.

        I struggled to upload Marlin software via CDC using Arduino though. It says “Done,” but nothing changes at all. So I went with USBTiny and got stuck like Redd reported above. After I left it for a while, I disconnected and connected to my pronterface. To my surprise, the new Firmware was there! I now see my name as the config author. So USBTiny method may have been working. I will test this board with the rest of the printer today.

  • wktey says:

    Hi,

    I am so interesting in your project which to bootload a printrboard using Arduino. However, I had tried the steps you stated in this post but I failed to install the Teensyduino. The software seems cannot find the Arduino.exe in my laptop during the installation. Any thoughts?
    Sorry for being noob as I am a beginner. :)

    Thanks,
    Tey

    • lincomatic says:

      Maybe you can try copying the installer to the same folder as your arduino.exe and seeing if that works?

  • 3dsheffield says:

    I am trying to get my printrbot to connect
    This is as far as I have got

    On a win 7 laptop I get the following in the pronterface .exe console. Com 5 is the port listed in device manager. Says device is abstract class control and fuctioning correctly I get one constant green LED on the printrboard (bought from a 3rd party fleabay seller in denmark)

    Exception AttributeError: “‘NoneType’ object has no attribute ‘stdout’” in <bound method Tee.__del__ of > ignored
    Traceback (most recent call last):
    File “pronterface.py”, line 1566, in connect
    File “printcore.pyc”, line 76, in connect
    File “serial\serialwin32.pyc”, line 30, in __init__
    File “serial\serialutil.pyc”, line 260, in __init__
    File “serial\serialwin32.pyc”, line 56, in open
    serial.serialutil.SerialException: could not open port COM5: [Error 5] Access is denied.

    Anything obvious?
    Many thanks
    Dave

    • lincomatic says:

      Did you use the INF file to enable the CDC serial port emulation? Try using a serial terminal emulator, such as PuTTY to talk to the Printrboard directly… can you type gcode directly to it?

  • Bill Del Sesto says:

    Help please when I tried your hid bootloader i get this error “error reading intel hex file MarlinBill.cpp.hex.” I had this problem before and i think there is an upgraded bootloader but my searches can’t find it

  • Bill Del Sesto says:

    I am trying to update my firmware I have a Solidoodle SD3 Solidoole board Rev E Printrboard) a sparkfun AVR pocket programmer (USBTiny ISP)
    I follow all stpes in your blog compile (using Arduino 1.0.5 R2 , find and copy MarlinBill,cpp.hex. file . Open cmd window navigate and point to file hit enter and get this code
    “Teensy Loader, Command Line, Version 2.0
    error reading intel hex “MarlinBill.cpp.hex ”
    I seem to remember from months ago when I added a Panelolu 2 I got this same error , and that I found an upgraded HID bootloader that worked it had something to do with larger memory of motherboard . I think . I had to replace my computer 2 months ago so I lost all of my files . I have tried searching but can only find your blog with the old bootloader . Any help would be greatly appreciated

    Bill D

  • Bill Del Sesto says:

    Any help would be great

    • Forrest Pieper says:

      Hi Bill,

      I just had the same problem, thought I’d let you know a solution that worked for me since you pointed me in the right direction.

      I edited hid_bootloader_cli.c, on line 769 like so:

      new #define MAX_MEMORY_SIZE 0×10000

      After recompiling I was able to load larger .hex files. Without this change I could only load hex files that used <50% of the memory on an at90usb1286, so I assume doubling the max size should be the correct solution.

      Hope this works for you

      -Forrest

      • Forrest Pieper says:

        Hmm, my formatting got messed up. the line should be changed from

        #define MAX_MEMORY_SIZE 0×10000

        to

        #define MAX_MEMORY_SIZE 0×20000

  • lincomatic says:

    Bill,
    Sorry, I didn’t see your latest messages. I have updated my BootloaderHID.zip to include a hid_bootloader_cli.exe with Forrest’s modification. Please try it out and let me know if it fixes your problem.

    Forrest,
    Thanks so much for sharing your fix!

  • Bill Del Sesto says:

    Sorry about delay in reply , I have been busy at work .This worked great I changed memory size and it worked . Once i uploaded it I got the display on my Panelolu to display but it says “NO SD CARD any ideas?

  • Bill Del Sesto says:

    Thank you Lincomatic you saved my life !!

    If you hadn’t solved my problem my wife would have killed me if i spent another $180 because I bricked the spare one .

  • javier says:

    Hi, do not know why, but instead of that options for uploading Marlin to the Teensylu, I pushed it via Teensy 2++. Now, PC does not recognize my Teensylu, neither in Windows nor Linux. Could you please help me?

  • javier says:

    Hi, do not know why, but instead of that options for uploading Marlin to the Teensylu, I pushed it via Teensy 2++. Now, PC does not recognize my Teensylu, neither in Windows nor Linux. Could you please help me? Arduino does not recognize it, neither lsusb in linux. I have tried to install bootloader from this http://blog.lincomatic.com/?p=548 and could not recognize the Teensylu

Write a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>