Skip to content

Instantly share code, notes, and snippets.

@hidsh
Last active March 20, 2022 12:26
Show Gist options
  • Save hidsh/4dc19284ddea311825950b2a1be621bc to your computer and use it in GitHub Desktop.
Save hidsh/4dc19284ddea311825950b2a1be621bc to your computer and use it in GitHub Desktop.
trivial shell script to program into raspberry pi pico using openocd
#!/bin/sh
PGM='openocd'
if [ $# != 1 ]; then
echo "USAGE: $(basename $0) ELF_PATH"
exit -1;
fi
if [ ! $(which $PGM) ]; then
echo "Error: Not executable: $PGM"
exit -1;
fi
ELF_PATH=$1
if [ ! -e $ELF_PATH ]; then
echo "Error: Not found: $ELF_PATH"
exit -1;
fi
command $PGM -f interface/picoprobe.cfg -f target/rp2040.cfg -c "program $ELF_PATH verify reset exit"
if [ $? != 0 ]; then
printf '\033[31m%s\033[m\n\n' '---- Error!! ----'
exit -1
fi
printf '\n'
printf '\033[32m%s\033[m\n\n' '---- Success!! ----'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment