Bus Pirate SPI guide

See the latest version in the documentation wiki.

Bus: SPI (serial peripheral interface).
Connections: four pins (MOSI/MISO/CLOCK/CS) and ground.
Output type: 3.3volt normal, or open collector (pull-up resistors required).
Pull-up resistors: required for open drain output mode (2K – 10K).
Maximum voltage: 5.5volts (5volt safe).

Syntax Description
A/a/@ Toggle auxiliary pin. Capital “A” sets AUX high, small “a” sets to ground. @ sets aux to input (high impedance mode) and reads the pin value.
D/d Measure voltage on the ADC pin (v1+ hardware only).
W/w Capital ‘W’ enables the on-board power supplies. Small ‘w’ disables them. (v1+ hardware only).
[ Chip select (CS) active (low).
{ CS active (low), show the SPI read byte after every write.
] or } CS disable (high).
R or r Read one byte by sending dummy byte (0xff). (r:1…255 for bulk reads)
0b Write this binary value. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001.
0h/0x Write this HEX value. Format is 0h01 or 0×01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters.
0-255 Write this decimal value. Any number not preceded by 0x, 0h, or 0b is interpreted as a decimal value.
, Value delimiter. Use a coma or space to separate numbers. Any combination is fine, no delimiter is required between non-number values: {0xa6,0, 0 16 5 0b111 0haF}.
& Delay 1uS. (&:1…255 for multiple delays)
(#) Run macro, (0) for macro list
Macro Description
0 Macro menu
1 SPI bus sniffer with configurable CS filter.

Configuration options

Speed – 30kHz, 125kHz, 250kHz, 1MHz.

Clock polarity – idle low, idle high.

Output clock edge – idle to active, active to idle.

Input sample phase – middle, end.

Output type – open drain/open collector (high=Hi-Z, low=ground) , normal (high=3.3volts, low=ground). Use open drain/open collector output types with pull-up resistors for multi-voltage interfacing.

SPI Bus sniffer

The SPI sniffer is implemented in hardware and should work up to 10MHz. It follows the configuration settings you entered for SPI mode.

  • [/]  – CS enable/disable
  • 0xXX – MOSI read
  • (0xXX)  – MISO read

SPI CS pin transitions are represented by the normal Bus Pirate syntax. The byte sniffed on the MISO pin is displayed inside ().

Sniff when:
1. CS low
2. CS high
3. All traffic
(1) >
SPI bus sniffer, any key exists

The SPI sniffer can read all traffic, or filter by the state of the CS pin. The byte sniffed on the MOSI pin is displayed as a HEX formatted value, the byte sniffed on the MISO pin is inside the ().

Join the Conversation


  1. I’m using the bus-pirate (v2go with v3.1FW) to sniff a SPI port, I sometimes get an output in the terminal which isn’t correctly HEX formatted, for example: 0x0x01F.
    Any ideas of what is causing this?

  2. Oh nevermind.. I’m sniffing continuous 8Mhz SPI data, so the little BusPirate isn’t happy as it is over running the buffer. I really should be using a logic analyser instead.

  3. We need BusPirate for SPI sniffing only (no outputs on bus, not exercising devices), but SPI mode interferes whenever connected to SPI bus!
    When SPI mode is not sniffing (at SPI prompt, esp. after sniffing interrupted by keystroke), data line (at least MOSI) appears to be driven or held by BusPirate, instead of released or left open (Hi-Z). The effect is system under test ceases to operate when BusPirate at SPI> prompt is attached. Workaround is to start sniffing “macro” (1) before attaching to SPI bus.
    What is needed (should be default, IMHO) is for all SPI pins to input-only except when issuing output onto the bus; or else a setting option for this.
    What is SPI (1) “macro” — can it be edited, can its commands be used?
    [Also, any option for BusPirate to power up back into last-used configuration and state, after power-down? We would like to “set and forget” instead of having to record/remember all configuration choice each time we re-power the device.]

    1. Hi Pete,

      The SPI sniffer macro is here:

      It uses two hardware SPI modules in the PIC to sniff the SPI traffic. The actual functions that do this are here:

      Your suggestion is very interesting, and I’m not sure quite sure how to integrate it into the code. The PIC hardware SPI modules actually control the pin state after the module is configured. Peripherals with the PIC PPS function override user pin configurations. Leaving all pins input unless they are outputting could adversely effect some chip clocks and CS (maybe not?). I guess we could assign and remove the SPI module from the pins between every write to make it an input, but this would probably send extra clock bits and CS line noise, especially with high-impedance bus configurations.

      Maybe we could make the SPI sniffer resettable so it would stay in high-z SPI sniffer mode instead of falling to the command prompt – space to reset/pause, X to exit, something like that?

      I started a discussion for this in the development forum. I’ll try to get some form of solution rolled into the next nightly build:

      Unfortunately the PIC in the Bus Pirate doesn’t have an EEPROM or anything (besides flash, which is all used up) to store persistent settings. It’s definitely something we have planned for the next version though.

  4. I’ll be more than happy to try things out and provide feedback.
    I’d also like to try some tweaks and builds of our own; if I can join the fray without disrupting it, is the build setup written up somewhere?

  5. I am trying to use BP to do some SPI sniffing as well… Not much success, even the instructions look straight forward….

    In my case, I just wanted to make sure I understand the process correctly. I am tapping into a circuit I build, with SPI running @ 5MHz. Beside from the effects (hold up the SPI bus before going into sniffing mode) I can’t seem to getting anything (maybe a [ or ] for one time and that’s it)

    And for the whole time I know the SPI bus is working because the other (16F88 -> MAX7219) end continuously receiving data…

    On a side note…. a tutorial (or even new feature – CAN Bus interface. Hint: OBD II) to use it with MCP2515 would be awesome!

  6. is it possible BUS pirate device use as a slave device in the SPI bus network and how?
    For SPI network, do i need to give external power supply for it.

      1. Thanks Ian,
        One more query i have, while looking the board, i have found their is no ckock IC. So how this message will send in the network without CLK.

      2. Hi PD,

        Which board do you mean? Your test board? If there is no clock I don’t think it can be SPI.

      3. Well, it kinda sorta is possible – you can use the SPI sniffer mode, which will allow you to passively receive data on the SPI bus. In this way, you can see what a SPI bus master is transmitting.

  7. How do I use Bus Pirate as a master when the slave will toggle an interrupt pin to indicate data ready? Do I just sit in a loop doing @, until Aux goes low? And then read 1 byte at a time until it goes high?


  8. Let me explain better. In my application, the slave will toggle the /INTR pin to indicate its need to talk. The master is expected to toggle CS, send enough clocks for the slave to transfer the message (the third byte is the length), and toggle CS back. How can I get a master to receive this using BP?

    1. Since it is a human-speed interface you generally never have to wait to read the signal – the chip will always be ready by the time you try to read it. You can also use the delay commands to wait the max recommended time (if that applies to your chip…).

  9. The buspirate-demo application in the libbuspirate-0.3.0 is unable to change the ‘speed’ and other SPI configurations !!!!

    Question: Suggest me a program that can be used to configure the Bus Pirate to a required configuration ?

    Bus pirate could be configured using the minicom….

    I am using Bus Pirate and the libbuspirate-0.3.0 on my ubuntu system and trying to run the SPI demo application, using the command.
    ./buspirate-demo /dev/ttyUSB0 4

    The OUTPUT is as shown below.

    Binary I/O mode version: 1
    *** SPI demo ***
    Entering SPI mode
    Binary I/O SPI version: 1
    Setting SPI speed
    Reading SPI speed
    Binary I/O SPI speed:
    Speed: 30kHz
    Setting SPI configlibbuspirate-0.3.0
    Reading SPI config
    Binary I/O SPI config (0):
    Output level : HiZ
    Clock idle : low
    Clock edge : active->idle
    Sample position: middle
    Reset device to user terminal

    However, the demo code is trying to set the speed to 8MHz (which is not happening) and other SPI configurations in the code are also different from the one that is displayed.


Leave a comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.