Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for DFU format #15

Open
karniv00l opened this issue Jul 6, 2023 · 5 comments
Open

Support for DFU format #15

karniv00l opened this issue Jul 6, 2023 · 5 comments

Comments

@karniv00l
Copy link

karniv00l commented Jul 6, 2023

Hi there,

firstly, thank you for this great library! I've stumbled upon it when researching DFU libraries for a Flutter package I was planing on developing.

I did some quick tests, flashing both .bin and .dfu formats.
So the .bin file works flawlessly without specifying address or interface, but after .dfu is downloaded, the microcontroller won't boot/run properly. The chip is STM32F405.

Here's how I tested it:

dfu-libusb

For both bin and dfu files, I use the same command, just a different file:

Binary

cargo run --example download -- --device 0483:df11 fw.bin

DFU

cargo run --example download -- --device 0483:df11 fw.dfu

dfu-util

Compared to dfu-util which works for both files, but different args are required:

Binary

dfu-util -a 0 --dfuse-address 0x08000000 -D fw.bin

DFU

dfu-util -d 0483:df11 -D fw.dfu

I'm attaching logs for both executions:

logs_bin.txt
logs_dfu.txt

not sure how much you can help me here, but I appreciate your time.

@cecton
Copy link
Member

cecton commented Jul 7, 2023

Hello!

Unfortunately we have not developed the DFU format afaik so that's probably why it doesn't work. It's writing the .dfu like it is a .bin file

If you have time feel free to make a PR. Otherwise maybe someone will take it at some point (maybe @yozhgoor if he wants to get into embedded development 😁)

@cecton cecton changed the title Binary vs DFU Support for DFU format Jul 7, 2023
@biner88
Copy link

biner88 commented Aug 7, 2023

Can you briefly talk about what work to do, or what documents to refer to, so that it can support files in dfu format? I have the time and interest to perfect it.
@cecton

@cecton
Copy link
Member

cecton commented Aug 9, 2023

hmm ... I will try 😅 @biner88

So... to avoid writing another state machine for the "download" command, we would need to make a reader (impl std::io::Read) that wraps the .dfu file. I think that's what I would do. You can even put that in a separate crate if you want (this could be useful for others I suppose?).

Then, in the DfuSync, we would need a new method that takes a .dfu file in argument.

Does that help? You probably need to find the specs for the .dfu file somewhere or just copy/inspire from the source code of dfu-util directly.

@biner88
Copy link

biner88 commented Sep 12, 2023

Sorry for replying so late, we finally used the bin file to update it. Thanks for sharing the crate.

@cecton
Copy link
Member

cecton commented Sep 12, 2023

No problem! I will keep the ticket open because it's a feature request (and it's useful)

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

No branches or pull requests

3 participants