Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active January 7, 2022 22:32
Show Gist options
  • Save Hermann-SW/8a9b4280d733930b808785de58902e9d to your computer and use it in GitHub Desktop.
Save Hermann-SW/8a9b4280d733930b808785de58902e9d to your computer and use it in GitHub Desktop.
load a file to topmost flash location of Raspberry Pico, appended with 4-byte length
#!/bin/bash
len=`wc --bytes $1 | cut -f1 -d\ `
hex=`printf "%08x" $len`
ofs=$(((256+2)*1024*1024-4-len))
ofshex=`printf "%08x" $ofs`
cp $1 /tmp/picoload.bin
printf "\x${hex:6:2}\x${hex:4:2}\x${hex:2:2}\x${hex:0:2}" >> /tmp/picoload.bin
sudo picotool load /tmp/picoload.bin -o $ofshex
@Hermann-SW
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment