Problems with programming STM32L mcu with stm32cubeIDE (failed to erase memory)
If your chip is respoinsive and you can access it using ST-Link utility or uVision the problem is that flash memory protection is enabled and attemp to erase, write (ans maybe also read) flash by debugger fails as expected. Probably in utility you also do not see code (instruction bytes) but you see only memory full of zeros or full of ones.
In ST-Link utility select in menu Target &gt; Option bytes and select Read out Protection to Level 0 and in the bottom pane select Unselect all to disable read and write protection of all sectors of flash. Then confirm by Apply button.