DFU bootloader has errors on new BlackPill F411

Post here first, or if you can't find a relevant section!
AndrewBCN
Posts: 105
Joined: Sun Apr 25, 2021 3:50 pm
Answers: 1
Location: Strasbourg, France

Re: DFU bootloader has errors on new BlackPill F411

Post by AndrewBCN »

david.prentice wrote: Thu Aug 26, 2021 1:22 pm My brand new WeAct V3.0 board arrived just now.

BOOT0 + RST does not start STM32 Bootloader.
Pressing KEY for 5 seconds does start STM32 Bootloader.
That is because they ship from WeAct with a proprietary bootloader that reacts to the KEY button. You can still put them in DFU mode by following method 2 a) which I described above.
david.prentice wrote: Thu Aug 26, 2021 1:22 pm I select Upload method: STMCubeProgrammer (DFU)
Build and run ASCIITable.ino
This creates a "STM Serial" on COM3.
When I select COM3 and open Serial Monitor : it displays the ASCII Table

Subsequent BOOT0+RST does not start STM32 Bootloader.
Subsequent KEY does not start STM32 Bootloader.
That is because at this stage you have overwritten WeAct's proprietary bootloader with your ASCIITable binary.
david.prentice wrote: Thu Aug 26, 2021 1:22 pm Selecting Upload method HID Bootloader 2.2 does not start any Bootloader.

However I can use (DFU) if I unplug USB. Re-plug with MODE0 button pressed.

So it appears that BOOT0 + RST does not start STM32 Bootloader reliably. I suspect that you might succeed after 100 attempts.
And the only way to Bootload is via a power cycle.
The BluePill uploads fine with HID 2.2 (and USB CDC Serial)

No, I have not measured the HSI frequency on either BlackPill yet.

David.
As you have confirmed, method 2 a) described above, which I have been using for the last 6 months, works rather well to put the Black Pill in DFU programming mode.

Just to summarize the recommended steps:

1. Compile (Verify) your sketch to make sure there are no compilation errors,
2. In the Arduino IDE, select DFU upload method.
3. Connect the USB C end of a good quality cable to the Black Pill.
4. Press and hold the BOOT button on the Black Pill.
5. While holding the BOOT button pressed, connect the USB A end of the cable to your computer. Release the BOOT button. The power led (red LED) on the Black Pill should be on, and your computer should have detected a DFU device (on a Linux computer, check dmesg).
6. Now click on the Upload button in the Arduino IDE and the binary for your sketch gets uploaded in a few seconds.
david.prentice
Posts: 19
Joined: Thu May 14, 2020 8:39 pm
Answers: 1

Re: DFU bootloader has errors on new BlackPill F411

Post by david.prentice »

I am using the main USB ports on a Desktop PC.

I presume that the WeAct BlackPill is supposed to respond as a HID Bootloader device.
In which case you could Upload sketches directly from the IDE via HID 2.2

Or does the WeAct HID not work with 2.2?

UsbView shows "STM Serial" when the USB CDC is running.
I don't see a HID device.

I possess an STLink V2. So I have no problem with SWD.
But I was hoping to have single USB cable functionality. i.e. CDC Serial and HID Bootload without unplugging or button gymnastics.

Reading AndrewBCN's reply it appears that HID is nothing more than an "application installed by the manufacturer that detects KEY".
Which gets destroyed as soon as you Upload your own program.

David.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: DFU bootloader has errors on new BlackPill F411

Post by ag123 »

@david.prentice it seemed we'd need to be a little careful forwards, i'm not too sure if there are 'batch' differences between what may seem like the same boards.

verifying usb functionality is the hard part, do boot0 work after that that the 'custom' boot loader is replaced? it is hard to tell that the native usb boot loader got the wrong HSE unless one has the equipment to look at signals in the usb lines
david.prentice
Posts: 19
Joined: Thu May 14, 2020 8:39 pm
Answers: 1

Re: DFU bootloader has errors on new BlackPill F411

Post by david.prentice »

Sorry, I am busy with other things at the moment.

Simple questions:
1. Does everyone just use SWD for the BlackPill ?
2. Does anyone use the WeAct HID Bootloader?
3. Does WeAct work with HID 2.2 ?
4. Does anyone upload without unplugging or button press?

I tend to use Nucleo boards. i.e. permanent Serial, permanent SWD.

However BluePill works pretty well with CDC-Serial and HID 2.2.
I was hoping that BlackPill would be foolproof. Especially since it has UDB-DFU in factory ROM.

Obviously they do not cater for my foolishness !!

David.
AndrewBCN
Posts: 105
Joined: Sun Apr 25, 2021 3:50 pm
Answers: 1
Location: Strasbourg, France

Re: DFU bootloader has errors on new BlackPill F411

Post by AndrewBCN »

david.prentice wrote: Thu Aug 26, 2021 2:37 pm ...
it appears that HID is nothing more than an "application installed by the manufacturer that detects KEY".
Which gets destroyed as soon as you Upload your own program.

