mirror of
https://github.com/MikronMIK32/mik32-uploader.git
synced 2026-01-01 21:37:05 +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,
|
TODO: implement setting byte array offset, add error handling,
|
||||||
improve progress visualization, add option check page immidiately after writing
|
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")
|
print(f"Write {len(words*4)} bytes")
|
||||||
with OpenOcdTclRpc() as openocd:
|
with OpenOcdTclRpc() as openocd:
|
||||||
|
|||||||
@ -334,7 +334,7 @@ def spifi_chip_erase(openocd: OpenOcdTclRpc):
|
|||||||
spifi_wait_intrq_timeout(openocd, "Timeout executing chip erase command")
|
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")
|
print("read data")
|
||||||
read_data: List[int] = []
|
read_data: List[int] = []
|
||||||
openocd.write_word(SPIFI_CONFIG_ADDR, address)
|
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):
|
for i in range(byte_count):
|
||||||
if read_data[i] != bin_data[address + i]:
|
if read_data[i] != bin_data[address + i]:
|
||||||
print(f"DATA[{i+address}] = {read_data[i]:#0x} - ошибка")
|
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):
|
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
|
break
|
||||||
print("address = ", address)
|
print("address = ", address)
|
||||||
spifi_write(openocd, address, bytes, 256)
|
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:
|
if (len(bytes) % 256) != 0:
|
||||||
print(
|
print(
|
||||||
f"address = {address}, +{len(bytes) - address-1}[{address + len(bytes) - address-1}]")
|
f"address = {address}, +{len(bytes) - address-1}[{address + len(bytes) - address-1}]")
|
||||||
spifi_write(openocd, address, bytes, len(bytes) - address)
|
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")
|
print("end")
|
||||||
if is_resume:
|
if is_resume:
|
||||||
openocd.resume(0)
|
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
|
@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)
|
@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
|
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":
|
if boot_source == "eeprom":
|
||||||
result = write_words(bytes2words(get_content(filename)), is_resume)
|
result = write_words(bytes2words(get_content(filename)), is_resume)
|
||||||
elif boot_source == "spifi":
|
elif boot_source == "spifi":
|
||||||
spifi_write_file(get_content(filename), is_resume)
|
result = spifi_write_file(get_content(filename), is_resume)
|
||||||
result = 0 # TODO
|
|
||||||
elif boot_source == "ram":
|
elif boot_source == "ram":
|
||||||
write_file(filename, is_resume)
|
write_file(filename, is_resume)
|
||||||
result = 0 # TODO
|
result = 0 # TODO
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user