Difference between revisions of "Facedancer"
m |
m (→Code) |
||
Line 70: | Line 70: | ||
</pre> |
</pre> |
||
===Code=== |
===Code=== |
||
− | <source lang |
+ | <source lang=python> |
#!/usr/bin/env python |
#!/usr/bin/env python |
||
# (C) 2013 Philippe Teuwen <phil at teuwen.org> |
# (C) 2013 Philippe Teuwen <phil at teuwen.org> |
Revision as of 09:59, 25 April 2013
Links
- http://travisgoodspeed.blogspot.be/2012/07/emulating-usb-devices-with-python.html
- http://blog.opensecurityresearch.com/2012/11/solder-time-facedancer11-and-goodfet41.html
- http://goodfet.sourceforge.net/hardware/facedancer11/
Merging Facedancer & R-Pi
Why?
Facedancer11 is a one-purpose version of the flexible GoodFET board.
It was well designed to move all the intelligence into the host controller, not in the embedded uC.
Facedancer11 hardware can be seen as:
USBconn -- FT232RL -- MSP430F2618TPM -- MAX3420E -- USBconn
where the first two chips are only converting busses:
USBconn -- FT232RL -- MSP430F2618TPM -- MAX3420E -- USBconn USB <> UART <> SPI ... (USB)
BoM view (excluding taxes, Farnell prices):
USBconn -- FT232RL -- MSP430F2618TPM -- MAX3420E -- USBconn USBconn + 5.45€ + 13.03€ + 8.27€ + USBconn
So 18.48€ to talk SPI over UART over USB while the Raspberry-Pi has natively SPI, hmmm.
Bus speed view: yes there is a kind of bottleneck there...
USBconn -- FT232RL -- MSP430F2618TPM -- MAX3420E -- USBconn 12MB/s 115200bauds 26MHz
Let's try to make a RPi extension board with only the MAX3420E. And to save a few cents and construction pain let's replace the USB connector by a USB cable from a cannibalized mouse. So:
RPI-MODA-256M -- MAX3420E -- USBcable
From a BoM point of view this becomes (depending on what you add to the RPi, nice casing etc):
RPI-MODA-256M -- MAX3420E -- USBcable 27.66€ + 8.27€
Bus speed view:
RPI-MODA-256M -- MAX3420E -- USBcable 26MHz
And we get a fully autonomous facedancer which can be even powered over USB and controlled remotely
Schematics
TODO
x x P3 Vcc P1 3v3 -- 0.1uF -- GND P4 Vcc P1 3v3 / P5 GND \ P P6 GND / x x x P10 -RST P15-GPIO22 P11 SCLK P12 -CS P13 MISO P14 MOSI x x (P17 INT) P18 GND P19 GND P20 -- 33 -- USB D- P21 -- 33 -- USB D+ P22 Vcc -- 1uF -- GND P23 Vcc P24 USB VBUS -- 1uF -- GND x P26 XTal -- 18pF -- GND P27 XTal -- 18pF -- GND x x x x x
Code
#!/usr/bin/env python
# (C) 2013 Philippe Teuwen <phil at teuwen.org>
import spi
import RPi.GPIO as GPIO
class GoodFET:
data=""
def __init__(self, *args, **kargs):
GPIO.setmode(GPIO.BOARD)
# pin15=GPIO22 is linked to MAX3420 -RST
GPIO.setup(15, GPIO.OUT, initial=GPIO.LOW)
GPIO.output(15,GPIO.HIGH)
spi.openSPI(speed=26000000)
def __del__(self):
spi.closeSPI()
GPIO.output(15,GPIO.LOW)
GPIO.output(15,GPIO.HIGH)
GPIO.cleanup()
def writecmd(self, app, verb, count=0, data=[]):
if verb: # ignore all but R/W cmd
return
if isinstance(data,str):
data = [ord(x) for x in data]
data = tuple(data)
data = spi.transfer(data)
self.data = "".join([chr(x) for x in data])
def serInit(self):
pass