feat: enhance logging for library loading and WiFi progress; update subproject commits

feature/vscode-extension
David Montero Crespo 2026-04-05 00:49:25 -03:00
parent 7ccd5a7b63
commit b0fe5b5d14
2 changed files with 18 additions and 4 deletions

View File

@ -190,6 +190,8 @@ def main() -> None: # noqa: C901 (complexity OK for inline worker)
if os.name == 'nt' and os.path.isdir(_MINGW64_BIN): if os.name == 'nt' and os.path.isdir(_MINGW64_BIN):
os.add_dll_directory(_MINGW64_BIN) os.add_dll_directory(_MINGW64_BIN)
try: try:
lib_size = os.path.getsize(lib_path) if os.path.isfile(lib_path) else 0
_log(f'Loading library: {lib_path} ({lib_size} bytes)')
lib = ctypes.CDLL(lib_path) lib = ctypes.CDLL(lib_path)
except Exception as exc: except Exception as exc:
_emit({'type': 'error', 'message': f'Cannot load DLL: {exc}'}) _emit({'type': 'error', 'message': f'Cannot load DLL: {exc}'})
@ -216,9 +218,12 @@ def main() -> None: # noqa: C901 (complexity OK for inline worker)
b'-drive', f'file={firmware_path},if=mtd,format=raw'.encode(), b'-drive', f'file={firmware_path},if=mtd,format=raw'.encode(),
] ]
# Deterministic instruction counting for stable timers (WiFi beacons, boot) # Deterministic instruction counting for stable timers.
# Required for ESP32-C3 boot; also needed for ESP32 WiFi on virtualized hosts # Required for ESP32-C3 boot (RISC-V needs deterministic timing).
if 'c3' in machine or wifi_enabled: # For ESP32 (Xtensa), -icount is NOT used: the WiFi AP beacon timer
# runs on QEMU_CLOCK_REALTIME, so decoupling virtual time from real
# time can cause beacon delivery issues on slow/virtualized hosts.
if 'c3' in machine:
args_list.extend([b'-icount', b'3']) args_list.extend([b'-icount', b'3'])
# ── WiFi NIC (slirp user-mode networking) ────────────────────────────── # ── WiFi NIC (slirp user-mode networking) ──────────────────────────────
@ -531,6 +536,14 @@ def main() -> None: # noqa: C901 (complexity OK for inline worker)
_reboot_count[0] += 1 _reboot_count[0] += 1
_emit({'type': 'system', 'event': 'reboot', _emit({'type': 'system', 'event': 'reboot',
'count': _reboot_count[0]}) 'count': _reboot_count[0]})
# WiFi progress logging (only in debug — helps diagnose prod issues)
if wifi_enabled:
line = chunk.decode('utf-8', errors='replace').strip()
if any(kw in line.lower() for kw in (
'wifi', 'connect', 'ip address', 'wl_connected',
'dhcp', 'sta_start', 'sta_got_ip', 'sta_disconnect',
)):
_log(f'[wifi-uart] {line}')
def _on_rmt_event(channel: int, config0: int, value: int) -> None: def _on_rmt_event(channel: int, config0: int, value: int) -> None:
if _stopped.is_set(): if _stopped.is_set():
@ -621,6 +634,7 @@ def main() -> None: # noqa: C901 (complexity OK for inline worker)
_emit({'type': 'system', 'event': 'booted'}) _emit({'type': 'system', 'event': 'booted'})
_log(f'QEMU started: machine={machine} firmware={firmware_path}') _log(f'QEMU started: machine={machine} firmware={firmware_path}')
_log(f'QEMU args: {[a.decode() for a in args_list]}')
# ── 7. LEDC polling thread (100 ms interval) ────────────────────────────── # ── 7. LEDC polling thread (100 ms interval) ──────────────────────────────

@ -1 +1 @@
Subproject commit 822927b6da5818b7e3b44e8bf48b967e5465f840 Subproject commit ab2c9f1868b22b78510e7d7f7b88036486bef4f7