-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash.sh
More file actions
executable file
·106 lines (92 loc) · 3.51 KB
/
Copy pathflash.sh
File metadata and controls
executable file
·106 lines (92 loc) · 3.51 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash -e
{ cd "${0%/*}"
# WRITE_BAUD_RATE="460800"
WRITE_BAUD_RATE="921600"
# WRITE_BAUD_RATE="2000000"
DEV_FS="$(realpath ./Device/ROM/Out)/onboard"
DEVS=($(ls /dev | grep -E '.*tty(ACM|USB).*' | sed 's/tty/\/dev\/tty/'))
[[ $1 == "--single" ]] && {
until [ -f /tmp/flash_flag ]; do
sleep 0.05
done
[[ -f /tmp/flash_bad_flag ]] && exit 0
DEV="$2"
UUID="$3"
FLASH_ROM=$([[ $4 == 'y' ]] && echo -n y || echo -n)
echo "Flashing ${DEV} - ${UUID:-"No UUID"}"
echo "Using esptool : \"$(which esptool )\""
echo "Using mpremote: \"$(which mpremote)\""
pushd ./Device
[[ -n "$FLASH_ROM" ]] && {
pushd ./ROM/Out
esptool -p "$DEV" -b "$WRITE_BAUD_RATE" erase-flash
esptool -p "$DEV" -b "$WRITE_BAUD_RATE" --chip esp32 \
--before default-reset --after hard-reset write-flash \
--flash-mode dio --flash-size 4MB --flash-freq 40m \
0x1000 bootloader.bin 0x8000 partition-table.bin \
0xD000 ota_data_initial.bin 0x10000 micropython.bin
# esptool --port "$DEV" --baud 115200 \
# --before no-reset --after no-reset --no-stub \
# --chip esp32 write_flash \
# --flash-mode dio --flash-size 4MB --flash-freq 40m \
# 0x1000 bootloader.bin \
# 0x8000 partition-table.bin \
# 0xD000 ota_data_initial.bin \
# 0x10000 micropython.bin
popd; };
pushd ./Onboard
stty -F "$DEV" 115200 raw -echo
for _ in {1..10}; do { printf '\x03'; sleep 0.025; } done > "$DEV"
sleep 0.1
mpremote connect "$DEV" fs cp -r ${DEV_FS}/* :/ || read
[[ -n "$UUID" ]] && {
tmp=$(mktemp)
echo "\"${UUID}\"" > "$tmp"
mpremote connect "$DEV" fs cp "$tmp" :/UUID || read
rm -f "$tmp"; }
# exec mpremote connect "$DEV" reset
exec mpremote connect "$DEV" run ./main._py || :
read; }
FLASH_ROM=$([[ $1 == 'y' ]] && echo -n y || echo -n)
BUILD_ROM=$([[ $2 == 'y' ]] && echo -n y || echo -n)
CLEAN_ROM=$([[ $3 == 'y' ]] && echo -n y || echo -n)
DEV_UUIDS=$([[ $4 == 'y' ]] && echo -n y || echo -n)
PRESET=${5:-"Normal"}
CONFIG_INJ=${6:-'{}'}
SCENES_INJ=${7:-'{}'}
# echo [${FLASH_ROM}] [${BUILD_ROM}] [${CLEAN_ROM}] [${DEV_UUIDS}] [${PRESET}]
killall mpremote && sleep 0.05 || :
rm /tmp/flash_flag || :
rm /tmp/flash_bad_flag || :
for i in "${!DEVS[@]}"; do
dev="${DEVS[i]}"
uuid=$([[ -n "$DEV_UUIDS" ]] && echo -n "testdevice${i}" || echo -n)
echo "Spawning flasher for \"${dev}\""
CMD=(bash "./$(basename "$0")" --single "$dev" "$uuid" "$FLASH_ROM")
if [[ "$SYSTEM" == "desktop" ]]; then
/c/Scripts/Path/term -T "(${i}) ${dev}" --option 'font.size=11' --command "${CMD[@]}" &
else
TARG="flash:main"
tmux has-session -t "flash" 2>/dev/null || \
tmux new-session -d -s "flash" -n main "${CMD[@]}"
if [[ $i -ne 0 ]]; then
tmux split-window -t "$TARG" -d "${CMD[@]}"
tmux select-layout -t "$TARG" tiled
fi
fi
done
unalias . || :; export PATH="$PATH:$PWD/Device/esp-idf"; source ./Device/esp-idf/export.sh
set +e
( set -e
cd ./Device
☾ generate_sigs.☾
if [[ -n "$BUILD_ROM" ]]; then
./ROM/build.sh ${CLEAN_ROM:+-c}
fi
./ROM/gen_files.sh '' "$PRESET" "$CONFIG_INJ" "$SCENES_INJ"
)
[[ $? != "0" ]] && touch /tmp/flash_bad_flag
set -e
touch /tmp/flash_flag
[[ "$SYSTEM" != "desktop" ]] && tmux a -t flash
exit $?; }