Skip to content

stop_during_init: MT7612U firmware dir, report a bring-up that throws - #506

Merged
josephnef merged 2 commits into
masterfrom
stop-during-init-mt7612u
Oct 29, 2026
Merged

josephnef merged 2 commits into
masterfrom
stop-during-init-mt7612u

Conversation

@josephnef

Copy link
Copy Markdown
Collaborator

Closes the last item on #504: the stop-during-Init matrix on the three backends the first round could not reach.

  • --fw-dir on the probe (FW_DIR on the script, DEVOURER_MT7612U_FW_DIR env) names the decompressed mt7662.bin + mt7662_rom_patch.bin for an MT7612U, whose firmware is not embedded.
  • A bring-up that throws out of Init is caught on the Init thread and reported as INIT_THREW with its message. Before this it escaped the thread and dumped core with no RESULT line, which is how every MT7612U cell first read.
  • README: the MT7612U command, and why its reported Init-return time is near zero (the stop call blocks on the lock bring-up holds, so it returns when bring-up ends and Init leaves right behind it).

Measured through the script at this commit, ch6, no kernel driver on the DUT:

backend Init returns after a stop at 100 / 400 / 1000 / 2500 ms restart after stop stale stop before Init
8812AU (Jaguar1) 1801 / 1469 / 895 / 30 ms OK, 290 frames OK, 240 frames
RTL8733B 2033 / 1579 / 965 / 40 ms OK, 253 frames OK, 264 frames
MT7612U ~0 ms, see above OK, 178 frames OK, 282 frames

18/18 on each; the verify loop after every honoured stop saw 158 to 1392 frames. With #505 that is all six backends.

🤖 Generated with Claude Code

The MT7612U's firmware is not embedded, so the probe takes --fw-dir (the
script: FW_DIR, env DEVOURER_MT7612U_FW_DIR) for the decompressed
mt7662.bin + mt7662_rom_patch.bin. A bring-up that throws out of Init is
caught on the Init thread and reported as INIT_THREW with its message,
where before it escaped the thread and dumped core with no RESULT line.

Run on the three backends the first round could not reach: 8812AU ch6
(Init back 1801/1469/895/30 ms after the stop), RTL8733B ch6
(2033/1579/965/40 ms), MT7612U ch6 — 18/18 OK.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Enable MT7612U stop-during-Init tests and report bring-up errors

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Pass an MT7612U firmware directory into the stop-during-Init probe so hardware tests can run.
• Report Init exceptions as INIT_THREW results instead of terminating without a result.
• Document the MT7612U command and explain its near-zero reported Init return time.
Diagram

graph TD
  Script["Test script"] --> Probe["Stop probe"] --> Config["Device config"] --> Radio["MT7612U radio"]
  Probe --> Thread["Init thread"] --> Result["RESULT output"]
  Thread --> Radio
  Probe --> Result
Loading
High-Level Assessment

Keep firmware selection in DeviceConfig rather than reading the environment inside the radio; this follows the existing library boundary. Catching exceptions on the Init thread is necessary to produce a probe result instead of terminating the process.

Files changed (3) +44 / -4

Bug fix (1) +31 / -1
stop_during_init_probe.cppConfigure firmware and report Init exceptions +31/-1

Configure firmware and report Init exceptions

• Accepts '--fw-dir' or 'DEVOURER_MT7612U_FW_DIR' and places the directory in DeviceConfig. Catches standard exceptions on the Init thread and emits a failing 'INIT_THREW' result, whether the failure is observed before or after the scheduled stop.

tests/stop_during_init_probe.cpp

Tests (1) +6 / -0
stop_during_init.shForward MT7612U firmware directory to the probe +6/-0

Forward MT7612U firmware directory to the probe

• Accepts 'FW_DIR' and passes it as '--fw-dir' when set. Adds an example command and identifies the required decompressed firmware files.

tests/stop_during_init.sh

Documentation (1) +7 / -3
README.mdDocument MT7612U setup and stop timing +7/-3

Document MT7612U setup and stop timing

