Skip to content

Conversation

@quic-kdybcio
Copy link
Contributor

No description provided.

Most (all?) fh implementations will not restart the device until the
host has consumed the log feedback after calling <reset>. Drain the
buffer after issuing that packet.

Reported-by: Axel Karjalainen <axel@axka.fi> # GH PR 29
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
The initial message buffer ("welcome logs") may look something like the
log attached below.

One may notice that there's a clear cut-off before the <configure>
packet, but the protocol gives no good way to delimit that, making
every session require waiting for the transport layer (USB) timeout,
signaling "end of data". Try being smart about it by checking for the
last message that usually comes from there.

<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: Binary build date: Feb 17 2022 @ 12:09:40" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: Binary build date: Feb 17 2022 @ 12:09:40
" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: Chip serial num: 648502458 (0x26a75cba)" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: Supported Functions (15):" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: program" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: read" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: nop" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: patch" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: configure" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: setbootablestoragedrive" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: erase" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: power" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: firmwarewrite" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: getstorageinfo" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: benchmark" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: emmc" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: ufs" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: fixgpt" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: getsha256digest" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: End of supported functions 15" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: Calling handler for configure" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="INFO: Storage type set to value UFS" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<log value="DEBUG: Calling usb_al_bulk_set_zlp_mode(TRUE), zlp is not set to 0" /></data>
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<response value="ACK" MemoryName="UFS" MinVersionSupported="1" Version="1" MaxPayloadSizeToTargetInBytes="1048576" MaxPayloadSizeToTargetInBytesSupported="1048576" MaxXMLSizeInBytes="4096" DateTime="Feb 17 2022 - 12:09:40" /></data>

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
nusb notably doesn't use libusb and should be helpful in trying to
overcome macOS's USB ZLP issues.

nusb is also purely written in Rust (utilizing OS native interfaces in
their specific backends) and has nice integrations with BufReader &
async APIs, which we'll hopefully take advantage of in the future.

This commit probably? removes support for *BSDs which may? have worked
prior, based on just libusb (if other dependencies weren't a blocker),
but the rusb backend can be brought back at any time if it's deemed
useful.

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Currently there's an attempted OOB read which crashes the program
anyway, handle it more reasonably.

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
@quic-kdybcio quic-kdybcio changed the title Move to rusb, fix some bugs, start flash promptly Move to nusb, fix some bugs, start flash promptly Nov 19, 2025
@quic-kdybcio quic-kdybcio merged commit d2fe890 into qualcomm:main Jan 7, 2026
8 checks passed
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.

2 participants