Compare commits

...

2 Commits

Author SHA1 Message Date
2aba3f5653 Increment to v2.0.0 2026-03-22 12:30:27 +01:00
de55955410 Flashing implemented 2026-03-22 12:29:21 +01:00
3 changed files with 78 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "neoecu" name = "neoecu"
version = "0.1.0" version = "2.0.0"
description = "NeoECU build and flash tooling" description = "NeoECU build and flash tooling"
authors = [{ name = "Hector van der Aa", email = "hector@h3cx.dev" }] authors = [{ name = "Hector van der Aa", email = "hector@h3cx.dev" }]
readme = "README.md" readme = "README.md"

View File

@@ -41,7 +41,7 @@ def main():
run(project_root, args) run(project_root, args)
elif args.command == "flash": elif args.command == "flash":
from .commands.flash import run from .commands.flash import run
run() run(project_root)
elif args.command == "envcheck": elif args.command == "envcheck":
from .commands.envcheck import run from .commands.envcheck import run
run() run()

View File

@@ -1,5 +1,79 @@
# Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev> # Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
# Copyright (C) 2026 Association Exergie <association.exergie@gmail.com> # Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
def run():
print("Flashing NeoECU...") from pathlib import Path
import neoecu.common
import subprocess
def gen_flash_script(jlink_path: Path, core: str, bin_path: Path) -> Path:
jlink_path.mkdir(parents=True, exist_ok=True)
script_path = jlink_path / "flash.jlink"
script_path.unlink(missing_ok=True)
new_script: str = ""
if (core == "M7") or (core == "CM7"):
new_script += "device STM32H747XI_M7\n"
elif (core == "M4") or (core == "CM4"):
new_script += "device STM32H747XI_M4\n"
else:
raise RuntimeError(f"Unknown core: {core}")
new_script += "si SWD\n"
new_script += "speed auto\n"
new_script += "\n"
new_script += "connect\n"
new_script += "\n"
new_script += f'loadfile "{bin_path}"\n'
new_script += "\n"
new_script += "r\n"
new_script += "g\n"
new_script += "exit"
script_path.write_text(new_script);
return script_path
def run(root_path: Path):
config = neoecu.common.load_config(root_path)
m7_root = root_path / config["build"]["m7_dir"]
m4_root = root_path / config["build"]["m4_dir"]
m7_jlink_scripts = m7_root / ".jlink_scripts"
m4_jlink_scripts = m4_root / ".jlink_scripts"
m7_build = m7_root / "CM7" / "build"
matches = list(m7_build.glob("*_CM7.elf"))
if not matches:
raise FileNotFoundError("No *_CM7.elf found in build directory")
if len(matches) > 1:
raise RuntimeError(f"Multiple CM7 ELF files found: {matches}")
m7_bin = matches[0]
m4_build = m4_root / "build" / "zephyr"
matches = list(m4_build.glob("zephyr.elf"))
if not matches:
raise FileNotFoundError("No *_CM4.elf found in build directory")
if len(matches) > 1:
raise RuntimeError(f"Multiple CM4 ELF files found: {matches}")
m4_bin = matches[0]
m7_flash_script = gen_flash_script(m7_jlink_scripts, "CM7", m7_bin)
m4_flash_script = gen_flash_script(m4_jlink_scripts, "CM4", m4_bin)
subprocess.run(["JLinkExe", "-CommanderScript", f"{m4_flash_script}"], cwd=m4_root)
subprocess.run(["JLinkExe", "-CommanderScript", f"{m7_flash_script}"], cwd=m7_root)