F4 DFU bootloader

Post here first, or if you can't find a relevant section!
victor_pv
Posts: 1741
Joined: Mon Apr 27, 2015 12:12 pm

Re: F4 DFU bootloader

Post by victor_pv » Sat Aug 26, 2017 11:54 pm

Great, I got my first compilation too, but still need to change the driver and try dfuutil, just modified this in the boards.cpp, and added that define in the .build.vect for the board:

Code: Select all

static void setupNVIC() {
#ifdef VECT_TAB_ADDR
    nvic_init(VECT_TAB_ADDR, 0);
Then changed the start and size of the flash in the linker script. I need to check your changes but I bet they are the same.
I need to upload my current sources for the bootloader somewhere. I gave it a large timeout because I didn't want to be chasing it with the reset button, so started big and we can go down.
I'll post the link as soon as I upload it somewhere. This version should be compatible with the F407 and all the others that share the same reference manual I believe, since it only uses the USB, GPIO, RCC and NVIC.

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 12:08 am

Hi Victor

The files I posted did work for me, but only when I uploaded via STLink to 0x8004000

At the moment I can't get dfu-util to work at all, it just keeps timing out and jumping to the application

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 12:17 am

Victor

I'm not sure if there is bug in the bootloader or if the problem is the command line, as I get a error message

Last page at 0x08009233 is not writeable

Code: Select all

D:\Documents\Arduino\f4_bootloader_test>dfu-util  -a 0 -s 0x08004000 -D f4_bootloader_test.ino.generic_f407v.bin
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/

Invalid DFU suffix signature
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 = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x08004000, size = 21044
Last page at 0x08009233 is not writeable

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 12:28 am

Victor

I tried using the internal bootloader using the same command (but setting the address to 0x8000000) and I was able to upload my Blink sketch

So there seems to definitely be some problem with Chris's bootloader code.

I even tried setting the address to 8000000 in case you had hard coded the start address etc

e.g.

Code: Select all

dfu-util  -a 0 -s 0x08000000 -D f4_bootloader_test.ino.generic_f407v.bin
But I still get the error about a page of flash not being writeable. Just in this case its 0x8005223

So I think some bug fixing is needed on the bootloader code :-(

victor_pv
Posts: 1741
Joined: Mon Apr 27, 2015 12:12 pm

Re: F4 DFU bootloader

Post by victor_pv » Sun Aug 27, 2017 12:30 am

I'm getting a similar error when trying to upload, and then reading the flash back I see that nothing was uploaded, but some pages got filled up with 0s.
I'll have to dig more in the bootloader to see what's going on.
Btw I tried with libusbK driver that Zadig could install with the same result.
I think I have an idea of the problem. I get this when I use the -v option with dfuutil:
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash "
Memory segment at 0x08000000 4 x 16384 = 65536 (r)
Memory segment at 0x08010000 1 x 65536 = 65536 (rew)
Memory segment at 0x08020000 3 x 131072 = 393216 (rew)
Downloading to address = 0x08004000, size = 24140
Last page at 0x08009e4b is not writeable
As you see all 4 of the initial 16KB pages are marked as (r) as opposed to the others being RW. Initially Chriss was reserving 4 pages for his bootloader, 64KB, but I changed that to 16KB. I must have left it unchanged in some place. I'll get back to the code and check it up.

BTW, if I set the upload address to 0x08010000 in dfuutil, it uploads without any error.

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 12:40 am

Hi Victor

OK

I did see that @pito was using the libusbK driver but WinUSB works fine for me using the built in bootloader, so I didnt try the libusbK version as it seemed to be irrelevant

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 12:42 am

Victor

OK.

I was going to suggest changing the offset vector to 0x8010000

but your code would not jump to that address, so even if it uploaded OK it would not run

victor_pv
Posts: 1741
Joined: Mon Apr 27, 2015 12:12 pm

Re: F4 DFU bootloader

Post by victor_pv » Sun Aug 27, 2017 1:20 am

Right. I could see it uploaded with the debugger, but would not jump to it.

Well, that is corrected now, all that's left is the enumeration.
I have replaced the attachment in the first post with one that uploads correctly to the right address (0x8004000) and run the code from there.
It still has the long timeout, that can be changed later for the definitive version. Just need to correct the issue with not re-enumerating. I thought it would do it since the code was already there from Chriss, but perhaps needs a longer time.

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 1:43 am

Thanks

I'll download again and test

User avatar
RogerClark
Posts: 7447
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: F4 DFU bootloader

Post by RogerClark » Sun Aug 27, 2017 1:46 am

Umm

I'm getting the same error

Can you repost the zip file under a different name, perhaps there is a file cacheing problem

Post Reply