tnc3-firmware icon indicating copy to clipboard operation
tnc3-firmware copied to clipboard

Flashing with `dfu-util`?

Open ge0rg opened this issue 5 years ago • 5 comments

Hi,

there is an OpenMoko project to flash STM32 devices at http://dfu-util.sourceforge.net/ which looks much leaner and more compact than the STM original software. It's also packaged in debian as dfu-util.

When I put the TNC3 into DFU mode, it's listed by dfu-util as follows:

dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 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/

Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="207E32823141"
Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7000/01*0001Ke", serial="207E32823141"
Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes  /0x1FFF7800/01*040 e", serial="207E32823141"
Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash  /0x08000000/0128*0002Kg", serial="207E32823141"

The last line has the 0x08000000 offset that you also mention in the official howto, but when I "upload" the firmware into a local file, it is just random data junk (encrypted?) and doesn't have an ELF header; so I didn't dare to try "downloading" the current firmware onto the device.

Do you think it's feasible to use dfu-util (or maybe dfu-tool from fwupd, but it complains about the DFU version being 0.00) to flash the TNC3?

ge0rg avatar Sep 04 '20 14:09 ge0rg

You will need to apply patches in order to program the device with dfu-util. See this still-open defect I reported a number of years ago: https://sourceforge.net/p/dfu-util/tickets/40/

I have a custom version with my patches that I have used for a number of years.

With dfu-util, you need to upload a bin file as it cannot handle ELF format. To get that you need to use objdump.

/usr/arm-none-eabi/bin/objcopy firmware.elf -O binary firmware.bin ~/dfu-util/src/dfu-util -d 0483:df11 -D firmware.bin -s 0x08000000:leave -a 0

Here's my attempt at using the stock dfu-util on Fedora 31:

$ dfu-util -d 0483:df11 -D firmware-2.0.1.bin -s 0x08000000:leave -a 0

dfu-util 0.9 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 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/ dfu-util: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! Opening DFU capable USB device... ID 0483:df11 Run-time device DFU version 011a Claiming USB DFU Interface... Setting Alternate Setting #0 ... Determining device status: state = dfuERROR, status = 10 dfuERROR, clearing status Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing DFU mode device DFU version 011a Device returned transfer size 2048 DfuSe interface name: "Internal Flash " Downloading to address = 0x08000000, size = 132252 Download [=========== ] 44% 59392 bytesdfu-util: Error during special command "ERASE_PAGE" get_status

$ rpm -q dfu-util

dfu-util-0.9-8.fc31.x86_64

Using my patched dfu-util the firmware download succeeds.

While I would prefer to use dfu-util, I have found the software from STM is far more reliable at programming these devices.

On Fri, Sep 4, 2020 at 9:20 AM Georg Lukas [email protected] wrote:

Hi,

there is an OpenMoko project to flash STM32 devices at http://dfu-util.sourceforge.net/ which looks much leaner and more compact than the STM original software. It's also packaged in debian as dfu-util.

When I put the TNC3 into DFU mode, it's listed by dfu-util as follows:

dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 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/

Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01004 e", serial="207E32823141" Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7000/010001Ke", serial="207E32823141" Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFF7800/01040 e", serial="207E32823141" Found DFU: [0483:df11] ver=2200, devnum=91, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/01280002Kg", serial="207E32823141"

The last line has the 0x08000000 offset that you also mention in the official howto, but when I "upload" the firmware into a local file, it is just random data junk (encrypted?) and doesn't have an ELF header; so I didn't dare to try "downloading" the current firmware onto the device.

Do you think it's feasible to use dfu-util (or maybe dfu-tool http://manpages.ubuntu.com/manpages/xenial/man1/dfu-tool.1.html from fwupd, but it complains about the DFU version being 0.00) to flash the TNC3?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobilinkd/tnc3-firmware/issues/12, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABD64DHRPZ2N4ORO5AAFKFLSEDZQ3ANCNFSM4QYOJ4KQ .

mobilinkd avatar Sep 04 '20 16:09 mobilinkd

I would love help getting the proposed dfu-util changes committed upstream. Please assist if you can make this happen.

https://sourceforge.net/p/dfu-util/tickets/40/

After that, we would just need to update the README.md with the instructions above.

Until the upstream changes are made, this is stalled.

mobilinkd avatar Sep 04 '20 19:09 mobilinkd

Just wanted to update - I just tried it using your objcopy and dfu-util commands Rob, and it appears to have worked perfectly with dfu-util 0.11 from Arch Linux package "dfu-util 0.11-2".

tarxvftech avatar Dec 02 '21 13:12 tarxvftech

fwiw dfu-util worked on Ubuntu 24.04 on the fifth try.

craigerl avatar Sep 09 '24 15:09 craigerl