how to upload bootloader to empty stm32 chip using openOCD - tomaskovacik/audi_concert1_chorus1_volume_fix GitHub Wiki
exactly as it is mentioned here credits to roger:
You need stlink (a cheap one for few $ from ebay will do)
The second option is to buy bluepill from china, put the fastboot bootloader for stm32duino on int, flash sketch from Arduino IDE and then use the chip from this bluepill board in your newly build module.
How to connect STlikv2 programer to boards
connect the stlink programmer to SWD connector of the module. Connect these pins: 5V, GND, SWDIO, SWCLK. For this purpose there are pins on the right side of the board:
then you need openocd, first uninstall one installed from repository(in case using linux) apt purge openocd for example, then:
git clone git://repo.or.cz/openocd.git
cd openocd
sudo apt-get install make libtool pkg-config autoconf automake texinfo libusb-1.0-0-dev
./bootstrap
./configure
make
sudo make install
for actual flashing bootloader you can use this command:
openocd -f /usr/local/share/openocd/scripts/interface/stlink.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg -c init -c 'reset halt' -c 'flash write_image erase ./generic_boot20_pc13_fastboot.bin 0x8000000;reset run'
or you can use stlink_upload which is provided with arduino ide: here