-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_umtrx_reset.py
72 lines (58 loc) · 1.74 KB
/
test_umtrx_reset.py
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
import os
import sys
import time
import subprocess
LOG = '/var/log/umtrx-log/current'
PRODUCTION = (
"SPI Flash has been initialized",
"Checking for valid production FPGA image...",
"Valid production FPGA image found. Attempting to boot.",
"SPI Flash has been initialized",
"Valid production firmware found. Loading...",
"Finished loading. Starting image.",
"TxRx-UHD-ZPU",
"LMS1 chip version = 0x22",
"LMS2 chip version = 0x22",
"eth link changed: speed = 1000")
SAFE = (
"SPI Flash has been initialized",
"Starting UmTRX in safe mode. Loading safe firmware.",
"LMS1 chip version = 0x22",
"LMS2 chip version = 0x22",
"eth link changed: speed = 1000")
def check_events(f, events, timeout):
start = time.time()
pos = 0
log = []
while time.time() - start < timeout:
for l in f:
# print (l)
log.append(l)
if l.find(events[pos]) >= 0:
print("FOUND: %s" % events[pos])
pos += 1
if pos == len(events):
return True
time.sleep(1)
print("FAILED!!!: %s" % str(log))
return False
with open(LOG, 'rt') as f:
# empty buffer
# for l in f:
# print ("Flashing out: %s", l)
# pass
f.seek(0, 2)
ret = subprocess.call("umtrx-safe-reset.sh", shell=True)
if ret != 0:
print("Unable to execute umtrx-safe-reset.sh")
sys.exit(1)
check_events(f, SAFE, 15) or sys.exit(2)
f.seek(0, 2)
ret = subprocess.call("umtrx-reset.sh", shell=True)
if ret != 0:
print("Unable to execute umtrx-safe-reset.sh")
sys.exit(3)
time.sleep(30)
check_events(f, PRODUCTION, 15) or sys.exit(4)
print("SUCCESS")
sys.exit(0)