Spark Logic

Trying to use F4x DFU bootloader

RogerClark Fri Nov 25, 2016 6:39 am

Looking forward to more STM32F4 series devices becoming available, I am looking at trying to use the built in bootloader in the F4, which is USB DFU

I found some code here

https://my.st.com/public/STe2ecommuniti … ntviews=33

Reboot_Loader PROC
EXPORT Reboot_Loader
LDR R0, =0x40023844 ; RCC_APB2ENR
LDR R1, =0x00004000 ; ENABLE SYSCFG CLOCK
STR R1, [R0, #0] LDR R0, =0x40013800 ; SYSCFG_MEMRMP
LDR R1, =0x00000001 ; MAP ROM AT ZERO
STR R1, [R0, #0] LDR R0, =0x1FFF0000 ; ROM BASE
LDR SP,[R0, #0] ; SP @ +0
LDR R0,[R0, #4] ; PC @ +4
BX R0
ENDP ; [email protected]

Replies

devan Fri Nov 25, 2016 8:32 am

STM32 parts use a version of DFU with some custom extensions that they refer to as DfuSe. The protocol layers some extra commands on top of the existing DFU commands to do extra things like specifying the start address to flash.

dfu-util has extra commands to handle DfuSe devices:
http://dfu-util.sourceforge.net/dfuse.html

Adding -s 0x08000000:leave should do the trick, i.e:
dfu-util -D C:\Users\rclark\AppData\Local\Temp\arduino_build_861808\Blink_PB0.ino.bin -a 0 -s 0x08000000:leave

RogerClark Fri Nov 25, 2016 8:54 am

@devan

Thanks, but it didnt work :-(

I downloaded the W64 binary for dfu-util 0.9 from Sourceforge,
and tried

D:\Documents\Arduino\hardware\arduino_stm32\tools\win\dfu-util-0.9-win64>dfu-util -D C:\Users\rclark\AppData\Local\Temp\arduino_build_861808\Blink_PB0.ino.bin -s 0x08000000:leave -a 0

ag123 Mon Nov 28, 2016 5:06 pm

@roger
u got me sufficiently curious/excited to power up a STM32F407 board i’ve got for a while but have stashed it away and is collecting dust :lol:
https://www.olimex.com/Products/ARM/ST/ … e-hardware

olimex programmed the board so that if i boot into the normal flash the board emulates a mouse
Bus 003 Device 005: ID 0483:5710 STMicroelectronics Joystick in FS Mode

RogerClark Mon Nov 28, 2016 8:53 pm

@ag123

My board has the USB connector on PA11 and PA12, just like a F103.

If I enable Boot0 I get the USB dfu device, so I used the libwdi installer we use or the maple dfu to force windows to install the driver.

I get the same sort of list if I try dfu-util -list

But I still cant upload.

I uploaded a sketch using STLink and if I call USBSerial.begin I can get a USB Device , but the PID and VID seem to show up as a “STM virtual com with FS”.

I need to check the core to see why it seems to be using STMs VID and PID, or whether I have really confused my PC as I have been testing some composite USB stuff for @Danieleff and my machine may be somewhat confused with PIDs and drivers at the moment.

I have not tried connecting the USB OTG but I have a STM discovery that I think has the OTG port connected to a USB socket.

But as these F407 boards are now under $10 USD, I think a lot more people will be buying them.

Btw. I posted to the other thread about f407 boards, that I expect we will end up doing our own F4 version of STMs core, as its been months since they released the F1 and L4 and we can probably get something working before they can ;-)

(not that this helps with the bootloading..)

ag123 Tue Nov 29, 2016 7:07 am

@roger

apparently STM32F407 has 2 sets of USB OTG host controllers, on my board for reasons i do not know it uses (i.e. enumerates at boot) one port PA 9 , 11, 12 for DFU (this is apparently a full speed USB port) (it enumerates only this port for DFU) while the other, PA 13, 14, 15 (this is apparently a high speed USB port) (it enumerates only this port for app) when the app runs from flash

the schematics of the board i’ve is here
https://www.olimex.com/Products/ARM/ST/ … _B_sch.pdf
https://www.olimex.com/Products/ARM/ST/ … e-hardware

i’m observing a similar VID/PID for the ‘app’ that’s installed by olimex, it has an STM VID
Bus 003 Device 005: ID 0483:5710 STMicroelectronics Joystick in FS Mode

RogerClark Tue Nov 29, 2016 7:17 am

@ag123

I just looked in the code and for some reason the VID and PID are

/** @defgroup USBD_DESC_Private_Defines
* @{
*/
#define USBD_VID 0x0483

#define USBD_PID 0x5740

ag123 Tue Nov 29, 2016 7:31 am

@roger
i’m running linux too, but then the other big wildcard is the PC & the usb cable itself :lol:

& on STM32 it’d seem STM may be keen on joining the mini-PC ‘revolution’, for what’s worth we may 1 day (soon) see a STM board ‘competing’ with the R-pi & beagleboards :lol:

danieleff Tue Nov 29, 2016 8:10 am

Try to use -v (multiple times for increased verbosity) with dfu-util to get more information.

RogerClark Tue Nov 29, 2016 8:38 am

danieleff wrote:Try to use -v (multiple times for increased verbosity) with dfu-util to get more information.

ag123 Tue Nov 29, 2016 9:14 am

in my case

in the case with an error
dfu-util -v -v -v -l

ibusb: debug [libusb_open] open 3.6
libusb: debug [usbi_add_pollfd] add fd 11 events 4
libusb: debug [add_to_flying_list] arm timerfd for timeout in 1000ms (first in line)
libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
libusb: debug [handle_events] poll() 4 fds with timeout in 60000ms
libusb: debug [handle_events] poll() returned 1
libusb: debug [reap_for_handle] urb type=2 status=0 transferred=8
libusb: debug [handle_control_completion] handling completion status 0
libusb: debug [disarm_timerfd] libusb: debug [usbi_handle_transfer_completion] transfer 0x14e23c0 has callback 0x7fd7d16865f0
libusb: debug [sync_transfer_cb] actual_length=8
dfu-util: Broken LANGID string descriptor
...
ibusb: debug [add_to_flying_list] arm timerfd for timeout in 1000ms (first in line)
libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
libusb: debug [handle_events] poll() 4 fds with timeout in 60000ms
libusb: debug [handle_events] poll() returned 1
libusb: debug [reap_for_handle] urb type=2 status=-71 transferred=0
libusb: debug [handle_control_completion] handling completion status -71
libusb: debug [handle_control_completion] low-level bus error occurred
libusb: debug [disarm_timerfd] libusb: debug [usbi_handle_transfer_completion] transfer 0x14e23c0 has callback 0x7fd7d16865f0
libusb: debug [sync_transfer_cb] actual_length=0
dfu-util: Failed to retrieve string descriptor 5
...

ag123 Tue Nov 29, 2016 9:32 am

RogerClark wrote:danieleff wrote:Try to use -v (multiple times for increased verbosity) with dfu-util to get more information.

RogerClark Tue Nov 29, 2016 9:41 am

Sounds like STM may not have implemented their DFU to match the specification

RogerClark Tue Nov 29, 2016 9:44 am

I found this on Partice’s site

https://community.particle.io/t/tutoria … -2015/3518

I tried the version that the article linked to, but it was worse than the versions I’ve already tried.

But I”m sure what zadiag is going, and whether it installs a different driver than the libusb one that I’m using

ag123 Tue Nov 29, 2016 10:03 am

@roger

i’m thinking that you may like to try out the DFU update app from STM since you are running Windows
http://www.st.com/en/development-tools/ … 32080.html

if STM’s s/w works while dfu-util doesn’t it possibly point to a software issue in dfu-util itself.

RogerClark Tue Nov 29, 2016 10:33 am

I doesn’t seem to recognise my DFU device.

I tried to find a ST Driver for their DFU device but couldn’t find one.

ag123 Tue Nov 29, 2016 12:20 pm

got a new *shielded* usb cable, better usb cables made a world of difference, no more errors :lol:

> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"
>
> ./dfu-util -l
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=5, cfg=1, intf=0, path="3-6", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3772346F3034"
Found DFU: [0483:df11] ver=2200, devnum=5, cfg=1, intf=0, path="3-6", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3772346F3034"

ag123 Tue Nov 29, 2016 12:26 pm

pulled the flash into a file as backup

./dfu-util -v -a 0 -Z 65535 -U stm32-app-backup.hex
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/

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 = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
Limiting default upload to 16384 bytes
Upload [=========================] 100% 16384 bytes
Upload done.

stevestrong Tue Nov 29, 2016 12:30 pm

Roger, have you tried this?

Or here your have also a 64bit Win OS demo, although it is specified to work up to Vista/Win7 (including drivers), it may work for win10 as well, I haven’t tried yet.

GrumpyOldPizza Tue Nov 29, 2016 12:56 pm

stevestrong wrote:Roger, have you tried this?

Or here your have also a 64bit Win OS demo, although it is specified to work up to Vista (including drivers), it may work for win10 as well, I haven’t tried yet.

stevestrong Tue Nov 29, 2016 1:11 pm

GrumpyOldPizza wrote:…pipe it throu their file manager type tool …

Sign in to reply