In Bus Pirate v3 single character configuration commands can be mixed with bus syntax commands in any arbitrary way. This was about all we could do on a tiny PIC chip. It just looped over user input and performed the action.
The current Bus Pirate 5 firmware is more advance, but the mix and match of configuration and syntax is limiting what we can do in the future. The goal of this rework is to have a clean separation of commands that configure the Bus Pirate and bus syntax that is used to communicate with a device.
Updated command line
- Configuration commands - commands that change settings or enable hardware on the Bus Pirate. Examples are w/W (power supply), p/P (pull-ups), m (changing modes), etc. These are entered one per line and have optional arguments.
- Bus syntax - Simple scripting language for communicating with a device over a bus. Examples are r (read), 0x/0b/0 (write value), a/A/@ (control individual pins), d/D (delays), [/] (start/stop) etc. These are compiled into bytecode, then ārunā full speed to best represent real world conditions. To execute syntax, start the line with [ or { or >
Configuration commands
[CMD_LS]="ls", //list files
[CMD_CD]="cd", //change dir
[CMD_MKDIR]="mkdir", //make dir
[CMD_RM]="rm", //delete file or empty directory
[CMD_CAT]="cat", //print file contents
[CMD_MODE]="m", //change mode
[CMD_PSU_EN]="W", //psu on
[CMD_RESET]="#", //reset
[CMD_BOOTLOAD]="$", //enter bootloader
[CMD_INT_FORMAT]="=", //convert int. formats in bin/hex/dec
[CMD_INT_INVERSE]="|", //inverse the bit in a byte
[CMD_HELP]="?", //help menu
[CMD_CONFIG_MENU]="c", //configuration menu
[CMD_FREQ_ONE]="f", //measure frequency once
[CMD_FREQ_CONT]="F", //measure frequency, press space to exit
[CMD_PWM_CONFIG]="G", //generate a frequency
[CMD_PWM_DIS]="g", //disable frequency generation
[CMD_HELP_MODE]="h", //mode specific help
[CMD_INFO]="i", //bus pirate info
[CMD_BITORDER_MSB]="l", //msb bit order
[CMD_BITORDER_LSB]="L", //lbs bit order
[CMD_DISPLAY_FORMAT]="o", //output display format
[CMD_PULLUPS_EN]="P", //pull-up on
[CMD_PULLUPS_DIS]="p", //pull-ups off
[CMD_PSU_DIS]="w", //psu off
[CMD_ADC_CONT]="V", //measure voltage, press space to exit
[CMD_ADC_ONE]="v", //measure voltage once
[CMD_SELFTEST]="~", //run self test
[CMD_AUX_IN]="@", //set pin input and read
[CMD_AUX_LOW]="a", //set pin low
[CMD_AUX_HIGH]="A" //set pin high
- Some commands accept arguments.
A 7
sets IO7 high.f 1
measures frequency on pin one. - Commands will show a menu of options if no arguments are provided.
- Multiple commands can be tied together with the linux operators
;
(execute next)||
(execute next if previous failed)&&
(execute next if previous did not fail).
Bus Syntax
case 'r': cmd=SYN_READ; break; //read
case '[': cmd=SYN_START; break; //start
case ']': cmd=SYN_STOP; break; //stop
case 'd': cmd=SYN_DELAY_US; break; //delay us
case 'D': cmd=SYN_DELAY_MS; break; //delay ms
case 'a': cmd=SYN_AUX_LOW; break; //aux low
case 'A': cmd=SYN_AUX_HIGH; break; //aux HIGH
case '@': cmd=SYN_AUX_INPUT; break; //aux INPUT
case 'v': cmd=SYN_ADC; break; //voltage report once
case 'f': cmd=SYN_FREQ; break; //measure frequency once
- Writes are decimal/hex/binary numbers (0, 0x or 0b number entry)
These are the bus syntax commands the compiler will accept. Not all commands are implemented, and I have only been testing in SPI mode.
- Begin the syntax with
[
,{
, or>
to tell the Bus Pirate you intend to send data over a bus
Download
If you actually want to use your Bus Pirate, use the latest stable build from here.
If you want to see what Iām working on for the future, Iād love to have some feedback on the experimental firmware. Current status:
- With an SD card inserted, try the new disk commands: ls, mkdir, cd, rm, cat.
- Configuration commands have a help option. ls -h to show help.
- Configuration commands have all been ported to the new system. Things that configure the Bus Pirate are entered one per line. A few will take arguments, but Iām not that far yet. Most will still show a series of menu prompts. Things that used
.
notation in the previous firmware (āf.7ā measure frequency on pin 7), are now entered with a space (f 7). - Use ; || or && to execute multiple commands on a single line.
- Bus Syntax must start with [ or { or > (start/CS)
- Bus Syntax compiles and runs up to 100 commands
- Bus Syntax can sort of post-process the result to the terminal (incomplete)
It is very much a prototype in progress. Iāll update this post as I get everything implemented.
Download syntax_rework auto builds
- Much progress.
- Now connected to the auto build server, grab the latest and greatest from the link above.
Developer tip
"terminal_usb_enable": 0,
"terminal_uart_enable": 1,
"terminal_uart_number": 1,
Debugging intensive work with a USB connection is a nightmare. The terminal IO can instead be put on two IO pins and then connected through the PICO probe auxiliary UART. Be sure to give it a power supply through the vout/vref pin with 3.3volts from the PICO.
- Open bpconfig.bp on the SD card.
- Disable the USB. both cannot work together due to some bug Iāve never been able to track down
- Enable the UART
- UART0 is on IO4/5. UART1 is on IO0/1. Choose one that doesnāt interfere with the stuff youāre debugging. Debug pins are protected and the Bus Pirate will refuse to reconfigure them.
- Restart the Bus Pirate