The STM32 has a read-out protection level 2 feature adjusted from ST-LINK Utility App (Options Bytes) so code cannot be read out via the debug interface (SWD) or any other way.
There was an explanation,ST Electronics website. I tried the proposed app named as Device Firmware Update (DFU). However, it did not work.
This is the MCU I work on.
In read out protection, Level 2 is selected and applied. After that, MCU cannot be seen or communicated.