David.
Yes, WeAct installs an HID bootloader before shipping their "true" Black Pills. Black Pill clones (i.e. not from WeAct) may or may not ship with an HID bootloader (they usually don't).

It doesn't really matter, imho, because I prefer to rely on the STM DFU bootloader, which has worked flawlessly hundreds of times for me, and works on a large variety of STM MCUs.

I happen to have an ST Link V2 in the drawer, but never got to use it until now!
david.prentice
Posts: 19
Joined: Thu May 14, 2020 8:39 pm
Answers: 1

Re: DFU bootloader has errors on new BlackPill F411

Post by david.prentice »

I wrote a 1 second PWM in CubeMXIDE that uses the 16MHz HSI. Then measured the period with a Logic Analyser.

Nucleo-F411 0.9874 sec
BlackPill-F411 #1 1.032 sec
BlackPill-F411 #2 1.012 sec

So the HSI is accurate +- 1.2% for the Nucleo and WeAct V3.0 (#2) but more than +-3% for my problem BlackPill #1

From AN2606
The system clock is derived from the embedded internal high-speed RC for USARTx, I2Cx and SPIx bootloaders. This internal clock is also used for CAN and DFU (USB FS Device) but only for the selection phase. An external clock multiple of 1 MHz (between 4 and 26 MHz) is required for CAN and DFU bootloader execution after the selection phase.
So I would expect the Bootloader to detect HSE, determine the XTAL value from 4MHz - 26MHz reliably. Obviously detecting a 8MHz XTAL is a no-brainer. But 26MHz versus 25MHz is 1.04 i.e. you need better than +-2% accuracy from the HSI

The real mystery is why did WeAct choose a 25MHz HSE ?
From CubeMX the F401 and F411 can only achieve 84MHz and 96MHz when you require 48MHz for USB.
They could have chosen a 4MHz XTAL or 8MHz XTAL for HSE. And got exactly the same range of operating Clocks.

Obviously I have not seen the HSE detection code used for DFU. I presume that they allow for the XTAL oscillations to stabilise. In which case I would expect DFU Boot to be 99% reliable with most HSI

Hey-Ho. You can change the HSI frequency by 0.005% with moderate warming of the chip. Hence the WeAct advice:
DFU Mode: Use the data line to connect to the computer. If there is an unrecognized problem, you can heat the chip appropriately (25°C) and then re-enter the ISP mode
Anyway, in an ideal world I would expect an HID to be running on a stable 48MHz USB. So it should be able to detect a "reset" signal from a Serial Terminal. After all the BluePill HID 2.2 Bootloader seems to work pretty well.

David.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: DFU bootloader has errors on new BlackPill F411

Post by ag123 »

@david.prentice i think 8 mhz crystals are bulkier, while 16mhz, 25mhz ones tend to have small smd packages.
the ease of mounting them could have been a reason, as they are likely all smd machine mounted and soldered

it looks like if the internal boot loader fails, a solution may be to use a custom usb boot loader if one still prefers a usb install.
this is about the only way to fix the PLL clocks configuration. literally, if you can get a custom usb boot loader to always work ok each time every time, it kind of confirmed the HSI slew affected guessing the correct HSE speeds.
david.prentice
Posts: 19
Joined: Thu May 14, 2020 8:39 pm
Answers: 1

Re: DFU bootloader has errors on new BlackPill F411

Post by david.prentice »

A swift look at 3.2x2.5 SMD XTALs on Farnell showed that there are lots of 12MHz, 16MHz available and in stock.
Yes, 8MHz are few. And more expensive.

Obviously Chinese component market is different to the UK. But I don't see any price advantage of 25MHz.

Perhaps there are some other factors.

I had not spotted the official HSI accuracy in the DS.
RC oscillator frequencies can vary from one chip to another due to manufacturing process
variations, this is why each device is factory calibrated by ST for 1% accuracy at TA= 25 °C.
13MHz/12MHz = 1.08 ie. +-4% HSI accuracy. 17MHz/16MHz needs +-3%. 26MHz/25MHz needs +-2%.
So a factory calibrated +-1% HSI should be 100% reliable @ 25C for the full 4MHz-26MHz range.

But the real practical question : "Is there a working HID 2.2 Bootloader available for F401 and F411 ?"
I just want to Upload to a BlackPill like I can with a BluePill.

David.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: DFU bootloader has errors on new BlackPill F411

Post by ag123 »

i'm thinking we can take that 'old' libmaple (roger's) bootloader and perhaps fix it up for F401, F411. don't think it is very 'hard'.

oh and the HID bootloader is here, it looks like it'd work on stm32f4
https://github.com/Serasidis/STM32_HID_Bootloader
david.prentice
Posts: 19
Joined: Thu May 14, 2020 8:39 pm
Answers: 1

Re: DFU bootloader has errors on new BlackPill F411

Post by david.prentice »

That is my point. Has anyone got the HID 2.2 Bootloader to work for BlackPills ?

In which case please post a link to a working .BIN file that can be installed via ST-Link, USART, USB, ...

David.
Post Reply

Return to “General discussion”