← Back to Pull requests

variants: unoq: fix flash verify performance regression #755

Closed
unknown closed this pull request without merging on Nov 26, 2026 16:36 UTC
View on GitHub
unknown unknown commented on Nov 13, 2026 12:41 UTC
Author

Since cf856640 the UNO Q flash script stops the CPU with "reset halt". The CPU then stays on the 4 MHz reset clock, and the OpenOCD checksum of the loader takes 5 s on every upload. This PR uses "reset init" instead. It halts at the same place and then sets the 160 MHz clock. The loader verify drops from 5.0 s to 0.2 s.

Why it was fast before cf856640

The old script ran "reset" and then "halt". Between the two commands the loader ran and switched the system clock to the PLL. So the checksum algorithm ran at 160 MHz. "reset halt" stops at the reset vector, before the loader sets the clock.

"reset init" halts the CPU

"reset init" stops at the same place as "reset halt": the PC is at z_arm_reset, and msp is the initial stack pointer from the vector table (0x2000a8b0). No instruction has run, so the fix of cf856640 stays. The reset-init event then runs clock_config, which sets the PLL.

How to test

The script resets the CPU in three ways. For each one it prints the PC, the clock source (RCC_CFGR1.SWS: 0 = MSI 4 MHz, 3 = PLL 160 MHz) and the time of a full flash verify_image of the loader.

why.cfg:

reset_config srst_only srst_nogate srst_push_pull connect_assert_srst
init
proc probe {name} {
        global filename0
        set t [target current]
        set sws [expr {([mrw 0x46020C1C] >> 2) & 3}]
        set s [clock milliseconds]
        log_output /dev/null
        set r [catch {flash verify_image ${filename0}}]
        log_output default
        echo "PROBE $name: state=[$t curstate] pc=[lindrify=[expr {[clock milliseconds]-$s}]ms fail=$r"
}
reset halt
probe "reset halt"
reset
halt
probe "reset+halt"
reset init
probe "reset init"
reset halt                                                                                                                                resume
sleep 100
mww 0x40036400 0xCAFFEEEE                                                                                                                 mww 0xE000EDF0 0xA05F0000
shutdown

Run it on an UNO Q with the 1.1.0 loader, connected over USB:

~/Library/Arduino15/packages/arduino/tools/remoteocd/0.1.1/remoteocd upload --adb-path "$(which adb)" -s <serial> -f why.cfg --verbose  ~/Library/Arduino15/packages/arduino/hardware/zephyr/1.no_uno_q_stm32u585xx.elf

Result:

PROBE reset halt: state=halted pc=0x08007d58 SWS=0 verify=5013ms fail=0
PROBE reset+halt: state=halted pc=0x08018326 SWS=3 verify=207ms fail=0
PROBE reset init: state=halted pc=0x08007d58 SWS=3 verify=206ms fail=0

Diff: 323 lines (+242 / -81) across 4 files Reviewer: facchinm Review duration: 18954m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 323 lines diff across 4 files
0.42
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.346
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #755"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 42.0% (MEDIUM) · Higher = larger blast radius
42.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.6% · Safe to merge
16.6%