From 8b2fac931c2175c74d09afc64d19ed15c682167d Mon Sep 17 00:00:00 2001 From: Jeremy Shen Date: Wed, 10 Jun 2026 15:50:31 +0800 Subject: [PATCH] fix: FirmWare version parsing + prevent boot-from-Flash in ELF step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue 1 — FirmWare version not parsed: Input: [Info] FirmWare:V1.2.1.2.1_11_07_pmu_log3 Fix: regex [Ff]irm[Ww]are:?\s* (was [Ff]irmware\s+ — no : or camelCase) Plus broader version capture: [Vv]\d+\.\d+\.\d+[^\s;,\n]* Issue 2 — ELF loaded from Flash instead of downloaded ELF: Root cause: Zynq devcfg.CTRL (0xF800025C) PCAP_PROG_B may trigger reconfiguration from Flash after fpga, causing CPU to jump to Flash-loaded code instead of our dow'd ELF. BIT step: add ps7_post_config after fpga (finalizes PL-PS interfaces) add mwr 0xF800025C 0x1 (disables PCAP reconfig) ELF step: add mwr 0xF800025C 0x1 after dow, before con (both attempt-1 and attempt-2 fallback) --- src/bitstream_programmer.py | 10 +++++++++- src/serial_monitor.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bitstream_programmer.py b/src/bitstream_programmer.py index 5279a99..fc5ab09 100644 --- a/src/bitstream_programmer.py +++ b/src/bitstream_programmer.py @@ -214,7 +214,7 @@ def _program_with_xsct( if callback: callback("progress", "Initializing PS then programming FPGA...") - # Build TCL: PS init first, then FPGA config + # Build TCL: PS init first, then FPGA config, then post-config lines = ["connect"] if ps7_init_tcl and Path(ps7_init_tcl).exists(): lines.append("targets 1") @@ -223,6 +223,12 @@ def _program_with_xsct( if callback: callback("progress", "PS initialized (clocks, DDR, MIO)") lines.append(f'fpga -file "{bit_path}"') + if ps7_init_tcl and Path(ps7_init_tcl).exists(): + lines.append("ps7_post_config") + if callback: + callback("progress", "PS post-config (PL-PS interfaces)") + # Prevent boot from Flash by disabling PCAP reconfiguration + lines.append("mwr 0xF800025C 0x00000001") lines.append("exit") tcl_script = "\n".join(lines) @@ -422,6 +428,7 @@ def _run_elf_with_xsct( "connect", "targets 2", "dow \"%s\"" % elf_path, + "mwr 0xF800025C 0x00000001", "con", "exit", ]) @@ -459,6 +466,7 @@ def _run_elf_with_xsct( "ps7_init", "targets 2", "dow \"%s\"" % elf_path, + "mwr 0xF800025C 0x00000001", "con", "exit", ]) diff --git a/src/serial_monitor.py b/src/serial_monitor.py index a0d367a..cef79dc 100644 --- a/src/serial_monitor.py +++ b/src/serial_monitor.py @@ -74,8 +74,8 @@ def parse_boot_output(lines: list[str]) -> BootInfo: version_patterns = [ re.compile(r"[Vv]ersion[:\s]+([^\s;,\n]+)", re.IGNORECASE), re.compile(r"[Bb]oot\s+([^\s;,\n]+)", re.IGNORECASE), - re.compile(r"[Ff]irmware\s+([^\s;,\n]+)", re.IGNORECASE), - re.compile(r"(?:^|[\s:=])(v\d+\.\d+\.\d+)(?:\s|$)", re.IGNORECASE), + re.compile(r"[Ff]irm[Ww]are:?\s*([^\s;,\n]+)", re.IGNORECASE), + re.compile(r"(?:^|[\s:=])([Vv]\d+\.\d+\.\d+[^\s;,\n]*)", re.IGNORECASE), ] boot_complete_patterns = [ re.compile(r"boot\s+complete", re.IGNORECASE),