Skip to content

Commit

Permalink
Basic flash update script.
Browse files Browse the repository at this point in the history
Detects a connected board, resets it into bootloader mode,
mounts the RPI-RP2 drive (found via blkid) and unzips the latest
release .uf2 (fetched from GitHub) to it.

Not very fault tolerant.

Requires firmware >= 0.0.5.
  • Loading branch information
Gadgetoid committed Nov 13, 2024
1 parent 81904da commit 2b7ebb6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
PRODUCT="picade-max-audio"
FIRMWARE_VERSION=$(curl -sSL https://api.github.com/repos/pimoroni/$PRODUCT/releases/latest | grep "tag_name" | cut -d \" -f4)
FIRMWARE_UF2="picade-max-audio.uf2"
FIRMWARE="https://github.com/pimoroni/picade-max-audio/releases/download/$FIRMWARE_VERSION/$PRODUCT-$FIRMWARE_VERSION.zip"

echo "Installing firmware: $FIRMWARE_VERSION."

SERIAL_DEVICE=$(find /dev/serial/by-id -name "usb-Pimoroni_Picade_USB_Audio_*")
DEVICE=$(blkid -L RPI-RP2)

if [[ -e "$SERIAL_DEVICE" ]]; then
echo "Found Picade Max Audio at: $SERIAL_DEVICE"
echo "multiverse:_usb" > "$SERIAL_DEVICE"
DEVICE=""
START=$EPOCHSECONDS
while [[ -z "$DEVICE" ]]; do
if (( EPOCHSECONDS-START > 10 )); then
echo "RP2 bootloader device not found."
exit 1
fi
sleep 1
DEVICE=$(blkid -L RPI-RP2)
done
echo "Found RP2 on $DEVICE"
MNT_TEMP=$(mktempi -t "$PRODUCT")
sudo mount "$DEVICE" "$MNT_TMP" > /dev/null 2>&1
FW_TEMP=$(mktemp -t "$PRODUCT")
echo "Fetching $FIRMWARE..."
wget -q "$FIRMWARE" -O "$FW_TEMP"
echo "Installing firmware..."
sudo unzip "$FW_TEMP" -d "$MNT_TEMP" "$FIRMWARE_UF2"
rm "$FW_TEMP"
sync
sudo umount .tmp_update
rm -r "$MNT_TEMP"
else
echo "Picade Max Audio not found?"
exit 1
fi

0 comments on commit 2b7ebb6

Please sign in to comment.