From cefcc982472b5c55555e216a193dfa9458f8e1ba Mon Sep 17 00:00:00 2001 From: Pat Deegan Date: Mon, 29 Apr 2024 02:50:09 -0400 Subject: [PATCH] emergency china test fix 1 --- src/ttboard/boot/rom.py | 45 +++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/ttboard/boot/rom.py b/src/ttboard/boot/rom.py index bcbebe8..90ea4f1 100644 --- a/src/ttboard/boot/rom.py +++ b/src/ttboard/boot/rom.py @@ -5,6 +5,11 @@ @copyright: Copyright (C) 2024 Pat Deegan, https://psychogenic.com ''' +import ttboard.logging as logging +log = logging.getLogger(__name__) +import ttboard.util.time as time + + class ChipROM: def __init__(self, project_mux): self.project_mux = project_mux @@ -14,19 +19,32 @@ def __init__(self, project_mux): def _send_and_rcv(self, send:int): self._pins.input_byte = send + time.sleep_ms(1) return self._pins.output_byte @property def shuttle(self): - return self.contents['shuttle'] + try: + return self.contents['shuttle'] + log.error("ROM has no 'shuttle'") + except: + return '' @property def repo(self): - return self.contents['repo'] + try: + return self.contents['repo'] + except: + log.error("ROM has no 'repo'") + return '' @property def commit(self): - return self.contents['commit'] + try: + return self.contents['commit'] + except: + log.error("ROM has no 'commit'") + return '' @property def contents(self): @@ -44,7 +62,6 @@ def contents(self): magic = self._send_and_rcv(0) if magic != 0x78: - return self._contents rom_data = '' @@ -54,14 +71,20 @@ def contents(self): break rom_data += chr(byte) + log.info(f'Got ROM data {rom_data}') + self._contents = {} - for l in rom_data.splitlines(): - try: - k,v = l.split('=') - self._contents[k] = v - except: - pass - + if not len(rom_data): + log.warn("ROM data empty") + else: + for l in rom_data.splitlines(): + try: + k,v = l.split('=') + self._contents[k] = v + except: + log.warn(f"Issue splitting {l}") + pass + log.debug(f"GOT ROM: {self._contents}") return self._contents