STM32 gotchas
272. In RDP Level 1, booting into SRAM prevents reading from FLASH and backup-SRAM

The readout protection (RDP) as set in the Option Bytes, is aimed at preventing IP theft by unauthorized reading out the FLASH content. RDP Level 2 is the ultimate protection, disabling entirely the debug interface, but that's also a point of no turning back, Level 2 cannot be reverted.

RDP Level 1 is a less stringent option, and the primary mechanism of protection there is preventing the debug interface from reading nor erasing/writing the FLASH (as well as the backup SRAM). So, the debug interface still works, and it can be used to change RDP to Level 0 (in which case the entire FLASH and backup SRAM are automatically erased, as part of the protection), but it also can be used to observe and change e.g. RAM content.

The fact, that reading FLASH is disabled while debugger interface is attached, has also the consequence, that it is not possible to run or single-step code from FLASH in the debugger. However, it is still possible to use the debugger to load code to RAM and run it from there, but that can't read FLASH either.

Additionally, not only the debugger being attached, but also booting from RAM (through manipulating the Option Bytes or through setting boot pins appropriately, or using any other mechanism available for that particular STM32) will disable access to FLASH and backup SRAM. This is to prevent an attack scenario, where rouge code would be loaded to RAM using the debugger, and then after detaching the debugger and resetting into RAM, this code would run and read the FLASH/backup SRAM content.

However, this mechanism may come as a surprise, if one attempts to implement a booting mechanism, where a legitimate boot code is loaded into RAM by the application in RDP Level 1 locked mcu, reboots into RAM and then attempts to read data from FLASH or backup SRAM using this code.