Repository navigation
Description
runSingleTest bounds laneSizes with a constant that only holds for one chipset geometry. Above the real limit the guard passes the request through and capture fails silently — passed: false, bytes: 0, no error — which is the outcome the guard exists to prevent.
examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp:512
const int max_leds_per_lane = mState->rx_buffer.size() / 32;rx_buffer is fl::span<uint8_t> of 3300 bytes, so the advertised cap is 3300 / 32 = 103.
Measured on an RP2350W (PIO0, GPIO0 -> GPIO1 bridge)
Every row reproduced 3/3:
| geometry | advertised cap | actual usable | above it |
|---|---|---|---|
WS2812B-V5 (800 kHz) |
103 | 100–102 | silent failure |
WS2811-400KHZ (400 kHz) |
103 | 60–64 | silent failure |
WS2811-400KHZ leds= 60 passed=True bytes=720
WS2811-400KHZ leds= 65 passed=False bytes=0 <- accepted by the guard, fails in capture
WS2812B-V5 leds=100 passed=True bytes=1200
WS2812B-V5 leds=103 passed=False bytes=0 <- the advertised maximum itself
WS2812B-V5 leds=110 -> {"error": "LaneSizeTooLarge", "message": "... exceeds max 103"}
Two defects
1. The advertised maximum does not work, even at 800 kHz. 103 is accepted and then fails, 3/3. A caller who trusts the number the device reports gets silence rather than LaneSizeTooLarge — strictly the worse of the two failures, since the guard's whole purpose is to turn this into a clean error.
2. A fixed divisor cannot express this limit. Decoded LED data is 3 bytes per LED; 32 bytes per LED means the buffer holds raw capture samples, whose cost scales with how long the frame lasts. A 400 kHz frame is twice as long as an 800 kHz frame of the same LED count, so no single constant describes both. At 400 kHz the cap is ~70% too high, and everything from 65 to 103 LEDs is accepted and silently fails.
Why this matters beyond the constant
The silent band is wide enough to be mistaken for a different bug. The AutoResearch default is 100 LEDs, which sits deep inside the 400 kHz failure band — so --chipset ws2811-400 appears to fail on every driver, and I spent a while concluding the RX decoder could not handle 400 kHz at all. It handles it fine below the real ceiling. Anyone testing a slower chipset will hit the same false trail.
Direction
runSingleTest already receives the timing ("timing": "WS2811-400KHZ") and resolves it to t1_ns/t2_ns/t3_ns a few lines later for make4PhaseTiming, so the information for a geometry-aware bound is available at the same call site — the cap could scale with the bit period rather than being constant.
I am deliberately not proposing a number. Deriving the true bytes-per-LED needs the PIO_RX sample rate and whether it is fixed or tracks the bit period, which I could not establish black-box: no simple model fits both thresholds. Frame duration does not (3.09 ms fails while 3.60 ms passes), bit count does not (2400 bits pass while 1560 fail), and even inverse-proportionality does not — halving the bit rate moves the usable cap by 1.6x, not 2x. Whoever owns that capture path can size it properly; the table above pins what any correct answer has to reproduce.
The guard's shape is right — a bounds check returning a clear error. Only the bound is wrong, and changing the constant will not fix it.
Found while working #3899. Related: #3899 (RP2350 HIL matrix).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 11, 2026
Exact boundary at 800 kHz: usable max is 100, advertised is 103
Narrowed the range from my original report. Driving
runSingleTestdirectly (no rebuild, so this is cheap to reproduce):So the guard admits three LED counts it cannot serve at 800 kHz, and each fails silently —
passed: false,bytes: 0, no error — where 104 and above get a cleanLaneSizeTooLarge.max_leds_per_lane = rx_buffer.size() / 32= 3300/32 = 103. The divisor is off by roughly 3% for this geometry, and the error compounds for slower ones: at 400 kHz the usable maximum is between 60 and 64 against the same advertised 103.On deriving the correct divisor
Two usable data points — 100 at a 1225 ns period, ~62 at 2500 ns — imply about 33 and 53 bytes per LED respectively. That is not proportional to the bit period (ratio 1.6 against 2.0), so a single constant cannot work and neither can a simple
k / period. A two-parameter form (bytes_per_led = k * period + fixed) fits both, but two points fitting two parameters is arithmetic, not evidence.I looked for a third geometry to test it against. The other supported chipsets are clustered too tightly to discriminate — WS2818 1200 ns, WS2812B-V5 1225 ns, UCS7604 1250 ns, WS2814 1280 ns — and the predicted maxima differ by only a few LEDs across that span, which is inside what I could distinguish reliably. So I am not proposing a formula; it would be fitted, not derived.
What the fix needs is the PIO_RX capture path's actual per-LED cost, which whoever owns that code can state directly rather than infer. The measurements here pin what any correct answer has to reproduce:
zackees commentedon Sep 11, 2026
Both boundaries now exact
WS2812B-V5WS2811-400KHZEach boundary confirmed 2/2 on both sides. At 400 kHz the guard admits 40 LED counts it cannot serve (64 through 103), every one failing silently.
Implied buffer cost against the 3300-byte
rx_buffer: 33.0 bytes/LED at 1225 ns, 52.4 at 2500 ns. The ratio is 1.59 against a period ratio of 2.04, so it is neither constant nor proportional — consistent with a per-LED component plus a duration-dependent one.I am still not proposing a formula. Two exact points admit a two-parameter fit, but that is solving for the parameters, not testing the model, and the remaining supported chipsets (1200/1250/1280 ns) are clustered too tightly to discriminate a prediction. Worth noting neither implied figure maps cleanly to an obvious mechanism either: 33 bytes/LED is under one byte per signal edge (48 edges/LED), which rules out per-edge timestamps as the whole story.
What is solid and actionable is the table: any correct bound must yield 100 at 1225 ns and 63 at 2500 ns.
zackees commentedon Sep 11, 2026
The ceiling is not period-dependent in the 800 kHz band — my two-parameter model is refuted
I said a two-parameter fit (
bytes_per_led = k * period + fixed) matched both known points but that I would not publish it without testing. Tested it, and it is wrong.The fit predicted WS2818 (1200 ns) -> 101 and WS2814 (1280 ns) -> 97. Measured, each boundary confirmed by the pass/fail transition:
WS2818WS2812B-V5WS2814WS2811-400KHZThree geometries spanning a 6.7% period range all cap at exactly 100. Period has no effect there, which no period-proportional model produces — WS2814 should have lost three LEDs and lost none. So the relationship is not smooth in the bit period; something changes between the 800 kHz band and 400 kHz rather than scaling with it.
That is worth more than the fit would have been. Had I published the formula, it would have been right at the two periods I derived it from and wrong at a third.
UCS7604 is a separate problem, not a data point
I nearly used its failure at 98 LEDs as a fourth point. It is not a ceiling:
It fails at every size tested, including sizes far below any ceiling, and with non-zero captured bytes (12/LED) rather than the
bytes: 0the capacity failure produces. So capture is working and the comparison is failing — a different fault, plausibly its 16-bit encoding.--chipset ucs7604appears unusable on this path at any length, which is worth its own look and is not what this issue is about.Constraint for any fix
Any correct bound must yield 100 at 1200, 1225 and 1280 ns, and 63 at 2500 ns. A constant divisor cannot (it gives 103 everywhere); neither can anything proportional to the period.
zackees commentedon Sep 11, 2026
The bound is a property of the shared capture path, not the TX driver
Ran the same boundaries on the other two PIO instances:
Identical to the LED, with the same
bytes: 0failure shape above each boundary. So the limit is not per-PIO-instance — it belongs to the shared RX capture path andrx_buffer, which is consistent withmax_leds_per_lanebeing computed frommState->rx_buffer.size().Practical consequence for a fix: the bound should be corrected once in the capture path rather than per driver, and any correction is testable against all three instances at no extra cost.
Consolidated constraint, all boundaries confirmed by their pass/fail transition:
(
UCS7604is excluded deliberately — it fails at every length for an unrelated reason, filed as #4373.)zackees commentedon Sep 11, 2026
I said I would not propose a number because no simple model fit both thresholds. With a third geometry the model turns out to be exact for the 800 kHz class, and it is one the code already contains.
The bound is the PIO edge pool, and it is written down
src/platforms/arm/rp/rpcommon/rx_pio_channel.h:16That is 100 LEDs x 3 bytes/LED x 16 phases/byte. The ceiling is not on LEDs — it is on wire bytes, and the usable maximum is
kRpPioRxEdgeCapacity / 16= 300 bytes.The guard's
rx_buffer.size() / 32divides an unrelated buffer:rx_bufferis the 3300-byte decode output, and 32 has no connection to the capture pool.3300 / 32 = 103only looks plausible because it lands near 100 by coincidence.Measured, 3/3 per row (RP2350W
2DCB876B587EA334, PIO0, GPIO0 -> GPIO1)Two geometries with nothing in common at the LED level — 100 LEDs versus 47 — break at exactly the same wire size, 303 bytes, the first value whose 16-phases-per-byte cost exceeds 4801. The prediction is not approximate: on both sides of the boundary it is right to the LED.
(UCS7604 wire bytes are
15 + 6*leds: a 15-byte preamble and 16-bit channels. Its numbers come from testing #4373, which had to be fixed first — before that the encoder never reached the transmitter, so every UCS7604 run put raw 3-byte pixels on the wire and this geometry did not exist to measure.)So the cap is expressible, and it has to be encoder-aware: at 800 kHz a UCS7604 channel tops out at 47 LEDs where WS2812 tops out at 100. A guard phrased in LEDs cannot be right for both; one phrased in wire bytes is right for both.
The 400 kHz ceiling is a different mechanism
400 kHz still does not fit, but the shape is now much sharper than "no model fits":
It breaks at 192 bytes — 36% under the pool. And the DMA is not the constraint:
rpPioWordCountreads exactly8 * wire_bytesin every row above, passing and failing alike, including 1536 words for the failing 400 kHz case against a 4801-word pool. One word per bit, no run splitting, nothing lost in capture. Whatever rejects the 400 kHz frame does so after the words are in memory.That kills the hypothesis in
capture()'s own comment — "a 400 kHz capture overflows and is discarded ... because long runs do not always land in one entry". The long runs do land in one entry. Something downstream of the word count draws a line at 190-192 wire bytes.Where that leaves the two defects
Defect 1 (the advertised maximum does not work) is explained: 103 is accepted and 4801/16 = 300 bytes = 100 LEDs is the truth, so 101, 102 and 103 all sit in the silent band. All three fail 3/3.
Defect 2 (a fixed divisor cannot express the limit) holds, and the correct form is now concrete for everything except 400 kHz:
The 400 kHz bound is lower and independent; a guard built only on the expression above would still accept the 64-LED case that fails 3/3. That part remains open, and my measurements point away from capture capacity as the cause.
zackees commentedon Sep 11, 2026
Correction and completion of my previous comment.
The correction first. I wrote that "the DMA is not the constraint" because
rpPioWordCountreads exactly8 * wire_bytesin every row.rpPioWordCountis not the RX DMA — it comes fromfl::BusTraits<fl::Bus::FLEX_IO, N>::instance().lastWordCount()(channel_engine_rp_pio.h:35), the transmitter. Eight words per byte is one TX word per bit, which is why it tracked byte count so cleanly and said nothing about capture. Everything I inferred from it about the 400 kHz case was unfounded. The edge-pool result in that comment is unaffected — it rests on the pass/fail boundaries, not on that number.With that removed, the 400 kHz ceiling has a clean explanation, and there are exactly two constraints. Each is the binding one in its own regime, which is why no single model fit.
Constraint 1 — the edge pool (bounds the fast chipsets)
As before:
wire_bytes * 16 <= kRpPioRxEdgeCapacity (4801), i.e. 300 wire bytes. Two phases per bit, eight bits per byte. Confirmed to the LED on WS2812B-V5 (300 B pass / 303 B fail) and UCS7604 (297 B pass / 303 B fail).Constraint 2 — the DMA sample-time budget (bounds the slow chipsets)
rx_pio_channel.cpp.hppsamples the pin into 32 samples per DMA word at a fixed clock:Any frame of 151 bytes or more clamps
mCapacityto 4801, somDmaWordCountis a constant 2465 words. That is a fixed quantity of wall-clock time, not of data:The capture must also observe
signal_range_max_ns(100 µs, theRxChannelConfigdefault, never overridden incapture()) of trailing idle beforefinishTailIfIdle()will terminate it, leaving ~3.84 ms for the frame itself. Measured boundary:The break sits exactly on the budget.
The two constraints are separable, and I measured them apart
Same wire size, same edge count, two bit periods:
192 bytes and 3072 edges either way. Only the duration differs, and only one of them fails. Constraint 2 is about time; constraint 1 is about size. Neither alone predicts both chipsets, and together they predict every boundary in this issue and in the driver-sweep comment above.
Why each is invisible in the other's regime: at 800 kHz the 300-byte pool ceiling caps the frame at 2.94 ms, so the 3.84 ms budget is never approached. At 400 kHz the 3.84 ms budget caps the frame at 192 bytes, so the 4801-edge pool is never approached. The two ceilings cross somewhere around a 1.6 µs bit period, which is why 800 kHz-class parts all report 100 and the single 400 kHz part reports 63.
What a correct guard looks like
Both inputs are available at the
runSingleTestcall site: the encoder is resolved a few lines below the guard (that is what #4373 was about), andt1_ns + t2_ns + t3_nsis the bit period it already computes formake4PhaseTiming. Defect 1 and defect 2 both fall out of taking the smaller of the two.Worth noting what this does to the advertised number for a 4-lane UCS7604 request: 47 LEDs, not 103.
All rows RP2350W
2DCB876B587EA334, PIO0, GPIO0 -> GPIO1, 3/3 each.docs(lessons): record diagnostic provenance and mutually-masking cons…
fix(autoresearch): carry the encoder into the channel so UCS7604 test…
fix(uart): stop 400 kHz picking a geometry whose '1' symbol nothing c…
fix(autoresearch): bound RP PIO lane sizes by what the capture can ac…
fix(autoresearch): bound RP PIO lane sizes by what the capture can ac…