Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

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.

Check out the scripts for removing flash protection: flash-unprotect.sh, flash-unprotect.ocd

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.

Check out the scripts for enabling flash protection: flash-protect.sh, flash-protect.ocd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.