Repository navigation
fix(lpc): on-board jumper scan; LPC845 pin-toggle-rx passes on silicon - #5262
Conversation
…n-drain pads skip IOCON MODE - pinToggleRx drives TX through fl::pinMode/fl::digitalWrite (#5260 backend) instead of the Arduino core's ::pinMode/::digitalWrite. - test_lpc_pin_toggle_rx / test_lpc_pwm_dma_cl call positional-parameter RPCs with RpcBench.call_flat; RpcBench.call wraps params as [args], so every RPC (including the echo health check) failed. - pin_lpc.hpp: LPC845 PIO0_10/PIO0_11 are true open-drain I2C pads with no pull resistors; IOCON bits 5:0 are reserved there (UM11029 Tables 207/208), so setPull no longer writes MODE for them. NOT hardware-validated: the P0_10->P0_11 loopback read edges=1 on both master and this build (see branch notes).
The LPC845 --pin-toggle-rx bench had never passed on hardware. Every capture reported edges=1 whatever the wiring. Fixed on LPC845-BRK: - pinToggleRx sized its read-back span from a pointer (sizeof(ptr)/sizeof(EdgeTime) == 1), so it returned one edge. The same bug in pwmDmaClCaptureSelf rejected any frame over 1 LED. - LpcSctRxChannel::pollOnce now records a rise and a fall seen in one poll in capture order. Rise-first made the delta wrap to ~2.1 s. - The bench's period stats: the linear-search sqrt ran for billions of steps on a wide spread and tripped the watchdog. The one-pass E[x^2]-floor(mean)^2 variance was off by up to ~1.4 us. Both are replaced (bitwise isqrt, two-pass variance). - TX edges run on SysTick deadlines and the capture is polled once per half period. delayMicroseconds + micros() (~19 us per call) added +20% to the period at 1 kHz and lost edges above ~7 kHz. - ticksToNs uses 32-bit math when it is exact. A 64-bit soft divide per edge stalled the poll loop. - Low-memory JSON: an int array with a value > 32767 was packed as vector<float>, and low-memory has no float -> int conversion, so pinToggleRx(..., 100000, ...) and every pwmDmaCl color argument were rejected. Large ints now stay i64 on low-memory builds. - Bench cases are 1/5/10 kHz with a 1 us sigma budget. A polled toggle plus polled capture tops out near 13 kHz on the 24 MHz M0+. Jumper discovery instead of assumed wiring: - findConnectedPins on the LPC low-memory build tests every pin against every other with fl::pinMode/digitalWrite/digitalRead: a control read with TX released, then TX Low against the RX pull-up and TX High against the RX pull-down. It reports every pair, stuck pins, skipped pads, and the LPC845 open-drain pads (P0_10/P0_11 are only drivers). - pin_probe_lpc.hpp: LPC845 probe skips SWD (PIO0_2/3), RESET (PIO0_5), ISP entry (PIO0_12) and the console USART0 (PIO0_24/25). - --pin-toggle-rx and --pwm-dma-cl pick the pair from the scan unless --tx-pin/--rx-pin are given (ci/autoresearch/lpc_pin_scan.py). - pinToggleRx drives TX through fl::pinMode/digitalWrite (the #5260 backend), not the LPC8xx core's pinMode (framework-arduino-lpc8xx#40). - pin_lpc.hpp: no IOCON MODE write on LPC845 PIO0_10/PIO0_11, where bits 5:0 are reserved (UM11029 Tables 207/208). - test_lpc_pin_toggle_rx / test_lpc_pwm_dma_cl call positional RPCs with call_flat; RpcBench.call wraps params as [args], so even the echo health check failed.
…e user what is wired Agents must scan for loopback pairs (findConnectedPins, both internal pulls) and add the scan where a build lacks it. Documents the LPC low-memory scan reply and the LPC845 open-drain P0_10/P0_11 pads.
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
Memory usage (this PR vs. its merge base)Change in
|
- Bind findConnectedPins on LPC845 only, the LPC with a pin-probe skip table; on LPC804 it would drive SWD/RESET/ISP/console pads. - resolve_pins rejects a lone --tx-pin or --rx-pin instead of dropping it. - run_scan tells 'not bound' apart from 'did not answer'. - LowMemTickClock starts SysTick via millis() before reading it. - Two-pass variance saturates instead of wrapping on clamped edges.
…d; skip IOCON-identity pins (FastLED#5274) * fix(autoresearch): LPC corePullCheck only in the --pin-toggle-rx build; skip IOCON-identity pins (FastLED#5270) - phases.py passes FASTLED_AUTORESEARCH_LPC_CORE_PULL_CHECK with --pin-toggle-rx; the sketch compiles corePullCheck only under it. The default lpc845 image drops from 60472 to 59684 bytes. - Platform-neutrality markers on the remaining LPC lines from FastLED#5262/FastLED#5264. - The pull check skips P0_4 and P0_24 (IOCON slot == GPIO bit, so they cannot detect framework-arduino-lpc8xx#40), and a missing binding in the --pin-toggle-rx build now fails instead of skipping. Refs FastLED#5268 * fix: address CodeRabbit review feedback - check_core_pulls probes the corePullCheck binding (four -1 slots) before scanning, so a missing RPC fails even when no idle pin qualifies or the scan fails - test_lpc_pin_toggle_rx documents that it requires the --pin-toggle-rx build - lowMemCorePullCheck reads back via lowMemSettledHigh (fl::digitalRead); only the vendor ::pinMode calls under test stay platform specific * fix(autoresearch): an unanswered corePullCheck probe fails instead of skipping
Hardware follow-up to #5261 / #5260. On an LPC845-BRK, the
--pin-toggle-rxbench now finds its own jumper and passes on silicon. It had never passed on hardware: every capture reportededges=1, whatever the wiring and whichever pin API drove TX.Evidence (LPC845-BRK on
/dev/ttyACM1,bash autoresearch lpc845 --pin-toggle-rx --upload-port /dev/ttyACM1, deployed through fbuild)Target identity, checked before any flash: the firmware already on the board answered
ws2812SctTest, an RPC bound only underFL_IS_ARM_LPC_845.Jumper scan (the new
findConnectedPins; no wiring was assumed):One net joins P0_10, P0_11 (true open-drain pads) and P0_13.
::pinMode/::digitalWrite, same wiring)summary: 3 pass / 0 fail out of 3 cases, exit 0.Root causes found on the bench
pinToggleRxsized it assizeof(edges_buf)/sizeof(edges_buf[0])on a pointer, which is 4/4 = 1. The same bug inpwmDmaClCaptureSelfrejected any frame over 1 LED.LpcSctRxChannel::pollOncerecorded rise before fall when both arrived in one poll, so the delta wrapped and saturated to about 2.1 s. It now records them in capture order.E[x^2] - floor(mean)^2variance was also off by up to about 1.4 us at a 1 ms period. Replaced with a bitwise isqrt and a two-pass variance.delayMicrosecondsadded each write and poll to the half period (+20% at 1 kHz), andmicros()costs about 19 us per call (two soft divides). Edges now run on SysTick deadlines, with the capture polled once per half period.ticksToNsdid a 64-bit soft divide per edge. It now uses exact 32-bit math when the value fits.vector<float>. Low-memory has no float -> int conversion, sopinToggleRx(..., 100000, ...)and everypwmDmaCl*color argument were rejected. Large ints now stayi64on low-memory builds.test_lpc_pin_toggle_rx/test_lpc_pwm_dma_clcalled positional RPCs withRpcBench.call, which wraps params as[args], so even theirechocheck failed.Jumper discovery
findConnectedPinson the LPC low-memory build tests every pin against every other throughfl::pinMode/digitalWrite/digitalRead(the fix(lpc): native LPC845/LPC804 pin backend; honor forced software pins #5261 backend, not the core'spinMode, pinMode() indexes IOCON by GPIO bit; pull mode is applied to the wrong pin on LPC845/LPC804 framework-arduino-lpc8xx#40). For each pair: a control read with TX released, then TX Low against the RX pull-up, then TX High against the RX pull-down. It reports every pair, plus stuck pins.pin_probe_lpc.hpp: the probe skips SWD (PIO0_2/3), RESET (PIO0_5), ISP entry (PIO0_12) and the console USART0 (PIO0_24/25).--pin-toggle-rxand--pwm-dma-cltake the pair from the scan unless--tx-pin/--rx-pinare given.pin_lpc.hpp: no IOCON MODE write for LPC845 P0_10/P0_11, where bits 5:0 are reserved.Bench changes
Cases are now 1/5/10 kHz, all with a 1 us sigma budget. 100 kHz was never reachable: with a captured edge, one half period costs about 36 us on the 24 MHz M0+ (
fl::digitalWrite5.2 us pluspollOncerecording the edge), which caps the polled bench near 13 kHz. The remaining sigma (0.3-0.9 us) is TX scheduling granularity; masking interrupts did not change it. The SCT timestamps themselves are hardware captures. The mean stays at +/-2% and measures within 0.01%.Known limitations, not fixed here
--pwm-dma-clcan run now (its color args used to be rejected), butpwmDmaClCaptureSelfwedges in theChannelEngineLpcSctDmapoll()spin aftershow(), and the watchdog resets the board. That's a separate engine/capture SCT-sharing problem.--ws2812-loopbackis unchanged: edges 0/1 on every case, the same output fix(lpc): interrupt-driven USART0 RX ends LPC845 RPC loss; SCT RX capture stops wedging the console #4676 recorded.HardFault_Handlerpushes 6 words beforeMRS MSP, so its printedPC=is really the stacked R0 (framework-arduino-lpc8xx).Tests
bash lintgreen.uv run pytest ci/tests/test_lpc_pin_scan.py ci/tests/test_autoresearch_phases.py -k lpc: 20 passed.bash compile lpc845 --examples AutoResearchOK; the ws2812-loopback (RX-DMA) build fits and deploys.Summary by CodeRabbit