If you have a board which comes without a bootloader such as a Bluepill, or you want to swap the bootloader for a different one, the below shows how to do it easily.
Here we will use a BluePill as the target board, as these are often supplied without a bootloader.
Connect your 3.3v USB to Serial adapter to the board as shown below:
Then ensure any jumpers which need setting to enable flash mode are set (e.g on BluePill BOOT0 must be set to 1), and ensure the board is reset, and the USB to Serial Adapter connected to the PC.
STM32 Flasher Tool
The simplest way to flash a bootloader is to use the STM32 Flash Downloader utility from ST. This only requires the serial connection and the image to flash to be available.
A variety of other tools are available to flash the bootloader onto your ST board
This is a driverless bootloader for STM32F10x and STM32F4xx based boards based on the HID Protocol.
This is a modified version of the Maple DFU Bootloader, and pre-built binary images are supplied.
To perform the update load the STM32 Flasher tool, and follow the below steps...
Select the correct COM Port for your board, and press Next
If you encounter an error, ensure all wiring is correct, and that any jumpers have been correctly set on your board.
Ensure the correct board has been detected, and press Next
Select the correct memory configuration for your board.
Ensure the sector is set to 8000000 as shown here (consult bootloader documentation for this value if unsure).
Select the "Download to Device" section, and click the [...] button to select your firmaware file
Locate the bootloader image file you downloaded previously (you may have to change the file type filter to suit your file format), and double click it.
Press Next to flash the board.
The flashing progress will be shown
And when completed simply click Close, and change your jumper back to "runtime" mode to begin to use your new bootloader.
Once all steps are complete the bootloader is now on your board, so you can upload via USB. Also note there are special functionality bootloaders for such tasks as the STLink Image, to allow you to turn a Blue Pill into an STLink Programmer/Debugger for other STM32 Boards....