How to flash protected STM8 MCU?
Make sure that the Read Out Protection (ROP) byte is set to off. Open STVP, go to the OPTION BYTE tab, set ROP to off and write out (Ctrl + P). Then, go to the PROGRAM MEMORY tab again and you should be able to write your hex file.