diff --git a/doc/reverse-engineering/dump-mcu.py b/doc/reverse-engineering/dump-mcu.py index 9131acf..2b3eebd 100644 --- a/doc/reverse-engineering/dump-mcu.py +++ b/doc/reverse-engineering/dump-mcu.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 # This curious script dumps all model info from STC-ISP. # Data is directly read from the binary. -# Offsets are for stc-isp-15xx-v6.86O.exe, sha1sum f70e317d758ef8c942613a8b0540147d7170589b +# Offsets are for stc-isp-15xx-v6.87P.exe, sha256sum d5413728d87cf5d7a6e036348ade5b38cce13113ae3bb090cfac7a232ba82a53 -MCU_TABLE_OFFSET = 0x0006ac80 -MCU_TABLE_SIZE = 984 +MCU_TABLE_OFFSET = 0x00071c30 +MCU_TABLE_SIZE = 1068 MCU_RECORD_SIZE = 32 -MCU_NAMES_OFFSET = 0x00087810 -MCU_NAMES_PTR_OFFSET = 0x00487810 +MCU_NAMES_OFFSET = 0x000924E8 +MCU_NAMES_PTR_OFFSET = 0x004924e8 import struct import sys diff --git a/stcgal/models.py b/stcgal/models.py index e7eba31..6822d0d 100644 --- a/stcgal/models.py +++ b/stcgal/models.py @@ -32,13 +32,90 @@ class MCUModelDatabase: MCUModel = collections.namedtuple("MCUModel", ["name", "magic", "total", "code", "eeprom"]) models = ( - MCUModel(name='STC8F1K02S2', magic=0xf661, total=20480, code=2048, eeprom=10240), - MCUModel(name='STC8F1K04S2', magic=0xf662, total=20480, code=4096, eeprom=8192), - MCUModel(name='STC8F1K06S2', magic=0xf663, total=20480, code=6144, eeprom=6144), - MCUModel(name='STC8F1K08S2', magic=0xf664, total=20480, code=8192, eeprom=4096), - MCUModel(name='STC8F1K10S2', magic=0xf665, total=20480, code=10240, eeprom=2048), - MCUModel(name='STC8F1K12S2', magic=0xf666, total=20480, code=12288, eeprom=0), - MCUModel(name='STC8F1K17S2', magic=0xf667, total=20480, code=17408, eeprom=0), + MCUModel(name='STC12H1K04', magic=0xf7b0, total=36864, code=4096, eeprom=24576), + MCUModel(name='STC12H1K08', magic=0xf7b1, total=36864, code=8192, eeprom=20480), + MCUModel(name='STC12H1K12', magic=0xf7b2, total=36864, code=12288, eeprom=16384), + MCUModel(name='STC12H1K16', magic=0xf7b3, total=36864, code=16384, eeprom=12288), + MCUModel(name='STC12H1K20', magic=0xf7b4, total=36864, code=20480, eeprom=8192), + MCUModel(name='STC12H1K24', magic=0xf7b5, total=36864, code=24576, eeprom=4096), + MCUModel(name='STC12H1K28', magic=0xf7b6, total=36864, code=28672, eeprom=0), + MCUModel(name='STC12H1K33', magic=0xf7b7, total=36864, code=33792, eeprom=0), + MCUModel(name='STC8H2K16T', magic=0xf7c1, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8H2K32T', magic=0xf7c2, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8H2K60T', magic=0xf7c3, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8H2K64T', magic=0xf7c4, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8H3K16S4', magic=0xf741, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8H3K32S4', magic=0xf742, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8H3K60S4', magic=0xf743, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8H3K64S4', magic=0xf744, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8H3K16S2', magic=0xf749, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8H3K32S2', magic=0xf74a, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8H3K60S2', magic=0xf74b, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8H3K64S2', magic=0xf74c, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8H8K16U', magic=0xf781, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8H8K32U', magic=0xf782, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8H8K60U', magic=0xf783, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8H8K64U', magic=0xf784, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8H1K16', magic=0xf721, total=36864, code=16384, eeprom=12288), + MCUModel(name='STC8H1K20', magic=0xf722, total=36864, code=20480, eeprom=8192), + MCUModel(name='STC8H1K24', magic=0xf723, total=36864, code=24576, eeprom=4096), + MCUModel(name='STC8H1K28', magic=0xf724, total=36864, code=28672, eeprom=0), + MCUModel(name='STC8H1K33', magic=0xf725, total=36864, code=33792, eeprom=0), + MCUModel(name='STC8H1K02', magic=0xf731, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8H1K04', magic=0xf732, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8H1K06', magic=0xf733, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8H1K08', magic=0xf734, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8H1K10', magic=0xf735, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8H1K12', magic=0xf736, total=20480, code=12288, eeprom=0), + MCUModel(name='STC8H1K17', magic=0xf737, total=20480, code=17408, eeprom=0), + MCUModel(name='STC8G2K16S4', magic=0xf761, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8G2K32S4', magic=0xf762, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8G2K60S4', magic=0xf763, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8G2K64S4', magic=0xf764, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8G2K16S2', magic=0xf769, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8G2K32S2', magic=0xf76a, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8G2K60S2', magic=0xf76b, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8G2K64S2', magic=0xf76c, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8G1K02T', magic=0xf771, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8G1K04T', magic=0xf772, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8G1K06T', magic=0xf773, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8G1K08T', magic=0xf774, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8G1K10T', magic=0xf775, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8G1K12T', magic=0xf776, total=20480, code=12288, eeprom=0), + MCUModel(name='STC8G1K17T', magic=0xf777, total=20480, code=17408, eeprom=0), + MCUModel(name='STC8G1K02A-8PIN', magic=0xf791, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8G1K04A-8PIN', magic=0xf792, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8G1K06A-8PIN', magic=0xf793, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8G1K08A-8PIN', magic=0xf794, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8G1K10A-8PIN', magic=0xf795, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8G1K12A-8PIN', magic=0xf796, total=20480, code=12288, eeprom=0), + MCUModel(name='STC8G1K17A-8PIN', magic=0xf797, total=20480, code=17408, eeprom=0), + MCUModel(name='STC8G1K02-8PIN', magic=0xf7a1, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8G1K04-8PIN', magic=0xf7a2, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8G1K06-8PIN', magic=0xf7a3, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8G1K08-8PIN', magic=0xf7a4, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8G1K10-8PIN', magic=0xf7a5, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8G1K12-8PIN', magic=0xf7a6, total=20480, code=12288, eeprom=0), + MCUModel(name='STC8G1K17-8PIN', magic=0xf7a7, total=20480, code=17408, eeprom=0), + MCUModel(name='STC8G1K02-20/16P', magic=0xf751, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8G1K04-20/16P', magic=0xf752, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8G1K06-20/16P', magic=0xf753, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8G1K08-20/16P', magic=0xf754, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8G1K10-20/16P', magic=0xf755, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8G1K12-20/16P', magic=0xf756, total=20480, code=12288, eeprom=0), + MCUModel(name='STC8G1K17-20/16P', magic=0xf757, total=20480, code=17408, eeprom=0), + MCUModel(name='STC8C2K16S4', magic=0xf7d1, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8C2K32S4', magic=0xf7d2, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8C2K60S4', magic=0xf7d3, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8C2K64S4', magic=0xf7d4, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8C1K02', magic=0xf701, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8C1K04', magic=0xf702, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8C1K06', magic=0xf703, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8C1K08', magic=0xf704, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8C1K10', magic=0xf705, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8C1K12', magic=0xf706, total=20480, code=12288, eeprom=0), + MCUModel(name='GX8S003', magic=0xf714, total=20480, code=8192, eeprom=4096), + MCUModel(name='GX8S012', magic=0xf716, total=20480, code=12288, eeprom=0), MCUModel(name='STC8F1K02', magic=0xf671, total=20480, code=2048, eeprom=10240), MCUModel(name='STC8F1K04', magic=0xf672, total=20480, code=4096, eeprom=8192), MCUModel(name='STC8F1K06', magic=0xf673, total=20480, code=6144, eeprom=6144), @@ -46,48 +123,13 @@ class MCUModelDatabase: MCUModel(name='STC8F1K10', magic=0xf675, total=20480, code=10240, eeprom=2048), MCUModel(name='STC8F1K12', magic=0xf676, total=20480, code=12288, eeprom=0), MCUModel(name='STC8F1K17', magic=0xf677, total=20480, code=17408, eeprom=0), - MCUModel(name='STC15U4K16S4', magic=0xf580, total=65536, code=16384, eeprom=44032), - MCUModel(name='STC15U4K24S4', magic=0xf581, total=65536, code=24576, eeprom=35840), - MCUModel(name='STC15U4K32S4', magic=0xf582, total=65536, code=32768, eeprom=27648), - MCUModel(name='STC15U4K40S4', magic=0xf583, total=65536, code=40960, eeprom=19456), - MCUModel(name='STC15U4K48S4', magic=0xf584, total=65536, code=49152, eeprom=11264), - MCUModel(name='STC15U4K56S4', magic=0xf585, total=65536, code=57344, eeprom=3072), - MCUModel(name='STC8A8K08S4A12', magic=0xf621, total=65536, code=8192, eeprom=57344), - MCUModel(name='STC8A8K16S4A12', magic=0xf622, total=65536, code=16384, eeprom=49152), - MCUModel(name='STC8A8K24S4A12', magic=0xf623, total=65536, code=24576, eeprom=40960), - MCUModel(name='STC8A8K32S4A12', magic=0xf624, total=65536, code=32768, eeprom=32768), - MCUModel(name='STC8A8K40S4A12', magic=0xf625, total=65536, code=40960, eeprom=24576), - MCUModel(name='STC8A8K48S4A12', magic=0xf626, total=65536, code=49152, eeprom=16384), - MCUModel(name='STC8A8K56S4A12', magic=0xf627, total=65536, code=57344, eeprom=8192), - MCUModel(name='STC8A8K60S4A12', magic=0xf629, total=65536, code=61440, eeprom=4096), - MCUModel(name='STC8A8K64S4A12', magic=0xf628, total=65536, code=65024, eeprom=512), - MCUModel(name='STC8A4K08S2A12', magic=0xf651, total=65536, code=8192, eeprom=57344), - MCUModel(name='STC8A4K16S2A12', magic=0xf652, total=65536, code=16384, eeprom=49152), - MCUModel(name='STC8A4K24S2A12', magic=0xf653, total=65536, code=24576, eeprom=40960), - MCUModel(name='STC8A4K32S2A12', magic=0xf654, total=65536, code=32768, eeprom=32768), - MCUModel(name='STC8A4K40S2A12', magic=0xf655, total=65536, code=40960, eeprom=24576), - MCUModel(name='STC8A4K48S2A12', magic=0xf656, total=65536, code=49152, eeprom=16384), - MCUModel(name='STC8A4K56S2A12', magic=0xf657, total=65536, code=57344, eeprom=8192), - MCUModel(name='STC8A4K60S2A12', magic=0xf659, total=65536, code=61440, eeprom=4096), - MCUModel(name='STC8A4K64S2A12', magic=0xf658, total=65536, code=65024, eeprom=512), - MCUModel(name='STC8F8K08S4A12', magic=0xf611, total=65536, code=8192, eeprom=57344), - MCUModel(name='STC8F8K16S4A12', magic=0xf612, total=65536, code=16384, eeprom=49152), - MCUModel(name='STC8F8K24S4A12', magic=0xf613, total=65536, code=24576, eeprom=40960), - MCUModel(name='STC8F8K32S4A12', magic=0xf614, total=65536, code=32768, eeprom=32768), - MCUModel(name='STC8F8K40S4A12', magic=0xf615, total=65536, code=40960, eeprom=24576), - MCUModel(name='STC8F8K48S4A12', magic=0xf616, total=65536, code=49152, eeprom=16384), - MCUModel(name='STC8F8K56S4A12', magic=0xf617, total=65536, code=57344, eeprom=8192), - MCUModel(name='STC8F8K60S4A12', magic=0xf619, total=65536, code=61440, eeprom=4096), - MCUModel(name='STC8F8K64S4A12', magic=0xf618, total=65536, code=65024, eeprom=512), - MCUModel(name='STC8F2K08S4', magic=0xf631, total=65536, code=8192, eeprom=57344), - MCUModel(name='STC8F2K16S4', magic=0xf632, total=65536, code=16384, eeprom=49152), - MCUModel(name='STC8F2K24S4', magic=0xf633, total=65536, code=24576, eeprom=40960), - MCUModel(name='STC8F2K32S4', magic=0xf634, total=65536, code=32768, eeprom=32768), - MCUModel(name='STC8F2K40S4', magic=0xf635, total=65536, code=40960, eeprom=24576), - MCUModel(name='STC8F2K48S4', magic=0xf636, total=65536, code=49152, eeprom=16384), - MCUModel(name='STC8F2K56S4', magic=0xf637, total=65536, code=57344, eeprom=8192), - MCUModel(name='STC8F2K60S4', magic=0xf639, total=65536, code=61440, eeprom=4096), - MCUModel(name='STC8F2K64S4', magic=0xf638, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8F1K02S2', magic=0xf661, total=20480, code=2048, eeprom=10240), + MCUModel(name='STC8F1K04S2', magic=0xf662, total=20480, code=4096, eeprom=8192), + MCUModel(name='STC8F1K06S2', magic=0xf663, total=20480, code=6144, eeprom=6144), + MCUModel(name='STC8F1K08S2', magic=0xf664, total=20480, code=8192, eeprom=4096), + MCUModel(name='STC8F1K10S2', magic=0xf665, total=20480, code=10240, eeprom=2048), + MCUModel(name='STC8F1K12S2', magic=0xf666, total=20480, code=12288, eeprom=0), + MCUModel(name='STC8F1K17S2', magic=0xf667, total=20480, code=17408, eeprom=0), MCUModel(name='STC8F2K08S2', magic=0xf641, total=65536, code=8192, eeprom=57344), MCUModel(name='STC8F2K16S2', magic=0xf642, total=65536, code=16384, eeprom=49152), MCUModel(name='STC8F2K24S2', magic=0xf643, total=65536, code=24576, eeprom=40960), @@ -97,6 +139,42 @@ class MCUModelDatabase: MCUModel(name='STC8F2K56S2', magic=0xf647, total=65536, code=57344, eeprom=8192), MCUModel(name='STC8F2K60S2', magic=0xf649, total=65536, code=61440, eeprom=4096), MCUModel(name='STC8F2K64S2', magic=0xf648, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8F2K08S4', magic=0xf631, total=65536, code=8192, eeprom=57344), + MCUModel(name='STC8F2K16S4', magic=0xf632, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8F2K24S4', magic=0xf633, total=65536, code=24576, eeprom=40960), + MCUModel(name='STC8F2K32S4', magic=0xf634, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8F2K40S4', magic=0xf635, total=65536, code=40960, eeprom=24576), + MCUModel(name='STC8F2K48S4', magic=0xf636, total=65536, code=49152, eeprom=16384), + MCUModel(name='STC8F2K56S4', magic=0xf637, total=65536, code=57344, eeprom=8192), + MCUModel(name='STC8F2K60S4', magic=0xf639, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8F2K64S4', magic=0xf638, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8F8K08S4A12', magic=0xf611, total=65536, code=8192, eeprom=57344), + MCUModel(name='STC8F8K16S4A12', magic=0xf612, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8F8K24S4A12', magic=0xf613, total=65536, code=24576, eeprom=40960), + MCUModel(name='STC8F8K32S4A12', magic=0xf614, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8F8K40S4A12', magic=0xf615, total=65536, code=40960, eeprom=24576), + MCUModel(name='STC8F8K48S4A12', magic=0xf616, total=65536, code=49152, eeprom=16384), + MCUModel(name='STC8F8K56S4A12', magic=0xf617, total=65536, code=57344, eeprom=8192), + MCUModel(name='STC8F8K60S4A12', magic=0xf619, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8F8K64S4A12', magic=0xf618, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8A4K08S2A12', magic=0xf651, total=65536, code=8192, eeprom=57344), + MCUModel(name='STC8A4K16S2A12', magic=0xf652, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8A4K24S2A12', magic=0xf653, total=65536, code=24576, eeprom=40960), + MCUModel(name='STC8A4K32S2A12', magic=0xf654, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8A4K40S2A12', magic=0xf655, total=65536, code=40960, eeprom=24576), + MCUModel(name='STC8A4K48S2A12', magic=0xf656, total=65536, code=49152, eeprom=16384), + MCUModel(name='STC8A4K56S2A12', magic=0xf657, total=65536, code=57344, eeprom=8192), + MCUModel(name='STC8A4K60S2A12', magic=0xf659, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8A4K64S2A12', magic=0xf658, total=65536, code=65024, eeprom=512), + MCUModel(name='STC8A8K08S4A12', magic=0xf621, total=65536, code=8192, eeprom=57344), + MCUModel(name='STC8A8K16S4A12', magic=0xf622, total=65536, code=16384, eeprom=49152), + MCUModel(name='STC8A8K24S4A12', magic=0xf623, total=65536, code=24576, eeprom=40960), + MCUModel(name='STC8A8K32S4A12', magic=0xf624, total=65536, code=32768, eeprom=32768), + MCUModel(name='STC8A8K40S4A12', magic=0xf625, total=65536, code=40960, eeprom=24576), + MCUModel(name='STC8A8K48S4A12', magic=0xf626, total=65536, code=49152, eeprom=16384), + MCUModel(name='STC8A8K56S4A12', magic=0xf627, total=65536, code=57344, eeprom=8192), + MCUModel(name='STC8A8K60S4A12', magic=0xf629, total=65536, code=61440, eeprom=4096), + MCUModel(name='STC8A8K64S4A12', magic=0xf628, total=65536, code=65024, eeprom=512), MCUModel(name='STC15H4K08S4', magic=0xf601, total=65536, code=8192, eeprom=57344), MCUModel(name='STC15H4K16S4', magic=0xf602, total=65536, code=16384, eeprom=49152), MCUModel(name='STC15H4K24S4', magic=0xf603, total=65536, code=24576, eeprom=40960), @@ -105,6 +183,12 @@ class MCUModelDatabase: MCUModel(name='STC15H4K48S4', magic=0xf606, total=65536, code=49152, eeprom=16384), MCUModel(name='STC15H4K56S4', magic=0xf607, total=65536, code=57344, eeprom=8192), MCUModel(name='STC15H4K64S4', magic=0xf608, total=65536, code=65024, eeprom=512), + MCUModel(name='STC15U4K16S4', magic=0xf580, total=65536, code=16384, eeprom=44032), + MCUModel(name='STC15U4K24S4', magic=0xf581, total=65536, code=24576, eeprom=35840), + MCUModel(name='STC15U4K32S4', magic=0xf582, total=65536, code=32768, eeprom=27648), + MCUModel(name='STC15U4K40S4', magic=0xf583, total=65536, code=40960, eeprom=19456), + MCUModel(name='STC15U4K48S4', magic=0xf584, total=65536, code=49152, eeprom=11264), + MCUModel(name='STC15U4K56S4', magic=0xf585, total=65536, code=57344, eeprom=3072), MCUModel(name='STC15F2K08S2', magic=0xf401, total=65536, code=8192, eeprom=54272), MCUModel(name='STC15F2K16S2', magic=0xf402, total=65536, code=16384, eeprom=46080), MCUModel(name='STC15F2K24S2', magic=0xf403, total=65536, code=24576, eeprom=37888),