Page 1 of 1

DFU from Linux

Posted: Mon Oct 04, 2021 7:43 pm
by ayard
Hi all,

I've been flashing the Proteus boards from my Linux machine using STLINK v3. But on the 0.6 board, there is no easily accessible JTAG connector other than the Tag-Connect connector. Since I don't have a Tag-Connect adapter, I thought I would use DFU over USB instead. I think I have the correct tools in place to do this from my Linux machine, but it requires a .dfu file. How do I convert from an .elf file to a .dfu file format?

Thanks,

Al

Re: DFU from Linux

Posted: Mon Oct 04, 2021 7:55 pm
by mck1117
All our firmware bundle zips include both bin and dfu - do you really need your own build?

Re: DFU from Linux

Posted: Mon Oct 04, 2021 7:56 pm
by mck1117
Also, the other side of the board has a footprint for the standard 10 pin cortex debug connector.

Re: DFU from Linux

Posted: Mon Oct 04, 2021 7:59 pm
by AndreyB
And if you need your own .dfu please see how our scripts produce those.

Re: DFU from Linux

Posted: Mon Oct 04, 2021 11:54 pm
by ayard
AndreyB wrote:
Mon Oct 04, 2021 7:59 pm
And if you need your own .dfu please see how our scripts produce those.
O/K .... thanks .... I'll look at the scripts and see if I can work it out from there.

Some of my planned projects will use the rusEFI firmware, which has the *.dfu file, some of the other projects aren't suitable for the rusEFI firmware, so I've written my own firmware for these, and need to convert the *.elf to a *.dfu.

Al

Re: DFU from Linux

Posted: Tue Oct 05, 2021 9:32 am
by Dron_Gus

Code: Select all

cd firmware/ ; cat flash_dfu.sh
#!/bin/bash
# This is a Linux/Unix script to do USB DFU (Device Firmware Update).
#
# The STM32 has multiple ways to write an application into the MCU.  One is
# is USB DFU mode.
# This can write a blank or overwrite a corrupted ECU, but does require
# that the processor be set into DFU mode by holding down the 'Program' (AKA
# 'Boot1') button at reset or power up.
# Note: The 'Program' button is only checked immediately after reset.  The
# button may be released after that instant.  A reset or power cycle may be
# needed to exit DFU mode.
#

# Future: Consider if creating a build/rusefi.dfu install file is more
# or less descriptive than multiple command line parameters.

dfu-util --alt 0 --download build/rusefi.bin --dfuse-address 0x08000000 --reset

# For Windows the batch file flash_dfu.bat runs the equivalent command
#   DfuSeCommand.exe -c -d --fn build/rusefi.dfu

Re: DFU from Linux

Posted: Tue Oct 05, 2021 11:36 am
by puff
probably, this line can be invoked from rusefi console?
however, it requires that dfu-util is installed.

Re: DFU from Linux

Posted: Tue Oct 05, 2021 9:48 pm
by ayard
I'm slowly gaining on this!

I found a little utility "elf2dfu", I just had to modify it for the correct PID/VID. This does the conversion from *.elf to *.dfu. Then I use dfu-util to do the upload.

On the Proteus 0.6 board, everything works great.

On the 0.4 board, it errors out. Apparently, this is a problem with the STM ROM code, they have a string descriptor where the length of the string doesn't match the length field. There are work-arounds for this, but I haven't bothered yet if it's only going to be this 1 board.

On the 0.3 board, it doesn't work at all. When you put the board into boot mode, the USB port doesn't even enumerate. I know the USB port is good, I use it for communication when the firmware is running.

Al