Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ is on main, the release is published with that section as its notes (AGENTS.md,

### Command line

- On Linux, an A12 device entered by a usbliter8 board starts by the ibss
route: the boot request can end in a USB protocol error while the iBSS
takes over, and the run no longer stops there.

- The A13 iPhones (iPhone 11, 11 Pro, 11 Pro Max, SE 2nd generation) get
their boot firmware built as the A12's: their patched iBSS takes the same
borrowed manifest, so no manifest of your own is needed.
Expand Down
12 changes: 10 additions & 2 deletions crates/usb/src/dfu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ const SUFFIX: [u8; 12] = [

/// The reply to a request that starts code, or that an exploit payload
/// answers, can be lost: the device leaves or the payload does not answer.
/// On Linux a device that leaves in the middle of the request can show as a
/// broken transfer (EPROTO) rather than a disconnect, as usbliter8's boot
/// request does on an iPhone XS Max while the iBSS starts.
fn reply_may_be_lost<T>(reply: Result<T, Fault>) -> Result<Sent, Fault> {
match reply {
Ok(_) => Ok(Sent::Acknowledged),
Err(e) if matches!(e.kind, Kind::Timeout | Kind::Stall | Kind::Disconnected) => {
Err(e)
if matches!(
e.kind,
Kind::Timeout | Kind::Stall | Kind::Disconnected | Kind::Fault
) =>
{
Ok(Sent::Unconfirmed)
}
Err(e) => Err(e),
Expand Down Expand Up @@ -546,7 +554,7 @@ mod tests {

#[test]
fn only_transfer_failures_can_be_unconfirmed() {
for kind in [Kind::Timeout, Kind::Stall, Kind::Disconnected] {
for kind in [Kind::Timeout, Kind::Stall, Kind::Disconnected, Kind::Fault] {
assert_eq!(
reply_may_be_lost::<()>(Err(Fault::new(kind, "test"))).unwrap(),
Sent::Unconfirmed
Expand Down
7 changes: 7 additions & 0 deletions crates/usb/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ pub enum Kind {
Stall,
/// The device is gone.
Disconnected,
/// The transfer broke off on the bus (Linux: EPROTO), as when the
/// device leaves in the middle of a request.
Fault,
/// The device answered, but not with what the protocol expects.
Unexpected,
/// The device is not in the mode this protocol talks to.
Expand Down Expand Up @@ -103,6 +106,10 @@ impl From<nusb::transfer::TransferError> for Fault {
T::Cancelled => Fault::new(Kind::Timeout, "timed out"),
T::Stall => Fault::new(Kind::Stall, "the device rejected the request"),
T::Disconnected => Fault::new(Kind::Disconnected, "the device disconnected"),
T::Fault => Fault::new(
Kind::Fault,
"the transfer broke off (hardware fault or protocol violation)",
),
other => Fault::new(Kind::Other, other.to_string()),
}
}
Expand Down
Loading