The article describe how to resolve the problem when you get "Read out protection is set" or "Write protection error" messages while programming Stm32 flash memory by StLinkP android application.
Readout protection is applied to all flesh memory. In generally it is three level of readout protection. Exception is Stm32F1 series which has only two level.
Level 0 - readout protection is not set.
Level 1 - readout protection is set. It is not possible both to read and to write flash memory.
Level 2 - this level is equal to level 1 with the one important difference. It is not possible to change this protection level.
Write protection is applied to sectors of flesh memory differently. So it is possible to protect some part of memory while other leave unprotected. Content of the sector with write protection cannot be modified.
What to do
For removing read out or write protection you should change option bytes.
Select menu item "Option bytes" in StLinkP application
New activity for review and edit of option bytes will be opened
Next screenshots is for Stm32F401 CPU but it's similarly for all CPU model.
After you make all needed changes you should press button "Apply" and wait until application would done changes in option bytes.