Add and use MCU model database
This commit is contained in:
@ -19,14 +19,19 @@ for i in range(MCU_TABLE_SIZE):
|
||||
inp.seek(mcu_record_offset)
|
||||
mcu_record = inp.read(MCU_RECORD_SIZE)
|
||||
flags, name_ptr, mcu_id, code_size, ee_size, _, total_size, _ = struct.unpack("<8I", mcu_record)
|
||||
mcu_id &= 0xffff
|
||||
|
||||
mcu_name_offset = MCU_NAMES_OFFSET + (name_ptr - MCU_NAMES_PTR_OFFSET)
|
||||
inp.seek(mcu_name_offset)
|
||||
name_str = inp.read(16).split(b'\00')[0].decode("ascii")
|
||||
|
||||
# 1 KB are reserved for some reason. in some cases even more. very odd.
|
||||
if ee_size > 0 and not name_str.startswith("IAP"):
|
||||
ee_size -= 1024
|
||||
# XXX: 1 KB are reserved one *some* MCUs for some reason
|
||||
#if ee_size > 0 and not name_str.startswith("IAP"):
|
||||
# ee_size -= 1024
|
||||
|
||||
# STC12C54xx always have 12 KB eeprom
|
||||
if name_str.startswith("STC12C54"):
|
||||
ee_size = 12 * 1024
|
||||
|
||||
print("MCUModel(name='%s', magic=0x%02x%02x, total=%d, code=%d, eeprom=%d)," %
|
||||
(name_str, mcu_id >> 8, mcu_id & 0xff, total_size, code_size, ee_size))
|
||||
|
1296
doc/dump-mcu.txt
1296
doc/dump-mcu.txt
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,9 @@ D364 (STC11F08XE)
|
||||
^ pointer to name string
|
||||
^ feature flags?
|
||||
|
||||
NOTE: the upper word of the mcu id actually contains something else for STC12C54xx
|
||||
series, and the eeprom size is broken.
|
||||
|
||||
000509a0 00 d8 00 00 00 00 00 00 00 00 01 00 00 00 00 00 |................|
|
||||
^ total flash size (incl. reserved space)
|
||||
(32 bit le)
|
||||
|
Reference in New Issue
Block a user