Issue after enabling Flash Read Protection

Hello,

I have my BLE Gatt Peripheral application working and running.

I am developing a reader that reads BLE credential.

Application is complete. I flash the .hex file and reads the BLE credential from mobile app without power cycling.

I then added Readback protection to my application.

Once i flash this application, i verified Readback is protected (since i added WARM_RESET after enabling APPROTECT), but my BLE credential doesn't read (although reader sees advertisement).

I have to power cycle the reader and then it reads.

I want suggestion to fix this issue. I want to read the BLE credential right after flashing the application without power cycling.

Thanks.

		#ifdef ENABLE_APPROTECT
			//Check if Read Protection is Enabled
			if ((NRF_UICR->APPROTECT & UICR_APPROTECT_PALL_Msk) !=
				(UICR_APPROTECT_PALL_Enabled << UICR_APPROTECT_PALL_Pos)) 
			{
				/* Enable Access Port Protection
				* Access through debugger to CPU registers, mapped-memory and RAM will be disabled
				* To disable protection ERASEALL command must be applied. */

				//Enable HW APPROTECT
				WriteWordNrfNvmcCfg((uint32_t)&NRF_UICR->APPROTECT, 
									((NRF_UICR->APPROTECT & ~((uint32_t)UICR_APPROTECT_PALL_Msk)) | 
									 (UICR_APPROTECT_PALL_Enabled << UICR_APPROTECT_PALL_Pos)));

				//Reset to activate
				sys_reboot(SYS_REBOOT_WARM);
			}
			else
			{
				//Access Port Protection is enabled
				
			}
		#else
			// CTRL-AP ERASEALL command will be applied during Flash / Debug Process which makes Access Port Protection disabled
		#endif //ENABLE_APPROTECT

  • The code i added is the Readback Protection i added first thing in the main(). I am using Rev2 (build code Dx00) NRF52840 SOC.

    Is this code ok ? Not sure something is messing up with BLE stack / code unless i power cycle.

  • There seems like a bug in VScode nRF Connect extension.
    The Release Build FW has ReadBack Protection enabled.
     -> If release build fw is flashed using VScode extension, BLE credential doesn't read, unless reader is power cycled.
     -> If release build fw is flashed using Programmer application {inside nRF Connect SDK (Windows Desktop Application)}, reads without needing to power cycle
  • Hi there,

    What SDK are you using? nRF Connect SDK or nRF5SDK, what version are you using?

    regards

    Jared

  • Jared,

    I am using nRF Connect SDK v2.0.

    This is the Visual Studio Code version

    This is the version of nRF Connect for VS

    This is the J-Link version

    If i program the Application FW using VScode extension FLASH operation, the BLE credential doesnt work (application is running: UART etc)

    I have to power cycle the HW and then everything works.

    But if i flash the same Application FW using Programmer Desktop Application, everything works (without performing power cycle)

  • Hi there,

    I'm a bit unsure how this is related to readback protection. Enabling readback protection by setting ENABLE_APPROTECT will not prevent the application to read from the internal flash. It will however prevent external devices to read internal data because the readback protection disables the debugger interface. 

    Flashing a board from the nRF Connect SDK VScode extension versus flashing it from nRF Connect Programmer app does indeed behave differently. The former will do a pin reset while the latter will do a soft reset. 

    The code snippet you've shared for enabling app protect isn't necessary, there is already a kconfig that can be set in the project kconfig that enables app protect, it's called "NRF_APPROTECT_LOCK". Have you already enabled this in your project, can you double check your build folder and see if it's enabled?

    I'm not sure if this is related directly to readback protection, however your code snippet might be causing the issue here.

    Can you:

    1. Disable NRF_APPROTECT_LOCK if it has already been enabled
    2. Remove the code snippet that you have added that enables readback protection
    3. Enable readback protection trough nRF Command Line Tools by using "nrfjprog --rbp ALL"

    The last step should enable readback protection on your device. Can you see if you're able to reproduce your problem with vs code when you're using this method instead of enabling it with your code from the application.

    regards

    Jared

Related