power.rack: pod-hosted TFTP staging client#92
Merged
Merged
Conversation
Adds RackController.tftp_put / tftp_delete / tftp_clear / tftp_list — the host-side wrappers for the pod's `/tftp/*` endpoints. Lets defib stage firmware bytes into the pod's PSRAM, then have the camera's U-Boot fetch from the pod itself (192.168.1.1:69) over the local camera-side LAN. Why this matters: defib install's existing U-Boot+TFTP path requires a host-side TFTP server (port 69 — conflicts with dnsmasq, needs sudo, needs NIC IP plumbing). Pod-hosted TFTP gets rid of every one of those. The trade-off is that firmware bytes traverse WiFi once (host → pod HTTP POST) before being served to the camera over Eth, vs the direct camera-pulls-through-NAPT path which only crosses WiFi once but on the slower path (camera → pod → host). Companion to a rack firmware change (local-only branch) that adds the `tftpd.c` server on the W5500 interface and the `POST /tftp/<name>` HTTP staging endpoints. End-to-end measurement on hi3516ev300 nor-neo install (kernel 2.0 MB + rootfs 4.2 MB): Method Total Stage Flash Host setup needed -----------------------+-------+--------+-------+-------------------- 1. Agent write_flash 92 s — 77 s none (just /fastboot) 2. Host TFTP + sf write 132 s — 100 s sudo + dnsmasq + NIC 3. Pod TFTP + sf write 193 s 50 s 96 s none -----------------------+-------+--------+-------+-------------------- Pod TFTP is slower than host TFTP because the bytes traverse WiFi twice (host upload + pod serve) instead of once. It wins on operational simplicity vs Method 2 (no sudo, no port-69 conflict, no NIC plumbing) and is the natural fallback when the agent path isn't usable for a given SoC. 6 new tests in TestTftpStaging: - tftp_put posts correct URL and body - tftp_put rejects path-traversal / empty names - tftp_delete one file - tftp_clear all - tftp_list returns the JSON dict - 503 OOM from the pod surfaces as PowerControllerError verbatim Suite: 486 passed / 2 skipped; ruff + mypy clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
RackController.tftp_put / tftp_delete / tftp_clear / tftp_list— the host-side wrappers for the pod's/tftp/*endpoints. Lets defib stage firmware bytes into the pod's PSRAM, then have the camera's U-Boot fetch from the pod itself (192.168.1.1:69) over the local camera-side LAN.Why it matters: defib's existing U-Boot+TFTP path requires a host-side TFTP server on port 69 — conflicts with
dnsmasq, needssudo, needs NIC IP plumbing on the camera's subnet. Pod-hosted TFTP gets rid of every one of those: zero host setup, the pod talks to the camera on its own local LAN.End-to-end measurement
OpenIPC
hi3516ev300-nor-neoinstall (kernel 2.0 MB + rootfs 4.2 MB):write_flashsf writesf writePod TFTP is slower than host TFTP because the bytes traverse WiFi twice (host upload + pod serve) instead of once (camera-pulls-through-NAPT). It wins on operational simplicity vs Method 2 (no sudo, no port-69 conflict, no NIC plumbing) and is the natural fallback when the agent path isn't usable for a given SoC.
The PSRAM cap on the prototype N8R8 is 8 MB, comfortably holding both kernel + rootfs staged simultaneously.
Companion firmware change
Local-only branch on the rack repo (not on GitHub per project policy): adds
tftpd.c— a tiny RFC 1350 TFTP server bound to the W5500 interface, plusPOST /tftp/<name>HTTP staging endpoints. Stores files in PSRAM via zero-copy ownership transfer (tftpd_add_file_owned) to avoid the double-buffer OOM that the initial naïve impl hit on a 4 MB rootfs.Tests
6 new
TestTftpStagingcases:tftp_putposts correct URL and bodytftp_putrejects path-traversal / empty namestftp_deleteone filetftp_clearalltftp_listreturns the JSON dict503OOM from the pod surfaces asPowerControllerErrorverbatim (callers can fall back)Test plan
uv run pytest tests/ -x -v --ignore=tests/fuzz— 486 passed / 2 skippeduv run ruff check tests/ src/defib/uv run mypy src/defib/power/rack.py --ignore-missing-imports🤖 Generated with Claude Code