mirror of
https://github.com/MikronMIK32/mik32-uploader.git
synced 2026-01-01 13:37:03 +03:00
show program speed
This commit is contained in:
parent
23a433baf0
commit
02aa40ecb2
@ -511,7 +511,14 @@ def spifi_write_file(bytes: List[int], openocd: OpenOcdTclRpc, is_resume=True):
|
||||
return 0
|
||||
|
||||
|
||||
def spifi_quad_page_program(openocd: OpenOcdTclRpc, ByteAddress: int, data: List[int], byte_count: int, progress: str = ""):
|
||||
def spifi_quad_page_program(
|
||||
openocd: OpenOcdTclRpc,
|
||||
ByteAddress: int,
|
||||
data: List[int],
|
||||
byte_count: int,
|
||||
progress: str = "",
|
||||
dma: Union[DMA, None] = None
|
||||
):
|
||||
print(f"Writing page {ByteAddress:#010x}... {progress}", flush=True)
|
||||
if byte_count > 256:
|
||||
raise Exception("Byte count more than 256")
|
||||
@ -519,7 +526,7 @@ def spifi_quad_page_program(openocd: OpenOcdTclRpc, ByteAddress: int, data: List
|
||||
spifi_write_enable(openocd)
|
||||
spifi_send_command(openocd, QUAD_PAGE_PROGRAM_COMMAND, SPIFI_Frameform.OPCODE_3ADDR,
|
||||
SPIFI_Fieldform.DATA_PARALLEL, byte_count=byte_count, address=ByteAddress,
|
||||
idata=0, cache_limit=0, direction=SPIFI_Direction.WRITE, data=data)
|
||||
idata=0, cache_limit=0, direction=SPIFI_Direction.WRITE, data=data, dma=dma)
|
||||
spifi_wait_busy(openocd)
|
||||
|
||||
|
||||
@ -618,7 +625,7 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
|
||||
|
||||
if (use_quad_spi):
|
||||
spifi_quad_page_program(
|
||||
openocd, page_offset, page_bytes, 256, f"{(index*100)//pages_offsets.__len__()}%")
|
||||
openocd, page_offset, page_bytes, 256, f"{(index*100)//pages_offsets.__len__()}%", dma=dma)
|
||||
else:
|
||||
spifi_page_program(openocd, page_offset, page_bytes,
|
||||
256, f"{(index*100)//pages_offsets.__len__()}%", dma=dma)
|
||||
|
||||
@ -51,6 +51,11 @@ class MemoryType(Enum):
|
||||
UNKNOWN = -1
|
||||
|
||||
|
||||
memory_page_size = {
|
||||
MemoryType.EEPROM : 128,
|
||||
MemoryType.SPIFI : 256
|
||||
}
|
||||
|
||||
class BootMode(Enum):
|
||||
UNDEFINED = 'undefined'
|
||||
EEPROM = 'eeprom'
|
||||
@ -251,12 +256,12 @@ def form_pages(segments: List[Segment], boot_mode=BootMode.UNDEFINED) -> Pages:
|
||||
pages_eeprom = segments_to_pages(
|
||||
filter_segments(segments, MemoryType.EEPROM,
|
||||
boot_mode.to_memory_type()),
|
||||
128
|
||||
memory_page_size[MemoryType.EEPROM]
|
||||
)
|
||||
pages_spifi = segments_to_pages(
|
||||
filter_segments(segments, MemoryType.SPIFI,
|
||||
boot_mode.to_memory_type()),
|
||||
256
|
||||
memory_page_size[MemoryType.SPIFI]
|
||||
)
|
||||
|
||||
return Pages(pages_eeprom, pages_spifi)
|
||||
@ -314,13 +319,24 @@ def upload_file(
|
||||
openocd.run(f"log_output \"{log_path}\"")
|
||||
openocd.run(f"debug_level 1")
|
||||
|
||||
start_time = time.perf_counter()
|
||||
if (pages.pages_eeprom.__len__() > 0):
|
||||
start_time = time.perf_counter()
|
||||
|
||||
result |= mik32_eeprom.write_pages(
|
||||
pages.pages_eeprom, openocd)
|
||||
|
||||
write_time = time.perf_counter() - start_time
|
||||
write_size = pages.pages_eeprom.__len__() * memory_page_size[MemoryType.EEPROM]
|
||||
print(f"Wrote {write_size} bytes in {write_time:.2f} seconds (effective {(write_size/(write_time*1024)):.1f} kbyte/s)")
|
||||
if (pages.pages_spifi.__len__() > 0):
|
||||
start_time = time.perf_counter()
|
||||
|
||||
result |= mik32_spifi.write_pages(
|
||||
pages.pages_spifi, openocd, use_quad_spi=use_quad_spi)
|
||||
|
||||
write_time = time.perf_counter() - start_time
|
||||
write_size = pages.pages_spifi.__len__() * memory_page_size[MemoryType.SPIFI]
|
||||
print(f"Wrote {write_size} bytes in {write_time:.2f} seconds (effective {(write_size/(write_time*1024)):.1f} kbyte/s)")
|
||||
|
||||
segments_ram = list(filter(
|
||||
lambda segment: (segment.memory is not None) and (segment.memory.type == MemoryType.RAM), segments))
|
||||
@ -328,9 +344,6 @@ def upload_file(
|
||||
mik32_ram.write_segments(segments_ram, openocd)
|
||||
result |= 0
|
||||
|
||||
write_time = time.perf_counter() - start_time
|
||||
print(f"All segments written in {write_time:.2f} seconds")
|
||||
|
||||
openocd.run(post_action)
|
||||
except ConnectionRefusedError:
|
||||
print("ERROR: The connection to OpenOCD is not established. Check the settings and connection of the debugger")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user