Blacklist STC8G series

stcgal may brick these untested MCUs.

Fixes #63.
This commit is contained in:
Grigori Goronzy 2021-01-09 03:27:45 +01:00
parent 15e04c1626
commit 9900e3088d
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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)