Skip to content

firehose: allow selecting the reset mode - #311

Draft
obbardc wants to merge 5 commits into
linux-msm:masterfrom
obbardc:wip/obbardc/reset-to-edl
Draft

obbardc wants to merge 5 commits into
linux-msm:masterfrom
obbardc:wip/obbardc/reset-to-edl

Conversation

@obbardc

@obbardc obbardc commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

The Firehose <power> command can reboot the device back into EDL or
power it off, not just reset it, but qdl only ever sent a plain reset.
Rebooting straight back into EDL saves a manual power cycle when flashing
the same board repeatedly. Modelled on the reset modes in
qdlrs.

This adds the mode in two places:

  • --reset-mode=<system|edl|off> for flashing runs, applied to the final
    reset (implicit or the reset verb). It is rejected together with
    --skip-reset.
  • qdl reset [--mode=<system|edl|off>] [<prog.mbn>]. Plain qdl reset
    keeps its Sahara behaviour. edl and off need Firehose, so the
    programmer is uploaded unless one is already running.

Supporting changes:

  • sahara_run() returns 1 when it finds a programmer already running, so
    qdl reset drains the startup banner of a freshly uploaded programmer
    before sending <power>, and skips the drain otherwise. Existing callers
    only check for a negative return.
  • Requesting an image with no programmer given now says so, instead of
    reporting an unknown image id.

Tests: unit tests for the mode decoding, the wire mapping, the drain
parser and --reset-mode parsing, plus a HIL step that resets into EDL
through a running programmer and from EDL, checking that the device
re-enumerates both times.

@obbardc
obbardc force-pushed the wip/obbardc/reset-to-edl branch from a58147c to c59bdb6 Compare August 25, 2026 19:49
The Firehose <power> command can also reboot the device back into EDL
or power it off, but firehose_reset() only ever sends "reset".
Rebooting into EDL avoids a manual power cycle when flashing
repeatedly.

Add enum qdl_reset_mode and pass it to firehose_reset(). All existing
callers use QDL_RESET_SYSTEM, so behaviour is unchanged. An invalid
mode is rejected rather than silently sent as a plain reset. The
function is not part of a stable ABI: both qdl and the nbdkit plugin
build it from source.

Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
When flashing the same board repeatedly, the final reset boots the
system and the board then has to be power cycled or strapped back into
EDL by hand before the next run.

Add --reset-mode=<system|edl|off> to choose what the final reset does,
for both the implicit reset and the explicit "reset" verb. It is
rejected together with --skip-reset, where there is no reset to apply
it to. The default stays "system".

Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
sahara_run() returns 0 both after uploading a programmer and when it
finds one already running, so callers cannot tell whether a programmer
has just started. A freshly started programmer is still printing its
startup banner, which a caller sending a lone command needs to wait
for, while one left running by an earlier run is ready straight away.

Return 1 when Firehose is detected and the upload is skipped, matching
sahara_device_reset(). All callers only test for a negative return, so
they are unaffected.

Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
A caller that expects a programmer to be running already passes no
images to sahara_run(). If the device is in fact still in Sahara, it
asks for the programmer and the user is told that an unknown image id
was requested, which does not point at the actual mistake.

Report that no programmer was given instead, and fold the identical
checks in the READ_DATA and READ_DATA64 handlers into one helper.

Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
"qdl reset" resets over Sahara and only falls back to a plain Firehose
reset, so it cannot reboot the device back into EDL or power it off
without also flashing.

Add --mode=<system|edl|off> and an optional programmer. Without them
the existing Sahara reset is kept. Otherwise the programmer is uploaded
unless one is already running, and the Firehose <power> command does
the reset. Extending "reset" rather than adding a second subcommand
keeps a single place to reset a device.

A programmer that has just started does not read its input until it
has printed its startup banner, so a lone <power> would time out and
be resent. Add firehose_drain() to consume the banner first, stopping
as soon as the output pauses, and only call it after an actual upload.

Add a HIL step that resets into EDL both through a running programmer
and from EDL, checking that the device re-enumerates each time.

Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
@obbardc
obbardc force-pushed the wip/obbardc/reset-to-edl branch from c59bdb6 to dc999bd Compare November 13, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant