I would like to continue what I started here about internal bootloader. Now I would like to add read protection to my uC.

1. Connect uC via UART2 to PC
2. Trigger jumping to internal bootloader by pressing some key
3. Send erase page by page commands (got ACKs)
4. Send new flash content to micro (got ACKs)
5. Send turn on read protection comnand (got ACK and uC resets, needs power on reset - it's ok)

So far so good, till this moment everything works as intended. After reset when read protection is turned on (I can check it via ST-Link utility). Now I want to send another SW to uC:

2. Send Extended Erase Memory command (0x44 0xBB) and get...0x1F. This is actually ok and works as shown on Figure 17 in AN3155 Rev5, page 26. I have RDP active and get NACK.
3. I want to turn it off, I send Readout Unprotect command (0x92 0x6D) and get double ACK (it's fine). Micro makes Mass Erase due to disabling RDP and makes reset.

From that point, flash is empty, BOOT0 pin is connected to GND (boot from user flash memory) and it's impossible to come back to bootloader to continue programming flash with new SW.

Is there any way to boot from system memory after such reset? It looks like only way to use internal bootloader is to have access to BOOT0 pin which in my case is not possible because whole device will be flooded in resin. Am I missing something from Boot configuration?

• Why do you want to disable readout protection? It doesn't prevent you from building a secured readout into your custom bootloader. It would enable SWD readout, but unless you expose those pins too what would be the use? – Chris Stratton Jan 29 '19 at 15:24
• I need to turn it off to be able to program flash with new data. For "outside world" there is only power supply and uart connector. I could add my custom bootloader but time schedule in the project is quite tight and there is not too much time to develop custom BL. I made it once, actually it's not a big deal but it will need some time to modify linker, startup, add procedures etc.and what is more, app on PC is already done. I would like to use already made bootloader and also save space in flash. – voldi Jan 29 '19 at 15:52
• I seem to remember on the blue pills that some of them came protected and when you sent the command through the bootloader to unprotect the bootloader became unresponsive and you had to power cycle or reset, but after that you were unprotected and could use the bootloader or swd to write the application flash. is this what you are seeing here? – old_timer Jan 29 '19 at 16:10
• in my case there was no way through the bootloader to get any other response, unprotect would just not respond, but would work. – old_timer Jan 29 '19 at 16:11
• I think you really want to leave yourself another way in before you pot these; however, if I remember correctly the security settings over-ride the boot pin, so you could perhaps configure the hardware strapping to start in the bootloader, use that to load and start custom code and then secure the chip at which point the bootloader would by skipped. To get back to the bootloader you'd have to build an erase (or at least jump) command into your custom firmware that you could trigger. The risk is that if you ever load a firmware where that doesn't work into a potted device, it is lost – Chris Stratton Jan 29 '19 at 16:33

If BOOT0 is tied low, then it will boot from flash, period. You can still reprogram it through the SWD pins, if they are accessible.