User Tools

Site Tools


hidkey_gpio

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
hidkey_gpio [2012/11/27 03:11]
steve_m [Results]
hidkey_gpio [2012/11/30 19:40]
steve_m [Update #1]
Line 1: Line 1:
 ====== AVR Programmer built from a USB Keyboard ====== ====== AVR Programmer built from a USB Keyboard ======
  
-Recently, my old keyboard became louder and louder while typing, so I decided to buy a new one. But what to do with the old one? Ever since I saw the [[http://​www.pjrc.com/​hub_isp/​|AVR programmer that uses a USB hub]], I thought of abusing a USB keyboard for that.+Recently, my keyboard became louder and louder while typing, so I decided to buy a new one. But what to do with the old one? Ever since I saw the [[http://​www.pjrc.com/​hub_isp/​|AVR programmer that uses a USB hub]], I thought of abusing a USB keyboard for that.
  
 ===== Theory ===== ===== Theory =====
Line 30: Line 30:
 |Caps lock|MOSI|out| |Caps lock|MOSI|out|
 |Scroll lock|Reset|out| |Scroll lock|Reset|out|
-|row/column of right shift key|MISO|in|+|row/column of right shift key|MISO ​(through optocoupler)|in|
  
 For the optocoupler I added a 470Ω current limiting resistor. For the optocoupler I added a 470Ω current limiting resistor.
Line 36: Line 36:
 ===== Software ===== ===== Software =====
  
-First I wrote a small libusb-based test utility for experimenting with the keyboard. I'm directly communicating with the keyboard from userspace, unloading the kernel driver first.+First I wrote a [[https://​github.com/​steve-m/​hidkey_gpio|small libusb-based test utility]] for experimenting with the keyboard. I'm directly communicating with the keyboard from userspace, unloading the kernel driver first.
  
 ==== Speed ==== ==== Speed ====
Line 83: Line 83:
 ===== Update #1 ===== ===== Update #1 =====
  
-Since reading the MISO input is much slower than writing the outputs, as I mentioned above, I took a closer look at the avrdude code. As it turns out, the inputs are read every time, even if the data isn't used at all (like when writing a byte). I applied a crude hack, so that MISO is only being read if the data is used afterwards. I pushed that change to a new [[https://​github.com/​steve-m/​avrdude/​tree/​speedup|speedup branch]] on github.+Since reading the MISO input is much slower than writing the outputs, as I mentioned above, I took a closer look at the avrdude code. As it turns out, the inputs are read every time, even if the data isn't used at all afterwards ​(like when writing a byte). I applied a crude hack, so that MISO is only being read if the data is used afterwards. I pushed that change to a new [[https://​github.com/​steve-m/​avrdude/​tree/​speedup|speedup branch]] on github.
  
 With those changes, flashing my 86 byte demo application is now over ten times faster (11.75s vs. 123.79s)! With those changes, flashing my 86 byte demo application is now over ten times faster (11.75s vs. 123.79s)!
Line 145: Line 145:
  
 I'd say that's quite an improvement,​ and very well acceptable for a chicken-and-egg bootstrap flasher :-) I'd say that's quite an improvement,​ and very well acceptable for a chicken-and-egg bootstrap flasher :-)
 +
 +This project was featured on [[http://​hackaday.com/​2012/​11/​26/​usb-keyboard-becomes-an-avr-programmer/​|Hackaday]].
  
 == Reference Literature == == Reference Literature ==
hidkey_gpio.txt · Last modified: 2013/02/27 01:10 by steve_m