<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67855/can-not-enter-application-after-readback-protect</link><description>Hi , 
 I wirte a python script to download FW to nRF52832 custom board, the FW is the merged file with softdevice（s132_nrf52_7.0.1_softdevice.hex）, bootload, bootload settings, and application, then setting readback protect. 
 After setting readback protect</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Feb 2021 10:26:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67855/can-not-enter-application-after-readback-protect" /><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/292176?ContentTypeID=1</link><pubDate>Mon, 01 Feb 2021 10:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8282fd10-7a37-48bf-b675-d69dac3ffef5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Susan,&lt;/p&gt;
&lt;p&gt;Ok, thanks for confirming that you were using the same J-link. &lt;/p&gt;
&lt;p&gt;I may be related to the clock speed as you say. The default speed is usually between the 2000 - 4000 kHz, so considerably slower than what your script is using. Could you try lowering the clock speed and see it helps? &lt;/p&gt;
&lt;p&gt;The verification step (checks integrity check of loaded image) you enabled with the high level API should detect any programming errors. Did you check the log to see if pynrfjprog reported any errors?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/292081?ContentTypeID=1</link><pubDate>Sun, 31 Jan 2021 14:21:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dd53461-d933-4272-90ac-1981c63849db</guid><dc:creator>Susan_cfx</dc:creator><description>&lt;div class="author"&gt;
&lt;div class="avatar"&gt;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/susan_5f00_cfx"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="content full threaded-reply-content user-defined-markup"&gt;
&lt;div class="content"&gt;
&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I haven&amp;#39;t see any failures&amp;nbsp; after you added the delay.&amp;nbsp;&lt;/span&gt;&amp;nbsp;Of course I am using the same J-link debugger&amp;nbsp;I use nrfjprog/nRFconnect.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;when I use flash script, the SWD speed is 10000kHz.&lt;/p&gt;
&lt;p&gt;What is the default SWD speed when I use nrfjprig/nRFconnect?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Does SWD speed affect the integrity check and cause this problem? Thank you very much.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Susan&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/291772?ContentTypeID=1</link><pubDate>Thu, 28 Jan 2021 12:12:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2475a52d-7eb7-4cf0-8949-80d63331bafb</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Susan,&lt;/p&gt;
&lt;p&gt;It sounded like the problem was more intermittent earlier, even when you didn&amp;#39;t enable readback protection.&amp;nbsp; Have you seen any failures now after you added the delay? Also, are you using the same J-link debugger when you use nrfjprog/nRFconnect?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/291686?ContentTypeID=1</link><pubDate>Thu, 28 Jan 2021 08:22:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdb8dd01-4e77-4b14-82ef-92fab3e6336a</guid><dc:creator>Susan_cfx</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Any update or&amp;nbsp; suggestions ? thank you very much.&lt;/p&gt;
&lt;p&gt;Susan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/291162?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 04:21:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f8e3e75-29b8-4ea8-bd67-aa3cf9c3e4ea</guid><dc:creator>Susan_cfx</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;According to your suggestion, I checked the version of mergehex , it is&amp;nbsp;&amp;nbsp;version: 10.4.1.&lt;/p&gt;
&lt;p&gt;And I modified the &lt;span&gt;programming&lt;/span&gt; script,&amp;nbsp;&lt;span&gt;&amp;nbsp;as shown in the example highlevel_programe_hex.py&lt;/span&gt;&lt;span&gt;,&amp;nbsp; it&lt;/span&gt;&lt;span&gt;&amp;nbsp;gives the same result.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Before if I don&amp;#39;t set readback_protect, the application can run. if set&amp;nbsp;&lt;span&gt;readback_protect,&amp;nbsp;still advertsing DfuTarg.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Following is the script,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="python"&gt;def program_target(dut):
    global jlink_serial, swd_speed, hex_file_path
    print (&amp;quot;Flash DUT with production firmware&amp;quot;)

    api = HighLevel.API(&amp;quot;NRF52&amp;quot;)  #add by Susan

    sleep(1)

    dut.hexfilemd5=md5(hex_file_path)
    try:
        api.open()
      #  api.connect_to_emu_with_snr(jlink_serial, swd_speed)  # comment out by Susan
        probe = HighLevel.DebugProbe(api, jlink_serial)   #add by Susan

        dut.hexfilename = hex_file_path
        print(&amp;quot;Writing %s to device...&amp;quot; % hex_file_path)

        # Make a program option struct to modify programming sequence.
        # If ommitted, the default programoptions struct specifies ERASE_ALL, SYSTEM_RESET, and VERIFY_NONE.
        #following add by Susan
        
        program_options = HighLevel.ProgramOptions(
            erase_action=HighLevel.EraseAction.ERASE_ALL,
            reset=HighLevel.ResetAction.RESET_SYSTEM,
            verify=HighLevel.VerifyAction.VERIFY_READ
        )
        
        probe.program(hex_file_path, program_options=program_options)

        sleep(1)  # if don&amp;#39;t add sleep time, will advertising DfuTarg.
        probe.readback_protect()
     #   probe.reset()  # if add reset, will except APIError.
        probe.close()

        dut.flash_success = True
        dut.programtime = str(datetime.datetime.now())
        return dut

    except HighLevel.APIError:
        print (&amp;quot;Programming adapter not found!---1&amp;quot;)
        dut.failure_desc=&amp;quot;No programming adapter or programming failed!&amp;quot;

        probe.close()  #add by susan
        dut.flash_success = False
        return dut
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I try to&amp;nbsp; add sleep time delay 0.01 seconds before probe.readback_protect,&amp;nbsp; the application can run,&lt;strong&gt;&amp;nbsp;why?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;sleep(0.01)&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;em&gt;# if don&amp;#39;t add sleep time, will advertising DfuTarg.&lt;/em&gt;&lt;br /&gt; probe.readback_protect()&lt;br /&gt; # probe.reset()&amp;nbsp; &amp;nbsp;&lt;em&gt;# i&lt;em&gt;f add reset, will except APIError.&lt;/em&gt; &lt;/em&gt;&lt;br /&gt; probe.close()&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;After probe.readback_protect(),&amp;nbsp; do I need to add probe.reset() ?&amp;nbsp;&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Try previous programming&amp;nbsp;script,&amp;nbsp;&amp;nbsp;which use the LowLevel API,&amp;nbsp; just add sleep time before api.readback_protect(2), test&amp;nbsp;10 times, the applicaiton can run.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="python"&gt;
def program_target(dut):
    global jlink_serial, swd_speed, hex_file_path
    print (&amp;quot;Flash DUT with production firmware&amp;quot;)
    
    api = LowLevel.API(&amp;quot;NRF52&amp;quot;)  
    sleep(1)

    dut.hexfilemd5=md5(hex_file_path)
    try:
        api.open()
        api.connect_to_emu_with_snr(jlink_serial, swd_speed)  # comment out by Susan

        # Program the parsed hex into the device&amp;#39;s memory.
        test_program = Hex.Hex(hex_file_path)
        dut.hexfilename = hex_file_path
        print(&amp;quot;Writing %s to device...&amp;quot; % hex_file_path)

        for segment in test_program:
            api.write(segment.address, segment.data, True)
            content = api.read(segment.address, len(segment.data))
            if not segment.data == content:
                print (&amp;quot;Program data mismatch starting at address: {}, segment length: {}&amp;quot;.format(str(segment.address, &amp;#39;x&amp;#39;), str(len(segment.data))))
                raise LowLevel.APIError
                break

        print (str(datetime.datetime.now()) + &amp;quot;: Resetting target...&amp;quot;)
        api.sys_reset()   
        api.go()
        
        sleep(0.01)  # if don&amp;#39;t add sleep time, will advertising DfuTarg.
        
        api.readback_protect(2)   # or api.write_u32(0x10001208, 0x00,True)
        print (&amp;quot;Pinreset...&amp;quot;)
        api.pin_reset()
        api.close().

        dut.flash_success = True
        dut.programtime = str(datetime.datetime.now())
        return dut
        
    except LowLevel.APIError:
        print (&amp;quot;Programming adapter not found!---1&amp;quot;)
        dut.failure_desc=&amp;quot;No programming adapter or programming failed!&amp;quot;
        api.close()   
        dut.flash_success = False
        return dut
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is differrent between HighLevel API and LowLevel API ?&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&lt;strong&gt;Which one should I use first？&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is it necessary to increase sleep time before readback protection?&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Please help me to check above two programming script , any problem, please help to corret, thank you very much.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Susan&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/290976?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2021 10:21:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3983b564-7510-4cf0-9bba-8b7e488438cd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Susan,&lt;/p&gt;
&lt;p&gt;Thanks for checking. So, the application image appears to be corrupted as the integrity check is failing.&lt;/p&gt;
&lt;p&gt;I noticed you are not doing any post validation in your programming script to see if the image was programmed correctly. Can you try to program the hex file as shown in the example script here: &lt;a href="https://github.com/NordicSemiconductor/pynrfjprog/blob/master/pynrfjprog/examples/highlevel_program_hex.py"&gt;https://github.com/NordicSemiconductor/pynrfjprog/blob/master/pynrfjprog/examples/highlevel_program_hex.py&lt;/a&gt; and see if it gives the same result?&lt;/p&gt;
&lt;p&gt;You may also be impacted by a bug in merghex if you are using the 10.12.x release as reported in this post: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69940/nrf52840---problems-merging-and-flashing-secure_bootloader_uart_mbr_pca10056-and-ble_app_uart_pca10056_s140/286885"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/69940/nrf52840---problems-merging-and-flashing-secure_bootloader_uart_mbr_pca10056-and-ble_app_uart_pca10056_s140/286885&lt;/a&gt;&lt;/p&gt;
[quote user="Susan_cfx"]I have to modify&amp;nbsp;--bl-settings-version&amp;nbsp;to 2,&amp;nbsp; why?[/quote]
&lt;p&gt;&amp;nbsp;SDK v15.3.0 and onwards uses the new BL settings format, which must be indicated by setting the --bl-settings-version to &amp;#39;2&amp;#39;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/290937?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2021 08:14:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77d85400-b3ca-4a9a-a833-ef7d679034d4</guid><dc:creator>Susan_cfx</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;According to your suggestion, I generate the bootloader settings page with&amp;nbsp;--app-boot-validation set to NO_VALIDATION, and flash the final merged firmware many times, all &lt;strong&gt;succeed, &lt;/strong&gt;no replicate the problem.&amp;nbsp; If not add this command NO_VALIDATION, most of time failed and advertised DfuTarg.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrfutil.exe settings generate --no-backup --family NRF52 --application %3 &lt;strong&gt;--app-boot-validation NO_VALIDATION&lt;/strong&gt; --application-version %1 --bootloader-version %2 --bl-settings-version 2 bootloader_settings.hex &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp;If add the integrity check of the application image, how to solve this problem?&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;By the way,&amp;nbsp; If I&amp;nbsp;set --bl-settings-version&amp;nbsp;1, prompt e&lt;/span&gt;rror: Invalid value for bl_settings_version: Bootloader settings version 1 does not support boot validation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I have to modify&amp;nbsp;--bl-settings-version&amp;nbsp;to 2,&amp;nbsp; why?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Looking forward your reply, thank you very much.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Susan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/290203?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 10:41:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3afadc55-2962-43f6-8d3d-c396d5f4e5d4</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Susan,&lt;/p&gt;
&lt;p&gt;The GPREGRET is usally only written to by the CPU when doing buttonless DFU, so I don&amp;#39;t think that&amp;#39;s related to the problem here. But it&amp;#39;s interesting that this occurs only intermidently when programed with your flash tool. Maybe the FW was loaded incorrectly in those cases. As a test, please try to generate the settings page with the --app-boot-validation set to NO_VALIDATION and see if you can replicate the problem then.&amp;nbsp; This will make the bootloader skip the integrity check of the application image on boot.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1611139455463v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/290122?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 07:22:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6083a8ff-f554-4b9a-ad43-e4b137a12c72</guid><dc:creator>Susan_cfx</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;I use nrfjprog and nRFConnect programmer, it is no problem, the beacon can boot into application.&lt;/p&gt;
&lt;p&gt;But If I use custom flashing script and Segger JLink, Sometimes, it can boot into application, and sometimes it&amp;nbsp; cannot boot into application, still advertising DFUtag.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks there are something different between Nordic flashing tool and our flashing tool.&lt;/p&gt;
&lt;p&gt;I learned the buttonless DFU module uses an MCU register (NRF_POWER-&amp;gt;GPREGRET) to decide whether to boot to bootloader or application.&lt;/p&gt;
&lt;p&gt;Does any GPREGRET-flag needs to be set?&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span&gt;How to modify&amp;nbsp;the bootloader firmware ? Thank you very much.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Susan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not enter application after readback protect?</title><link>https://devzone.nordicsemi.com/thread/278084?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 13:28:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97ff43b9-fa8e-4d00-82f9-16aacade07a8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It should not make any difference if readback protection is enabled or not. I also did not manage to replicate this with the hex file you uploaded. Your script looks to be correct, but could you try and see if you get the same result if you use nrfjprog as well?&lt;/p&gt;
&lt;p&gt;I used the following commands (nrfjprog version 10.10.0 + JlinkARM.dll 6.84a):&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$ nrfjprog --program 1185.ed_sd_bl_set_app.hex --chiperase -r&lt;br /&gt;Parsing hex file.&lt;br /&gt;Erasing user available code and UICR flash areas.&lt;br /&gt;Applying system reset.&lt;br /&gt;Checking that the area to write is not protected.&lt;br /&gt;Programming device.&lt;br /&gt;Applying system reset.&lt;br /&gt;Run.&lt;br /&gt;&lt;br /&gt;$ nrfjprog --rbp all&lt;br /&gt;Protected the device against read and debug. Only a --recover, --debugreset,&lt;br /&gt;or --pinreset operations will work from now on.&lt;br /&gt;&lt;br /&gt;$ nrfjprog --pinreset&lt;br /&gt;Applying pin reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>