Raspdancer
What?
Merging Facedancer & Raspberry 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 which RPi, 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
MAX Signal RPi Signal P3 Vcc P17 3v3 \ 0.1uF -- GND P4 Vcc P17 3v3 / P5 GND P25 GND P6 GND P25 GND P10 -RES P15 GPIO22 P11 SCLK P23 SCLK P12 -SS P24 CE0 P13 MISO P21 MISO P14 MOSI P19 MOSI P17 INT currently not connected, could be e.g. connected to P18=GPIO24 P18 GND P25 GND P19 GND P25 GND ---------- USB conn GND P20 D- ----------- R33 -- USB conn D- P21 D+ ----------- R33 -- USB conn D+ P22 Vcc P17 3v3 \ 1uF -- GND P23 Vcc P17 3v3 / P24 VBCOMP ------------------ USB conn Vcc -- 1uF -- GND P26 XI ------------Xtal1- 18pF -- GND P27 XO ------------Xtal2- 18pF -- GND
One can also connect MAX_P24 VBCOMP to RPi_P4 5V0 to power directly the RPi via this USB entry but beware:
- you're fuzzing the one which is powering you, don't cry if you experience power losses...
- the polyfuse is left out, you can re-introduce a polyfuse 1A 6V (but being powered from a *real* USB port should be fine)
Components
LQFP32 MAX3420E Quantity: 1 0603 33R USB Series Resistors Quantity: 2 0603 1.0µF Capacitors Quantity: 2 0603 0.1µF Decoupling Capacitors Quantity: 1 0603 18pF Capacitors Quantity: 2 5x3.2 12MHz SMD Crystal, 18pF Quantity: 1 (see note) USB Mini Receptacle UX60-MB-5ST Quantity: 1 2x13 Receptacle, 2.54mm, 26way Quantity: 1 (see note)
Comparing to the components reused from the original Facedancer, differences are:
- smaller crystal package
- 2x13 connector towards RPi, e.g. a SAMTEC BCS-113-L-D-TE, or even a smaller conn as 2x6 is enough, but be the sure to plug the board correctly into the larger connector!
First proto
Using a TQFP32 to DIP32 PCB adapter from http://www.ett.co.th/ and a regular through-hole crystal
Real PCB
Thanks to Jean-Christophe Nicaise for his help!
I didn't touch Eagle for so many years ^^
400px
400px
Code
Travis did an amazing job at building a Python library and examples for the MAX3420E, let's reuse them!
You'll need to get GPIO Python support and SPI Python support for your Raspberry Pi.
From the original facedancer code, you'll need GoodFETMAXUSB.py and the goodfet.maxusb* scripts
Then instead of the original GoodFET.py library, use [{{#file: GoodFET.py}} this GoodFET.py version]:
#!/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 MAX3420E -Reset
GPIO.setup(15, GPIO.OUT, initial=GPIO.LOW)
GPIO.output(15,GPIO.HIGH)
spi.openSPI(speed=26000000)
def __del__(self):
spi.closeSPI()
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
There are probably better ways to integrate it into the GoodFET software stack but with this small code snippet, you can take the latest great GoodFETMAXUSB.py and goodfet.maxusb* python scripts and just drop them along this GoodFET.py, without need for re-applying any patch.
Note that with the raspdancer, goodfet.maxusbhid is becoming too fast and I'm missing the beginning of the injected string. I had to add some initial "NoEvent / key up" chars ("\x00" * 20) in typestring() in GoodFETMAXUSB.py:
def typestring(self):
if self.typestrings.has_key(self.OsLastConfigType):
return ("\x00" * 20) + self.typestrings[self.OsLastConfigType];
else:
return ("\x00" * 20) + self.typestrings[-1];