feat(vesc): extend motor diagnostics, configuration and transport recovery

Add firmware and extension catalogues, configuration transactions, sample review and QML diagnostics. Preserve explicit authority, bounded retries and stop recovery in motor transport.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:09:59 +03:00
parent 115476d2e6
commit f32c7b400b
186 changed files with 21197 additions and 339 deletions
+28 -13
View File
@@ -12,11 +12,14 @@ import re
import shutil
import subprocess
import tarfile
from engine_profile import load_profile, contract
SYSTEM = {"libc.so.6", "libm.so.6", "libpthread.so.0", "libdl.so.2", "librt.so.1", "libresolv.so.2", "ld-linux-x86-64.so.2"}
def build(engine, sysroot, source, output):
def build(engine, sysroot, source, output, qml_sysroot):
profile = load_profile((engine.parent / "engine-profile.json").read_bytes())
upstream = profile["upstream"]
output.mkdir(mode=0o700, exist_ok=False)
staging = output / "payload"
(staging / "bin").mkdir(parents=True)
@@ -27,9 +30,17 @@ def build(engine, sysroot, source, output):
qtlib = sysroot / "usr/lib/x86_64-linux-gnu"
plugin = qtlib / "qt5/plugins/platforms/libqoffscreen.so"
shutil.copyfile(plugin, staging / "plugins/platforms/libqoffscreen.so")
renderer = staging / "bin/mission-core-vesc-qml-preview"
shutil.copyfile(engine.parent / renderer.name, renderer); renderer.chmod(0o755)
qml = qml_sysroot / "usr/lib/x86_64-linux-gnu/qt5/qml"
shutil.copytree(qml, staging / "qml")
shutil.copytree(qml_sysroot / "usr/share/fonts/truetype/dejavu", staging / "fonts")
qml_plugins = list((staging / "qml").rglob("*.so"))
if len(qml_plugins) < 5: raise RuntimeError("QML runtime modules missing")
closure_inputs = [engine, renderer, plugin, *qml_plugins]
env = dict(os.environ, LD_LIBRARY_PATH=str(qtlib), LC_ALL="C")
sources = {}
for executable in (engine, plugin):
for executable in closure_inputs:
result = subprocess.run(["/usr/bin/ldd", str(executable)], env=env, capture_output=True, text=True, check=True).stdout
if "not found" in result: raise RuntimeError("Native runtime dependency missing")
for name, path in re.findall(r"^\s*(\S+) => (/[\S]+) \(", result, re.MULTILINE):
@@ -41,7 +52,7 @@ def build(engine, sysroot, source, output):
env.update(LD_LIBRARY_PATH=str(staging / "lib"), QT_PLUGIN_PATH=str(staging / "plugins"),
QT_QPA_PLATFORM="offscreen", XDG_CONFIG_HOME=str(output / "config"), XDG_CACHE_HOME=str(output / "cache"))
# All non-glibc ELF dependencies must now resolve inside the shipped payload.
for executable in (binary, staging / "plugins/platforms/libqoffscreen.so"):
for executable in [binary, renderer, staging / "plugins/platforms/libqoffscreen.so", *qml_plugins]:
result = subprocess.run(["/usr/bin/ldd", str(executable)], env=env, capture_output=True, text=True, check=True).stdout
if "not found" in result: raise RuntimeError("Bundled native closure incomplete")
for name, path in re.findall(r"^\s*(\S+) => (/[\S]+) \(", result, re.MULTILINE):
@@ -52,19 +63,22 @@ def build(engine, sysroot, source, output):
responses = [json.loads(line) for line in proc.stdout.splitlines()]
if len(responses) != 2 or not responses[0]["ready"] or responses[1]["result"]["connected"]:
raise RuntimeError("Bundled engine acceptance failed")
info = responses[1]["result"]
if info.get("version") != upstream["version"] or info.get("commit") != upstream["commit"] or info.get("contract") != contract(profile):
raise RuntimeError("Bundled engine version or contract differs from reviewed profile")
(output / "offline.stdout").write_bytes(proc.stdout)
(output / "offline.stderr").write_bytes(proc.stderr)
(staging / "licenses").mkdir()
shutil.copyfile(source / "LICENSE", staging / "licenses/VESC-Tool-LICENSE")
(staging / "licenses/UPSTREAM-SOURCE.txt").write_text(
"VESC Tool 7.00, unmodified upstream sources and resources:\n"
"https://github.com/vedderb/vesc_tool/tree/01d5f10901116c311e3fb84d5a1541f663d3ce20\n"
"Source archive SHA-256: 4565ecec4e41e094bcc43127a51970e810aa9080a9d7c025af64632bfd4c0189\n"
"The process adapter source is included alongside this notice.\n")
for name in ("engine_main.cpp", "config_export.h"):
f"VESC Tool {upstream['version']}, unmodified upstream sources and resources:\n"
f"{upstream['repository']}/tree/{upstream['commit']}\n"
f"Source archive SHA-256: {upstream['source_sha256']}\n"
"The process adapter source and release profile are included alongside this notice.\n")
for name in ("qml_vesc_interface.h", "qml_broker.h", "qml_interactive.h", "sample_data.h", "qml_preview.cpp", "qml_sandbox.h", "engine_main.cpp", "config_export.h", "config_edit.h", "firmware_image.h", "firmware_source.h", "firmware_native.h", "swd_native.h", "tools_native.h", "bms_native.h", "custom_native.h", "code_native.h", "package_native.h", "engine_profile.h", "engine-profile.json"):
shutil.copyfile(engine.parent / name, staging / "licenses" / name)
# Preserve dependency notices available in the private signed-package sysroot.
for index, path in enumerate(sorted((sysroot / "usr/share/doc").glob("*/copyright"))):
for index, path in enumerate(sorted((sysroot / "usr/share/doc").glob("*/copyright")) + sorted((qml_sysroot / "usr/share/doc").glob("*/copyright"))):
shutil.copyfile(path, staging / "licenses" / (path.parent.name + ".copyright"))
# Host libraries copied into the closure retain their distribution notices.
for library in sources.values():
@@ -80,8 +94,9 @@ def build(engine, sysroot, source, output):
with tarfile.open(archive, "w:gz") as stream:
for path in sorted(staging.rglob("*")):
if path.is_file(): stream.add(path, arcname=str(path.relative_to(staging)))
report = {"schema":"missioncore.vesc.native-runtime/v1", "upstream_version":"7.00",
"upstream_commit":"01d5f10901116c311e3fb84d5a1541f663d3ce20", "os":"ubuntu-24.04-amd64",
report = {"schema":"missioncore.vesc.native-runtime/v1", "upstream_version":upstream["version"],
"upstream_commit":upstream["commit"], "upstream_source_sha256":upstream["source_sha256"],
"engine_contract":contract(profile), "os":profile["environment"],
"file":archive.name, "bytes":archive.stat().st_size, "sha256":hashlib.sha256(archive.read_bytes()).hexdigest(),
"engine_sha256":hashlib.sha256(binary.read_bytes()).hexdigest(), "files":metadata,
"host_libraries":sorted(SYSTEM), "offline_verified":True, "hardware_qualified":False,
@@ -91,5 +106,5 @@ def build(engine, sysroot, source, output):
if __name__ == "__main__":
parser=argparse.ArgumentParser()
for name in ("engine","sysroot","source","output"):parser.add_argument("--"+name,type=Path,required=True)
args=parser.parse_args();build(args.engine,args.sysroot,args.source,args.output)
for name in ("engine","sysroot","source","output","qml-sysroot"):parser.add_argument("--"+name,type=Path,required=True)
args=parser.parse_args();build(args.engine,args.sysroot,args.source,args.output,args.qml_sysroot)