optional resume at the end of uploading

This commit is contained in:
Sergey Shchelkanov 2023-04-25 16:25:35 +03:00
parent eebca60bda
commit 0978eed36d
4 changed files with 13 additions and 10 deletions

View File

@ -193,7 +193,7 @@ def eeprom_check_data_ahb_lite(openocd: OpenOcdTclRpc, words: list[int]) -> int:
return 0
def write_words(words: list[int], write_by_word = False, read_through_apb = False) -> int:
def write_words(words: list[int], write_by_word = False, read_through_apb = False, is_resume=True) -> int:
"""
Write words in MIK32 EEPROM through APB bus
@ -249,7 +249,8 @@ def write_words(words: list[int], write_by_word = False, read_through_apb = Fals
result = eeprom_check_data_apb(openocd, words)
else:
result = eeprom_check_data_ahb_lite(openocd, words)
openocd.resume(0)
if is_resume:
openocd.resume(0)
if result == 0:
print("EEPROM write file done!")
return result

View File

@ -2,10 +2,11 @@ from .tclrpc import TclException
from .tclrpc import OpenOcdTclRpc
from pathlib import Path
def write_file(filename):
def write_file(filename, is_resume=True):
with OpenOcdTclRpc() as openocd:
openocd.reset_halt()
print(openocd.run("load_image {%s} 0x0" % Path(filename)))
openocd.resume(0)
if is_resume:
openocd.resume(0)
print("RAM write file maybe done")

View File

@ -420,7 +420,7 @@ def spifi_write(openocd: OpenOcdTclRpc, address: int, data: list[int], data_len:
print("written")
def spifi_write_file(bytes: list[int]):
def spifi_write_file(bytes: list[int], is_resume=True):
"""
Write bytes in MIK32 External SPIFI Flash memory
@ -451,4 +451,5 @@ def spifi_write_file(bytes: list[int]):
spifi_write(openocd, address, bytes, len(bytes) - address)
spifi_read_data(openocd, address, len(bytes) - address, bytes)
print("end")
openocd.resume(0)
if is_resume:
openocd.resume(0)

View File

@ -32,7 +32,7 @@ def test_connection():
raise Exception("ERROR: no regs found, check MCU connection")
def upload_file(filename: str, boot_source: str = "eeprom") -> int:
def upload_file(filename: str, boot_source: str = "eeprom", is_resume=True) -> int:
"""
Write ihex or binary file into MIK32 EEPROM or external flash memory
@ -69,12 +69,12 @@ def upload_file(filename: str, boot_source: str = "eeprom") -> int:
# proc.kill()
if boot_source == "eeprom":
result = write_words(bytes2words(get_content(filename)))
result = write_words(bytes2words(get_content(filename)), is_resume)
elif boot_source == "spifi":
spifi_write_file(get_content(filename))
spifi_write_file(get_content(filename), is_resume)
result = 0 # TODO
elif boot_source == "ram":
write_file(filename)
write_file(filename, is_resume)
result = 0 # TODO
else:
raise Exception("Unsupported boot source, use eeprom or spifi")