You can protect pages on most flash devices (e.g. internal microcontroller storage). Lock the bootloader and factory reset image, so you can still update the running firmware, but also have a way to recover from any scenario with a hardware button or sufficiently clever watchdog.