Добавлена базовая обработка ошибок связи с OpenOCD

This commit is contained in:
sh-sergey committed 2024-11-18 17:23:22 +03:00
1 parent 5135347032
commit 328112232c
9 files changed
+90 -45

No files matched your search

+10 -1
View File
@@ -7,6 +7,15 @@ from dataclasses import dataclass
import mik32_debug_hal.registers.memory_map as mem_map
import mik32_debug_hal.registers.bitfields.dma as dma_fields
class DmaError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return ("ERROR: " + repr(self.value))
# ReadStatus. Разрешить читать текущий статус канала
class CurrentValue(Enum):
ENABLE = 0 # Текущие значения
@@ -201,4 +210,4 @@ class DMA:
if self.get_control() & mask != 0:
return
raise Exception
raise DmaError
+2 -2
View File
@@ -117,8 +117,8 @@ def eeprom_check_data_ahb_lite(openocd: OpenOcdTclRpc, words: List[int], offset:
print("EEPROM check through AHB-Lite...", flush=True)
mem_array = openocd.read_memory(0x01000000 + offset, 32, len(words))
if len(words) != len(mem_array):
raise Exception(
"Wrong number of words in read_memory output!")
print("ERROR: Wrong number of words in read_memory output!")
return 1
progress = 0
if print_progress:
print("[", end="", flush=True)
+10 -2
View File
@@ -13,6 +13,14 @@ import mik32_debug_hal.dma as dma
import flash_drivers.generic_flash as generic_flash
class SpifiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return ("ERROR: " + repr(self.value))
def spifi_intrq_clear(openocd: OpenOcdTclRpc):
openocd.write_word(mem_map.SPIFI_CONFIG_STAT, openocd.read_word(mem_map.SPIFI_CONFIG_STAT) |
spifi_fields.SPIFI_CONFIG_STAT_INTRQ_M)
@@ -70,7 +78,7 @@ def spifi_wait_intrq_timeout(openocd: OpenOcdTclRpc, error_message: str):
while time.perf_counter() < time_end:
if (openocd.read_word(mem_map.SPIFI_CONFIG_STAT) & spifi_fields.SPIFI_CONFIG_STAT_INTRQ_M) != 0:
return
raise Exception(error_message)
raise SpifiError(error_message)
class Frameform(Enum):
@@ -167,7 +175,7 @@ def send_command(
def write(openocd: OpenOcdTclRpc, address: int, data: List[int], data_len: int):
if data_len > 256:
raise Exception("Byte count more than 256")
raise SpifiError("Byte count more than 256")
generic_flash.page_program(openocd, address, data, data_len)