UART mode updates


See the latest version in the documentation wiki.

UART mode requires special handling compared to the other Bus Pirate modes because data can arrive at any time. Displaying data as it arrives is a unique challenge because it has to be converted to ASCII and sent to the user terminal. Each incoming byte takes about 10 bytes to display on the PC.

The UART library has been largely neglected since early releases. This post outlines changes in the v2.7 release that solve a number of issues that were plaguing the UART library, including speed setting problems and buffer errors.

Parity and framing errors

READ: -p -f 0x40 <<<-p -f flag set

The Bus Pirate now reports framing errors (-f) and parity errors (-p) when reading a byte from the UART. It’s unlikely you’ll see these errors unless the UART speed is mismatched with the sender.

Buffer overrun errors

The Bus Pirate hardware has a four-byte UART buffer that holds data until you read it with an ‘r’ command, or until it can be printed to the terminal if live display is enabled with ‘[‘. After it fills, new data will be lost. This is called a buffer overrun.

READ: 0x40 *Bytes dropped*<<<bytes dropped error

The Bus Pirate now detects buffer errors, clears them, and alerts you of dropped bytes. The overrun bit is cleared any time you use the r, {, or [ commands. If you close the live UART display (]) and more than 5 bytes come in, the next read command (r) will clear the error and print the *bytes dropped* warning.

Prevent buffer problems by reducing the amount of data the Bus Pirate transfers over USB for each byte of UART data. Raw display mode reduces the four byte hex value 0x00 to a single raw byte value. A better way is to use macro (1) or (2) to view unformatted UART output, this is a 1:1 transfer of bytes that should work at the highest possible speeds.

Macro additions, changes

UART>(1)<<<macro 1, transparent UART bridge
UART bridge. Space continues, anything else exits.
Reset to exit.

The transparent UART mode macro (1) clears any buffer errors before starting. This should eliminate garbage data  problems.

Buffer errors that occur during bridge mode are NOT cleared. A stream of the same byte will alert you to a buffer problem. A future update will probably clear the error but dim the MODE LED to alert you of the error.

UART>(2)<<<macro 2, UART monitor
Raw UART input. Space to exit.

The new UART monitor macro (2) shows a live display of UART input as raw byte values without any type of formatting. Press any key to exit the live monitor. This mode works best with a terminal that can display raw byte values in a variety of formats.

This macro is like the transparent UART macro (1) but without transmission abilities, and it can be exited with a key press. It’s useful for monitoring high-speed UART input that causes buffer overrun errors in other modes.

Join the Conversation


  1. Seeing a return of the null-char bug from v2.5 on v2go, can attach fine on using ‘screen /dev/cu.usbserial-A7004Iqz 115200’ but ZTerm is showing blank even though I can see the rx LED flashing on the buspirate.

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.