STM32F1 is it possible to read the flash by DFU?

STM32duino bootloader aka Maple bootloader
Post Reply
Phil242
Posts: 7
Joined: Tue Aug 09, 2022 10:10 pm

STM32F1 is it possible to read the flash by DFU?

Post by Phil242 »

Hello,

I start a spare-time project with some bluepills.
It needs to be managed only by USB. That's the only port exposed from the bluepill.

I was reading the Roger Clark's bootloader source code regarding the DFU features :
https://github.com/rogerclarkmelbourne/ ... ster/dfu.c :

Code: Select all

if (pInformation->USBbRequest == DFU_DNLOAD)
...
if (pInformation->USBbRequest == DFU_UPLOAD)
This means that everything should be flashable by DFU. And, more interesting feature, I should be able to read back the flash by DFU.

Did you have ever achieved a such thing ?

Thanks.

Phil
Phil242
Posts: 7
Joined: Tue Aug 09, 2022 10:10 pm

Re: STM32F1 is it possible to read the flash by DFU?

Post by Phil242 »

Hum, I have some doubt ...

I've flashed the bootloder on a bluepill and here is what dfu-util told me:

Code: Select all

dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 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: [1eaf:0003] ver=0201, devnum=21, cfg=1, intf=0, path="1-2", alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=21, cfg=1, intf=0, path="1-2", alt=1, name="STM32duino bootloader v1.0  Upload to Flash 0x8005000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=21, cfg=1, intf=0, path="1-2", alt=0, name="STM32duino bootloader v1.0  ERROR. Upload to RAM not supported.", serial="LLM 003"
There is no entry for a "read", only flash, so upload only...

I'll continue to dig the subject.

Phil
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F1 is it possible to read the flash by DFU?

Post by ag123 »

flashing and retrieval probably works, check the options for dfu-util.
it probably works the same for stm32 native usb dfu as well, e.g. the stm32f4xx series.
Phil242
Posts: 7
Joined: Tue Aug 09, 2022 10:10 pm

Re: STM32F1 is it possible to read the flash by DFU?

Post by Phil242 »

ag123 wrote: Wed Aug 10, 2022 1:15 pm flashing and retrieval probably works, check the options for dfu-util.
it probably works the same for stm32 native usb dfu as well, e.g. the stm32f4xx series.
Yes, that was the right path. Got the flash zone after bootloader by DFU, with dfu-util.
Thanks for the suggestion 8-).

Now I need to program the "stock" bootloader, because I've modified it for wait on the DFU init sequence to allow me to make my tests (no more jump to application or bypass). And to try to run the "blink" design on Arduino IDE with STM32duino added.

Regards,

Phil
Phil242
Posts: 7
Joined: Tue Aug 09, 2022 10:10 pm

Re: STM32F1 is it possible to read the flash by DFU?

Post by Phil242 »

All the tests I've done are successful.
I've played with several bootloaders and I can program it with the Arduino SDK.
Sometime I need to do some "connect under reset" to flash it, but I don't remember the exact case.

I've also played with the timing, to keep it in DFU mode, or keep it longer in DFU mode.
You can easily compile it and flash it with ST-link.

Until now it's only a proof of concept, now I need to start the full project.

If you have specifics questions regarding Bluepill and bootloader, just ask. Maybe I can help.

Last: bluepill are 99% sold with counterfeit MCU, so all the things need to be validated on all the bluepills you own :roll:
Post Reply

Return to “USB bootloader”