Repair EEPROM program process of IAP serial MCU
The release V1.6 could download EEPROM file correctly when use the option 'program_eeprom_split' and splited eeprom larger than 512 Bytes for IAP serial MCU. Repaired now!
This commit is contained in:
parent
56d2629763
commit
b92ba84bfb
@ -24,6 +24,7 @@ import sys
|
|||||||
import argparse
|
import argparse
|
||||||
import stcgal
|
import stcgal
|
||||||
import serial
|
import serial
|
||||||
|
from stcgal.models import MCUModelDatabase
|
||||||
from stcgal.utils import BaudType
|
from stcgal.utils import BaudType
|
||||||
from stcgal.protocols import Stc89Protocol
|
from stcgal.protocols import Stc89Protocol
|
||||||
from stcgal.protocols import Stc12AProtocol
|
from stcgal.protocols import Stc12AProtocol
|
||||||
@ -107,6 +108,12 @@ class StcGal:
|
|||||||
def program_mcu(self):
|
def program_mcu(self):
|
||||||
"""Execute the standard programming flow."""
|
"""Execute the standard programming flow."""
|
||||||
|
|
||||||
|
if self.opts.option: self.emit_options(self.opts.option)
|
||||||
|
|
||||||
|
if self.protocol.split_code and self.protocol.model.name in MCUModelDatabase.MCU_IAP_List:
|
||||||
|
code_size = self.protocol.split_code
|
||||||
|
ee_size = self.protocol.split_eeprom
|
||||||
|
else:
|
||||||
code_size = self.protocol.model.code
|
code_size = self.protocol.model.code
|
||||||
ee_size = self.protocol.model.eeprom
|
ee_size = self.protocol.model.eeprom
|
||||||
|
|
||||||
@ -140,8 +147,6 @@ class StcGal:
|
|||||||
if len(bindata) % 512:
|
if len(bindata) % 512:
|
||||||
bindata += b'\xff' * (512 - len(bindata) % 512)
|
bindata += b'\xff' * (512 - len(bindata) % 512)
|
||||||
|
|
||||||
if self.opts.option: self.emit_options(self.opts.option)
|
|
||||||
|
|
||||||
self.protocol.handshake()
|
self.protocol.handshake()
|
||||||
self.protocol.erase_flash(len(bindata), code_size)
|
self.protocol.erase_flash(len(bindata), code_size)
|
||||||
self.protocol.program_flash(bindata)
|
self.protocol.program_flash(bindata)
|
||||||
|
@ -31,6 +31,13 @@ class MCUModelDatabase:
|
|||||||
|
|
||||||
MCUModel = collections.namedtuple("MCUModel", ["name", "magic", "total", "code", "eeprom"])
|
MCUModel = collections.namedtuple("MCUModel", ["name", "magic", "total", "code", "eeprom"])
|
||||||
|
|
||||||
|
MCU_IAP_List = ("STC8H1K28", "STC8H1K33", "STC8H1K12", "STC8H1K17", "STC8H3K64S4", "STC8H3K64S2",
|
||||||
|
"STC8H8K64U", "STC8H2K64T", "STC8G1K12-20/16P", "STC8G1K17-20/16P", "STC8G1K12-8P",
|
||||||
|
"STC8G1K17-8P", "STC8G1K12A-8P", "STC8G1K17A-8P", "STC8G1K12T", "STC8G1K17T",
|
||||||
|
"STC8G2K64S4", "STC8G2K64S2", "STC8A8K64S4A12", "STC8A4K64S2A12", "STC8F2K64S4",
|
||||||
|
"SATC8F2K64S2", "STC8F1K12S2", "STC8F1K17S2", "STC8C2K64S4", "STC8C2K64S2",
|
||||||
|
"STC8A8K64D4", "STC12H1K28", "STC12H1K33")
|
||||||
|
|
||||||
models =(
|
models =(
|
||||||
MCUModel(name='STC12H1K04', magic=0xf7b0, total=36864, code=4096, eeprom=24576),
|
MCUModel(name='STC12H1K04', magic=0xf7b0, total=36864, code=4096, eeprom=24576),
|
||||||
MCUModel(name='STC12H1K08', magic=0xf7b1, total=36864, code=8192, eeprom=20480),
|
MCUModel(name='STC12H1K08', magic=0xf7b1, total=36864, code=8192, eeprom=20480),
|
||||||
|
@ -86,6 +86,8 @@ class StcBaseProtocol(ABC):
|
|||||||
self.mcu_bsl_version = ""
|
self.mcu_bsl_version = ""
|
||||||
self.options = None
|
self.options = None
|
||||||
self.model = None
|
self.model = None
|
||||||
|
self.split_eeprom = None
|
||||||
|
self.split_code = None
|
||||||
self.uid = None
|
self.uid = None
|
||||||
self.debug = False
|
self.debug = False
|
||||||
self.status_packet = None
|
self.status_packet = None
|
||||||
@ -1613,6 +1615,9 @@ class Stc8Protocol(Stc15Protocol):
|
|||||||
print("Target ref. voltage: %d mV" % self.reference_voltage)
|
print("Target ref. voltage: %d mV" % self.reference_voltage)
|
||||||
print("Target mfg. date: %04d-%02d-%02d" % self.mfg_date)
|
print("Target mfg. date: %04d-%02d-%02d" % self.mfg_date)
|
||||||
|
|
||||||
|
def set_option(self, name, value):
|
||||||
|
super().set_option(name, value)
|
||||||
|
|
||||||
def calibrate(self):
|
def calibrate(self):
|
||||||
"""Calibrate selected user frequency frequency and switch to selected baudrate."""
|
"""Calibrate selected user frequency frequency and switch to selected baudrate."""
|
||||||
|
|
||||||
@ -1882,6 +1887,12 @@ class Stc8dProtocol(Stc8Protocol):
|
|||||||
def __init__(self, port, handshake, baud, trim):
|
def __init__(self, port, handshake, baud, trim):
|
||||||
Stc8Protocol.__init__(self, port, handshake, baud, trim)
|
Stc8Protocol.__init__(self, port, handshake, baud, trim)
|
||||||
|
|
||||||
|
def set_option(self, name, value):
|
||||||
|
super().set_option(name, value)
|
||||||
|
if name=='program_eeprom_split':
|
||||||
|
self.split_code = Utils.to_int(value);
|
||||||
|
self.split_eeprom = self.model.total - Utils.to_int(value);
|
||||||
|
|
||||||
def choose_range(self, packet, response, target_count):
|
def choose_range(self, packet, response, target_count):
|
||||||
"""Choose appropriate trim value mean for next round from challenge
|
"""Choose appropriate trim value mean for next round from challenge
|
||||||
responses."""
|
responses."""
|
||||||
|
Loading…
Reference in New Issue
Block a user