diff --git a/mik32_dma.py b/mik32_dma.py index f14288e..e2da677 100644 --- a/mik32_dma.py +++ b/mik32_dma.py @@ -227,10 +227,6 @@ class DMA_Channel: destination_address: int, length: int, ): - self.set_source(source_address) - self.set_destination(destination_address) - self.set_length(length) - self.write_buffer |= (DMA_CFG_CH_ENABLE_M | (self.priority.value << DMA_CFG_CH_PRIOR_S) | (self.read_mode.value << DMA_CFG_CH_READ_MODE_S) @@ -246,7 +242,7 @@ class DMA_Channel: | (self.write_request.value << DMA_CFG_CH_WRITE_REQ_S) | (self.write_ack.value << DMA_CFG_CH_ACK_WRITE_S)) - self.set_config(self.write_buffer) + self.openocd.write_memory(DMA_CHANNEL_DESTINATION(1), 32, [destination_address, source_address, length, self.write_buffer]) class DMA: diff --git a/mik32_eeprom.py b/mik32_eeprom.py index b330f4e..0b286c6 100644 --- a/mik32_eeprom.py +++ b/mik32_eeprom.py @@ -70,9 +70,8 @@ class EEPROM_AffectedPages(Enum): def eeprom_execute_operation(openocd: OpenOcdTclRpc, op: EEPROM_Operation, affected_pages: EEPROM_AffectedPages, offset: int, buffer: List[int]): # buffer write enable and select affected pages - openocd.write_word(EEPROM_REGS_EECON, (1 << EEPROM_BWE_S) - | (affected_pages.value << EEPROM_WRBEH_S)) - openocd.write_word(EEPROM_REGS_EEA, offset) + openocd.write_memory(EEPROM_REGS_EEA, 32, [offset, (1 << EEPROM_BWE_S) + | (affected_pages.value << EEPROM_WRBEH_S)]) if buffer.__len__() > 32: return diff --git a/mik32_ram.py b/mik32_ram.py index b98f5dd..91b733c 100644 --- a/mik32_ram.py +++ b/mik32_ram.py @@ -3,6 +3,7 @@ from mik32_upload import Segment from tclrpc import TclException from tclrpc import OpenOcdTclRpc from pathlib import Path +import time from utils import bytes2words @@ -17,7 +18,9 @@ def write_file(filename): def write_segments(segments: List[Segment], openocd: OpenOcdTclRpc): openocd.halt() for segment in segments: - print("Writing segment %s with size %d..." % (hex(segment.offset), segment.data.__len__())) + t = time.localtime() + current_time = time.strftime("%H:%M:%S", t) + print("[{current_time}] Writing segment %s with size %d..." % (hex(segment.offset), segment.data.__len__())) segment_words = bytes2words(segment.data) openocd.write_memory(segment.offset, 32, segment_words) diff --git a/mik32_spifi.py b/mik32_spifi.py index cc9d7e9..05d4361 100644 --- a/mik32_spifi.py +++ b/mik32_spifi.py @@ -293,11 +293,7 @@ def spifi_send_command( 255 ) - openocd.write_word(SPIFI_CONFIG_ADDR, address) - # if idata != 0: - # openocd.write_word(SPIFI_CONFIG_IDATA, idata) - # if cache_limit != 0: - # openocd.write_word(SPIFI_CONFIG_CLIMIT, cache_limit) + openocd.write_memory(SPIFI_CONFIG_ADDR, 32, [address, idata]) # # spifi_intrq_clear(openocd) # openocd.write_word(SPIFI_CONFIG_CMD, (cmd << SPIFI_CONFIG_CMD_OPCODE_S) | @@ -315,7 +311,7 @@ def spifi_send_command( (idata_length << SPIFI_CONFIG_CMD_INTLEN_S) | (direction.value << SPIFI_CONFIG_CMD_DOUT_S)) - openocd.write_memory(SPIFI_CONFIG_CMD, 32, [cmd_write_value, address, idata, cache_limit]) + openocd.write_memory(SPIFI_CONFIG_CMD, 32, [cmd_write_value]) if direction == SPIFI_Direction.READ: out_list = [] @@ -594,10 +590,18 @@ def check_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp print("SPIFI page checking completed", flush=True) return 0 +# # PROFILING IMPORTS +# import cProfile, pstats, io +# from pstats import SortKey def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_spi=False, use_chip_erase=False): result = 0 + # # PROFILING INIT + # pr = cProfile.Profile() + # pr.enable() + # # PROFILING INIT END + openocd.halt() spifi_init(openocd) @@ -686,6 +690,15 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp if (use_quad_spi): spifi_quad_disable(openocd) + # # PROFILING GET STATS + # pr.disable() + # s = io.StringIO() + # sortby = SortKey.CUMULATIVE + # ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + # ps.print_stats() + # print(s.getvalue()) + # # PROFILING GET STATS END + if result == 0: print("SPIFI page recording completed", flush=True) return 0 diff --git a/mik32_upload.py b/mik32_upload.py index cef76e9..7d02557 100644 --- a/mik32_upload.py +++ b/mik32_upload.py @@ -247,8 +247,10 @@ def upload_file( write_time = time.perf_counter() - start_time write_size = pages.pages_eeprom.__len__( ) * memory_page_size[MemoryType.EEPROM] + t = time.localtime() + current_time = time.strftime("%H:%M:%S", t) print( - f"Wrote {write_size} bytes in {write_time:.2f} seconds (effective {(write_size/(write_time*1024)):.1f} kbyte/s)") + f"[{current_time}] Wrote {write_size} bytes in {write_time:.2f} seconds (effective {(write_size/(write_time*1024)):.1f} kbyte/s)") if (pages.pages_spifi.__len__() > 0): gpio_init(openocd, mik_version) start_time = time.perf_counter() @@ -259,8 +261,10 @@ def upload_file( write_time = time.perf_counter() - start_time write_size = pages.pages_spifi.__len__( ) * memory_page_size[MemoryType.SPIFI] + t = time.localtime() + current_time = time.strftime("%H:%M:%S", t) print( - f"Wrote {write_size} bytes in {write_time:.2f} seconds (effective {(write_size/(write_time*1024)):.1f} kbyte/s)") + f"[{current_time}] Wrote {write_size} bytes in {write_time:.2f} seconds (effective {(write_size/(write_time*1024)):.1f} kbyte/s)") gpio_deinit(openocd, mik_version) segments_ram = list(filter(