firehose: allow selecting the reset mode - #311
Draft
obbardc wants to merge 3 commits into
Draft
Conversation
The firehose power command accepts more than a plain reset: the device can also be rebooted straight back into EDL or powered off. Only "reset" was ever emitted in qdl, so callers that want the device to come back up in EDL, which is useful when flashing repeatedly to avoid a manual power cycle, had no way to ask for it. Add enum qdl_reset_mode and make firehose_reset() take it as an argument, mapping the mode onto the value attribute. All existing callers pass QDL_RESET_NORMAL, preserving current behaviour. Changing the signature is safe for both consumers: qdl links the common sources through the qdl_common static library and the nbdkit plugin recompiles those same sources into its shared module. Neither exposes the function across a stable ABI. Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
The reset modes the previous patch made available are not reachable from the command line: the "reset" subcommand goes through Sahara and only falls back to a plain Firehose reset; the "reset" flashing verb only runs at the end of a flash. Neither can leave the device in EDL or powered off. Add "qdl firehose-reset [<prog.mbn>] <edl|off|system>". Since the <power> command needs a programmer running on the target, the programmer is taken as an optional leading argument and uploaded through sahara_run() exactly as a flashing run does. sahara_run() skips the upload on its own when the target already answers in firehose, so passing the programmer is harmless and can be left out entirely when one is known to be up. Keeping this separate from "reset" also makes each mode testable on its own, without reflashing the board first, so a mode that a given programmer rejects can be identified directly. Tested on RB3gen2 with a UFS target, uploading prog_firehose_ddr.elf from a freshly booted EDL device: Sahara transfers the programmer, the programmer logs "bsp_target_reset_edl()" in response to <power value="reset_to_edl">, acknowledges it and the device re-enumerates in EDL. Argument handling was checked separately - an unknown power mode is rejected, an optional programmer binary is handled correctly too. Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
"firehose-reset" sends <power> as the only command of the session, immediately after Sahara hands control to a programmer that has just started. The programmer is still printing its startup banner at that point and is not reading its input endpoint, so the write times out after a second; firehose_write() then drains the backlog itself and retries; the retry is what the programmer answers. The result is a wasted second and a duplicate <power> document on the wire on every invocation, reproducible on an emmc target: FIREHOSE WRITE: <data><power value="reset_to_edl" .../></data> LOG: INFO: Binary build date: ... [ ~20 more banner lines ] FIREHOSE WRITE: <data><power value="reset_to_edl" .../></data> LOG: INFO: Calling handler for power The flashing path never hits this because the configure exchange in firehose_detect_and_configure() consumes the banner first. Export firehose_drain() and call it from the subcommand when it uploaded the programmer itself so the first write is the one that lands. It is skipped when no programmer was passed, where the session is already past its startup output. Tested on RB3gen2: the banner is consumed before the write, the single <power> that follows is acknowledged and the device comes back in EDL. Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
obbardc
force-pushed
the
wip/obbardc/reset-to-edl
branch
from
August 25, 2026 19:49
a58147c to
c59bdb6
Compare
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.
Implement various supported reset options and add a CLI target to call them separately.
As per qdlrs