hidkey_gpio
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
hidkey_gpio [2012/11/26 19:30] – [Results] steve_m | hidkey_gpio [2013/02/27 00:10] (current) – [Results] steve_m | ||
---|---|---|---|
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:// | + | 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:// |
===== 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 |
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:// |
==== Speed ==== | ==== Speed ==== | ||
Line 59: | Line 59: | ||
==== Results ==== | ==== Results ==== | ||
< | < | ||
- | $ ./avrdude -c hidkey -C avrdude.conf -pattiny2313 | + | $ ./avrdude -c hidkey -C avrdude.conf -p attiny2313 |
avrdude: AVR device initialized and ready to accept instructions | avrdude: AVR device initialized and ready to accept instructions | ||
Line 79: | Line 79: | ||
</ | </ | ||
- | Well, as you can see, programming takes quite a while, mainly because of the slow input speed I mentioned before, but is very reliable. Since I assume that many people have some old USB keyboard | + | Well, as you can see, programming takes quite a while, mainly because of the slow input speed I mentioned before, but is very reliable. Since I assume that many people have some old USB keyboard |
+ | |||
+ | ===== 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 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:// | ||
+ | |||
+ | With those changes, flashing my 86 byte demo application is now over ten times faster (11.75s vs. 123.79s)! | ||
+ | < | ||
+ | $ ./avrdude -c hidkey -C avrdude.conf -p attiny2313 -U flash: | ||
+ | |||
+ | avrdude: AVR device initialized and ready to accept instructions | ||
+ | |||
+ | Reading | ################################################## | ||
+ | |||
+ | avrdude: Device signature = 0x1e910a | ||
+ | avrdude: NOTE: " | ||
+ | To disable this feature, specify the -D option. | ||
+ | avrdude: erasing chip | ||
+ | avrdude: reading input file "/ | ||
+ | avrdude: writing flash (86 bytes): | ||
+ | |||
+ | Writing | ################################################## | ||
+ | |||
+ | avrdude: 86 bytes of flash written | ||
+ | avrdude: verifying flash memory against / | ||
+ | avrdude: load data flash data from input file / | ||
+ | avrdude: input file / | ||
+ | avrdude: reading on-chip flash data: | ||
+ | |||
+ | Reading | ################################################## | ||
+ | |||
+ | avrdude: verifying ... | ||
+ | avrdude: 86 bytes of flash verified | ||
+ | |||
+ | avrdude: safemode: Fuses OK | ||
+ | |||
+ | avrdude done. Thank you. | ||
+ | </ | ||
+ | |||
+ | Programming the whole flash of the ATiny2313 now only takes 4 minutes 37 seconds: | ||
+ | |||
+ | < | ||
+ | $ ./avrdude -c hidkey -C avrdude.conf -p attiny2313 -U flash: | ||
+ | avrdude: AVR device initialized and ready to accept instructions | ||
+ | |||
+ | Reading | ################################################## | ||
+ | |||
+ | avrdude: Device signature = 0x1e910a | ||
+ | avrdude: NOTE: " | ||
+ | To disable this feature, specify the -D option. | ||
+ | avrdude: erasing chip | ||
+ | avrdude: reading input file "/ | ||
+ | avrdude: writing flash (2046 bytes): | ||
+ | |||
+ | Writing | ################################################## | ||
+ | |||
+ | avrdude: 2046 bytes of flash written | ||
+ | avrdude: verifying flash memory against / | ||
+ | avrdude: load data flash data from input file / | ||
+ | avrdude: input file / | ||
+ | avrdude: reading on-chip flash data: | ||
+ | |||
+ | Reading | ########## | ||
+ | </ | ||
+ | |||
+ | I'd say that's quite an improvement, | ||
+ | |||
+ | This project was featured on [[http:// | ||
== Reference Literature == | == Reference Literature == |
hidkey_gpio.1353958230.txt.gz · Last modified: 2012/11/26 19:30 by steve_m