Skip to content

Commit cefcc98

Browse files
committed
emergency china test fix 1
1 parent 3318aa7 commit cefcc98

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

src/ttboard/boot/rom.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
@copyright: Copyright (C) 2024 Pat Deegan, https://psychogenic.com
66
'''
77

8+
import ttboard.logging as logging
9+
log = logging.getLogger(__name__)
10+
import ttboard.util.time as time
11+
12+
813
class ChipROM:
914
def __init__(self, project_mux):
1015
self.project_mux = project_mux
@@ -14,19 +19,32 @@ def __init__(self, project_mux):
1419

1520
def _send_and_rcv(self, send:int):
1621
self._pins.input_byte = send
22+
time.sleep_ms(1)
1723
return self._pins.output_byte
1824

1925
@property
2026
def shuttle(self):
21-
return self.contents['shuttle']
27+
try:
28+
return self.contents['shuttle']
29+
log.error("ROM has no 'shuttle'")
30+
except:
31+
return ''
2232

2333
@property
2434
def repo(self):
25-
return self.contents['repo']
35+
try:
36+
return self.contents['repo']
37+
except:
38+
log.error("ROM has no 'repo'")
39+
return ''
2640

2741
@property
2842
def commit(self):
29-
return self.contents['commit']
43+
try:
44+
return self.contents['commit']
45+
except:
46+
log.error("ROM has no 'commit'")
47+
return ''
3048

3149
@property
3250
def contents(self):
@@ -44,7 +62,6 @@ def contents(self):
4462

4563
magic = self._send_and_rcv(0)
4664
if magic != 0x78:
47-
4865
return self._contents
4966

5067
rom_data = ''
@@ -54,14 +71,20 @@ def contents(self):
5471
break
5572
rom_data += chr(byte)
5673

74+
log.info(f'Got ROM data {rom_data}')
75+
5776
self._contents = {}
58-
for l in rom_data.splitlines():
59-
try:
60-
k,v = l.split('=')
61-
self._contents[k] = v
62-
except:
63-
pass
64-
77+
if not len(rom_data):
78+
log.warn("ROM data empty")
79+
else:
80+
for l in rom_data.splitlines():
81+
try:
82+
k,v = l.split('=')
83+
self._contents[k] = v
84+
except:
85+
log.warn(f"Issue splitting {l}")
86+
pass
87+
log.debug(f"GOT ROM: {self._contents}")
6588
return self._contents
6689

6790

0 commit comments

Comments
 (0)