Hello,
To protect the flash you will use Censorship feature.
A password mechanism is designed to grant the legitimate user access to the non-volatile memory.
Please refer to detailed procedure described in Reference manual: 34.7 Censorship

Here is the example for Lauterbach debugger for censoring and uncensoring uC.
Best regards,
Peter