BlackPill V3.1 Bootmode wrong USB VID/PID

Post here first, or if you can't find a relevant section!
dipr
Posts: 13
Joined: Fri Mar 03, 2023 9:26 am

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by dipr »

GonzoG wrote: Fri Mar 03, 2023 5:35 pm Connect PA9 to GND with resistor (eg. 10k) and try to reset it into DFU.
Interesting thought! But are you sure about PA9 ? That's USART1 TXD, a serial transmit pin e.g. outgoing pin, right?

AN2606 https://www.st.com/resource/en/applicat ... ronics.pdf says on p 154 that for USART1 bootloader the data input is expected on PA10 ! ;)

As there is no USART2 (would be PD6 RX pin acc. to ST AN2606) on Black Pill, making sure that USART1 input is perceived as "quiet" should be suffifient to make ST-ROM Bootloader progress its scan to USB_DFU. Only USART1 as boot source has to be successfully skipped according to the bootloader flowchart in Fig. 37 on p.157 , then USB_DFU should kick in.
Question is how does "USB cable detection" work? :?:

Image
dipr
Posts: 13
Joined: Fri Mar 03, 2023 9:26 am

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by dipr »

ag123 wrote: Sat Mar 04, 2023 12:26 am for f4xx I won't bother with a custom bootloader, it takes flash memory and it takes the traditional 0x8000000 start of flash address.
and much less fuss bothering with custom bootloaders e.g. that your sketch is compiled for an incompatible address etc.
you would more than likely need a custom ld script file that specify where your sketch needs to sit and won't be 0x8000000
All true, but going back to USART bootloading would mean one has to dump that nifty, new, one-single-USB-cable-does-it-all approach. :cry:
A feature that was reliably available back in the chip45 atmega168 days. :geek:
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by ag123 »

dipr wrote: Sat Mar 04, 2023 9:28 am
ag123 wrote: Sat Mar 04, 2023 12:26 am for f4xx I won't bother with a custom bootloader, it takes flash memory and it takes the traditional 0x8000000 start of flash address.
and much less fuss bothering with custom bootloaders e.g. that your sketch is compiled for an incompatible address etc.
you would more than likely need a custom ld script file that specify where your sketch needs to sit and won't be 0x8000000
All true, but going back to USART bootloading would mean one has to dump that nifty, new, one-single-USB-cable-does-it-all approach. :cry:
A feature that was reliably available back in the chip45 atmega168 days. :geek:
well if it is a *real* stm32f4xx, then I'd expect USB DFU to be just threre, i.e. that button dance sequence would simply put it in DFU mode ready to update flash using DFU. no need for uart whatsoever.
only stm32f103 and various others that don't do DFU needs to do the serial route.
check that chip on the black pill though, there are STM32F401/F411 black pills, as there are others that use STM32F103, they probably cost different.
and be wary of *clones*, it seemed there are a bunch of 'clones' going around in the 'online flea markets' ebay / aliX etc
STM32F103 can't do DFU and it is a reason why the maple custom bootloader or (roger's fork of maple bootloader) is originally invented for that purpose.
that is where maple mini (libmaple stm32duino) started.
there is also a HID bootloader, you would need to search around here for that e.g. using the search box here on top. or 'google' search for it
accordngly, that uses a different flashing program as well e.g. hid-flash something like such.
But I've never used the HID bootloader myself hence, can't comment about that.
if it is a stm32f103, then you would need a st-link or the serial route (e.g. use a usb-uart dongle) to flash the custom bootloader.

custom bootloaders has all the troubles with the ld script , start address etc that you need to get them correct for your sketch build.
you would need to google around for information on those.

