Skip to content

Instantly share code, notes, and snippets.

@MichaelBell
Last active February 4, 2021 22:58
Show Gist options
  • Select an option

  • Save MichaelBell/9d139356e018ec8b0fa57019274ec1d9 to your computer and use it in GitHub Desktop.

Select an option

Save MichaelBell/9d139356e018ec8b0fa57019274ec1d9 to your computer and use it in GitHub Desktop.
Pico UF2 reload script
#!/bin/bash
# First interrupt pico and run make
[ ! -c /dev/ttyACM0 ] || stty -F /dev/ttyACM0 1200 || exit
make || exit
echo
# Find file to program
UF2_FILE=$1
if [ -z "$UF2_FILE" ]; then
UF2_FILES=(*.uf2)
if [[ ${#UF2_FILES[@]} -ne 1 ]]; then
echo "Multiple UF2 files in this directory, please specify which to use"
exit
fi
UF2_FILE=${UF2_FILES[0]}
fi
if [ ! -f $UF2_FILE ]; then
echo "Couldn't find UF2 file to program"
exit
fi
echo "Programming $UF2_FILE to pico"
# Wait for drive to be available to mount, then mount and copy
while ! picotool info > /dev/null; do
sleep 0.2
done
picotool load $UF2_FILE
picotool reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment