fix: cancel SD timer on new log output; change popup prompt to QSPI
This commit is contained in:
+17
-7
@@ -1823,7 +1823,7 @@ class MainWindow(ctk.CTk):
|
||||
|
||||
# Abort if SD boot timeout fired
|
||||
if not self._is_running:
|
||||
self._log_message(f" ⚠ Step {i+1} aborted (SD boot mode)")
|
||||
self._log_message(f" ⚠ Step {i+1} aborted (SD boot mode — switch to QSPI)")
|
||||
self._set_step_status(i, "error")
|
||||
results.append(False)
|
||||
break
|
||||
@@ -2163,9 +2163,11 @@ class MainWindow(ctk.CTk):
|
||||
# ── SD Boot Detection ──────────────────────────────────────
|
||||
|
||||
def _check_sd_boot(self, line: str) -> None:
|
||||
"""Scan a log line for SD boot mode; start 30s timer if detected."""
|
||||
if self._sd_detected:
|
||||
return
|
||||
"""Scan a log line for SD boot mode; start 30s timer if detected.
|
||||
|
||||
New log output after detection resets the timer — recovery
|
||||
may indicate the DIP switch was changed.
|
||||
"""
|
||||
import re
|
||||
for pattern in [
|
||||
re.compile(r"[Bb]oot\s*[Mm]ode\s*(?:is)?\s*[:\[=\s]*(\w+)"),
|
||||
@@ -2173,10 +2175,18 @@ class MainWindow(ctk.CTk):
|
||||
]:
|
||||
m = pattern.search(line)
|
||||
if m and m.group(1).upper() == "SD":
|
||||
if not self._sd_detected:
|
||||
self._sd_detected = True
|
||||
self._log_message(" ⚠ SD boot mode detected — waiting 30s for JTAG switch...")
|
||||
self._log_message(" ⚠ SD boot mode detected — waiting 30s for QSPI switch...")
|
||||
else:
|
||||
self._log_message(" ⚠ SD boot mode still present — resetting 30s timer")
|
||||
self.after_cancel(self._sd_timer_id)
|
||||
self._sd_timer_id = self.after(30000, self._on_sd_timeout)
|
||||
return
|
||||
# Any other log output resets the timer (boot mode may have changed)
|
||||
if self._sd_detected:
|
||||
self._log_message(" ✓ New output received — cancelling SD timer")
|
||||
self._cancel_sd_timer()
|
||||
|
||||
def _cancel_sd_timer(self) -> None:
|
||||
"""Cancel the SD boot timeout if still pending."""
|
||||
@@ -2189,12 +2199,12 @@ class MainWindow(ctk.CTk):
|
||||
"""SD boot mode persisted 30s — kill hw_server, alert user, stop workflow."""
|
||||
self._sd_timer_id = None
|
||||
self._sd_detected = False
|
||||
self._log_message(" ✗ SD boot mode persisted >30s — switch DIP to JTAG mode!")
|
||||
self._log_message(" ✗ SD boot mode persisted >30s — switch DIP to QSPI mode!")
|
||||
self._kill_hw_server()
|
||||
from tkinter import messagebox
|
||||
messagebox.showerror(
|
||||
"启动拨码开关位置错误!",
|
||||
"检测到 Boot mode 为 SD,请将拨码开关切换到 JTAG 模式后重试。",
|
||||
"检测到 Boot mode 为 SD,请将拨码开关切换到 QSPI 模式后重试。",
|
||||
)
|
||||
# Stop current workflow execution
|
||||
self._is_running = False
|
||||
|
||||
Reference in New Issue
Block a user