Microcontroller enumerates as USB printer — can be programmed by printing

avr-programming-by-printing

This is a fascinating concept. We’re not sure of its usefulness, but it definitely stands on its own just for the concept. [Dean Camera] just added a new HID class to the LUFA project that lets you flash AVR chips by printing to them. This means once you have a file like the one seen open in Notepad above, you can just click on File, then on Print, and the firmware will be uploaded to the chip.

[Dean] is the creator of the LUFA project and still likes to get his hands dirty hacking around with it. This idea came to him while he was exploring the concept of using the MIDI protocol to program a chip. That didn’t pan out because of the way Microsoft has handled MIDI in newer versions of Windows. But he did get the idea of making LUFA identify itself as a simple USB printer. He dug into the specification and figured out how to do that. Once Windows connects to the device it doesn’t really care what data gets sent to it. So [Dean] wrote a parser for the bootloader which could accept the incoming hex code and write it to the chip’s program memory.

Comments

  1. Mulvane says:

    This is…… awesome. No, really. I can’t imagine how much time this would save me in some projects.

  2. Jon says:

    Fascinating! That’s a really neat concept.

  3. ejonesss says:

    that will make it universally programmable even on a mac as long as it shows up as a printer you can flash it.

    if it is like the netv http://adafruit.com/products/609 all the software lives on a fat 32 formatted micro sd card like your cameras use so if you can get a card reader you can then copy the files.

  4. HackerK says:

    Now where is the PIC version of it? :)

  5. Askarel says:

    Giving to notepad the feature of a full blown IDE without adding software to the host.
    Simple but brilliant.

  6. Przemek Klosowski says:

    Why is it better than presenting it as mass storage to which you store a firmware file? That’s how Freescale ARM FRDM dev boards work.

  7. Ray Moore says:

    Probably not a PIC version of this as the guy who wrote it works for ATMEL perhaps? Just saying….

  8. Hack Man says:

    Movie plot gimmick. That actually works!

  9. joseph L says:

    Now, here’s a though… would it work over a cheap USB network bridge?

  10. bobfeg says:

    Dean’s a great hacker. Atmel is lucky to have him on board.

  11. smoketester says:

    Love this hack! Poking the box like this is why I enjoy HAD so much.

  12. Echoes says:

    God only knows how many times people will print hex code on paper by mistake… or send PDFs to LUFA :D

    • pdfs says:

      Echo said:
      “God only knows how many times people will print hex code on paper by mistake… or send PDFs to LUFA :D ”
      The HAD way to encourage code documentation? :D

  13. Hawk777 says:

    Please stop calling it HID class. Printers are NOT human interface devices. HID refers to mice, keyboards, gamepads, and other buttons-and-knobs-and-blinky-lights devices. Printers belong to the printer class, not the HID class.

    • Dan says:

      Well, you better tell the USB spec designers that, HID class 7 seems to have an awful lot to do with printers…

      • Hawk777 says:

        If you mean HID usage table #7, then no, that’s keyboard/keypad usages. If you mean USB device class 7, then yes, that’s the printer class. Not the HID class. It’s a USB device class, but it is not equal to or part of the HID class. All HID-compliant interfaces have interface device class set to 3, while all printers have interface device class set to 7. They are different things; printer class is USB, but that does not make it HID.

  14. Chris says:

    Wow, I feel silly. I actually design+program microcontroller systems for actual printers, and so use this exact method all the time… on printers. It never once dawned on me to use this method on non-printer devices!
    Although alternatives exist for USB-enabled MCUs (E.G. DFU specification or mass storage class), printer ports can also be set up for serial or parallel ports. Very nice.

  15. Steffen says:

    HP came up with this before (and yes, they regreted it):

    • fuzzyfuzzyfungus says:

      Just in the spirit of pedantry, HP’s implementation was markedly more complex, at least on their nicer printers. Since the printer has a full PCL/PJL implementation(sometimes Postscript as well) you can send it full programs, with reasonably alarming capabilities, just by ‘printing’ them(such programs can result in printed output; but tend to suppress that, since nobody wants to waste paper spewing an entire firmware update). Effectively, the printer’s OS would execute, with full permissions(since there wasn’t a permissions model) any commands sent to it, with ‘security’ being provided by the assumption that well-behaved users would only send commands that printed documents, rather than performed filesystem operations or other shenanigans.

      Since HP’s printer security model is somewhere between ‘pitiful’ and ‘nonexistent’, the full power of the PCL/PJL environment was available to anybody with the ability to send a job to the printer. Pretty much analogous to take a knife to a gunfight, or a traditionally-single-user OS without filesystem permissions to the public internet.

      The system in this hack is much simpler, no interpreter involved, just a way to dump a data blob directly to storage(and, thankfully, since there is no ‘hook it up to the office LAN and let everybody have access’ use case for a microcontroller being flashed’ the total lack of access control isn’t an issue, unlike the HP case).

  16. YS says:

    As I’ve understood, now the MCU programs itself with a firmware downloaded by printer protocol. So I’m waiting for a printer interface based programmer which will program other chips this way.

  17. steaky says:

    this is brilliant. nothing else to say, except hopefully someone does a PIC version

  18. furrysalamander says:

    Google Cloud Print anyone?

  19. Spacedog says:

    very cool hack, but Windows printing is not practical method for programming chips. what if you send a document to it by mistake? bricked chip is what,

  20. Brilliant! Any reason this couldn’t be used for transferring 3d printing models as well?

  21. electronics says:

    Brilliant idea! It is really excellent.

  22. JRSmile says:

    Dean is a clever guy and a kind person, no wonder he came up with this awesome idea.

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 96,615 other followers