-
-
Notifications
You must be signed in to change notification settings - Fork 475
fix: msposd OSD lost on Star6E boot (missing -d, waybeam respawn race) #2395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,13 +129,65 @@ start_telemetry() { | |
| size=$(curl -s localhost/api/v1/config.json | jsonfilter -qe "@.video0.size") | ||
| fi | ||
| msposd -b 115200 -c 8 -r "$osd_fps" -m /dev/"$serial" \ | ||
| -o 127.0.0.1:"$port_tx" -z "$size" > /dev/null & | ||
| -o 127.0.0.1:"$port_tx" -z "$size" -d > /dev/null & | ||
|
|
||
| [ "$router" = "msposd" ] && watch_waybeam_respawn "$osd_fps" "$serial" "$port_tx" "$size" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Some camera targets remain untested watch_waybeam_respawn is added to the shipped telemetry startup path, but the PR test plan leaves the non-Star6E and majestic hardware item unchecked and explicitly says it was not tested. The added watcher is intended to execute or no-op across those builds, so those camera paths remain within the claimed blast radius without board output confirming either behavior. Agent Prompt
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the blocking line. So on every image that ships this script, |
||
|
|
||
| sleep 5 | ||
| echo "&L70&F28&G8CPU:&C TEMP:&T\n&B" >/tmp/MSPOSD.msg | ||
| fi | ||
| } | ||
|
|
||
| # msposd needs -d/--osd to actually draw the OSD overlay (MI_RGN_Init) — | ||
| # without it, it runs and parses FC telemetry fine but never renders | ||
| # anything. See github.com/OpenIPC/msposd for the flag. | ||
| # | ||
| # waybeam (the venc/encoder daemon on Star6E SoCs) does an internal | ||
| # cold-restart shortly after its own startup (fork+exec, to lock in a | ||
| # cold-boot FPS re-kick — see src/star6e_pipeline.c in OpenIPC/waybeam), | ||
|
Comment on lines
+145
to
+147
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mechanism is not what waybeam does, and the comment will outlive the misunderstanding if it lands.
The fork+exec cold restart lives in So whatever produced the teardown you captured in |
||
| # which destroys and recreates its venc channel. msposd binds its OSD | ||
| # region to whatever venc channel exists at its own startup, once, via | ||
| # MI_RGN_Init, and never reattaches — so if msposd starts before this | ||
| # happens (which it always does: this script starts msposd right after | ||
| # S95waybeam returns, which is before waybeam's internal respawn fires), | ||
| # the OSD region is silently destroyed along with the old channel and | ||
| # never comes back. Re-scan /tmp/waybeam.log (whole file each check, | ||
| # since the respawn can complete before we start watching) for the | ||
| # respawn, then wait for its "ISP channel ready" to appear a second time | ||
| # (the real signal the new channel is up, not a guessed delay — it also | ||
| # appears once during the normal pre-respawn boot), then restart msposd | ||
| # so it reattaches. The bounded loops below are a safety net, not the | ||
| # wait mechanism. No-op on SoCs/builds where waybeam doesn't do this | ||
| # respawn (or majestic is in use instead) — /tmp/waybeam.log never gets | ||
| # the marker and this just exits after the timeout. | ||
| watch_waybeam_respawn() { | ||
| osd_fps="$1"; serial="$2"; port_tx="$3"; size="$4" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These assignments are not
watch_waybeam_respawn() {
local osd_fps="$1" serial="$2" port_tx="$3" size="$4" |
||
| ( | ||
| elapsed=0 | ||
| while [ "$elapsed" -lt 30 ]; do | ||
| grep -q "Respawning:" /tmp/waybeam.log 2>/dev/null && break | ||
| sleep 0.5 | ||
| elapsed=$((elapsed + 1)) | ||
| done | ||
|
Comment on lines
+166
to
+171
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Either name it |
||
| grep -q "Respawning:" /tmp/waybeam.log 2>/dev/null || exit 0 | ||
|
|
||
| elapsed=0 | ||
| while [ "$elapsed" -lt 20 ]; do | ||
| [ "$(grep -c "ISP channel ready" /tmp/waybeam.log 2>/dev/null)" -ge 2 ] && break | ||
| sleep 0.3 | ||
| elapsed=$((elapsed + 1)) | ||
| done | ||
|
|
||
| echo_log "waybeam respawned post-boot, restarting msposd to reattach OSD" | ||
| killall -q msposd | ||
|
Comment on lines
+181
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Slow encoder restarts lose the overlay watch_waybeam_respawn falls through to the restart path when its readiness loop times out, without confirming that a second ISP channel ready marker exists. If replacement-channel initialization takes longer than six seconds or fails, msposd starts before a usable channel exists and cannot perform the intended reattachment. Agent Prompt
Comment on lines
+174
to
+182
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the readiness loop times out, execution falls straight through to the restart anyway — there is no success flag and no post-loop guard. So when the replacement channel is slow or never arrives, msposd is killed and restarted against a channel that is not up, re-orphaning the region with no further retry. That is strictly worse than leaving the running instance alone: you lose whatever OSD was there. Gate the restart on the condition actually being met: ready=0
tries=0
while [ "$tries" -lt 20 ]; do
[ "$(grep -c "ISP channel ready" /tmp/waybeam.log 2>/dev/null)" -ge 2 ] && { ready=1; break; }
sleep 0.3
tries=$((tries + 1))
done
[ "$ready" = 1 ] || { echo_log "waybeam respawned but the channel never came up, leaving msposd alone"; exit 0; }(Also raised by the automated review — agreed.) |
||
| while pidof msposd >/dev/null 2>&1; do | ||
| sleep 0.2 | ||
| done | ||
|
Comment on lines
+183
to
+185
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wait is unbounded and never escalates.
|
||
| msposd -b 115200 -c 8 -r "$osd_fps" -m /dev/"$serial" \ | ||
| -o 127.0.0.1:"$port_tx" -z "$size" -d > /dev/null & | ||
|
Comment on lines
+186
to
+187
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a byte-for-byte copy of the invocation at lines 131-132. Two copies of a command line with seven flags will drift — the Factor it out: start_msposd() {
msposd -b 115200 -c 8 -r "$osd_fps" -m /dev/"$serial" \
-o 127.0.0.1:"$port_tx" -z "$size" -d > /dev/null &
}and call it from both places. |
||
| ) & | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Stopped telemetry can start itself again watch_waybeam_respawn backgrounds an untracked subshell, while stop() kills only named telemetry binaries and never cancels that watcher. A stop or rapid restart during either wait leaves the prior watcher alive, so it can later kill the new instance or launch msposd after the service was stopped. Agent Prompt
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The subshell is backgrounded and untracked, and Two reachable consequences:
If the watcher survives review at all it needs to be tracked — write its PID to (Also raised by the automated review — agreed.) |
||
| } | ||
|
|
||
| video_settings() { | ||
| for card in $(lsusb | awk '{print $6}' | uniq); do | ||
| case "$card" in | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-dis correct and I want to keep it — but it is not the whole story, and the PR description has the cause slightly wrong.DrawOSDstartsfalsein msposd and is set from two places in the option loop:case 'd', andcase 'z'— butcase 'z'sets it only insideif (limit), wherelimit = strchr(buffer, 'x'). So-z 1920x1080already implies-d. The only way the existing line draws nothing is$sizearriving empty or without anx, which happens when majestic's HTTP server is not yet listening at S98 time, or.video0.sizeis unset inmajestic.yaml.That matters because
-dalone masks it rather than fixing it: with an empty-z,set_resolution()is never called and msposd falls back to its built-in default, clamped to 1280x720. The overlay then comes up at the wrong geometry instead of not at all — which is harder to notice than the current failure.Please guard the value as well, something like:
Keep
-das the belt-and-braces so the overlay no longer depends on that curl succeeding.