Resolved! Bug in STM32L051 reference manual descriptions for some FLASH_PECR bits
The descriptions of FLASH_PECR bits 1, 2 (PRGLOCK, OPTLOCK) on page 103 appear to have the meanings of 0 and 1 swapped. For example, referring to PRGLOCK (Bit1) the RM says:0: The write and erase operations in the Flash program memory are disabled.1...