@@ -8,21 +8,25 @@ echo "-----------------------"
88while :
99do
1010
11+ NOW=` date -u +' %d/%m/%Y - %H:%M:%S' `
12+
1113 echo " "
12- read -p " Press Enter key to start, or Ctrl-C to quit"
1314 echo " " >> log.txt
15+ read -p " Press Enter key to start, or Ctrl-C to quit"
1416
1517 # Automatically assign port depending if MacOS or Linux
1618 if [ " ` uname` " = Darwin ]; then
17- PORT=` ls /dev/cu.usbmodem* 1 2> /dev/null | grep " cu. " `
19+ PORT=` ls /dev/cu.usbmodem* 1 2> /dev/null`
1820 else
19- PORT=/dev/ttyACM0 2> /dev/null
21+ PORT=` ls /dev/ttyACM0 2> /dev/null`
2022 fi
2123
22- # Create timestamp
23- NOW=` date -u +' %d/%m/%Y - %H:%M:%S' `
24+ if [ $? -eq 1 ]; then
25+ echo " $NOW - Error: Programmer not found" | tee -a log.txt
26+ continue
27+ fi
2428
25- # Unlock chip
29+ # Unlock chip (and ignore errors)
2630 echo " $NOW - Unlocking chip" | tee -a log.txt
2731 arm-none-eabi-gdb \
2832 -nx \
4448 -ex " monitor erase_mass" \
4549 2> /dev/null
4650
47- # If successful, continue otherwise throw and error and return to top of loop
48- if [ $? -eq 0 ]; then
49-
50- # Get and print device ID
51- echo -n " $NOW - " | tee -a log.txt
52- arm-none-eabi-gdb \
53- -nx \
54- --batch-silent \
55- -ex " target extended-remote ${PORT} " \
56- -ex " monitor swd_scan" \
57- -ex " attach 1" \
58- -ex " set logging file /dev/stdout" \
59- -ex " set logging enabled on" \
60- -ex " monitor read deviceid" \
61- -ex " set logging enabled off" \
62- 2> /dev/null \
63- | tee -a log.txt
64-
65- # Get and print device address
66- echo -n " $NOW - " | tee -a log.txt
67- arm-none-eabi-gdb \
68- -nx \
69- --batch-silent \
70- -ex " target extended-remote ${PORT} " \
71- -ex " monitor swd_scan" \
72- -ex " attach 1" \
73- -ex " set logging file /dev/stdout" \
74- -ex " set logging enabled on" \
75- -ex " monitor read deviceaddr" \
76- -ex " set logging enabled off" \
77- 2> /dev/null \
78- | tee -a log.txt
79-
80- # Program sections
81- echo " $NOW - Programming chip. Please wait"
82- arm-none-eabi-gdb \
83- -nx \
84- --batch-silent \
85- -ex " target extended-remote ${PORT} " \
86- -ex ' monitor swd_scan' \
87- -ex ' attach 1' \
88- -ex ' load' \
89- -ex ' compare-sections' \
90- -ex ' kill' \
91- frame-firmware-v* .hex \
92- 2> /dev/null
93-
94- # If successful, start the camera focusing script otherwise throw error
95- if [ $? -eq 0 ]; then
96- echo " $NOW - Programmed successfully" | tee -a log.txt
97- echo -n " Press y if display is working, otherwise n"
98- read -s -n1 input
99-
100- # If okay, test the microphone
101- if [ $input == " y" ]; then
102- echo -e -n $" \r\033[2K"
103- echo " $NOW - Display okay" | tee -a log.txt
104-
105- echo -e -n " Recording audio\r"
106- python test_microphone_script.py
107- echo -e -n $" \r\033[2K"
108- echo -n " Press y if microphone is working, otherwise n"
109- read -s -n1 input
110-
111- # Run the camera focusing script
112- if [ $input == " y" ]; then
113- echo -e -n $" \r\033[2K"
114- echo " $NOW - Microphone okay" | tee -a log.txt
115-
116- python focus_camera_script.py 2> /dev/null
117-
118- # Done
119- if [ $? -eq 0 ]; then
120-
121- echo -e -n $" \r\033[2K"
122- echo " $NOW - Camera focused" | tee -a log.txt
123- echo " $NOW - Done" | tee -a log.txt
124-
125- else
126- echo -e -n $" \r\033[2K"
127- echo " $NOW - Error: Could not connect to start focusing" | tee -a log.txt
128- fi
129-
130- else
131- echo -e -n $" \r\033[2K"
132- echo " $NOW - Error: Microphone not working" | tee -a log.txt
133- fi
134-
135- else
136- echo -e -n $" \r\033[2K"
137- echo " $NOW - Error: Display not working" | tee -a log.txt
138- fi
139-
140- else
141- echo " $NOW - Error: Chip could not be programmed" | tee -a log.txt
142- fi
143-
144- else
51+ if [ $? -eq 1 ]; then
14552 echo " $NOW - Error: Chip not found" | tee -a log.txt
53+ continue
54+ fi
55+
56+ # Get and print device ID
57+ echo -n " $NOW - " | tee -a log.txt
58+ arm-none-eabi-gdb \
59+ -nx \
60+ --batch-silent \
61+ -ex " target extended-remote ${PORT} " \
62+ -ex " monitor swd_scan" \
63+ -ex " attach 1" \
64+ -ex " set logging file /dev/stdout" \
65+ -ex " set logging enabled on" \
66+ -ex " monitor read deviceid" \
67+ -ex " set logging enabled off" \
68+ 2> /dev/null \
69+ | tee -a log.txt
70+
71+ # Get and print device address
72+ echo -n " $NOW - " | tee -a log.txt
73+ arm-none-eabi-gdb \
74+ -nx \
75+ --batch-silent \
76+ -ex " target extended-remote ${PORT} " \
77+ -ex " monitor swd_scan" \
78+ -ex " attach 1" \
79+ -ex " set logging file /dev/stdout" \
80+ -ex " set logging enabled on" \
81+ -ex " monitor read deviceaddr" \
82+ -ex " set logging enabled off" \
83+ 2> /dev/null \
84+ | tee -a log.txt
85+
86+ # Program sections
87+ echo " $NOW - Programming chip. Please wait"
88+ arm-none-eabi-gdb \
89+ -nx \
90+ --batch-silent \
91+ -ex " target extended-remote ${PORT} " \
92+ -ex ' monitor swd_scan' \
93+ -ex ' attach 1' \
94+ -ex ' load' \
95+ -ex ' compare-sections' \
96+ -ex ' kill' \
97+ frame-firmware-v* .hex \
98+ 2> /dev/null
99+
100+ if [ $? -eq 1 ]; then
101+ echo " $NOW - Error: Chip could not be programmed" | tee -a log.txt
102+ continue
103+ fi
104+
105+ echo " $NOW - Programmed successfully" | tee -a log.txt
106+
107+ # Short delay to allow the chip to boot
108+ sleep 3
109+
110+ # Test display/LED
111+ echo -e -n " Running display/LED test\r"
112+ python test_display_led_script.py 2> /dev/null
113+
114+ if [ $? -eq 1 ]; then
115+ echo -e -n $" \r\033[2K"
116+ echo " $NOW - Error: Could not connect to start microphone test" | tee -a log.txt
117+ continue
118+ fi
119+
120+ echo -n " Press y if display/LED is working, otherwise n"
121+ read -s -n1 input
122+
123+ if [ $input == " n" ]; then
124+ echo -e -n $" \r\033[2K"
125+ echo " $NOW - Error: Display/LED not working" | tee -a log.txt
126+ continue
146127 fi
147128
129+ echo -e -n $" \r\033[2K"
130+ echo " $NOW - Display/LED okay" | tee -a log.txt
131+
132+ # Test microphone
133+ echo -e -n " Recording audio\r"
134+ python test_microphone_script.py 2> /dev/null
135+
136+ if [ $? -eq 1 ]; then
137+ echo -e -n $" \r\033[2K"
138+ echo " $NOW - Error: Could not connect to start microphone test" | tee -a log.txt
139+ continue
140+ fi
141+
142+ echo -e -n $" \r\033[2K"
143+ echo -n " Press y if microphone is working, otherwise n"
144+ read -s -n1 input
145+
146+ if [ $input == " n" ]; then
147+ echo -e -n $" \r\033[2K"
148+ echo " $NOW - Error: Microphone not working" | tee -a log.txt
149+ continue
150+ fi
151+
152+ echo -e -n $" \r\033[2K"
153+ echo " $NOW - Microphone okay" | tee -a log.txt
154+
155+ # Run the camera focusing script
156+ python test_focus_camera_script.py 2> /dev/null
157+
158+ if [ $? -eq 1 ]; then
159+ echo -e -n $" \r\033[2K"
160+ echo " $NOW - Error: Could not connect to start focusing" | tee -a log.txt
161+ continue
162+ fi
163+
164+ echo -e -n $" \r\033[2K"
165+ echo " $NOW - Camera focused" | tee -a log.txt
166+
167+ echo " $NOW - Done" | tee -a log.txt
168+
148169done
0 commit comments