#!/bin/sh # Launch BusPirate using screen, tio, etc. It checked for mounted file systems # If in boot mode, asks to copy firmware onto BusPirate # Time-stamp: <2024-10-04 15:11:44 (grymoire)> # Usage: BusPirate [-n] [terminal] [baud] # i.e. BusPirate /dev/ttyACM2 - if it's on a different port #Some variables you might need to change BP5FIRMWARE=bus_pirate5_rev10.uf2 #BP5FIRMWARE=bus_pirate5_rev8.uf2 # BusPirate 5 rev 8 prototype BP6FIRMWARE=bus_pirate6.uf2 #BP6FIRMWARE=bus_pirate5xl.uf2 # Where would the firmware be located? FW=${BPFW:=.} # Use current directory PORT=${1:-"/dev/ttyACM0"} # default port BAUD=${2:-"11520"} # default baud rate connect() { # Connect to BusPirate #screen "$PORT" "$BAUD" tio -n bp #minicom -b "$BAUD" } usage() { printf "%s: ERROR: %s\n" $(basename "$0") "$@" 1>&2 printf "usage: %s [-n] [port] [baud]\n" $(basename "$0") 1>&2 printf " -n = Do not look for a /mnt/%s/BUS_PIRATE5 directory\n" "$USER" 1>&2 exit 1 } check() { # Checks that the Bus Pirate is mounted #Is it in bootloader mode and an BP5? if [ -d "/media/$USER/RPI-RP2" ] then if [ -f "$FW/$BP5FIRMWARE" ] then printf "Do you want me to install the new firmware %s? " "$FW/$BP5FIRMWARE" read -r answer case "$answer" in [Yy]* ) cp "$FW/$BP5FIRMWARE" /media/"$USER"/RPI-RP2 exit ;; * ) printf "In boot mode - Unplug and replug the BusPirate\n" exit ;; esac else echo "In boot mode - Unplug and replug the BusPirate" exit fi elif [ -d "/media/$USER/RP2350" ] # BusPirate 6 or 5xl then if [ -f "$FW/$BP6FIRMWARE" ] then printf "Do you want me to install the new firmware %s? " "$FW/$BP6FIRMWARE" read -r answer case "$answer" in [Yy]* ) cp "$FW/$BP6FIRMWARE" /media/"$USER"/RP2350 ;; * ) printf "In boot mode - Unplug and replug the BusPirate\n" exit ;; esac else printf "In boot mode - Unplug and replug the BusPirate\n" exit fi elif [ -d "/media/$USER/BUS_PIRATE5/" ] then : # Looks good else echo "No file system mounted - Please plug in your Bus Pirate" exit 1 fi } CHECK=1 # Look for optional -n argument if [ "$#" -gt 0 ] then case "$1" in -n) CHECK=0; shift;; -*) usage "Unknown argument '$1'"; exit;; esac fi PORT=${1:-"/dev/ttyACM0"} # default port BAUD=${2:-"11520"} # default baud rate if [ "$CHECK" -eq 1 ] then # check for mounted filesystems check fi connect