Repository navigation
Buspirate library - #30
Open
JohnAZoidberg wants to merge 13 commits into
Open
JohnAZoidberg wants to merge 13 commits into
JohnAZoidberg wants to merge 13 commits into
Conversation
Python library on top of pybpio for driving an EC through the Bus Pirate 5 from test code: - All BPIO requests raise on failure instead of printing and returning False, and are serialized with a lock - Background capture of the EC console, cleaned of ANSI escapes, with optional timestamped log file - expect(regex, timeout), wait_quiet(), boot() and command() for running console commands and reading their output - flash() runs uartupdatetool over a PTY bridge with a timeout - PTY buffer bounded by bytes instead of chunk count Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Make buspirate_ctrl.py a thin CLI over ectarget.EcTarget and add options for use from shell scripts and CI: - --expect REGEX: wait for output after --reset/--flash, exit 1 on timeout - --send CMD (repeatable): run console commands, print their output - --timeout: bounds --expect/--send, sets the duration of --log - --logfile: timestamped console log - --flash-timeout: uartupdatetool no longer hangs forever Status messages now go to stderr so stdout only carries EC output, and failures give a non-zero exit code instead of a traceback or 0. Fix --reset-hold: the RST pin used to be released and the PSU disabled on exit, so the EC was never actually held. Skip teardown in that case; the next connection releases it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shells start background jobs with SIGINT ignored, and Python keeps that disposition, so a backgrounded --pty-bridge or --log could not be stopped with kill -INT. Install handlers for both SIGINT and SIGTERM so the BP5 is always torn down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hardware-in-the-loop tests on top of ectarget, run with pytest --ec-build <build dir> from scripts/: - flash the given build (skipped without --ec-build) - boot reaches "Inits done" with reset-pin cause and no panic, assert or watchdog messages - `version` reports matching RO/RW, equal to the version in ec.bin - console responds to commands - five back-to-back reboots Add pytest to shell.nix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
JohnAZoidberg
force-pushed
the
buspirate-library
branch
from
November 25, 2026 11:01
26e6fbf to
a97568e
Compare
JohnAZoidberg
marked this pull request as ready for review
November 25, 2026 11:03
Running `ssh host buspirate_ctrl.py --log` without -t and pressing Ctrl+C only kills the local ssh client. The remote process gets no SIGINT and, without a pty, no SIGHUP either; it is reparented to init and keeps the Bus Pirate port open, so the next run fails with "already open by: python". Once the EC goes quiet nothing is written to stdout, so not even a broken pipe ends it. While logging, poll stdin and stdout for POLLHUP/POLLERR and tear down as on Ctrl+C when either peer has closed. OpenSSH closes our stdout pipe; Tailscale SSH closes stdin right away but keeps stdout open until something is written. stdin is only watched if it was open when logging started, so `--log </dev/null` keeps working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EcTarget._quiet() hides pybpio's chatter with redirect_stdout(), which replaces sys.stdout process-wide. When the ec-console reader thread delivered data in that window, _Stream wrote to the StringIO's missing .buffer, raised AttributeError and killed the thread, so the rest of the EC log (e.g. the whole boot log after --reset) never showed up. Bind the real stdout buffer when _Stream is created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BusPirateConsoles owns the BPIO port and exposes the Bus Pirate's two hardware UARTs as independent channels: EC on IO4/IO5 (channel 0) and SoC on IO0/IO1 (channel 1). Each UartChannel supports write/send/read/expect, independent configuration and TX enable, an optional PTY and a raw log. Nothing touches the PSU or pull-ups; both channels start receive-only. RX faults are recovered per channel with a one second backoff. Requires firmware reporting uart_channel_count >= 2. Update the BPIO submodule for the new schema and client support. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the default cooked line discipline and echo, target output written
to the PTY master was echoed back and transmitted to the target as input
until a terminal program attached and set raw mode. Seen on hardware as
the EC shell receiving its own log lines ("command not found"). Set the
slave raw with TCSANOW so no flush is generated, preserving the bridge's
buffer-until-reader behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
set_pin(io, value) drives or releases an auxiliary IO (e.g. EC reset on IO3); the firmware refuses pins owned by an active UART channel. Recover RX faults with a per-channel backoff starting at 50 ms and doubling to 1 s while the line keeps faulting, reset once data flows. With a fixed 1 s interval an EC reset (line held low, second break on the first recovery) lost the first ~0.5 s of EC boot output; now the log starts at the Zephyr boot banner. Co-Authored-By: Claude Opus 5.5 <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.
For easy scripting and automation