Skip to content

Instantly share code, notes, and snippets.

@Laura7089
Created July 8, 2022 01:48
Show Gist options
  • Save Laura7089/020716775ce9ad5e32dfb6c810c665e5 to your computer and use it in GitHub Desktop.
Save Laura7089/020716775ce9ad5e32dfb6c810c665e5 to your computer and use it in GitHub Desktop.
Small `picotool` wrapper intended for use as a cargo runner
#!/bin/sh
set -eu
# To use as a cargo runner, set:
#
# [target.YOUR_TARGET_NAME]
# runner = "./picotool.sh" # or wherever you put this script
#
# in .cargo/config.toml
# YOUR_TARGET_NAME is probably thumbv6m-none-eabi for the pico
TARGET="$(grep "^target = " ./.cargo/config.toml | head -n 1 | awk -F'\"' '{print $2}')"
PROJECT="$(grep "^name = " ./Cargo.toml | head -n 1 | awk -F'\"' '{print $2}')"
ELF_FILE="./target/$TARGET/release/$PROJECT"
cp -v "$ELF_FILE" "$ELF_FILE.elf"
picotool load "$ELF_FILE.elf"
picotool reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment