mirror of
https://github.com/MikronMIK32/mik32-uploader.git
synced 2026-10-29 18:11:13 +03:00
Заменен абсолютный путь на относительный
This commit is contained in:
1 parent
c821a3c5fd
commit
50d0e3a9d5
23 files changed
+59
-21
No files matched your search
@@ -287,7 +287,7 @@ def combine_pages(pages: Dict[int, List[int]]) -> List[int]:
|
||||
return bytes_list
|
||||
|
||||
|
||||
def write_memory(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc) -> int:
|
||||
def write_memory(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, driver_path: str) -> int:
|
||||
"""
|
||||
Записать всю память с использованием драйвера.
|
||||
|
||||
@@ -309,10 +309,7 @@ def write_memory(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc) -> int:
|
||||
openocd.run("wp 0x2003800 4 w") # готовимся поймать результат записи
|
||||
|
||||
print("Uploading driver...", flush=True)
|
||||
# openocd.run("load_image {%s}" % pathlib.Path(os.path.join(pathname, "firmware.hex")))
|
||||
openocd.run("load_image {%s}" % pathlib.Path(
|
||||
"C:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_eeprom\\.pio\\build\\mik32v2\\firmware.hex"
|
||||
))
|
||||
openocd.run("load_image {%s}" % pathlib.Path(driver_path))
|
||||
|
||||
print("Uploading data...", flush=True)
|
||||
openocd.write_memory(0x02001800, 8, bytes_list)
|
||||
@@ -322,7 +319,7 @@ def write_memory(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc) -> int:
|
||||
|
||||
wait_halted(openocd, 10) # ждем, когда watchpoint сработает
|
||||
openocd.run("rwp 0x02003800") # watchpoint ловит до изменения слова
|
||||
openocd.run("step") # делаем шаг чтобы слово изменилось
|
||||
openocd.run("step") # делаем шаг, чтобы прочитать новое слово
|
||||
|
||||
result = openocd.read_memory(0x2003800, 32, 1)[0]
|
||||
|
||||
@@ -331,7 +328,7 @@ def write_memory(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc) -> int:
|
||||
else:
|
||||
miss_page = (result >> 8) & (64 - 1)
|
||||
miss_byte = (result >> 16) & (128 - 1)
|
||||
expected_byte = pages(miss_page*128)[miss_byte]
|
||||
expected_byte = pages[miss_page*128][miss_byte]
|
||||
miss_byte = (result >> 24) & 0xFF
|
||||
|
||||
print(f"EEPROM writing failed!", flush=True)
|
||||
|
||||
@@ -268,7 +268,7 @@ def check_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
|
||||
generic_flash.chip_reset(openocd)
|
||||
|
||||
JEDEC_ID = send_command(openocd, generic_flash.JEDEC_ID_COMMAND,
|
||||
Frameform.OPCODE_NOADDR, Fieldform.ALL_SERIAL, 3)
|
||||
Frameform.OPCODE_NOADDR, Fieldform.ALL_SERIAL, 3)
|
||||
|
||||
print(f"JEDEC ID = {JEDEC_ID[0]:02x} {JEDEC_ID[1]:02x} {JEDEC_ID[2]:02x}")
|
||||
|
||||
@@ -324,7 +324,7 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
|
||||
generic_flash.chip_reset(openocd)
|
||||
|
||||
JEDEC_ID = send_command(openocd, generic_flash.JEDEC_ID_COMMAND,
|
||||
Frameform.OPCODE_NOADDR, Fieldform.ALL_SERIAL, 3)
|
||||
Frameform.OPCODE_NOADDR, Fieldform.ALL_SERIAL, 3)
|
||||
|
||||
print(f"JEDEC ID = {JEDEC_ID[0]:02x} {JEDEC_ID[1]:02x} {JEDEC_ID[2]:02x}")
|
||||
|
||||
@@ -334,7 +334,7 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
|
||||
generic_flash.erase(openocd, generic_flash.EraseType.CHIP_ERASE)
|
||||
else:
|
||||
generic_flash.erase(openocd, generic_flash.EraseType.SECTOR_ERASE,
|
||||
get_segments_list(list(pages), 4*1024))
|
||||
get_segments_list(list(pages), 4*1024))
|
||||
|
||||
# for addr in range(0, 4096*2, 256):
|
||||
# result = spifi_read_data(openocd, addr, 256, [0xFF]*256, dma=dma)
|
||||
@@ -365,7 +365,7 @@ def write_pages(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_sp
|
||||
openocd, page_offset, page_bytes, 256, f"{(index*100)//pages_offsets.__len__()}%", dma=dma_instance)
|
||||
else:
|
||||
generic_flash.page_program(openocd, page_offset, page_bytes,
|
||||
256, f"{(index*100)//pages_offsets.__len__()}%", dma=dma_instance)
|
||||
256, f"{(index*100)//pages_offsets.__len__()}%", dma=dma_instance)
|
||||
|
||||
result = generic_flash.read_data(
|
||||
openocd, page_offset, 256, page_bytes, dma=dma_instance, use_quad_spi=use_quad_spi)
|
||||
@@ -396,7 +396,12 @@ def wait_halted(openocd: OpenOcdTclRpc, timeout_seconds: float = 2):
|
||||
openocd.run(f'wait_halt {int(timeout_seconds * 1000)}')
|
||||
|
||||
|
||||
def write_pages_by_sectors(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc, use_quad_spi=False, use_chip_erase=False):
|
||||
def write_pages_by_sectors(pages: Dict[int, List[int]],
|
||||
openocd: OpenOcdTclRpc,
|
||||
driver_path: str,
|
||||
use_quad_spi=False,
|
||||
use_chip_erase=False,
|
||||
):
|
||||
result = 0
|
||||
|
||||
openocd.halt()
|
||||
@@ -417,9 +422,7 @@ def write_pages_by_sectors(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc,
|
||||
openocd.run("wp 0x2003000 4 w")
|
||||
|
||||
# openocd.run("load_image {%s}" % pathlib.Path(os.path.join(pathname, "firmware.hex")))
|
||||
openocd.run("load_image {%s}" % pathlib.Path(
|
||||
"C:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\.pio\\build\\mik32v2\\firmware.hex"
|
||||
))
|
||||
openocd.run("load_image {%s}" % pathlib.Path(driver_path))
|
||||
|
||||
openocd.resume(0x2000000)
|
||||
wait_halted(openocd)
|
||||
@@ -441,7 +444,8 @@ def write_pages_by_sectors(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc,
|
||||
wait_halted(openocd, 10)
|
||||
print(f"Check page result {openocd.read_memory(0x2003000, 32, 1)}")
|
||||
|
||||
print(f"{datetime.datetime.now().time()} Program sector {sector} complete", flush=True)
|
||||
print(
|
||||
f"{datetime.datetime.now().time()} Program sector {sector} complete", flush=True)
|
||||
|
||||
init_memory(openocd)
|
||||
|
||||
|
||||
+34
-5
@@ -17,6 +17,8 @@ from _version import applicaton_version
|
||||
from parsers import *
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from sys import exit
|
||||
|
||||
program_name = f'mik32-uploader-{applicaton_version}'
|
||||
|
||||
@@ -39,6 +41,19 @@ openocd_interface_path = os.path.join("interface", "ftdi", "mikron-link.cfg")
|
||||
openocd_target_path = os.path.join("target", "mik32.cfg")
|
||||
default_post_action = "reset run"
|
||||
|
||||
default_drivers_path = os.path.dirname(os.path.realpath(__file__))
|
||||
default_drivers_build_path = ''
|
||||
|
||||
if os.path.split(default_drivers_path)[-1] == '_internal':
|
||||
default_drivers_path = os.path.join(
|
||||
os.path.dirname(default_drivers_path),
|
||||
'upload-drivers'
|
||||
)
|
||||
else:
|
||||
default_drivers_path = os.path.join(default_drivers_path, 'upload-drivers')
|
||||
default_drivers_build_path = os.path.join('.pio', 'build', 'mik32v2')
|
||||
|
||||
|
||||
default_log_path = "/dev/null"
|
||||
if os.name == 'nt':
|
||||
default_log_path = "nul"
|
||||
@@ -254,10 +269,16 @@ def upload_file(
|
||||
if (pages.pages_eeprom.__len__() > 0):
|
||||
start_time = time.perf_counter()
|
||||
|
||||
# result |= eeprom.write_pages(
|
||||
# pages.pages_eeprom, openocd)
|
||||
result |= eeprom.write_memory(
|
||||
pages.pages_eeprom, openocd)
|
||||
pages.pages_eeprom,
|
||||
openocd,
|
||||
os.path.join(
|
||||
default_drivers_path,
|
||||
'jtag-eeprom',
|
||||
default_drivers_build_path,
|
||||
'firmware.hex'
|
||||
)
|
||||
)
|
||||
|
||||
write_time = time.perf_counter() - start_time
|
||||
write_size = pages.pages_eeprom.__len__(
|
||||
@@ -273,7 +294,16 @@ def upload_file(
|
||||
# result |= spifi.write_pages(
|
||||
# pages.pages_spifi, openocd, use_quad_spi=use_quad_spi)
|
||||
result |= spifi.write_pages_by_sectors(
|
||||
pages.pages_spifi, openocd, use_quad_spi=use_quad_spi)
|
||||
pages.pages_spifi,
|
||||
openocd,
|
||||
os.path.join(
|
||||
default_drivers_path,
|
||||
'jtag-spifi',
|
||||
default_drivers_build_path,
|
||||
'firmware.hex'
|
||||
),
|
||||
use_quad_spi=use_quad_spi,
|
||||
)
|
||||
|
||||
write_time = time.perf_counter() - start_time
|
||||
write_size = pages.pages_spifi.__len__(
|
||||
@@ -434,7 +464,6 @@ if __name__ == '__main__':
|
||||
namespace = parser.parse_args()
|
||||
|
||||
print(program_name)
|
||||
print(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
if namespace.filepath:
|
||||
upload_file(
|
||||
|
||||
@@ -75,6 +75,14 @@ def tar_gz_directory(directory_path, tar_gz_path):
|
||||
|
||||
shutil.copytree('./openocd-scripts/',
|
||||
f'./dist/{program_name}/openocd-scripts/')
|
||||
|
||||
os.makedirs(f'./dist/{program_name}/upload-drivers/jtag-eeprom/')
|
||||
shutil.copy('./upload-drivers/jtag-eeprom/.pio/build/mik32v2/firmware.hex',
|
||||
f'./dist/{program_name}/upload-drivers/jtag-eeprom/')
|
||||
os.makedirs(f'./dist/{program_name}/upload-drivers/jtag-spifi/')
|
||||
shutil.copy('./upload-drivers/jtag-spifi/.pio/build/mik32v2/firmware.hex',
|
||||
f'./dist/{program_name}/upload-drivers/jtag-spifi/')
|
||||
|
||||
if os.name == 'nt':
|
||||
zip_directory(f'./dist/{program_name}/',
|
||||
f'./dist/mik32-uploader-{applicaton_version_line}.zip')
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user