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 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,8 +108,14 @@ class StcGal:
def program_mcu(self): def program_mcu(self):
"""Execute the standard programming flow.""" """Execute the standard programming flow."""
code_size = self.protocol.model.code if self.opts.option: self.emit_options(self.opts.option)
ee_size = self.protocol.model.eeprom
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="") print("Loading flash: ", end="")
sys.stdout.flush() sys.stdout.flush()
@ -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)

File diff suppressed because it is too large Load Diff

View File

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