Serasidis / STM32_HID_Bootloader

Driverless USB HID bootloader and flashing tool for STM32F10X devices
424 stars 151 forks source link

Please add support for Black Pill F401CC Device #23

Closed ajaybnl closed 2 years ago

ajaybnl commented 5 years ago

Please add support for Black Pill F401CC Device

roboticboyer commented 4 years ago

I suggest to use the WeAct Bootloader. In case is used a Black Pill is required to press the P0 button to enter in the boot mode

There is also a HID Bootloader forked from the Serasidis' one but not tested from me

samveen commented 4 years ago

@roboticboyer The WeAct Bootloader doesn't seem to integrate with Arduino IDE like the HID Bootloader does. Not only that, their fork of the HID Bootloader modifies the flag check, and thus also doesn't work with the HID Bootloader upload method in the Arduino IDE. I managed to get a working version, but I am unsure if it qualifies to be be merged into here.

roboticboyer commented 4 years ago

I wrote some notes how to use the WeAct Bootloader @samveen where is available your bin file of the modified bootloader?

samveen commented 4 years ago

@roboticboyer I didn't put it up anywhere, expecting that people might be more comfortable building it themselves. However you can find it via this google drive link Edit: I figured out attachments :man_facepalming: hid_bootloader.bin-2.2.2-6-g296db49.gz

roboticboyer commented 4 years ago

I have a Black Pill F401CC I have uploaded your hid_bootloader.bin file but the HID 2.2 uploader is not able to find the usb devide 1209:BEBA When I connect the blackpill there is only 0483:df11

I tried with DFU: ./dfu-util -a 0 -s 0x08000000 -D hid_bootloader.bin and: ./stm32CubeProg.sh 2 hid_bootloader.bin -g

Also using an ST-Link programmer: ./stm32CubeProg.sh 0 hid_bootloader.bin -g

Where I'm wrong?

samveen commented 4 years ago

I used dfu-util to write it to the board. One thing I'll note is that I'm using a 411, instead of a 401. May I suggest that you look at the changed code and see if you can build it locally instead of using the one I built, given that I am a beginner myself, so my changes might need reviewing before you use them.

roboticboyer commented 4 years ago

Thank you I'll check and recompile the firmware for the 401 Please only confirm that the parameters of dfu-util are correct: ./dfu-util -a 0 -s 0x08000000 -D hid_bootloader.bin

Is required to press the Button PA0 to enter in Boot mode?

samveen commented 4 years ago

I used dfu-util -a 0 -d 0483:df11 -s 0x8000000:mass-erase:force -D hid_bootloader.bin -t 1024

zoobab commented 3 years ago

I have a WeAct BlackPill:

http://zoobab.wikidot.com/stm32f401-devboard

Those guys at WeAct are shooting themselves in the foot, as what people are interested in is Arduino IDE support, which cannot happen if the flashing tools are forked from BSD-licensed software and made proprietary.

dreamcat4 commented 3 years ago

hello, sorry am a bit new to this device, and just wanted to know:

rgoulter commented 3 years ago

how can i upload sketches without having to press a physical button on the device, etc?

A compilation output of an Arduino sketch is a firmware for the device. A bootloader is firmware which helps you update the 'application' firmware (e.g. the Arduino sketch).

The easiest / most reliable way I've found is to use an STLink.

Whereas, I've found DFU to be ... finicky; sometimes only working if I hold down both the BOOT and NRST buttons for a long time (30s+), or not work at all. (Different levels of success depending on the OS / which particular dev board is used).

This HID bootloader in this repo (IIUC) would allow updating the firmware when used with the hid flashing program (also in this repo). This particular fork of the HID bootloader is geared towards Arduino. -- The benefit being, you could update the firmware without needing to push any buttons on the dev board. - If you flash the bootloader with the correct configuration, this should let you upload from Arduino IDE.

dreamcat4 commented 3 years ago

well i have the weact f411 here on platformio. and have been flashing it in dfu mode. pressing the button

could plugin an stlink i suppose. its just more wires / cables

but if you think i can have hid flashing without needing the buttons for this device? because that might seem worth it

can then add a custom uploader cmdline in the platformio.ini file to call it

however what confuses me, and makes me ask about butonless HID mode is because the README seems to say i still need to press some button... key instead of boot0, same difference really.

