-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-mcu.sh
executable file
·64 lines (51 loc) · 1.36 KB
/
setup-mcu.sh
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
#!/bin/bash
#Enable errors
set -e
echo "This script will configure your teensy for inference"
read -p "Please specify the role of the device to be configured: " mcu_role
read -p "Please specify the id of the device to be configured: " mcu_id
if test -s MCU_code/testbed.json; then
echo "Current testbed:"
cat MCU_code/testbed.json
echo ""
fi
read -p "Would you like to append $mcu_role $mcu_id to the testbed? (Yy/Nn)" append_to_testbed
export mcu_role
export mcu_id
export append_to_testbed
read -p "Is the device connected to the PC? (Y/N)" ynconn
case $ynconn in
[yY]*);;
*) echo "Check connection and try again"
exit;;
esac
echo "configuring Teensy 4.1 as $mcu_role $mcu_id"
cd ./MCU_code/PlatformIO_code/download
pio run --target upload
echo "Waiting for COM connection"
sleep 5
wait
echo "Download coordinator weights..."
cd ../../
python ./write_into_mcus.py /dev/ttyACM0 c
echo "Logging..."
sleep 10
echo "Download worker weights..."
python ./write_into_mcus.py /dev/ttyACM0 w
echo "Logging..."
sleep 30
echo "Flashing worker code"
cd ./PlatformIO_code/worker_code
pio run -e teensy41_autoconf --target upload
sleep 5 &
wait
echo "checking if the configuration was successful"
ip_last=$((124-$mcu_id))
ping -c 5 169.254.71.$ip_last
res=$?
if [[ $res -eq 0 ]]; then
echo "----DONE setting up $mcu_role $mcu_id!----"
else
echo "FAILED!"
exit
fi