Platformio DFU MODE

Ecco la traduzione in inglese:


Hello everyone, I’m back here writing after a few days of banging my head on this.

I need some explanations regarding the firmware upload process using the DFU protocol.

I have set up the Platformio.ino file with these settings:

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
board_build.core = maple
upload_protocol = dfu

But I can’t upload the firmware; I get the following errors. Surely, I’m making a major mistake. Who can help me?

Checking size .pio\build\genericSTM32F103C8\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  21.1% (used 4312 bytes from 20480 bytes)
Flash: [===       ]  29.8% (used 19520 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = dfu
Looking for upload port...
Auto-detected: COM14
Uploading .pio\build\genericSTM32F103C8\firmware.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
dfu-util - (C) 2007-2008 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Couldn't find the DFU device: [1EAF:0003]

Thank You

  • Was DFU upload working in the past?
  • Did it select the right COM port to reset (COM14)?
  • Did you burn the Maple bootloader into the device?

-Dfu has never worked for me
-doesn’t it select the com port by itself?, then from the log I see that it selected the right port by itself…
-maple bootloader doesn’t load it by simply inserting this line?
board_build.core = maple

I certainly have confused ideas

No, this just selects whether to use Arduino Core STM32 or Maple core code, as is documented.

When you write

upload_protocol = dfu

you set PlatformIO up to expect a board that already has the Maple (DFU) bootloader flashed onto it.

Initially, you have to burn the Maple bootloader into your STM32F103C8 by using the UART bootloader (serial) or SWD (e.g., with ST-Link) uplink method and a software like STM32CubeProgrammer.

Once the Maple bootloader is burned into the device, then it will appear as a USB DFU device with VID:PID 1EAF:0003 to the computer, and the uploader program can upload via USB.

This will not work at all if you don’t yet have the bootloader burned into your device beforehand.

There are various tutorials online on how to do this, e.g., here.

And if you want to upload via serial (UART), that is the UART Bootloader on the STM32F103C8 that can be entered with BOOT0 set to 1 (docs), then

upload_protocol = serial

is correct.

then I have already loaded the maple bootloader previously.
Exactly with generic_boot20_pc13.bin, via STLINK V2.

But after the procedure I get the error posted in the first post.

Can you confirm that for DFu loading:
Boot 0 must be on 0
Boot 1 must be on 0

thanks for the help

Yes, that’s correct. Since the Maple bootloader is just application code in flash, all Boot pins to 0 is correct.

You could still be using the wrong drivers though. Can you download and open Zadig (https://zadig.akeo.ie/) and select the Maple DFU device? There should be two interfaces, one for UART and one for USB DFU. The USB DFU interface should have libusb-win32 drivers loaded.

I should have installed the drivers with Zadig, tomorrow I’ll try to check that here in Italy it’s evening :-). I’ll update you tomorrow and see if I installed the correct drivers, thanks again

Good morning,
-I tried to update all the drivers with Zadig,
-I put the bootloader generic_boot20_pc13.bin loaded with stlink v2
-I tried to load but it gives me the same error

The port com me find it
image

I also tried webUsbDfu
I tried selecting the right port but this comes up
image

:pensive:

What does the device manager show in View → Device By Container? What does Zadig show for all recognized Maple interfaces?

This
image
and this
image

No, it’s not supposed to be just a serial. There’s supposed to be a serial and USB DFU device. You only have one.

Can you erase the flash of your microcontroller again completely with the ST-Link (and STM32CubeProg or whatever) and reflash the bootloader_only_binaries/generic_boot20_pc13.bin?

nothing, I tried to do what you tell me but it doesn’t work.

I tried to load this bootloader and something strange happens:

-I load the bootloader stm32f1_dfu.bin
-it is recognized by Stm32CubeProgrammer or by WebUsb DFU
-I load the firmware compiled by visualstudio
-but after this step the DFU is no longer found…is it possible that my firmware will overwrite the bootloader “stm32f1_dfu.bin”?

I tried to buy a new bluepill. but it gives me the same problem… who can help me??