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

  • nrfjprog --rbp ALL works fine as well to protect read back.

    After several testing it seems like this issue is not related to ENABLING FLASH protection.

     There seems like a bug in VScode nRF Connect extension for FLASH action
        -> If the fw is flashed using VScode extension, the application runs but the Mobile BLE credential doesn't read, unless reader is power cycled.
        -> If the fw is flashed using Programmer application {inside nRF Connect SDK (Windows Desktop Application)}, the Mobile BLE credential reads right away without needing to power cycle*/
    You did said:
    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. 
    Does that makes a difference in performing what application needs to do ?
    Does pin reset halt the application and softreset doesnt ?
    If yes, how can i run the application after i perform FLASH from VScode extension.
  • Hi,

    Yes, most likely this is not related to readback protection. I suspect that it's somewhat related to your code snippet that you shared above. 

    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).

    Can you try to debug your application when you read after the "warm_reset" and see if the program asserts? Do you have any logging on the mobile application or the nRF that would tell something about the state of the program when you try to read the BLE characteristic? Could you capture and share a trace with nRF Sniffer?

    regards

    Jared 

  • when i read after the "warm reset" and see if the program asserts? Yes, i cannot read log on RTT since APPLOCK is enabled.

    I have NRF52840 DK as well as Dongle to work with and android app for nRF Sniffer. Can you share me online video tutorial / document that explains how do i use nRF Sniffer to capture BLE logs OTA ?

    Can i use same phone (android) to run NRF SNIFFER APP on which my other BLE credential is being used to read ?

    or can i use nRF Sniffer app on windows PC while using DK / Dongle to capture ?

  • Hi,

    Deep Patel said:
    when i read after the "warm reset" and see if the program asserts? Yes, i cannot read log on RTT since APPLOCK is enabled.

    I see..

    Deep Patel said:

    I have NRF52840 DK as well as Dongle to work with and android app for nRF Sniffer. Can you share me online video tutorial / document that explains how do i use nRF Sniffer to capture BLE logs OTA ?

    Can i use same phone (android) to run NRF SNIFFER APP on which my other BLE credential is being used to read ?

    or can i use nRF Sniffer app on windows PC while using DK / Dongle to capture ?

    You have to use a separate DK or Dongle to sniff packets between two devices. You can not use a device that is already a part of the communication that is going to be sniffed. We have this outdated video that gives you a brief overview of the sniffer, but you should really look at the documentation that explains how to run the sniffer. You can find the documentation here.

    regards

    Jared

Related