diff --git a/mik32_eeprom.py b/mik32_eeprom.py index 4f69215..417388b 100644 --- a/mik32_eeprom.py +++ b/mik32_eeprom.py @@ -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 diff --git a/mik32_ram.py b/mik32_ram.py index 506301e..e2c7299 100644 --- a/mik32_ram.py +++ b/mik32_ram.py @@ -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") diff --git a/mik32_spifi.py b/mik32_spifi.py index a685120..d89e672 100644 --- a/mik32_spifi.py +++ b/mik32_spifi.py @@ -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) diff --git a/mik32_upload.py b/mik32_upload.py index 9a84071..74d36b0 100644 --- a/mik32_upload.py +++ b/mik32_upload.py @@ -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")