Bus Pirate binary SPI sniffer utility

From DP

Jump to: navigation , search

This is a small program that displays SPI sniffer data from the Bus Pirate. It uses the binary mode SPI sniffer access, so it has a speed advantage over the terminal mode display. The computer takes the burden of converting raw byte values to HEX output.

Contents

Version

Clock edge and polarity did not work in v0.2. v0.3 fixes that, plus attempts to decode the output to human-readable format.

The old raw mode is still available with the -r flag.

Downloads

  • A Windows version and source is available here (v0.3).
  • The latest source is available in SVN and should compile on most systems with minimal tweaking.

Usage

 SPIsniffer  -d <serial port> -e <clock edge> -p <clock polarity> -s <port speed> -r <output mode>

Where

  • -d device is port e.g. COM1 (required)
  • -e ClockEdge is 0 or 1 default is 1
  • -p Polarity is 0 or 1 default is 0
  • -s Speed is port Speed default is 115200
  • -r Rawoutput is 0 for decoded output, 1 for raw HEX output. Default is 0.

Only the serial port is required.

spisniffer -d COM3
spisniffer -d COM3 -e 0 -p 1

This is a Windows example. On Linux it would look like this:

spisniffer -d /dev/ttyUSB0
spisniffer -d /dev/ttyUSB0 -e 0 -p 1

On Linux, the usage of the Escape key for exiting seems to be broken, so one needs to re-attach the Bus Pirate after exiting with Ctrl-C.

Could you please add a Mac example if you're using this app on this platform?

Example

C:\>spisniffer -d COM3 -r 1
Bus Pirate binary mode SPI SNIFFER utility v0.3 (CC-0)
http://dangerousprototypes.com
Press escape to exit

Parameters used: Device = COM3, Speed = 115200, Clock Edge= 1, Polarity= 0

Opening Bus Pirate on COM3 at 115200bps...
Starting SPI sniffer...
Configuring Bus Pirate...
Entering binary mode...
(OK) Happy sniffing! Press ESC to stop.
5B 5C 01 00 5C 02 00 5C 03 00 5D
Esc key hit, stopping...
Clean up Bus Pirate...
(Bye for now!)

C:\>pause

Run the SPIsniffer utility from the command line. It configures the Bus Pirate and displays any values output by the sniffer mode.

Press escape to exit the program.

v0.3 attempts to decode the output to human-readable format. The old raw mode is still available with the -r flag.

Raw output decoding

v0.3 attempts to decode the output to human-readable format.
The old raw mode is still available with the -r flag.

See the SPI binary mode documentation for more about the SPI sniffer output. Here's a quick example.

5B 5C 01 00 5C 02 00 5C 03 00 5D

This output was sniffed from another Bus Pirate that sent [ 0x01 0x02 0x03 ], which is also: CS low, 1, 2, 3, CS high.

  • 5B - ASCII code for [ (CS low).
  • 5C - ASCII code for \, escapes each data pair. This is repeated with each byte pair so you can find your place in the datastream.
  • 01 - Value sniffed on the Bus Pirate MOSI pin.
  • 00 - Value sniffed on the MISO pin.
  • 5C - \, escapes the next data pair.
  • 02 - Value sniffed on the MOSI pin.
  • 00 - Value sniffed on the MISO pin.
  • 5C - \, escapes the next data pair.
  • 03 - Value sniffed on MOSI pin.
  • 00 - Value sniffed on MISO pin.
  • 5D - ASCII code for ] (CS high).

Limitations

  • Currently only sniffs when CS low with default SPI settings.
  • This can be changed by modifying the source, but should be added as a command line option.