Skip to content

fix: the last DFU state of non-manifestation tolerant devices should be DfuManifestWaitReset#29

Closed
matteo-meluzzi wants to merge 2 commits into
dfu-rs:mainfrom
matteo-meluzzi:main
Closed

fix: the last DFU state of non-manifestation tolerant devices should be DfuManifestWaitReset#29
matteo-meluzzi wants to merge 2 commits into
dfu-rs:mainfrom
matteo-meluzzi:main

Conversation

@matteo-meluzzi

Copy link
Copy Markdown
Contributor

I ran into the following error while trying to update a non-manifestation tolerant device which uses embassy-usb-dfu in the firmware:

called `Result::unwrap()` on an `Err` value: Dfu(InvalidState { got: DfuManifestWaitReset, expected: DfuManifest })

Therefore, there must be a mistake either in this library or in embassy-usb-dfu.
By looking at other implementations like this one, I think that the mistake is in dfu-core.
Could you please double check?

@matteo-meluzzi

Copy link
Copy Markdown
Contributor Author

@cecton can you determine whether this is a bug in dfu-core? I am not very familiar with the details of how usb dfu works myself.

@cecton

cecton commented Nov 24, 2025

Copy link
Copy Markdown
Member

hey! sorry I completely missed the PR somehow. I will look into it

@cecton cecton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc seems to agree with the WaitReset but when I tested on my device it fails:

[/home/deck/repos/dfu-libusb/src/lib.rs:135:17] &functional_descriptor = FunctionalDescriptor {
    can_download: true,
    can_upload: true,
    manifestation_tolerant: false,
    will_detach: true,
    detach_timeout: 255,
    transfer_size: 2048,
    dfu_version: (
        1,
        26,
    ),
}

The error is really not helpful:

Error: could not write firmware to the device

Caused by:
    0: rusb: Input/Output Error
    1: Input/Output Error

I'm sorry it will take a bit more time for me to validate this. If you know anybody who can give feedback on this or if anyone is passing by and looking at this issue, don't hesitate to comment.

Comment thread src/download.rs
(State::DfuManifest, State::DfuIdle)
} else {
(State::DfuManifest, State::DfuManifest)
(State::DfuManifest, State::DfuManifestWaitReset)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@cecton

cecton commented Nov 24, 2025

Copy link
Copy Markdown
Member

@matteo-meluzzi maybe it's worth checking with the folks of embassy-dfu-usb? They are probably way more knowledgeable about this than me and will have an idea.

I tested on a real device I use for a client and this PR seems to break the final step at the end. So it's also possible that the error might be in embassy-dfu-usb rather than here.

@matteo-meluzzi

Copy link
Copy Markdown
Contributor Author

Hi @cecton, thank you very much for looking into this. Indeed it's entirely possible that there is a bug in embassy-dfu-usb. I will contact a maintainer of that project and ask them.

Thanks again for your help and this super useful crate! 🤠

@cecton

cecton commented Dec 30, 2025

Copy link
Copy Markdown
Member

Thanks!! Please keep me updated on this I really want to help, I'm just really unsure because I tested on a real device and it doesn't seem to behave properly if I apply the fix here.

@matteo-meluzzi

Copy link
Copy Markdown
Contributor Author

After talking with someone with more experience, it seems that the issue is indeed on the embassy side.
I'll close this PR and make a new one there.

Thanks very much for your help! Thanks for making this amazing crate!

@cecton

cecton commented Feb 25, 2026

Copy link
Copy Markdown
Member

Thank you so much for you motivating words 💙 it really helps. I maintain this crate for work but it's not always easy and I'm happy to hear it's useful to someone.

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