I have taken refernce from embextronics for understanding how to write bootloader for STM32 and where to place the application program. (https://www.youtube.com/watch ...
It's almost impossible to erase device with enabled write protection in bootloader, because you need to change option bytes, then do power cycle and then mass erase. Issues it, after power cycle, ...