platformio / platform-ststm32

ST STM32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/ststm32
Apache License 2.0
405 stars 312 forks source link

Real DFU upload #566

Open dzarda opened 3 years ago

dzarda commented 3 years ago

When upload_protocol = dfu is selected, we seem to force DfuSe - the ST's revision of the protocol. DfuSe appears to be activated by the -s parameter which is always passed to the upload command:

https://github.com/platformio/platform-ststm32/blob/214e5ce95b33bb1fef9bdd44af55bfbdbbf78a46/builder/main.py#L217:L218

When invoked on a device running DFU-compliant bootloader, the upload fails in the following way:

...
CURRENT: upload_protocol = dfu
dfu-util -d vid:pid,0x2C99:0x0010 -a 0 -s 0x08000000:leave -D "C:\Users\Dzarda\Documents\src\pen\.pio\build\penboard_dfu\firmware.bin"
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2020 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Match vendor ID from file: 2c99
Match product ID from file: 0010
Opening DFU capable USB device...
ID 2c99:0010
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Could not read name, sscanf returned 0
Device returned transfer size 128
Failed to parse memory layout
*** [upload] Error 74

I tried doing upload_unflags = "-s" but that's not recognized.

Is there a way of invoking dfu-util without -s ?

maxgerhardt commented 3 years ago

You can only give it a completely new upload_command but you can't un-flags only some parts of the command (if you don't want to modify builder/main.py)