Repository navigation
Description
Source PR: #3863
Source comments:
- feat(rp2350w): add BTstack BLE transport #3863 (comment)
- feat(rp2350w): add BTstack BLE transport #3863 (comment)
- feat(rp2350w): add BTstack BLE transport #3863 (comment)
- feat(rp2350w): add BTstack BLE transport #3863 (comment)
- feat(rp2350w): add BTstack BLE transport #3863 (comment)
Why this matters: current peer-OTA success accounting and HTTP framing can report success for a failed transfer, while a blocking download can exceed the RP2350W watchdog window and an out-of-range port can silently target the wrong endpoint.
CodeRabbit suggestions (verbatim):
Guard the
servedRequestsconversion.
int(served.get(servedRequests, 0))raisesValueErrororTypeErrorwhen the device returns a non-numeric value. Neither exception is in the handler tuple at Line 161, so the run aborts with a traceback instead of the failure message.
Feed the watchdog during the blocking OTA download.
pollOtaArtifactUpdatecallsHTTPUpdate::update(client, ...)synchronously, butloop()only feedsFastLED.watchdog()at scope start/end viaFL_WATCHDG_AUTO(AUTORESEARCH_WATCHDOG_TIMEOUT_MS). A full firmware download can exceed the configured5000ms timeout and reset the board mid-upgrade. Disable the watchdog for this update or register an HTTPUpdate progress callback that callsFastLED.watchdog().feed().
Count only served requests that deliver the artifact.
serveOtaArtifactincrementsserved_requestsbefore it opens the file. A 404 response then still counts.run_ota_peer_autoresearchtreatsservedRequests >= 1as proof that the RP2350W downloaded the image, so a failed download can pass the check. Increment the counter after the transfer completes.
Don’t add
Content-Lengthto a chunked OTA response.
httpd_resp_send_chunksends HTTP responses as chunked transfer encoding. SettingContent-Lengthadds conflicting OTA framing, so usehttpd_resp_sendwith the full buffer instead, or confirm this Arduino-Pico OTA client accepts chunked responses for the active core version.
Reject port values outside the
uint16_trange.
static_cast<uint16_t>(port)truncates. A request withport: 70000becomes port 4464 and the update targets the wrong endpoint. Validate the upper bound too.
Acceptance criteria:
- RED: focused host tests show malformed/non-numeric
servedRequestsis reported as a controlled failure and a 404/partial artifact response cannot satisfy served-transfer proof. - GREEN: validate status types explicitly and increment
served_requestsonly after a complete successful response. - RED: a focused request test shows ports <= 0 and > 65535 are rejected before narrowing.
- GREEN: accept only the full
uint16_tendpoint range without truncation. - RED: a focused OTA transport repro exercises an update lasting longer than the 5-second watchdog interval and the current conflicting Content-Length/chunked response framing.
- GREEN: keep the watchdog fed (or safely disable/restore it) during the blocking update and emit one standards-compliant framing mode supported by the pinned Arduino-Pico HTTPUpdate client.
- Preserve cleanup on read/send/update failure and add deterministic tests for success, 404, partial-send, malformed status, timeout/watchdog, and framing behavior.
- Run focused tests, strict lint, RP2350W and ESP32-C6 builds, then prove OTA build-marker, reboot, CDC/network recovery, and serial RPC health on hardware.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(ota): keep Content-Length, halt watchdog, don't fake a complete body
fix(ota): harden RP2350W peer OTA accounting, framing and port range (#…
zackees commentedon Aug 21, 2026
Landed via #3961 (
a03fa0b30b). All five CodeRabbit findings addressed.Done
serveOtaArtifactincrementedserved_requestsbefore opening the artifact, so a 404 or a mid-transfer send failure still counted, and the host'sservedRequests >= 1proof passed on a transfer that never happened. The counter now bumps only after the final chunk is accepted.ESP_FAILwithout a terminating zero chunk. A zero-length chunk is precisely the "body ended normally" signal, so emitting one after a failed read presented a half-written firmware image as a well-formed response.pollOtaArtifactUpdatenow halts the counter withdisable()across the blocking download and re-arms to the sketch timeout immediately after.fl::net::tryParsePort(src/fl/net/port.h) accepts exactly[1, 65535]. BothapplyOtaArtifactandrunNetClientTestroute through it; the latter previously had no range check at all.servedRequestsparsing is now total. Anything that is not a plain non-negativeintreads as zero and surfaces as the ordinary failure instead of aValueError/TypeErrortraceback.boolis excluded explicitly, since it is anintsubclass andTruewould otherwise have counted as one served request. The artifact-server port reply is range-checked too.One finding resolved differently than suggested — worth recording
The suggestion to drop
Content-Lengthfrom the chunked response carried the caveat "or confirm this Arduino-Pico OTA client accepts chunked responses for the active core version." Confirmed against the pinned core (rp2040-5.7.0): it does not.HTTPClient::_sizeis initialised to-1and only ever assigned from aContent-Lengthheader (HTTPClient.cpp:1111), andHTTPUpdaterequireslen > 0or fails withHTTP_UE_SERVER_NOT_REPORT_SIZE(HTTPUpdate.cpp:232,:295). Removing the header would have made everyapplyOtaArtifactfail with "Server did not report size". The client decodes the chunked body but takes the image size fromContent-Length, so both are required and the header stays, now documented in-place with that evidence.Related: re-arming the watchdog with a longer timeout is not viable on this silicon —
Watchdog::begin()clamps toFL_WATCHDOG_MAX_TIMEOUT_MS, which is 16777 ms on RP2350 (watchdog_rp.impl.hpp:47,:111) because the counter is 24-bit microseconds. Hencedisable()/re-arm rather than a widened window.Verification: 283/283 host unit tests (new
tests/fl/net/port.cpppinning the 65536/65537/70000/74001 truncation boundaries), 16 cases inci/tests/test_ota_peer_hardening.py, 930 Python tests overall,bash lintclean,rp2350wandesp32c6builds green, and the newport must be in [1, 65535]string confirmed present in the linked rp2350w firmware.Still open — why this issue is not closed
The final bullet asks to prove OTA build-marker, reboot, CDC/network recovery and serial RPC health on hardware. No RP2350W is attached to this bench, so none of the above is validated on-device — only by host tests and target builds. Leaving open for that HIL pass.
zackees commentedon Sep 7, 2026
The hardware clause on this issue is now unblocked.
The bench fixture is confirmed a Raspberry Pi Pico 2 W — live evidence, not the historical record:
Until now the variant was unestablished, so the W-only acceptance criteria here could not be attempted at all. They can be run now:
bash autoresearch rp2350w --rpc-smoke— PASS (71 RPC methods, dual-core concurrency 200/200)bash autoresearch rp2350w --net-peer— deploys both boards; six full cycles ofwifiConnect→ join the C6 SoftAP →startNetServer→ bidirectional HTTP →stopNet→ pingDeploying the W build onto a board running non-W firmware needs
--upload-port— fbuild refuses to guess which board to BOOTSEL and fails clean without flashing.One known blocker for long soaks: #4173 — the RP2350W hangs in
wifiConnecton the 7th consecutive peer cycle and watchdog-resets. It self-recovers, so it limits repetition rather than stranding the fixture.Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Hardware criterion attempted — peer OTA never reaches the transfer
The blocker on this issue's last criterion ("prove OTA build-marker, reboot, CDC/network recovery, and serial RPC health on hardware") was that the fixture's variant was unproven. That is resolved — it is a Pico 2 W (
2E8A:F00F,status.platform"Raspberry Pi Pico 2 W (RP2350)"). So--net-peer --otacan now be run. It fails before any OTA work happens.Symptom
Reproducible across two runs with a clean daemon state:
ID 1is the first request on theprimaryclient — thestatuscall atci/autoresearch/ota.py:110, beforebeginOtaArtifact. So none of the artifact staging, framing, or served-counter logic from #3961 is exercised; the run dies at the handshake.The device is healthy
Queried immediately after the failure, over the same port:
Not a watchdog reset, not a crash, and
status— the exact call that timed out — answers immediately. The schema fetch had also just succeeded against this board, so RPC was working seconds before.What is not the cause
--net-peergenerally. The same two boards run--net-peerwithout--otathrough six full cycles —wifiConnect→ join the C6 SoftAP →startNetServer→ bidirectional HTTP →stopNet→ ping. See RP2350W hangs in wifiConnect on the 7th peer cycle, tripping the watchdog #4173 for that path's own separate limit.ota.py:99-106buildsprimary/peerthe same waynet.py:493-503does — passed-in interface for primary, fresh one for the peer.The delta is
--otaspecifically: different firmware on both boards, and a C6 deploy that takes ~67 s between the RP's flash and the first RPC.Suggested next step
Someone with the fixture should instrument between
primary.connect()and the firstrpc_data(primary, "status")inrun_ota_peer_autoresearch— the device is provably reachable on either side of that window, so the handshake itself is where it goes wrong. A longerboot_wait, or reconnecting rather than reusing the pre-attachedserial_iface, are the obvious things to try.Environment: NixOS 6.18.48, fbuild 2.5.23, RP2350W
2E8A:F00Fon /dev/ttyACM1, ESP32-C6303A:1001on /dev/ttyACM0.Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees commentedon Sep 7, 2026
Correction to my previous comment — wrong board, and wrong about the cause
Two things I got wrong above, both now settled by instrumenting the handshake.
1. It is the ESP32-C6 that fails, not the RP2350W. I said
ID 1was thestatuscall onprimary. Adding a per-link ping with a bounded retry shows the RP2350W settles silently on its first ping and the C6 fails all three:The original error,
No response with ID 1 within 20.0s, names neither the board nor the call, which is how I misattributed it.2. The fbuild fd leak IS implicated. I first blamed FastLED/fbuild#1426, then retracted that because a pre-flight check found no process holding either port. The retraction was wrong: the leak is created by the run's own C6 deploy, so checking beforehand cannot rule it out. Immediately after the failure:
Four distinct
fbuild-daemonpids did this across today's runs (414394, 434691, 544820, 551628). Each leaves the portEBUSYfor the next client on a board that stays enumerated and healthy.Why
--net-peerworks but--net-peer --otadoes notIt looks like a race with deploy duration:
--net-peer--net-peer --otaThe shorter OTA-mode deploy means the leaked handle is still live when the RPC client connects. That also explains why this looked like an OTA-logic fault when it is a serial-lifetime one.
Remaining unknown
After killing the holder, the C6 answers
pingwithnullrather than timing out — channel healthy, device returning nothing — while running the OTA-fixture firmware. The standardesp32c6AutoResearch build passes RPC smoke on the same board immediately afterwards. That may be a second, separate issue in the OTA fixture; I have not characterised it and am not claiming it is the same bug.Status
#3961's hardening still has not been exercised on silicon — the run dies at the handshake, before
beginOtaArtifact. Unblocking it most likely depends on FastLED/fbuild#1426 rather than on anything in this issue's own scope.Both boards are healthy and back to known-good builds.
Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
fix(autoresearch): handle KeyboardInterrupt explicitly in the settle …
fix(autoresearch): honor the run deadline while settling, and fix the…
fix(autoresearch): retry the settle ping when the serial write fails (#…
fix(autoresearch): name the board that failed the peer-OTA handshake (#…
zackees commentedon Sep 7, 2026
Status check on this issue's code items — most are already landed. I re-read the review comments against current
masterrather than assuming, and four of five are addressed:servedRequestsconversionci/autoresearch/ota.py:33documents the ValueError/TypeError fix++served_requestsnow runs afterhttpd_resp_send_chunk(request, nullptr, 0)returnspollOtaArtifactUpdate(uint32_t watchdog_restore_ms)feedsFastLED.watchdog(), with a note on the 24-bit hardware counteruint16_tfl::net::tryParsePort(), comment cites this issue and the 70000 -> 4464 wrapContent-Lengthto a chunked responseOn the last one:
Content-Lengthis retained alongside chunked framing, and the code comment citesHTTPClient.cpp:1111andHTTPUpdate.cpp:232/:295showing the pinned Arduino-Pico client requires the header to size the image, even though the body streams chunked. That is a reasoned resolution of the review comment rather than an oversight, and it matches this issue's own GREEN criterion ("emit one standards-compliant framing mode supported by the pinned Arduino-Pico HTTPUpdate client").The hardware-proof criterion is what remains, and my attempt at it wedged the peer. Recording it because it is a real hazard for anyone running this next.
bash autoresearch rp2350w --net-peer --ota --peer-environment esp32c6reflashes both boards, then failed at the first step:The C6 was then unopenable:
Diagnosis, in order — and two of my three initial reads were wrong:
fbuild-daemon <defunct>plusConnection refusedon its WebSocket.fbuild daemon restartfixed the transport./proc/*/fdscan found no process holding/dev/ttyACM2, so this was the kernelcdc_acmside, not userspace.fbuild daemon locksshowed no port locks either.authorized/unbind/removeall root-only, no passwordless sudo. I could not reset it.fbuild deploybrought it fully back:Chip type: ESP32-C6FH4 (QFN32),RESULT: RPC smoke PASS.Both boards are healthy now.
Practical warning for this criterion: the peer-OTA flow reflashes the fixture as well as the DUT, and the C6 has no watchdog/bootloader escape armed the way the RP2350W does (#4167/#4172). If the C6's CDC wedges mid-run on an unattended bench, there is no software path back without root — a USB reset needs privileges this account does not have. Worth either arming an escape on the fixture, or gating this run behind the PPPS-capable hub tracked in #3713/#3714.
The hardware-proof criterion is therefore still open. I am not going to retry it unattended without one of those mitigations in place.
ci(esp32s3): reduce the example sweep from 8 shards to 3 (#4165)
ci(esp32s3): reduce the example sweep from 8 shards to 3 (#4165) (#4242)
11 remaining items
docs(autoresearch): name the OTA chunk size and record what limits it
zackees commentedon Sep 10, 2026
Located: truncated requests are discarded without a reply
Traced the device-side receive path.
createSerialRequestSource()insrc/fl/remote/transport/serial.hreads a line and then:Returning
fl::nulloptmeans "no request available" — indistinguishable toServer::pull()from an idle link. So a line that arrives damaged is dropped with no response, no error, and no log. That is precisely the observed symptom: the host transmits all 735 bytes, the device replies with nothing at all, and the next RPC answers in 0.07 s.Worth noting what is not the limit:
readStringUntil()insrc/fl/system/serial.cpp.hpphas no size cap. It accumulates until the delimiter or a 1 s idle timeout, resetting the timer on every byte. So nothing in the line reader truncates at 512.That leaves the RX buffer as the place bytes go missing.
AutoResearch.inoalready anticipates this and callsSerial.setRxBufferSize(4096)beforeserial_begin(), with the correct ordering and a comment naming this exact hazard — yet the measured cliff sits right where the default 256-byte HWCDC queue would put it once framing is added. Whether that call takes effect on the C6's HWCDC is the thing to check next; I have not verified it, and it is a one-line experiment for someone with the part in front of them.Why this cost so much to find
The two defects compound. Bytes go missing silently, and then the damaged line is discarded silently. Neither layer says anything, so the failure presents as "the device stopped answering this one method" — which is what sent this investigation through port locks, CDC re-enumeration, partition tables, and firmware identity before arriving here.
Suggested fix, independent of the buffer question: when a line arrives that does not parse, respond. Even a JSON-RPC parse error with a null id, or a single
FL_WARNnaming the length received, would have made this immediate. A receive path that can only succeed or vanish is very expensive to debug from the far end of a serial link.Summary for this issue
app0, 20.6 KB overflow — fixed (#4276){lines returnnullopt— silently droppedsetRxBufferSize(4096)is called with correct ordering, effect on HWCDC unverifiedfix(autoresearch): replace every partition key, and name the OTA bloc…
fix(autoresearch): apply the OTA fixture partition table exactly once (…
fix(rpc): report a discarded request line instead of dropping it sile…
zackees commentedon Sep 10, 2026
Reopening the substance: I closed this prematurely, and there were four more layers
I closed this as completed at 15:00 today after root-causing the 512-byte chunk limit. That was wrong. Clearing that limit only revealed the next failure, and clearing that revealed the next. Peer OTA still does not complete. #4318 fixes what I could verify.
The layers, in the order they surfaced
startOtaArtifactServer→Artifact HTTP server start failedArtifact write failed at byte 200448on every run after the firstservedRequests: 0with no reason recorded anywhereUpdate error: ERROR[4]: Not Enough Spaceon the RP2 — control-socket collision.
HTTPD_DEFAULT_CONFIG()hardcodes.ctrl_port = ESP_HTTPD_DEF_CTRL_PORT(32768, confirmed in the IDF header).startNetServerruns immediately before, andfl::asio::http::Server::start()takes the same default, so the secondhttpd_startbinds a control socket the first owns. A distinctserver_portdoes not help — which is why 8081-vs-80 looked sufficient.3 — the fixture filesystem cannot hold two artifacts.
finishOtaArtifactdrops the old/rp2350.binonly after the new one verifies. Partition0x130000= 1,245,184 B; image = 1,030,348 B; headroom = 214,836 B; observed failure at byte 200,448, the difference being LittleFS block overhead. That arithmetic is what reconciled two runs I nearly wrote off as contradictory — run 1 hit a blank filesystem and transferred all 1,030,348 bytes with a matching SHA-256, run 2 inherited run 1's artifact and died 200 KB in.4 — the reason was being written to a closed port. The RP does explain itself via
FL_WARN("[OTA] RP2350W artifact update failed: ..."), butpollOtaArtifactUpdateruns fromloop()after the harness deliberately closes the RPC link so the board can reboot. A failed fetch and a fetch that never ran produced byte-identical evidence.rpOtaUpdateStatusnow carries the outcome back.5 — and it paid off immediately. First run with the probe:
Arduino-Pico stages an incoming image into the filesystem region —
Updater.cpp:101rejects when&_FS_start + size > &_FS_end,:121setsupdateStartAddress = &_FS_start.board_build_filesystem_sizewas0.5m= 524,288 B against a 1,030,348 B image. Raised to2m.Worth flagging for anyone else touching this: only the sizes
rpipico2wdeclares inboards.txtare selectable (0, 64K, 128K, 256K, 512K, 1M, 2M, 3M), because fbuild matches the string againstmenu.flash.<flash>_<fs>. An unmatched value does not error — it yieldsfs_start == fs_end, and the build dies much later insidePicoOTA.cppasthe comparison reduces to '(0 > 130048)'. I lost a cycle to1.5mexactly that way. 2M over 1M because 1M is 1,048,576 B against a 1,030,348 B image — an 18 KB margin the next commit to this sketch would erase.On the chunk size
The preflight still refuses 512, so the flow cannot run unedited. But the choice was never binary:
318 encodes to 424 characters, inside the 428 the device is measured to answer. I have not landed this — the constant was set to 512 deliberately when both known candidates failed, and reversing that is a call to make on evidence rather than inside a bug fix. But "both values fail" is not the whole option space.
What is not verified
Layer 5 is argued from the device's own error message, the arduino-pico source, and the arithmetic — not from a green run. Every attempt after it was killed mid-run by this bench's memory monitor, five times. The
2mbuild compiles, deploys and passes--rpc-smoke;1.5mreproducibly fails the assert. The fetch past that point remains unproven, and I would rather say so than imply a pass I do not have.Separately,
No response with ID 1 within 20.0scost me four wrong hypotheses before I found_connect_peer_with_retry's docstring already describing it as a race on the C6's CDC re-enumeration, captured four times previously. #4318 makes that error name the board, the port and the method.zackees commentedon Sep 10, 2026
Reopening: the flow does not complete. I closed this after explaining one blocker; four more sat behind it. Two are fixed and verified, one is fixed but unverified end to end, and the chunk-size preflight still refuses the committed value. Detail in the comment above; fixes in #4318.
fix(ota): unblock four stages of the RP2350W peer OTA flow, and stop …
fix(test): answer the OTA peer run's apply criterion in its success-p…