From 9900e3088d6f5d33d30a83b9cdac898d363066b7 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sat, 9 Jan 2021 03:27:45 +0100 Subject: [PATCH] Blacklist STC8G series stcgal may brick these untested MCUs. Fixes #63. --- stcgal/models.py | 10 +++++++++- stcgal/protocols.py | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stcgal/models.py b/stcgal/models.py index 6822d0d..8507409 100644 --- a/stcgal/models.py +++ b/stcgal/models.py @@ -1143,10 +1143,18 @@ class MCUModelDatabase: MCUModel(name='IAP15L14AD', magic=0xd4de, total=14336, code=14336, eeprom=0), ) + @classmethod + def check_model(self, model): + # User reported bricked MCUs, GH #63 + if model.name.startswith("STC8G"): + raise ValueError("MCU model {} is blacklisted".format(model.name)) + @classmethod def find_model(self, magic): for model in self.models: - if model.magic == magic: return model + if model.magic == magic: + self.check_model(model) + return model raise NameError @classmethod diff --git a/stcgal/protocols.py b/stcgal/protocols.py index aeaed46..e7ed581 100644 --- a/stcgal/protocols.py +++ b/stcgal/protocols.py @@ -214,6 +214,8 @@ class StcBaseProtocol(ABC): print(msg, file=sys.stderr) self.model = MCUModelDatabase.MCUModel(name="UNKNOWN", magic=self.mcu_magic, total=63488, code=63488, eeprom=0) + except ValueError as ex: + raise StcProtocolException(ex) # special case for duplicated mcu magic, # 0xf294 (STC15F104W, STC15F104E)