Usually F3 boards will come with Cleanflight 1.9.0 and there has been a tonne of updates since then.

I tried flashing and kept getting the error “Communication with bootloader failed”

Download the latest Betaflight or Cleanflight from the website (at this time it is betaflight_2.6.1_SPRACINGF3.hex)

Then goto firmware on clean flight configuration tab and make sure you load the file then change the settings to this

-Full chip erase.

-Manual baud rate 256000.

Flash and it should work!