Bus Pirate 101

in Bus Pirate by Ian | 9 comments

BPv3-101

This is an old version, see the latest version on the documentation wiki.

In this introductory tutorial we cover the basics of the Bus Pirate universal serial interface. First, we identify the different parts of the Bus Pirate and explain their function. Next, we cover driver installation and terminal configuration. Finally, we explain the user interface and demonstrate some basic terminal menu commands. There’s links to everything you need to start hacking with the Bus Pirate.

Bus Pirate parts

bp-overview

1. Mini-B USB port. Connects the Bus Pirate to a PC. The Bus Pirate draws power from the USB port, and uses the data connection to communicate with the PC.

2. USB transmit indicator. This LED flashes when there’s traffic from the PIC to the PC.

3. Power indicator. This LED lights when the Bus Pirate is powered by the USB supply.

4. Mode indicator. This LED lights when the Bus Pirate is configured for a protocol mode from the user terminal (menu ‘m’). The I/O pins might be active when the mode indicator is on. The pins should be in a safe, non-powered, high-impedance state when the mode LED is off.

5. Voltage regulator indicator. This LED lights when the on-board power supplies have been activated from the user terminal (command capital ‘W’ ).

6. I/O pins. This 2×5 block of 0.1″ pin header connects the Bus Pirate to external circuits. See the pinout table below, or the Bus Pirate manual.

Pin name
Description (Bus Pirate is the master)
MOSI Master data out, slave in (SPI, JTAG), Serial data (1-Wire, I2C, KB), TX* (UART)
CLK Clock signal (I2C, SPI, JTAG, KB)
MISO Master data in, slave out (SPI, JTAG) RX (UART)
CS* Chip select (SPI), TMS (JTAG)
AUX Auxiliary IO, frequency probe, pulse-width modulator
ADC Voltage measurement probe (max 6volts)
Vpu Voltage input for on-board pull-up resistors (0-5volts).
+3.3v +3.3volt switchable power supply
+5.0v +5volt switchable power supply
GND Ground, connect to ground of test circuit

Notes: * TX moved from CS to MOSI in firmware v0g.

7. In circuit serial programming (ICSP) header. This 1×5 block of 0.1″ pin header is the programming connection for the PIC 24FJ64GA002 microcontroller. These pins can be used to write new firmware to the microcontroller with a programmer like the PICKIT2 or ICD2 . The Bus Pirate firmware can also be updated over the USB connection using a bootloader, so the ICSP header is normally only used to program it the first time at the factory. Put a jumper between the PGC and PGD pins to trigger the on-board bootloader for firmware updates.

8. Serial terminal (ST) header. Version v2go only. This unpopulated header is a tap into the UART connection between the PIC microcontroller and the FTDI 232BL chip that provides the USB connection. The Bus Pirate firmware defaults to a 115200bps/8/N/1 UART.

FTDI driver install and configuration

ftdi-driver

Windows will request a driver the first time the Bus Pirate connects to a PC. Extract the latest virtual com port drivers from FTDI into a folder and browse to them using the ‘Found New Hardware’ wizard. Install guides and drivers for other systems are also available on the FTDI driver download page.

com-port

To find the COM port number assigned to the Bus Pirate go to the Windows device manager (Start->Settings->Control panel->System->Hardware->Device manager). Look in ‘Ports (COM & LPT)’  for ‘USB Serial Port’, ours is COM5.

com-port-change.ii

You can change the serial port assigned to the FTDI chip. Go to USB Serial Port properties->Port settings tab->Advanced, change the COM port in the drop-down box.

Terminal setup

Windows terminal is cranky, but it appears to work with the Bus Pirate when VT100 emulation is enabled. We highly recommend a better terminal, we like Tera Term Pro for Windows.

First, configure the correct COM port and settings. The Bus Pirate operates at 115200bps/8/N/1 on the COM port assigned by Windows. Flow control is no longer required. Disable it!

tt-setup2

