send to reg by 4 bytes, print time for debug

This commit is contained in:
Sergey Shchelkanov 2023-07-25 17:22:53 +03:00
parent c22c4d559b
commit 116a001fe0
2 changed files with 39 additions and 4 deletions

View File

@ -310,10 +310,26 @@ def spifi_send_command(
return out_list return out_list
if direction == SPIFI_Direction.WRITE: if direction == SPIFI_Direction.WRITE:
for i in range(byte_count): start_time = time.perf_counter()
# openocd.write_word(SPIFI_CONFIG_DATA32, data[i+ByteAddress])
openocd.write_memory(SPIFI_CONFIG_DATA32, 8, [data[i]])
openocd.write_memory(0x02003F00, 8, data)
write_time = time.perf_counter() - start_time
print(f"write ram time {write_time:.2f}")
start_time = time.perf_counter()
if (byte_count % 4) == 0:
for i in range(0, byte_count, 4):
# openocd.write_word(SPIFI_CONFIG_DATA32, data[i+ByteAddress])
openocd.write_memory(SPIFI_CONFIG_DATA32, 32, [data[i] + data[i+1] * 256 + data[i+2] * 256 * 256 + data[i+3] * 256 * 256 * 256])
else:
for i in range(byte_count):
openocd.write_memory(SPIFI_CONFIG_DATA32, 8, [data[i]])
write_time = time.perf_counter() - start_time
print(f"write memory time {write_time:.2f}")
return [] return []
@ -345,7 +361,7 @@ def spifi_chip_erase(openocd: OpenOcdTclRpc):
def spifi_sector_erase(openocd: OpenOcdTclRpc, address: int): def spifi_sector_erase(openocd: OpenOcdTclRpc, address: int):
print("Erase sector %s..." % hex(address), flush=True) print(f"Erase sector {address:#010x}...", flush=True)
spifi_send_command(openocd, SECTOR_ERASE_COMMAND, spifi_send_command(openocd, SECTOR_ERASE_COMMAND,
SPIFI_Frameform.OPCODE_3ADDR, SPIFI_Fieldform.ALL_SERIAL, address=address) SPIFI_Frameform.OPCODE_3ADDR, SPIFI_Fieldform.ALL_SERIAL, address=address)
@ -487,6 +503,7 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
address = 0 address = 0
if (use_quad_spi): if (use_quad_spi):
print("quad enable")
spifi_quad_enable(openocd) spifi_quad_enable(openocd)
else: else:
spifi_quad_disable(openocd) spifi_quad_disable(openocd)
@ -496,12 +513,17 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
for index, page_offset in enumerate(pages_offsets): for index, page_offset in enumerate(pages_offsets):
page_bytes = pages[page_offset] page_bytes = pages[page_offset]
start_time = time.perf_counter()
if (use_quad_spi): if (use_quad_spi):
spifi_quad_page_program( 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__()}%")
else: else:
spifi_page_program(openocd, page_offset, page_bytes, spifi_page_program(openocd, page_offset, page_bytes,
256, f"{(index*100)//pages_offsets.__len__()}%") 256, f"{(index*100)//pages_offsets.__len__()}%")
page_program_time = time.perf_counter() - start_time
print(f"page program time {page_program_time:.2f}")
result = spifi_read_data(openocd, page_offset, 256, page_bytes) result = spifi_read_data(openocd, page_offset, 256, page_bytes)

View File

@ -2,6 +2,7 @@ import shlex
import argparse import argparse
import subprocess import subprocess
import os import os
import time
from enum import Enum from enum import Enum
from typing import List, Dict, NamedTuple, Union from typing import List, Dict, NamedTuple, Union
from tclrpc import OpenOcdTclRpc, TclException from tclrpc import OpenOcdTclRpc, TclException
@ -212,6 +213,7 @@ def run_openocd(
openocd_target=openocd_target_path, openocd_target=openocd_target_path,
is_open_console=False is_open_console=False
) -> subprocess.Popen: ) -> subprocess.Popen:
print(openocd_scripts)
cmd = shlex.split( cmd = shlex.split(
f"{openocd_exec} -s {openocd_scripts} " f"{openocd_exec} -s {openocd_scripts} "
f"-f {openocd_interface} -f {openocd_target}", posix=False f"-f {openocd_interface} -f {openocd_target}", posix=False
@ -312,6 +314,7 @@ def upload_file(
openocd.run(f"log_output \"{log_path}\"") openocd.run(f"log_output \"{log_path}\"")
openocd.run(f"debug_level 1") openocd.run(f"debug_level 1")
start_time = time.perf_counter()
if (pages.pages_eeprom.__len__() > 0): if (pages.pages_eeprom.__len__() > 0):
result |= mik32_eeprom.write_pages( result |= mik32_eeprom.write_pages(
pages.pages_eeprom, openocd) pages.pages_eeprom, openocd)
@ -325,6 +328,9 @@ def upload_file(
mik32_ram.write_segments(segments_ram, openocd) mik32_ram.write_segments(segments_ram, openocd)
result |= 0 result |= 0
write_time = time.perf_counter() - start_time
print(f"All segments written in {write_time:.2f} seconds")
openocd.run(post_action) openocd.run(post_action)
except ConnectionRefusedError: except ConnectionRefusedError:
print("ERROR: The connection to OpenOCD is not established. Check the settings and connection of the debugger") print("ERROR: The connection to OpenOCD is not established. Check the settings and connection of the debugger")
@ -430,6 +436,13 @@ def createParser():
default=default_log_path, default=default_log_path,
help=f"Путь к файлу журнала. По умолчанию: {default_log_path}" help=f"Путь к файлу журнала. По умолчанию: {default_log_path}"
) )
# parser.add_argument(
# '--log-terminal',
# dest='log_termir',
# action='store_true',
# default=False,
# help='Вывод журнала в консоль'
# )
parser.add_argument( parser.add_argument(
'--post-action', '--post-action',
dest='post_action', dest='post_action',