<?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>Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55158/problem-debugging-bootloader-using-ozone</link><description>Hi, 
 I&amp;#39;m trying to debug my bootloader (I2C specifically) using Ozone. However the CPU only seems to halt when trying to debug the bootloader. 
 Also setting breakpoints only results in the error code: 
 
 SetBreakpoint: JLINK API call failed 
 
 
 Settings</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Dec 2019 12:42:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55158/problem-debugging-bootloader-using-ozone" /><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224170?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 12:42:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2d72eda-7fdc-4d3a-a187-c466fded9f98</guid><dc:creator>AntonHellbe</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Using the UICR registers as you suggested worked perfectly.&lt;/p&gt;
&lt;p&gt;And as you said, after programming through Ozone and reading the MBR it shows 0xFF..FF.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224109?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 09:53:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74f64971-56ac-489e-8e3e-a5affc5e5374</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks. So I got the same hardfault with GDB and turns out it&amp;#39;s erasing the MBR section when setting the BL start and MBR param page address. Try to use the UICR registers instead:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-cfc3fecbd7f845338b5657f351cb6bac/pastedimage1575625885151v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When you have updated the registers in UICR, program the bootloader image first, and the Softdevice after.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-cfc3fecbd7f845338b5657f351cb6bac/pastedimage1575625981891v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Edit: you can &amp;#39;nrfjprog memrd 0&amp;#39; after programming the bootloader in Ozone and see if it reads 0xFF..FF to determine if the MBR got erased.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224097?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 09:18:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee1d0d95-d74e-45c4-996e-5ceb08aefc75</guid><dc:creator>AntonHellbe</dc:creator><description>&lt;p&gt;Here&amp;#39;s the *.out file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224095?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 09:16:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e01ddf10-8055-43aa-86a6-4ddec8d8d9d5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The PC is 0xFF..FE so that explains the hardfault. It may even have lead to a lockup reset had you not been in debug mode. Unfortunately, I don&amp;#39;t see any obvious reasons to how it could happen. Would it be possible to upload the bootloader .elf/.out so I can try it here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224090?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 09:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91de0a3a-e895-41db-915a-839c5ac593f4</guid><dc:creator>AntonHellbe</dc:creator><description>&lt;p&gt;For some reason I have missed looking at the Call stack. Seems like we are stuck in a Hardfault handler.&lt;/p&gt;
&lt;p&gt;Here are the screenshots:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/527x938/__key/communityserver-discussions-components-files/4/ozone0.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/542x240/__key/communityserver-discussions-components-files/4/ozone1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Edit:&lt;/p&gt;
&lt;p&gt;the CPU halting only occurs when using Ozone. If I upload the hex file using nrfjprog the bootloader start and I can start a DFU upgrade without any issues (logs printed aswell), however with Ozone no logs are printed and the bootloader doesn&amp;#39;t react to I2C messages.&lt;/p&gt;
&lt;p&gt;Modified the AfterTargetReset / Download:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void AfterTargetReset (void) {
/*
  unsigned int SP;                                                
  unsigned int PC;                                                
  unsigned int VectorTableAddr;                                   
                                                                  
  VectorTableAddr = Elf.GetBaseAddr();                            
                                                                  
  if (VectorTableAddr == 0xFFFFFFFF) {                            
    Util.Log(&amp;quot;Project file error: failed to get program base&amp;quot;); 
  } else {                                                        
    SP = Target.ReadU32(0x0);                         
    Target.SetReg(&amp;quot;SP&amp;quot;, SP);                                    
                                                                  
    PC = Target.ReadU32(0x0 + 0x4);                     
    Target.SetReg(&amp;quot;PC&amp;quot;, PC);                                    
  }
*/
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224085?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 08:44:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1eced1fc-edff-46ab-8c95-d8c1110ddc48</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Do you know that the CPU halting only occurs when debugging with Ozone? I&amp;#39;ve not been able to replicate this with the SDK bootloader. I just downloaded Ozone v2.70e and tested with and without&amp;nbsp;&lt;span&gt;AfterTargetReset() implemented. Can you post a screenshot of the CPU registers and call stack when it has halted?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/224067?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 07:56:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59353607-ff73-4532-acc4-9f3cd35e62b7</guid><dc:creator>AntonHellbe</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;I have tried that, the CPU still halts.&lt;/p&gt;
&lt;p&gt;Here is the main function of the bootloader, I&amp;#39;m expecting it to run forever in the while loop as there is not valid application on the chip.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    ret_code_t ret;
    bootloader_callbacks_t bootloader_callbacks;

    bootloader_callbacks.start_application = start_application;
    bootloader_callbacks.send_i2c_message  = send_i2c_message;

    ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);
    nrf_drv_clock_lfclk_request(NULL);

    // Protect MBR and bootloader code from being overwritten.
    ret = nrf_bootloader_flash_protect(0, MBR_SIZE, false);
    APP_ERROR_CHECK(ret);
    ret = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false);
    APP_ERROR_CHECK(ret);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    APP_ERROR_CHECK(app_timer_init());

    NRF_LOG_INFO(&amp;quot;Inside main&amp;quot;);

    bootloader_app_init(&amp;amp;bootloader_callbacks);
    
    if (dfu_enter())
    {
        twi_slave_init();
        send_fw_upgrade_response();
        NRF_LOG_DEBUG(&amp;quot;DFU Enter requested. Waiting for FW&amp;quot;);
        while(!new_fw_received)
        {
        }
    }
    else
    {
    }

    // Either there was no DFU functionality enabled in this project or the DFU module detected
    // no ongoing DFU operation and found a valid main application.
    // Boot the main application.
    //
    NRF_LOG_INFO(&amp;quot;Starting application&amp;quot;);
    nrf_bootloader_app_start();

    // Should never be reached.
    NRF_LOG_INFO(&amp;quot;After main&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;/ Anton&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem debugging bootloader using Ozone</title><link>https://devzone.nordicsemi.com/thread/223920?ContentTypeID=1</link><pubDate>Thu, 05 Dec 2019 13:33:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:151a53e7-88eb-4c3d-9804-45b8baa6ec7f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Anton,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you try comment out everything inside AfterTargetReset()? It should not be necessary to set SP and PC manually.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>