roger's libmaple bootloader is here
https://github.com/rogerclarkmelbourne/ ... bootloader
mainly only for the stm32f103c8, cb chips. you would need to find out about the start address, ld scripts etc.
I think for roger's bootloader, there are 'preconfigured' selections on the arduino menu for the 'down(up)load method' - maple - or stm32duino (i.e. roger's) bootloader, usb-uart or st-link etc which would pick the correct ld script that goes with the custom (roger's) stm32duino or maple bootloader
note that 'roger's stm32duino' bootloader and 'maple' bootloader has different start address.
and
that it needs dfu-util, I'm not sure if there could be issues in windows with it.
https://dfu-util.sourceforge.net/
dfu-util is normally bundled with the core in the tools folder.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by GonzoG »

dipr wrote: Sat Mar 04, 2023 9:04 am Interesting thought! But are you sure about PA9 ? That's USART1 TXD, a serial transmit pin e.g. outgoing pin, right?
You're right. It should be PA10. Don't know why I wrote PA9... and I did check the pin in an earlier thread: viewtopic.php?p=10865#p10865
dipr
Posts: 13
Joined: Fri Mar 03, 2023 9:26 am

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by dipr »

ag123 wrote: Sat Mar 04, 2023 5:25 pm well if it is a *real* stm32f4xx, then I'd expect USB DFU to be just threre, i.e. that button dance sequence would simply put it in DFU mode ready to update flash using DFU. no need for uart whatsoever.
All nice an fine, but the real question is:

- which pins of a WeAct F411 BlackPill need pull-downs to GND
to safely enable the ROM STM USB-DFU bootloader to configure USB_DFU bootload,
e.g. make a USB device with VID/PID of 0x483/0xdf11 pop up in Win10 ?

The STM ROM Bootloader per AN2606 cycles through USART1, USB_DFU, I2C and SPI in search for uploads,
thus we must make sure that it does NOT percive any signal from USART (first choice) and
positively "detecty-USB cable" to enter USB_DFU bootload (second choice)
dipr
Posts: 13
Joined: Fri Mar 03, 2023 9:26 am

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by dipr »

F*$!* different PC, same USB cable, WeAct BlackPill V3.1 autostart pgm cyclically dims and brightens LED,so far so old.
Pressing KEY for ~3 Seconds results in LED going off and USB TreeView showing STM Booloader Decive 0x483/0xDF11 appearing, BTDT.

But this time the Devices stay accessible, it does NOT vanish after 5 Seconds! :D :D :D
AND it ist accessible via STM Porgrammer in USB_DFU mode !!
AND memory contents is displayed !!! :P :P

I'm totally lost why the DF11 Device vanished on my PC in the Office and why it says accessible an is usabel on my Home PC.

Office PC had WeAct board connected to an USB 3 Hub on the Monitor and directly on an USB3 Port on the PC. Device is gone after 5 Seconds.
When connected to the USB3 Port on the Home PC (Zotac Micro PC, no fan, just office work CPU power) everything works as WeAct presumably have planned. :!:

----------- but there are some principal issues here ---------

With STM ROM bootloader its easy:
- reset run the "program" (pre flashed stuff fro mWeAct or later on my program)
- boot0 + reset runs the STM bootloader (broken, probalby wrong USB clock)

How do I integrate the perfectly working WeAct bootloader into my program?
When I uplaod a program of my own it is what should be running after a reset, right?

How can I control if reset will start my program or the WeAct custom bootloader?
Holding down Boot0 is "taken" by the STM ROM Bootloader.
Last edited by dipr on Sat Mar 04, 2023 9:10 pm, edited 4 times in total.
dipr
Posts: 13
Joined: Fri Mar 03, 2023 9:26 am

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by dipr »

Even weirder: on my ZOTAC PC WeAct Black Pill conencted to the USB3 Port the simple STM Bootloader activision (holding down boot0 while hitting reset) WORKS! :shock: :shock: :shock:

The process is :
- hook up WeAct to USB port
- fire up STM CubePorgrammer, set to usb in top right corner of the window, click refresh button beneath, no device found
- on WeAct press and hold Boot0 while hitting reset
- click refrsh on ST MCubeProgrammer window and voilá it finds Port "USB1" click connect and you are connected!

Same is true for WeAct Bootlaoder
- hook up WeAct to USB port
- fire up STM CubePorgrammer, set to usb in top right corner of the window, click refresh button beneath, no device found
- on WeAct hit reset (preloaded WeAct program will run cyclicylly dimming a nd brightening die LED)
- then press and hold KEY button for appr. 2 seconds until the LED start to blink rapidly
- click refrsh on ST MCubeProgrammer window and voilá it find Ports "USB1" click connect and you are connected!

Conclusion: everything is fine bootloader entry works like a charm, the STM ROM bootloader and the WeAct bootloader both work. :D
Its your PC or your USB Hubs etc if things fail or produce a USB device with bad VID/PID

edit:
there is even a fine video demonstrating how the STM Bootloader can be "distracted" by acitivty on the wrong interface,
thereby ignoring the interface one intends to use. This is for a differnet MCU, a G-type so the input pin of the usart is PA10.
The info is all out there except it's spread all over the net.

1) One needs to read AN2606 and the eference manual for one's MCU , exact type is important!
2) Then one has to make sure all interfaces which in the bootloader scan sequence are scanned BEFORE the one we'd like to use are "quiet", e.g. have no activity on their "input pin" or the bootloader will turn to the wrong interface.
3) apparently success depends on Windows PC as well. Problablybest not to use any intermediary USB hubs but to plug it directly into a "motherboard USB port" but of course the might still be behind some intern USB hub.
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by Bingo600 »

I just toyed around with a F401 Blackpill on linux, and initially i had issues getting into BootLoader mode.
Press RST+BOOT0, then release RST , and then release BOOT0.
Seemed strange, as i have done that many times on a F411 Blackpill.

It was a F401 Blackpill just taken out of the "bag" - No pins soldered , and only USB were connected.

I found it worked if i released RST + BOOT0 quite fast after each other.

For "Hand holding" the board
I have now used my indexfinger nail in a sort of "rolling move".
Roll over RST , then Boot0 (now both down) ... Keep rolling , releasing RST , then Boot0.

Hmmm ... Absolutely not 100% conststant to enter the BL.
The BP has a 25MHz Xtal , wonder if this is in play
http://www.efton.sk/STM32/gotcha/g125.html

Well being on linux, it's easy to see if things went wrong (tail syslog).
But often it requires several attempts to get into BL mode.

Well ... Who can complain when getting a F401 for ~$5 ..... :D

Edit: Once it's in BL mode i have no issue uploading via DFU, it's getting it in BL mode, that's a bit tricky ....

/Bingo
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by GonzoG »

@Bingo600
viewtopic.php?t=1680
Try using pull down resistor for PA10 pin.
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: BlackPill V3.1 Bootmode wrong USB VID/PID

Post by Bingo600 »

GonzoG wrote: Sun Mar 05, 2023 6:40 pm @Bingo600
viewtopic.php?t=1680
Try using pull down resistor for PA10 pin.
Thnx ... Might try a 10K or higher (100K) to GND or VCC - Seems like it's just to keep it from floating during boot,
I's like to use the Uart too.
Post Reply

Return to “General discussion”