serial_uboot_state
Detect whether a serial session is in U-Boot or a system shell, then sync the session mark so command wrapping stays correct. Use set/clear to force the mark when auto-detection is out of sync.
Instructions
Query, detect, or force-set the U-Boot mark of a serial session. The mark decides serial_exec's marker wrapping (U-Boot sessions use plain style without subshell). Actions: 'detect' (default) — classify the live environment in two layers. Passive first (zero side effects): buffer-tail anchors only — U-Boot prompt, login prompt, kernel boot, autoboot countdown. Anything else (e.g. a bare '#' tail, ambiguous between Linux root shell and custom U-Boot prompts) falls through to an active two-step probe: 'printenv' (>=2 U-Boot env verify keys → U-Boot), then 'echo $$' (whole-line numeric PID → system; whole-line '$$' or 'Unknown command' → U-Boot). Conclusive results sync the mark automatically. WARNING: each probe consumes one line of input — do NOT detect while a command may still be running or waiting for interactive input (e.g. Y/N). 'set'/'clear' — force the mark when auto-detection is out of sync; 'status' — read the mark only, no device I/O.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | detect (default) = probe live environment and sync mark; set/clear = force mark; status = read mark only | |
| session_id | Yes | The session ID returned by serial_open |