-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash.sh
More file actions
executable file
·56 lines (40 loc) · 996 Bytes
/
flash.sh
File metadata and controls
executable file
·56 lines (40 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
# Default to debug build
if test "$RELEASE"; then
REL=Release
else
REL=Debug
fi
BUILD_ROOT=./build
BUILD_DIR=$BUILD_ROOT/$REL
TO_FLASH=$(find $BUILD_DIR -maxdepth 1 -name '*.uf2')
if ! test -e "$TO_FLASH"; then
./build.sh
TO_FLASH=$(find $BUILD_DIR -maxdepth 1 -name '*.uf2')
fi
# Check if pico is here
PICO_INFO=$(sudo picotool info -a || true)
if grep -q 'appears to have a USB serial connection' <<< "$PICO_INFO"; then
# need to reboot to BOOTSEL
sudo picotool reboot -f -u
sleep 1
PICO_INFO=$(sudo picotool info -a || true)
fi
if grep -qE 'boot type:.*bootsel' <<< "$PICO_INFO"; then
echo "Found pi in BOOTSEL mode"
else
echo "Couldn't bring pi to a flashable state, abort."
exit 42
fi
# Flash the uf2 file
sudo picotool load --update "$TO_FLASH"
# Manual way:
# sudo mount /dev/sdb1 /mnt
# sudo cp blink/blink.uf2 /mnt
# sync
# sudo umount /mnt
sudo picotool info
# Back to app?
sudo picotool reboot -a
echo YAY