"Failed to init device" while uploading to stm32 bluepill

I was trying to upload a blinky code to the bluepill dev board and got failed.
I got the following output on terminal.

Linking .pio/build/bluepill_f103c8/firmware.elf
Checking size .pio/build/bluepill_f103c8/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.1% (used 844 bytes from 20480 bytes)
Flash: [==        ]  15.1% (used 9928 bytes from 65536 bytes)
Building .pio/build/bluepill_f103c8/firmware.bin
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, mbed, serial, stlink
CURRENT: upload_protocol = serial
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/bluepill_f103c8/firmware.bin
Failed to init device.
stm32flash Arduino_STM32_0.9

http://github.com/rogerclarkmelbourne/arduino_stm32

Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1

*** [upload] Error 1

how to fix this

Have you put the board in bootloader mode with the boot0 and 1 pins?

The code got uploaded after unplugging and plugging the ftdi module from m y pc.

it didnt work for me