2-Wire Protocol Commands
Overview
- Bus: 2 wire bus with bidirectional data (SDA) line and a clock (SCL) line
- Connections: two pins (SDA/SCL) and ground. An additional pin is reserved for RESET, and is controlled by the
{
/}
commands. - Output type: open drain/open collector
- Pull-up resistors: always required (2K - 10K ohms)
- Maximum voltage: 5volts
2-wire is a generic 8bit protocol mode with a bidirectional data line (SDA) and a clock line (SCL). 2-wire can be used to interface with SLE4442 smart cards, half-duple SPI devices and other 2 wire busses that don't use a full I2C implementation.
Connections
Bus Pirate | Direction | Circuit | Description |
---|---|---|---|
SDA | ↔ | SDA | Serial Data |
SCL | → | SCL | Serial Clock |
RST | → | RST | Reset signal for some devices |
GND | ⏚ | GND | Signal Ground |
Configuration options
1kHz to 1000kHz
x. Exit
kHz (400kHz*) > 20
Mode: 2WIRE
2WIRE>
Pull-up resistors
2-Wire is an open-collector bus, it requires pull-up resistors to hold the clock and data lines high and create the data '1'. In 2-Wire mode, the Bus Pirate doesn't output high, it only pulls low. Without pull-up resistors there can never be a '1'.
Enable the Bus Pirate onboard pull-up resistors with the P
command.
- 2-Wire requires pull-up resistors to hold the clock and data lines high.
- Without pull-up resistors there can never be a '1'.
- Enable the Bus Pirate onboard pull-up resistors with the
P
command.
Syntax
Command | Description |
---|---|
[ | Issue I2C-style start condition. Some devices don't follow the I2C standard, but still use a similar START condition. |
] | Issue I2C-style stop condition. Some devices don't follow the I2C standard, but still use a similar STOP condition. |
{ | RST/reset pin high |
} | RST/reset pin low |
r | Read one byte, send ACK. (r:1…255 for bulk reads) |
0b | Write this binary value, check ACK. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001. |
0x | Write this HEX value, check ACK. Format is 0x01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters. |
0-255 | Write this decimal value, check ACK. Any number not preceded by 0x or 0b is interpreted as a decimal value. |
space | Value delimiter. Use a space to separate numbers. No delimiter is required between non-number values: {0xa6 0 0 16 5 0b111 0xaF rrrr}. |
Commands
Bus Pirate 5 has global commands available everywhere, and mode commands specific to the currently selected mode. Type help
to see all commands in every mode, or help mode
for the currently available mode commands.
sle4442
The sle4442
command in the Bus Pirate's 2-WIRE mode automates the process of reading, writing and unlocking a SLE4442 smart card.
Help
usage:
sle4442 [init|dump|unlock|write|erase|psc]
[-a <address>] [-v <value>] [-p <current psc>] [-n <new psc>] [-h(elp)]
Initialize and probe: sle4442 init
Dump contents: sle4442 dump
Unlock card: sle4442 unlock -p 0xffffff
Write a value: sle4442 write -a 0xff -v 0x55
Erase memory: sle4442 erase
Update PSC: sle4442 psc -p 0xffffff -n 0x000000
SLE4442 smart card interface
init Initialize card with ISO7816-3 ATR. Default action
dump Display main, security and protect memory
unlock Unlock card with Programmable Security Code (PSC)
write Write data to card (requires unlock)
erase Erase data from range 0x32-0x255 (requires unlock)
psc Change Programmable Security Code (PSC)
-a Write address flag
-v Write value flag
-p Current Programmable Security Code (PSC) flag
-n New Programmable Security Code (PSC) flag
2WIRE>
Use sle4442 -h
to see the latest options and features.
Most Bus Pirate commands have help and usage examples. Add the -h flag to any command to see the available options and examples.
Options and flags
Option | Description |
---|---|
sle4442 init | Initialize and probe the card Answer To Reset |
sle4442 dump | Display main, security and protect memory |
sle4442 unlock | Unlock card with Programmable Security Code (PSC) |
sle4442 write | Write data to card (requires unlock) |
sle4442 erase | Erase data from range 0x32-0x255 (requires unlock) |
sle4442 psc | Change Programmable Security Code (PSC) |
Flag | Description |
---|---|
-a | Write address flag |
-v | Write value flag |
-p | Current Programmable Security Code (PSC) flag |
-n | New Programmable Security Code (PSC) flag |
Reset SLE4442 card, decode ATR response
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x00 0x00 0x00
Remaining attempts: 3 (0x7)
sle4442
and sle4442 init
reset the card and decodes the Answer To Reset (ATR) response.
Dump SLE4442 card memory
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x00 0x00 0x00
Remaining attempts: 3 (0x7)
Protection memory: 0xff 0xff 0xff 0xff
Memory:
0xa2 0x13 0x10 0x91 0xff 0xff 0x81 0x15 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xd2 0x76 0x00 0x00 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
sle4442 dump
reads and displays the main, security and protection memory areas.
Unlock SLE4442 card with passcode
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x12 0x34 0x56
Remaining attempts: 3 (0x7)
Unlocking with PSC: 0x123456
Using free security bit: 0x03
Card unlocked, security bits reset
Security memory: 0x07 0x12 0x34 0x56
Remaining attempts: 3 (0x7)
sle4442 unlock
unlocks the card using the Programmable Security Code (PSC). Use the -p
flag to specify the PSC.
New cards usually have a default PSC of 0xffffff.
Write data to SLE4442 card
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x12 0x34 0x56
Remaining attempts: 3 (0x7)
Writing 0x88 to 0xff
sle4442 write
writes a single byte of data to the card. Specify the address with the -a
flag and the data value with the -v
flag.
The card must be unlocked before writing data.
Change SLE4442 passcode/PSC
--SLE44xx decoder--
ATR: 0xa2 0x13 0x10 0x91
Protocol Type: S 10
Structure Identifier: General Purpose (Structure 1)
Read: Read to end
Data Units: 256
Data Units Bits: 8
Security memory: 0x07 0x12 0x34 0x56
Remaining attempts: 3 (0x7)
Unlocking with PSC: 0x123456
Using free security bit: 0x03
Card unlocked, security bits reset
Security memory: 0x07 0x12 0x34 0x56
Remaining attempts: 3 (0x7)
Updating with PSC: 0xFFFFFF
PSC updated to: 0xFFFFFF
Security memory: 0x07 0xff 0xff 0xff
Remaining attempts: 3 (0x7)
sle4442 psc
changes the Programmable Security Code (PSC). Use the -p
flag to specify the current PSC and the -n
flag to specify the new PSC.