Flash memory must be deleted before you rewrite it.
monitor flash protect 0 0 11 off
monitor flash erase_address 0x08000000 0x40000
monitor flash write_image erase *"/path/to/hex/file.hex"* 0 ihex
Or instead of telnet and hex files, use arm-none-eabi-gdb and ELF with the following commands:
arm-none-eabi-gdb
target remote localhost:3333
monitor reset halt
file */path/to/elf/file.elf*
load
monitor reset
continue
Note that when using ELF files, you do not need to specify the address where it will be (usually 0x08000000 or 0x08008000 with bootloaders).
Also, consider using a bootloader like OpenBLT, it will help you to master the principles like VTOR, offsets, stack addresses etc.