What is "flash protection"?
PineTime’s flash memory is protected by the Access Port Protection feature of the Nordic nRF52 Microcontroller
The Access Port Protection feature locks the nRF52 flash ROM from any dumping, modification and prevents debugging. Access Port Protection is enabled in production devices, so that people can’t snoop into an nRF52 gadget and tamper with the ROM.
Access Port Protection prevents us from flashing and debugging PineTime in its shipped form, so we need to remove the protection.
To remove Access Port Protection, we need to set the
ERASEALL register to
1. Upon restart, the nRF52 Microcontroller will erase all contents of the flash ROM and allow flashing / debugging.
Turning on flash protection is more tricky... We need to load nRF52's UICR flash region from a file to set
APPROTECT register to 0.