Next, check the terminal setup. Turn off local echo and use a VT100 terminal type. The Bus Pirate should work with any type of new-line character, but we use the CR setting.

Get to know the terminal interface

help

The Bus Pirate is controlled by text commands entered through the serial terminal. If the terminal is blank, press enter to show the command prompt. Press ‘?’, followed by enter, to show the help menu.

  • Menus configure various Bus Pirate options like pull-up resistors, terminal speed, data display format (DEC, HEX, BIN), etc. Type the menu command, followed by enter, to display the options.
  • Syntax is used to interact with a device connected over a bus. Commands are mostly single characters, such as ‘r’ to read a byte. Enter up to 4000 characters of syntax, press enter to execute the sequence.

Each menu and syntax option is documented fully in the Bus Pirate manual.

Most menus have a default option shown in () before the prompt:

Output type:
1. High-Z outputs (H=input, L=GND)
2. Normal outputs (H=Vcc, L=GND)
(1) > <<< option 1 is the default

Press enter to select the default option.

Bus modes, protocol libraries

HiZ>M <<< bus mode menu
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. JTAG
7. RAW2WIRE
8. RAW3WIRE
9. PC KEYBOARD
10. MIDI
11. LCD
(1) >5 <<< enter SPI bus mode

The ‘bus mode’ menu (M) configures the Bus Pirate for a specific protocol, like 1-Wire, I2C, SPI, etc. The default start-up mode is HiZ, all pins are inputs and all power supplies are off.

Most modes have additional options, like open drain outputs or speed settings. Each bus mode is documented in the Bus Pirate manual.

SPI READY
SPI>p <<< pull-up configuration menu
1. Pullup off
2. Pullup on
(1) >2 <<< pull-up on
PULLUP RESISTORS ON
SPI>W <<< power supplies ON syntax
POWER SUPPLIES ON
SPI>v <<< check power supply output
VOLTAGE MONITOR: 5V: 4.9 | 3.3V: 3.3 | VPULLUP: 0.0 |
SPI>

Once a mode is configured, you can enable other options.  Turn on the on-board voltage regulators (capital ‘W’) and check the output levels (v). Configure the pull-up resistors (p).

Taking it further

Now might be a good time to run a hardware self-test and update to the latest firmware (Windows, OSX, Python).

For lots of device demonstrations, and to learn more about the Bus Pirate syntax, menus, pinout, modes, and more, check the  Bus Pirate manual and the Bus Pirate forum.

Part 2

Continue reading Bus Pirate 102.

This entry was posted in Bus Pirate and tagged , .

Comments

  1. hack says:

    Hey Ian, why aren’t you posting this stuff at Hackaday anymore?

  2. Ideanator says:

    I’m hung up at the terminal, its set up correctly, but I can’t type into the terminal, pardon me for the probably noobish question, I’ve never played with anything serial before, what am I doing wrong?

  3. siberiansun says:

    Well, same Problem for me, tested it on Windows+Tera Term and Realterm and even on Mac with ZTerm.. Nothing is replied from Bus Pirate

    Whats wrong?

  4. siberiansun says:

    I finaly got it working!
    First of all, I was using the Hackaday v2go-Bus Pirate which shipped without firmware. So I was trying hard to upload the firmware, but downloaded the wrong one, so I downloaded the old v2-firmware and now it works!

  5. Bobby Joe says:

    Windows 2000 does not need a driver. Yay.

  6. Every link to the “bus pirate manual” just takes me to the sales page… no pdf manual exists?

  7. Jaukh says:

    Ditto on the manual links.
    Does there exist any command reference or user guide anywhere?
    I got a v4 on the way and would like to get familiar with the environment before I power-up.
    thanx

  8. Jaukh says:

    In going through the various “manual” pages I could find, I noticed the firmware download file was called “frimware” as was the file I downloaded:

    BPv4-frimware-v6.1.hex

    Is this an unchecked error or does it have some significance (meaningful or otherwise)?

Leave a Comment

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

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