mirror of
https://github.com/MikronMIK32/mik32-uploader.git
synced 2026-01-01 13:37:03 +03:00
spifi return error
This commit is contained in:
parent
02de7b066b
commit
4b257406e1
@ -203,6 +203,8 @@ def write_words(words: List[int], write_by_word = False, read_through_apb = Fals
|
||||
|
||||
TODO: implement setting byte array offset, add error handling,
|
||||
improve progress visualization, add option check page immidiately after writing
|
||||
|
||||
@return: return 0 if successful, 1 if failed
|
||||
"""
|
||||
print(f"Write {len(words*4)} bytes")
|
||||
with OpenOcdTclRpc() as openocd:
|
||||
|
||||
@ -334,7 +334,7 @@ def spifi_chip_erase(openocd: OpenOcdTclRpc):
|
||||
spifi_wait_intrq_timeout(openocd, "Timeout executing chip erase command")
|
||||
|
||||
|
||||
def spifi_read_data(openocd: OpenOcdTclRpc, address: int, byte_count: int, bin_data: List[int]):
|
||||
def spifi_read_data(openocd: OpenOcdTclRpc, address: int, byte_count: int, bin_data: List[int]) -> int:
|
||||
print("read data")
|
||||
read_data: List[int] = []
|
||||
openocd.write_word(SPIFI_CONFIG_ADDR, address)
|
||||
@ -374,6 +374,9 @@ def spifi_read_data(openocd: OpenOcdTclRpc, address: int, byte_count: int, bin_d
|
||||
for i in range(byte_count):
|
||||
if read_data[i] != bin_data[address + i]:
|
||||
print(f"DATA[{i+address}] = {read_data[i]:#0x} - ошибка")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def spifi_page_program(openocd: OpenOcdTclRpc, ByteAddress: int, data: List[int], byte_count: int):
|
||||
@ -444,13 +447,16 @@ def spifi_write_file(bytes: List[int], is_resume=True):
|
||||
break
|
||||
print("address = ", address)
|
||||
spifi_write(openocd, address, bytes, 256)
|
||||
spifi_read_data(openocd, address, 256, bytes)
|
||||
if spifi_read_data(openocd, address, 256, bytes) == 1:
|
||||
return 1
|
||||
|
||||
if (len(bytes) % 256) != 0:
|
||||
print(
|
||||
f"address = {address}, +{len(bytes) - address-1}[{address + len(bytes) - address-1}]")
|
||||
spifi_write(openocd, address, bytes, len(bytes) - address)
|
||||
spifi_read_data(openocd, address, len(bytes) - address, bytes)
|
||||
if spifi_read_data(openocd, address, len(bytes) - address, bytes) == 1:
|
||||
return 1
|
||||
print("end")
|
||||
if is_resume:
|
||||
openocd.resume(0)
|
||||
return 0
|
||||
|
||||
@ -39,6 +39,8 @@ def upload_file(filename: str, boot_source: str = "eeprom", is_resume=True) -> i
|
||||
@filename: full path to the file with hex or bin file format
|
||||
@boot_source: boot source, eeprom, ram or spifi, define memory block mapped to boot memory area (0x0 offset)
|
||||
|
||||
@return: return 0 if successful, 1 if failed
|
||||
|
||||
TODO: Implement error handling
|
||||
"""
|
||||
|
||||
@ -71,8 +73,7 @@ def upload_file(filename: str, boot_source: str = "eeprom", is_resume=True) -> i
|
||||
if boot_source == "eeprom":
|
||||
result = write_words(bytes2words(get_content(filename)), is_resume)
|
||||
elif boot_source == "spifi":
|
||||
spifi_write_file(get_content(filename), is_resume)
|
||||
result = 0 # TODO
|
||||
result = spifi_write_file(get_content(filename), is_resume)
|
||||
elif boot_source == "ram":
|
||||
write_file(filename, is_resume)
|
||||
result = 0 # TODO
|
||||
|
||||
Loading…
Reference in New Issue
Block a user