Binary raw-wire mode
See the latest version in the documentation wiki.
Raw-wire binary mode provides access to the Bus Pirate’s raw 2- and 3-wire libraries. This new mode will make it easier to script operations on arbitrary serial protocols used by devices like smart cards, shift registers, etc. A completed raw-wire binary mode will be in the next firmware release, for now you can grab the latest v2.9 nightly compile.
Here’s all the binmode documentation so far. Binary raw-wire mode specification follows after the break.
- 00000000 – Enter raw bitbang mode, reset to raw bitbang mode
- 00000001 – Mode version string (RAW1)
- 0000001x – I2C-style start (0) / stop (1) bit
- 0000010x- CS low (0) / high (1)
- 00000110 – Read byte
- 00000111 – Read bit
- 00001000 – Peek at input pin
- 00001001 – Clock tick
- 0000101x – Clock low (0) / high (1)
- 0000110x – Data low (0) / high (1)
- 0001xxxx – Bulk transfer, send 1-16 bytes (0=1byte!)
- 0010xxxx – Bulk clock ticks, send 1-16 ticks
- 0011xxxx – Bulk bits, send 1-8 bits of the next byte (0=1bit!) (added in v4.5)
- 0100wxyz – Configure peripherals, w=power, x=pullups, y=AUX, z=CS
- 0101xxxx – Bulk read, read 1-16bytes (0=1byte!) (coming soon)
- 011000xx – Set speed, 3=~400kHz, 2=~100kHz, 1=~50kHz, 0=~5kHz
- 1000wxyz – Configure mode, w=output type, x=2/3wire, y=msb/lsb, z=n/a
- 101000xx – PIC command bits, 00=4/16, 01=6/14 (unimplemented)
- 10100100 – PIC write. Send command + 2 bytes of data, read 1 byte (v5.1)
- 10100101 – PIC read. Send command, read 1 byte of data (v5.1)
Enter binary raw-wire mode by first entering bitbang mode, then send 0×05 to enter raw-wire mode.
Most commands are a single byte. Commands generally return 1 for success, 0 for failure.
00000000 – Exit to bitbang mode, responds “BBIOx”
This command resets the Bus Pirate into raw bitbang mode from the user terminal. It also resets to raw bitbang mode from any protocol mode. This command always returns a five byte bitbang version string “BBIOx”, where x is the current bitbang protocol version (currently 1).
00000001 – Display mode version string, responds “RAWx”
Once in binary raw-wire mode, send 0×01 to get the current mode version string. The Bus Pirate responds ‘RAWx’, where x is the protocol version (currently 1). Get the version string at any time by sending 0×01 again. This command is the same in all binary modes, the current mode can always be determined by sending 0×01.
0000001x – I2C-style start (0) / stop (1) bit
Send an I2C start or stop bit. Responds 0×01. Useful for I2C-like 2-wire protocols, or building a custom implementation of I2C using the raw-wire library.
0000010x- CS low (0) / high (1)
Toggle the Bus Pirate chip select pin, follows HiZ configuration setting. CS high is pin output at 3.3volts, or HiZ. CS low is pin output at ground. Bus Pirate responds 0×01.
00000110 – Read byte
Reads a byte from the bus, returns the byte. Writes 0xff to bus in 3-wire mode.
00000111 – Read bit
Read a single bit from the bus, returns the bit value.
00001000 – Peek at input pin
Returns the state of the data input pin without sending a clock tick.
00001001 – Clock tick
Sends one clock tick (low->high->low). Responds 0x01.
0000101x – Clock low (0) / high (1)
Set clock signal low or high. Responds 0x01.
0000110x – Data low (0) / high (1)
Set data signal low or high. Responds 0x01.
0001xxxx – Bulk transfer, send 1-16 bytes (0=1byte!)
Bulk write transfers a packet of xxxx+1 bytes to the bus. Up to 16 data bytes can be sent at once. Note that 0000 indicates 1 byte because there’s no reason to send 0. BP replies 0×01 to each byte in 2wire mode, returns the bus read in 3wire (SPI) mode.
0010xxxx – Bulk clock ticks, send 1-16 ticks
Create bulk clock ticks on the bus. Note that 0000 indicates 1 clock tick because there’s no reason to send 0. BP replies 0×01.
0011xxxx – Bulk bits, send 1-8 bits of the next byte (0=1bit!) (added in v4.5)
Bulk bits sends xxxx+1 bits of the next byte to the bus. Up to 8 data bytes can be sent at once. Note that 0000 indicates 1 byte because there’s no reason to send 0. BP replies 0×01 to each byte.
This is a PIC programming extension that only supports 2wire mode. All writes are most significant bit first, regardless of the mode set with the configuration command.
0100wxyz – Configure peripherals w=power, x=pullups, y=AUX, z=CS
Enable (1) and disable (0) Bus Pirate peripherals and pins. Bit w enables the power supplies, bit x toggles the on-board pull-up resistors, y sets the state of the auxiliary pin, and z sets the chip select pin. Features not present in a specific hardware version are ignored. Bus Pirate responds 0×01 on success.
Note: CS pin always follows the current HiZ pin configuration. AUX is always a normal pin output (0=GND, 1=3.3volts).
0110000x – Set speed, 1=high (50kHz) 0=low (5kHz) (changed in v4.2+)
011000xx – Set speed, 3=~400kHz, 2=~100kHz, 1=~50kHz, 0=~5kHz
The last bit of the speed command determines the bus speed. Startup default is high-speed. Bus Pirate responds 0×01.
1000wxyz – Config, w=HiZ/3.3v, x=2/3wire, y=msb/lsb, z=not used
Configure the raw-wire mode settings. w= pin output type HiZ(0)/3.3v(1). x= protocol wires (0=2, 1=3), toggles between a shared input/output pin (raw2wire), and a separate input pin (raw3wire). y= bit order (0=MSB, 1=LSB). The Bus Pirate responds 0×01 on success.
Default raw startup condition is 000z. HiZ mode configuration applies to the data pins and the CS pin, but not the AUX pin.
10100100 – PIC write. Send command + 2 bytes of data, read 1 byte (v5.1)
An extension for programming PIC microcontrollers. Writes 20bits to the 2wire interface.
Payload is three bytes.
The first byte is XXYYYYY, where XX are the delay in MS to hold the PGC pin high on the last command bit, this is a delay required at the end of a page write. YYYYYY is a 4 or 6 bit ICSP programming command to send to the PIC (enter 4 bit commands as 00YYYY, commands clocked in LSB first).
The second and third bytes are 16bit instructions to execute on the PIC.
See the PIC 16F/18F programming specifications for more about ICSP.
10100101 – PIC read. Send command, read 1 byte of data (v5.1)
An extension for programming PIC microcontrollers. Writes 12bits, reads 8bits.
Payload is one byte 00YYYYYY, where YYYYYY is a 4 or 6 bit ICSP programming command to send to the PIC. Enter 4 bit commands as 00YYYY, all commands are clocked in LSB first.
The Bus Pirate send the 4/6bit command, then 8 ‘0’ bits, then reads one byte. The read byte is returned.
See the PIC 16F/18F programming specifications for more about ICSP.This entry was posted in binmode, Bus Pirate and tagged binmode, raw-wire.