scripts: Add HW revision support to flash.sh
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m25s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m25s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
@@ -16,14 +16,15 @@ check_command lsusb
|
||||
check_command picotool
|
||||
|
||||
DEVICEPATH=/dev/disk/by-label/RPI-RP2
|
||||
IMAGEPATH=lib/micropython/ports/rp2/build-TONBERRY_RPI_PICO_W/firmware.uf2
|
||||
IMAGEPATH=lib/micropython/ports/rp2/build-TONBERRY_RPI_PICO_W/
|
||||
REVISION=Rev1
|
||||
|
||||
flash_via_mountpoint()
|
||||
{
|
||||
while [ ! -e "$DEVICEPATH" ] ; do sleep 1; echo 'Waiting for RP2...'; done
|
||||
|
||||
udisksctl mount -b "$DEVICEPATH"
|
||||
cp "$IMAGEPATH" "$(findmnt "$DEVICEPATH" -n -o TARGET)"
|
||||
cp "$IMAGEFILE" "$(findmnt "$DEVICEPATH" -n -o TARGET)"
|
||||
}
|
||||
|
||||
PID="2e8a"
|
||||
@@ -40,7 +41,7 @@ flash_via_picotool()
|
||||
local device="${bus_device[1]//[!0-9]/}"
|
||||
echo "Found RP2 with serial $serial on Bus $bus Device $device"
|
||||
|
||||
picotool load --bus "$bus" --address "$device" "$IMAGEPATH"
|
||||
picotool load --bus "$bus" --address "$device" "$IMAGEFILE"
|
||||
}
|
||||
|
||||
FLASH_VIA_MOUNTPOINT=0
|
||||
@@ -52,11 +53,12 @@ usage()
|
||||
echo
|
||||
echo " -m, --via-mountpoint Mount first found RP2 and flash image by"
|
||||
echo " copying to mountpoint."
|
||||
echo " -r, --revision <rev> Hardware revision to flash. Default is Rev1"
|
||||
echo " -h, --help Print this text and exit."
|
||||
exit 2
|
||||
}
|
||||
|
||||
PARSED_ARGUMENTS=$(getopt -a -n "$0" -o mh --long via-mountpoint,help -- "$@")
|
||||
PARSED_ARGUMENTS=$(getopt -a -n "$0" -o mhr: --long via-mountpoint,revision:,help -- "$@")
|
||||
# shellcheck disable=SC2181
|
||||
# Indirect getopt return value checking is okay here
|
||||
if [ "$?" != "0" ]; then
|
||||
@@ -68,6 +70,7 @@ while :
|
||||
do
|
||||
case "$1" in
|
||||
-m | --via-mountpoint) FLASH_VIA_MOUNTPOINT=1 ; shift ;;
|
||||
-r | --revision) REVISION=$2 ; shift 2 ;;
|
||||
-h | --help) usage ;;
|
||||
--) shift; break ;;
|
||||
*) echo "Unexpected option: $1"
|
||||
@@ -80,6 +83,8 @@ if [ $# -gt 0 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
IMAGEFILE="$IMAGEPATH"/firmware-filesystem-$REVISION.uf2
|
||||
|
||||
if [ "$FLASH_VIA_MOUNTPOINT" -eq 0 ]; then
|
||||
flash_via_picotool
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user