gk7205v200/v300: failsafe rescue mode, flash-free DRAM boot counter, crash-log capture - #2396
Conversation
PR Summary by QodoAdd Goke failsafe boot, DRAM counter, and crash capture
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. Other cameras get a Goke memory write
|
…sh log Builds the recovery loop on top of the pstore region (#2392) and the bootcount arm/disarm (#2391), converting the counter off the NOR env. - Move the boot counter from the U-Boot env to a single DRAM word at 0x41f20000 (a no-map reserved region, board DTS): S99bootok clears it through /dev/mem once majestic is proven healthy, and sysupgrade arms it the same way. Writing the env every boot is NOR wear and a mid-write brick risk; a healthy boot now writes zero flash. On a U-Boot/kernel without the region the write lands in spare reserved RAM -- harmless. - rcS gains a failsafe branch: when U-Boot appends "failsafe" to the cmdline after bootlimit failed boots, bring up only logging, mdev, networking and SSH -- skip the SDK and the streamer -- so a crashlooping camera lands reachable instead of looping. The overlay stays mounted (claim intact); the counter is reset on entry so failsafe does not re-escalate. - S98crashlog preserves a crashed boot's pstore log into /etc/crash on the next normal boot (gzipped, capped to the latest, pstore ring then freed) and rcS drops a breadcrumb when it fell into failsafe, for the WebUI to offer the owner. Overlay-only, no flash on a clean boot. Proven on hardware, both allocators: gk7205v200 (64M) and gk7205v300 (128M) -- crashloop escalates to failsafe and self-recovers, pstore panic is harvested, counter resets on a healthy boot.
…served S98crashlog, S99bootok and the failsafe branch's DRAM-counter write lived in the shared overlay, so every board shipped them and cleared physical address 0x41f20000 on healthy boots, upgrades and manual failsafe entry -- even families that never reserve that word. On a HiSilicon layout it is live memory, not the counter, so a Goke-only write was being issued fleet-wide (qodo review on #2396). Shipping the two scripts to every board also pushed hi3518ev300_lite past its rootfs cap. Move the machinery into an openipc-failsafe package selected only by the gk7205v200/gk7205v300 defconfigs: - bootcount-clear derives the counter address from the board DTS reserved-memory node (bootcount@<addr>), so it is a safe no-op on any image that does not reserve it, and never touches flash; - failsafe-rescue is the failsafe branch, extracted from rcS; - S98crashlog and S99bootok move verbatim / switch to bootcount-clear. rcS keeps only a tiny dispatcher that runs failsafe-rescue when it is present, and sysupgrade calls bootcount-clear when present. Neither shared file writes another platform's memory now, and boards without the package carry none of the weight.
5055121 to
b7a2503
Compare
…served S98crashlog, S99bootok and the failsafe branch's DRAM-counter write lived in the shared overlay, so every board shipped them and cleared physical address 0x41f20000 on healthy boots, upgrades and manual failsafe entry -- even families that never reserve that word. On a HiSilicon layout it is live memory, not the counter, so a Goke-only write was being issued fleet-wide (qodo review on #2396). Shipping the two scripts to every board also pushed hi3518ev300_lite past its rootfs cap. Move the machinery into an openipc-failsafe package selected only by the gk7205v200/gk7205v300 defconfigs: - bootcount-clear derives the counter address from the board DTS reserved-memory node (bootcount@<addr>), so it is a safe no-op on any image that does not reserve it, and never touches flash; - failsafe-rescue is the failsafe branch, extracted from rcS; - S98crashlog and S99bootok move here and switch to bootcount-clear. rcS keeps only a tiny dispatcher that runs failsafe-rescue when it is present, and sysupgrade calls bootcount-clear when present. Neither shared file writes another platform's memory now, and boards without the package carry none of the weight. Also hardens the two reliability paths qodo flagged: bootcount-clear propagates the devmem exit status and S99bootok logs a healthy-boot clear that did not land, instead of silently letting U-Boot count toward failsafe; and S98crashlog stages tar to a file so a partial capture cannot pass gzip's exit status and then delete the pstore records it failed to preserve.
b7a2503 to
7d82a58
Compare
|
Addressed all three findings from the Qodo review in 1 · Rule violation — "Other cameras get a Goke memory write" (Rule 5): fixed by moving the machinery out of the shared overlay into a new
2 · Bug — "Healthy cameras can enter rescue mode": 3 · Bug — "Failed captures erase crash evidence": Off-camera gates re-run clean locally: Hardware note: the escalation path this enables was validated end-to-end on both a gk7205v200 (64M) and a gk7205v300 (128M) — bootlimit → U-Boot |
Why
The recovery + owner-diagnostics rungs, on top of the pstore region (#2392), the DTS no-map regions (OpenIPC/linux), and the bootcount arm/disarm (#2391) — which this converts off the NOR env.
What
0x41f20000(ano-mapreserved region in the board DTS).S99bootokclears it through/dev/memonce majestic is proven healthy;sysupgradearms it the same way. Writing the NOR env every boot is wear + a mid-write brick risk — a healthy boot now writes zero flash. On a U-Boot/kernel without the region the write lands in spare reserved RAM (harmless). Pairs with the DRAM bootcount inu-boot-gk7205v200#22.failsafeto the cmdline afterbootlimitfailed boots,rcSbrings up only logging, mdev, networking and SSH — no SDK, no streamer — so a crashlooping camera lands reachable instead of looping. The overlay stays mounted (claim intact); the counter is reset on entry so failsafe doesn't re-escalate.S98crashlog). On the normal boot after a crash, preserve the pstore log into/etc/crash(gzipped, capped, ring freed), and drop a breadcrumb when it fell into failsafe — for the WebUI to offer the owner (majestic-webui#427). Overlay-only, nothing on a clean boot.Proven on hardware — two Goke SoCs
0xB0010001→0002→boot Dev #3 →Bootlimit (2) exceeded → altbootcmd → FAILSAFE(network+SSH only, breadcrumb, counter reset), then self-recovers on the next normal boot; a real panic is captured in pstore and harvested to/etc/crash; the WebUI banner + download return the actual panic dmesg; a sustained-healthy boot resets the counter to 0.Overview for maintainers: https://claude.ai/code/artifact/71b8f759-6d64-408c-89c3-8db8227e1e07