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:
Creative Lau 2021-07-27 13:56:07 +08:00
parent 56d2629763
commit b92ba84bfb
3 changed files with 1138 additions and 1115 deletions

View File

@ -24,6 +24,7 @@ import sys
import argparse
import stcgal
import serial
from stcgal.models import MCUModelDatabase
from stcgal.utils import BaudType
from stcgal.protocols import Stc89Protocol
from stcgal.protocols import Stc12AProtocol
@ -107,8 +108,14 @@ class StcGal:
def program_mcu(self):
"""Execute the standard programming flow."""
code_size = self.protocol.model.code
ee_size = self.protocol.model.eeprom
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
ee_size = self.protocol.model.eeprom
print("Loading flash: ", end="")
sys.stdout.flush()
@ -140,8 +147,6 @@ class StcGal:
if 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.erase_flash(len(bindata), code_size)
self.protocol.program_flash(bindata)

File diff suppressed because it is too large Load Diff

View File

@ -86,6 +86,8 @@ class StcBaseProtocol(ABC):
self.mcu_bsl_version = ""
self.options = None
self.model = None
self.split_eeprom = None
self.split_code = None
self.uid = None
self.debug = False
self.status_packet = None
@ -1613,6 +1615,9 @@ class Stc8Protocol(Stc15Protocol):
print("Target ref. voltage: %d mV" % self.reference_voltage)
print("Target mfg. date: %04d-%02d-%02d" % self.mfg_date)
def set_option(self, name, value):
super().set_option(name, value)
def calibrate(self):
"""Calibrate selected user frequency frequency and switch to selected baudrate."""
@ -1881,7 +1886,13 @@ class Stc8dProtocol(Stc8Protocol):
def __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):
"""Choose appropriate trim value mean for next round from challenge
responses."""