in which case it does not achieve the set goal, and is no better than dfu mode for me. sorry for the confusion, but i am really confused by this. wherever i look online about it for this particular board :)

hehe

rgoulter commented 3 years ago

however what confuses me, and makes me ask about butonless HID mode is because the README seems to say i still need to press some button... key instead of boot0, same difference really.

Where in the README does it say that?

dreamcat4 commented 3 years ago

in the WeAct one here

https://github.com/WeActTC/MiniSTM32F4x1/tree/master/Soft/WeAct_HID_FW_Bootloader

rgoulter commented 3 years ago

Ah, that's right. Sorry, I haven't yet tried this bootloader. I recall seeing the code has a comment in the entrypoint:

In case of incoming magic number or <BOOT_1_PIN> is LOW, jump to HID bootloader

https://github.com/Serasidis/STM32_HID_Bootloader/blob/master/bootloader/F4/Src/main.c#L138 (Per WeAct's changes, the WeAct MiniF4's <key> is the boot_1 being referred to).

so presumably, the bootloader can be entered by setting the value & triggering a reset from the firmware, and could be entered without pushing a button.

dreamcat4 commented 3 years ago

and could be entered without pushing a button.

how?

you lost me again. sorry i could not follow that explanation

rgoulter commented 3 years ago

This is what makes sense to me; I haven't tried it. I don't have any significant experience with embedded development; so I'd suggest the search terms "stm32 software reset"; and/or figure out how to set a particular register to a particular value in the stm32duino port.

Again, the bootloader in this repo enters the HID bootloader if the boot_1 is low (i.e. <key> is held down), or "incoming magic number" (value of a particular register has a specific value) when the bootloader starts. i.e. after a reset or when the device is plugged in. - As you point out, the "key held down" part isn't more useful than the built-in DFU; but I'd expect it's possible to write to a register and reset the MCU from the firmware.

dreamcat4 commented 3 years ago

so this is... some WIP not finished yet?

https://github.com/stm32duino/Arduino_Core_STM32/issues/1118#issuecomment-657580833

in PR #710 ?

pathnirvana commented 3 years ago

I wrote some notes how to use the WeAct Bootloader @samveen where is available your bin file of the modified bootloader?

I was able to get f401cc working with platformio by following some of the above steps by @roboticboyer

In wsl or linux objcopy -Iihex -j .sec1 -Obinary WeAct_HID_Bootloader_F4x1.hex WeAct_HID_Bootloader_F4x1.bin dfu-suffix -a WeAct_HID_Bootloader_F4x1.bin

then in windows .\st-flash.exe write .\WeAct_HID_Bootloader_F4x1.bin 0x8000000

finally in platformio.ini file [env:blackpill_f401cc] platform = ststm32 board = blackpill_f401cc framework = arduino upload_protocol = dfu

to put in the bootloader mode press nrst button while boot0 is pressed. you should see STM32 BOOTLOADER in windows device manager when it is in the bootloader mode.

hope this helps someone

pathnirvana commented 3 years ago

probably not much related here. But recently I changed to using tinyuf2 instead of the hid bootloader for both f401 and f411 blackpills. much easier to get into the bootloader mode - just double tap the reset button. can be flashed easily with .\st-flash.exe write .\tinyuf2-stm32f401_blackpill-0.5.0.bin 0x8000000

also the releases can be downloaded from https://github.com/adafruit/tinyuf2/releases/

xromansx commented 2 years ago

So for now only one working option to flash blackpill through USB without touching it is WeAct_HID_Bootloader

xromansx commented 2 years ago

I used dfu-util to write it to the board. One thing I'll note is that I'm using a 411, instead of a 401. May I suggest that you look at the changed code and see if you can build it locally instead of using the one I built, given that I am a beginner myself, so my changes might need reviewing before you use them.

I recompiled you version but can't get it working.

samveen commented 2 years ago

I used dfu-util to write it to the board. One thing I'll note is that I'm using a 411, instead of a 401. May I suggest that you look at the changed code and see if you can build it locally instead of using the one I built, given that I am a beginner myself, so my changes might need reviewing before you use them.

I recompiled you version but can't get it working.

It's been quite some time since I touched it. Things may have changed a lot during that time. Please check the errors and see if you are able to fix them, as I haven't touched this code for more than 2 years.