• Adds the MT7612U test command, its firmware-directory requirement, and the 'INIT_THREW' outcome. Explains why a stop blocked by bring-up can yield a near-zero measured Init return time and records coverage across six backends.

tests/README.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Bring-up errors can break result parsing ✓ Resolved
Description
The new INIT_THREW result interpolates the raw exception message into a machine-readable stdout
line without escaping it. An exception containing a quote or newline, including one originating from
firmware-path or device errors, produces malformed or multiple result records for the probe's
parser.
Code

tests/stop_during_init_probe.cpp[R172-173]

+    std::printf("RESULT mode=%s outcome=INIT_THREW what=\"%s\"\n", mode.c_str(),
+                init_what.c_str());
Evidence
The changed probe emits INIT_THREW directly to stdout and places the unescaped exception text
inside a quoted field. This conflicts with the requirement that machine events remain reliably
parseable and line-delimited.

CLAUDE.md: Maintain Structured Event and Diagnostic Logging Contracts: CLAUDE.md: Maintain Structured Event and Diagnostic Logging Contracts: CLAUDE.md: Maintain Structured Event and Diagnostic Logging Contracts: CLAUDE.md: Maintain Structured Event and Diagnostic Logging Contracts
tests/stop_during_init_probe.cpp[172-173]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
Issue description
The `INIT_THREW` stdout record inserts `init_what` verbatim inside a quoted field, so diagnostic text containing quotes or newlines can violate the machine-event logging contract and corrupt result parsing.
Fix Focus Areas
- tests/stop_during_init_probe.cpp[172-173]
- tests/stop_during_init_probe.cpp[192-193]
Recommended Fix
Serialize the `INIT_THREW` event through the same structured-event path used by the logging contract, escaping quotes, backslashes, and control characters and ensuring the event is emitted as one complete flushed stdout record. Keep detailed human diagnostics on stderr if they cannot be safely represented in the machine event.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. The probe can test unintended firmware ✓ Resolved
Description
The probe assigns --fw-dir to the device configuration without checking it, while
resolve_fw_dir() tries system and local directories if the supplied directory lacks either
firmware file. When an explicit path is wrong but a fallback contains both files, the matrix can
pass using different firmware, and the script deletes the log that identifies the directory actually
used.
Code

tests/stop_during_init_probe.cpp[R120-121]

+  if (!fw_dir.empty())
+    cfg.mt7612u.firmware_dir = fw_dir;
Evidence
The new option is assigned to the configuration, but the backend treats that directory as the first
candidate rather than a required source. The script captures the backend's firmware-source log and
removes it after a passing matrix.

tests/stop_during_init_probe.cpp[89-90]
tests/stop_during_init_probe.cpp[119-123]
src/mt7612u/Mt7612uRadio.cpp[31-48]
tests/stop_during_init.sh[64-80]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An invalid explicit firmware directory can silently fall back to other firmware, so a passing probe run need not use the files the caller selected.
## Fix Focus Areas
- tests/stop_during_init_probe.cpp[119-123]
## Recommended Fix
Before creating the radio, require both expected firmware files to exist when a nonempty directory was explicitly supplied. Report a clear failure for an invalid directory; preserve the backend's normal fallback behavior when no directory was supplied.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread tests/stop_during_init_probe.cpp Resolved
Comment thread tests/stop_during_init_probe.cpp Resolved
…keep INIT_THREW one record

An explicit --fw-dir that is missing mt7662.bin or mt7662_rom_patch.bin
now ends the run with BAD_FW_DIR (exit 2) before the radio exists; the
backend would otherwise fall back to its default search paths and a pass
could rest on firmware the caller did not name. The INIT_THREW message is
flattened (quotes, backslashes and control characters replaced) so the
RESULT line stays one parseable record whatever the exception carried.

Re-run 12/12 on the MT7612U and the 8812AU, ch6.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@josephnef
josephnef merged commit 09c2ff3 into master Oct 29, 2026
30 checks passed
@josephnef
josephnef deleted the stop-during-init-mt7612u branch October 29, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant