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
+55
-17
No files matched your search
@@ -287,7 +287,7 @@ def combine_pages(pages: Dict[int, List[int]]) -> List[int]:
|
|||||||
return bytes_list
|
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") # готовимся поймать результат записи
|
openocd.run("wp 0x2003800 4 w") # готовимся поймать результат записи
|
||||||
|
|
||||||
print("Uploading driver...", flush=True)
|
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(driver_path))
|
||||||
openocd.run("load_image {%s}" % pathlib.Path(
|
|
||||||
"C:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_eeprom\\.pio\\build\\mik32v2\\firmware.hex"
|
|
||||||
))
|
|
||||||
|
|
||||||
print("Uploading data...", flush=True)
|
print("Uploading data...", flush=True)
|
||||||
openocd.write_memory(0x02001800, 8, bytes_list)
|
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 сработает
|
wait_halted(openocd, 10) # ждем, когда watchpoint сработает
|
||||||
openocd.run("rwp 0x02003800") # watchpoint ловит до изменения слова
|
openocd.run("rwp 0x02003800") # watchpoint ловит до изменения слова
|
||||||
openocd.run("step") # делаем шаг чтобы слово изменилось
|
openocd.run("step") # делаем шаг, чтобы прочитать новое слово
|
||||||
|
|
||||||
result = openocd.read_memory(0x2003800, 32, 1)[0]
|
result = openocd.read_memory(0x2003800, 32, 1)[0]
|
||||||
|
|
||||||
@@ -331,7 +328,7 @@ def write_memory(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc) -> int:
|
|||||||
else:
|
else:
|
||||||
miss_page = (result >> 8) & (64 - 1)
|
miss_page = (result >> 8) & (64 - 1)
|
||||||
miss_byte = (result >> 16) & (128 - 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
|
miss_byte = (result >> 24) & 0xFF
|
||||||
|
|
||||||
print(f"EEPROM writing failed!", flush=True)
|
print(f"EEPROM writing failed!", flush=True)
|
||||||
|
|||||||
@@ -396,7 +396,12 @@ def wait_halted(openocd: OpenOcdTclRpc, timeout_seconds: float = 2):
|
|||||||
openocd.run(f'wait_halt {int(timeout_seconds * 1000)}')
|
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
|
result = 0
|
||||||
|
|
||||||
openocd.halt()
|
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("wp 0x2003000 4 w")
|
||||||
|
|
||||||
# openocd.run("load_image {%s}" % pathlib.Path(os.path.join(pathname, "firmware.hex")))
|
# openocd.run("load_image {%s}" % pathlib.Path(os.path.join(pathname, "firmware.hex")))
|
||||||
openocd.run("load_image {%s}" % pathlib.Path(
|
openocd.run("load_image {%s}" % pathlib.Path(driver_path))
|
||||||
"C:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\.pio\\build\\mik32v2\\firmware.hex"
|
|
||||||
))
|
|
||||||
|
|
||||||
openocd.resume(0x2000000)
|
openocd.resume(0x2000000)
|
||||||
wait_halted(openocd)
|
wait_halted(openocd)
|
||||||
@@ -441,7 +444,8 @@ def write_pages_by_sectors(pages: Dict[int, List[int]], openocd: OpenOcdTclRpc,
|
|||||||
wait_halted(openocd, 10)
|
wait_halted(openocd, 10)
|
||||||
print(f"Check page result {openocd.read_memory(0x2003000, 32, 1)}")
|
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)
|
init_memory(openocd)
|
||||||
|
|
||||||
|
|||||||
+34
-5
@@ -17,6 +17,8 @@ from _version import applicaton_version
|
|||||||
from parsers import *
|
from parsers import *
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
program_name = f'mik32-uploader-{applicaton_version}'
|
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")
|
openocd_target_path = os.path.join("target", "mik32.cfg")
|
||||||
default_post_action = "reset run"
|
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"
|
default_log_path = "/dev/null"
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
default_log_path = "nul"
|
default_log_path = "nul"
|
||||||
@@ -254,10 +269,16 @@ def upload_file(
|
|||||||
if (pages.pages_eeprom.__len__() > 0):
|
if (pages.pages_eeprom.__len__() > 0):
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
|
|
||||||
# result |= eeprom.write_pages(
|
|
||||||
# pages.pages_eeprom, openocd)
|
|
||||||
result |= eeprom.write_memory(
|
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_time = time.perf_counter() - start_time
|
||||||
write_size = pages.pages_eeprom.__len__(
|
write_size = pages.pages_eeprom.__len__(
|
||||||
@@ -273,7 +294,16 @@ def upload_file(
|
|||||||
# result |= spifi.write_pages(
|
# result |= spifi.write_pages(
|
||||||
# pages.pages_spifi, openocd, use_quad_spi=use_quad_spi)
|
# pages.pages_spifi, openocd, use_quad_spi=use_quad_spi)
|
||||||
result |= spifi.write_pages_by_sectors(
|
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_time = time.perf_counter() - start_time
|
||||||
write_size = pages.pages_spifi.__len__(
|
write_size = pages.pages_spifi.__len__(
|
||||||
@@ -434,7 +464,6 @@ if __name__ == '__main__':
|
|||||||
namespace = parser.parse_args()
|
namespace = parser.parse_args()
|
||||||
|
|
||||||
print(program_name)
|
print(program_name)
|
||||||
print(os.path.dirname(os.path.realpath(__file__)))
|
|
||||||
|
|
||||||
if namespace.filepath:
|
if namespace.filepath:
|
||||||
upload_file(
|
upload_file(
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ def tar_gz_directory(directory_path, tar_gz_path):
|
|||||||
|
|
||||||
shutil.copytree('./openocd-scripts/',
|
shutil.copytree('./openocd-scripts/',
|
||||||
f'./dist/{program_name}/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':
|
if os.name == 'nt':
|
||||||
zip_directory(f'./dist/{program_name}/',
|
zip_directory(f'./dist/{program_name}/',
|
||||||
f'./dist/mik32-uploader-{applicaton_version_line}.zip')
|
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