Repository navigation
feat(autoresearch): add a 400 kHz chipset so UART is reachable on RP - #4224
Conversation
The RP PL011 cannot drive any 800 kHz part over UART. maxBaudRate() is clk_peri/16 = 3.0 MBaud on this silicon, while WS2812's 1250 ns period needs >=3.2 MBaud even at the coarsest geometry the encoder will accept (4 pulses/bit). Every --chipset choice was 800 kHz, so `--uart` on RP could only ever report `attempted=False ... needs a baud above the UART backend maximum` -- the backend looked broken when it was simply never given a chipset it could clock. Add WS2811-400KHZ (2500 ns), which needs 1.6-2.0 MBaud and fits. First UART transmission on RP: before attempted=False started=False encodedBytes=0 actualBaud=0 after attempted=True started=True encodedBytes=1200 actualBaud=2000000 Loopback still fails to decode, and the captured waveform says why -- see the PR. That is an encoder geometry issue, not a transport one, and is now observable for the first time because the data actually reaches the wire. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe autoresearch runner now accepts ChangesWS2811 400 kHz support
Priority: ⬇️ Low — Defer the narrow autoresearch and remote-test support change because it only adds 400 kHz WS2811 timing for RP UART transmission and leaves the default chipset unchanged. Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: 🟡 Moderate · up to The new ws2811-400 option can transmit within RP UART baud limits, but its encoded T1H remains out of tolerance and loopback decoding fails. The default chipset is unaffected, though the new option should be corrected or explicitly accepted as nonfunctional before merge. Sequence Diagram(s)sequenceDiagram
participant AutoresearchCLI
participant AutoresearchPhases
participant RemoteRunner
AutoresearchCLI->>AutoresearchPhases: Select ws2811-400
AutoresearchPhases->>RemoteRunner: Generate WS2811-400KHZ
RemoteRunner->>RemoteRunner: Resolve 400 kHz timing and encoder
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Correcting a claim in this PR's description, and a follow-up measurementThe description is wrong about geometry selection. I wrote that constexpr u32 kHysteresisNs = 50;
if (fit4.total_err_ns + kHysteresisNs < fit5.total_err_ns) { P = 4; } else { P = 5; }So the selection is best-fit, not first-fit. Apologies — that sentence should not have gone in. What is actually happeningFor WS2811-400 (T0H 500 ns, T1H 1200 ns, period 2500 ns):
P=4 has the lower total error, but the 50 ns hysteresis favouring P=5 means The summed-error metric is what misleads here. What matters per symbol is whether it lands inside the chipset's tolerance band:
A 200 ns error that leaves a symbol out of spec is not equivalent to a 125 ns error that stays in spec, but Measured, by neutralising the hysteresis locallySetting But the loopback still fails. In fact the capture gets worse: So the encoder geometry is a genuine defect, and it is not the blocker. Putting both symbols in spec does not make UART loopback pass on RP — there is a further problem in the RX/decode path, and P=4 makes byte capture worse rather than better. I have no evidence for why, and am not going to guess. The experiment is reverted; this PR remains just the additive Net position: UART loopback on RP is not achievable today. Two distinct problems are now measured rather than hypothesised — geometry selection scoring quantization error without regard to tolerance bands, and an RX/decode failure that persists with an in-spec waveform. |
…asses (#4228) The UART decoder hardcoded one chipset's quantised wire timing: fl::ChipsetTiming uart_timing{250, 500, 500, 50, "UART_4Mbps"}; Those values describe WS2812 at a nominal 1250 ns. At the 400 kHz rate that is the only one an RP PL011 can clock (#4224), they misclassify every symbol. Using uartWireTiming() to derive them from the chipset: before TEST UART0 lanes=1 leds=40 FAIL 533ms 40/40 LEDs wrong after TEST UART0 lanes=1 leds=40 PASS 527ms Three consecutive passes; PIO loopback unaffected (PASS 685ms). Worth recording that this closes the residual I had been calling a "missing final byte". Deriving the timing by hand for P=5 left 1/40 LEDs wrong, and I attributed the remainder to a capture defect. It was not one -- my hand derivation omitted the minimum-symbol-separation bump that fitUartWave() applies, so the decode windows were subtly wrong. The helper reproduces the encoder's rules exactly and the frame decodes completely. There was never a final-byte defect to chase. kMaxUartBaudRate is used rather than the backend's own ceiling, which is not portably reachable here; the geometry depends on the ceiling only through a feasibility gate, so the two agree wherever UART transmits at all. The comment records the case that would disagree. Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51 Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
The UART backend on RP was never actually exercised
bash autoresearch rp2350w --uartfails with:attempted=False— it declined before transmitting. Not wiring (pin discovery correctly appliestxPin: 0, and GPIO0 is a valid UART0 TX pin), and not a regression (A/B'd against #4218, which rewrote this teardown: identical failure with it reverted).The cause is arithmetic.
canRepresentTimingForMaxBaudaccepts a chipset if 5 or 4 pulses per LED bit fits, wherebaud = pulses × 1e9 / period_ns:RpUartPeripheral::maxBaudRate()ismin(clk_peri/16, 6.25 MBaud), andclk_peri/16binds at 3.0 MBaud on this silicon (the constant's own comment records "achieved 3000000"). So every 800 kHz part is rejected — and every--chipsetchoice was 800 kHz (ws2812,ws2814,ws2818, anducs7604, which is UCS7604-800KHZ).The backend was not broken. It was never handed a chipset it could clock.
This PR
Adds
--chipset ws2811-400, mapped to the existingTIMING_WS2811_400KHZ. First UART transmission on RP:1200 bytes is 100 LEDs × 3 × 4, and 2.0 MBaud is exactly 5 pulses/bit at 2500 ns.
Loopback still fails — and now we can see why
Period is 2500 ns as intended, and the two symbols are 500 ns and 1000 ns. But WS2811-400 specifies T0H = 500 ns and T1H = 1200 ns ±150 ns (1050–1350). The encoded
1lands at 1000 ns — 50 ns below the low edge of tolerance.That is quantization, and it is avoidable:
canRepresentTimingForMaxBaudevaluatesfitUartWave(timing, 5, ...) || fitUartWave(timing, 4, ...)— it takes the first geometry that fits rather than the one that reproduces the datasheet timing most closely. For this chipset the coarser geometry is strictly better on both symbols.I have not changed that selection here. It affects every platform using the UART backend, ESP32 included, and I can only test RP — so it belongs in its own change with someone able to check the ESP32 side. Filing this PR with the measurement so that decision has evidence behind it.
Scope note
--chipset ws2811-400is additive; the default staysws2812, and no existing invocation changes behaviour.🤖 Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
Summary by CodeRabbit