<?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>Branch from non softdevice bootloader to the application with softdevice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109112/branch-from-non-softdevice-bootloader-to-the-application-with-softdevice</link><description>Hello, 
 I am using nrf52832 as a peripheral and running SD S112, nordic UART Profile and SDK 17.1.0 on it. 
 I have written custom bootloader which talks over spi. It starts from address 0x76000. This bootloader doesn&amp;#39;t use the softdevice. The address</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 12 Mar 2024 16:16:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109112/branch-from-non-softdevice-bootloader-to-the-application-with-softdevice" /><item><title>RE: Branch from non softdevice bootloader to the application with softdevice</title><link>https://devzone.nordicsemi.com/thread/473505?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2024 16:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eff69625-950e-4a0a-9772-f534dea5c53a</guid><dc:creator>Justin</dc:creator><description>&lt;p&gt;Found the issue. It was in my application. I was getting NRF_ERROR_NO_MEM error while calling the sd_ble_enable() function. This was due to not the amount of memory assigned to the softdevice was not large enough to fit the config memory requirement.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much for your help in looking into this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Branch from non softdevice bootloader to the application with softdevice</title><link>https://devzone.nordicsemi.com/thread/473308?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2024 22:46:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d09c0d3b-24ca-4a19-a96f-877b867250a7</guid><dc:creator>Justin</dc:creator><description>&lt;p&gt;Hello Sigurd,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for you reply and for the pointer to the code.&lt;/p&gt;
&lt;p&gt;I did exactly following the nrf_bootloader_app_start() and nrf_bootloader_app_start_final() in the SDK_folder.&lt;/p&gt;
&lt;p&gt;However, I am still not able to boot to the application. Debugging, I see that jump_to_addr is getting called with the &lt;strong&gt;new_msp&lt;/strong&gt; value is &lt;strong&gt;0x20000CD0&lt;/strong&gt; and the &lt;strong&gt;reset_handler address&lt;/strong&gt; as &lt;strong&gt;0x00018A59&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Are these address values supposed to be correct ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In the application linker I am setting following parameters.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;define symbol __ICFEDIT_intvec_start__ = 0x19000;&lt;br /&gt; /*-Memory Regions-*/&lt;br /&gt; define symbol __ICFEDIT_region_ROM_start__ = 0x19000;&lt;br /&gt; define symbol __ICFEDIT_region_ROM_end__ = 0x26000;&lt;br /&gt; define symbol __ICFEDIT_region_RAM_start__ = 0x200022c0;&lt;br /&gt; define symbol __ICFEDIT_region_RAM_end__ = 0x2000ffff;&lt;br /&gt; export symbol __ICFEDIT_region_RAM_start__;&lt;br /&gt; export symbol __ICFEDIT_region_RAM_end__;&lt;br /&gt; /*-Sizes-*/&lt;br /&gt; define symbol __ICFEDIT_size_cstack__ = 2048;&lt;br /&gt; define symbol __ICFEDIT_size_heap__ = 2048;&lt;br /&gt; /**** End of ICF editor section. ###ICF###*/&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In the Bootloader linker I am setting following parameters.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;define symbol __ICFEDIT_intvec_start__ = 0x76000;&lt;br /&gt; /*-Memory Regions-*/&lt;br /&gt; define symbol __ICFEDIT_region_ROM_start__ = 0x76000;&lt;br /&gt; define symbol __ICFEDIT_region_ROM_end__ = 0x7e000;&lt;br /&gt; define symbol __ICFEDIT_region_RAM_start__ = 0x20005968;&lt;br /&gt; define symbol __ICFEDIT_region_RAM_end__ = 0x2000ffff;&lt;br /&gt; export symbol __ICFEDIT_region_RAM_start__;&lt;br /&gt; export symbol __ICFEDIT_region_RAM_end__;&lt;br /&gt; /*-Sizes-*/&lt;br /&gt; define symbol __ICFEDIT_size_cstack__ = 2048;&lt;br /&gt; define symbol __ICFEDIT_size_heap__ = 2048;&lt;br /&gt; /**** End of ICF editor section. ###ICF###*/&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Please find the code below&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; #define MBR_IRQ_FORWARD_ADDRESS_ADDRESS (0x20000000)
 #define DEBUG_ADDRESS (0x20008000)

  /**@brief Function that sets the stack pointer and starts executing a particular address.
   *
   * @param[in]  new_msp  The new value to set in the main stack pointer.
   * @param[in]  addr     The address to execute.
   */
  void jump_to_addr(uint32_t new_msp, uint32_t addr)
  {
      __set_MSP(new_msp);
     *(uint32_t *)(DEBUG_ADDRESS + 4) = new_msp;

     *(uint32_t *)(DEBUG_ADDRESS) = 0xDEA4;

     *(uint32_t *)(DEBUG_ADDRESS + 8) = addr;
      ((void (*)(void))addr)();
     *(uint32_t *)(DEBUG_ADDRESS) = 0xDEA5;
  }


  /**@brief Function for booting an app as if the chip was reset.
   *
   * @param[in]  vector_table_addr  The address of the app&amp;#39;s vector table.
   */
  __STATIC_INLINE void app_start(uint32_t vector_table_addr)
 {
      const uint32_t current_isr_num = (__get_IPSR() &amp;amp; IPSR_ISR_Msk);
      const uint32_t new_msp         = *((uint32_t *)(vector_table_addr));                    // The app&amp;#39;s Stack Pointer is       found as the first word of   the vector table.
      const uint32_t reset_handler   = *((uint32_t *)(vector_table_addr + sizeof(uint32_t))); // The app&amp;#39;s Reset Handler is       found as the second word of  the vector table.

      __set_CONTROL(0x00000000);   // Set CONTROL to its reset value 0.
      __set_PRIMASK(0x00000000);   // Set PRIMASK to its reset value 0.
      __set_BASEPRI(0x00000000);   // Set BASEPRI to its reset value 0.
      __set_FAULTMASK(0x00000000); // Set FAULTMASK to its reset value 0.

     *(uint32_t *)(DEBUG_ADDRESS) = 0xDEA2;
     if(current_isr_num == 0)
     {
         *(uint32_t *)(DEBUG_ADDRESS + 12) = 0xDEAD;
     }
      ASSERT(current_isr_num == 0); // If this is triggered, the CPU is currently in an interrupt.
     *(uint32_t *)(DEBUG_ADDRESS) = 0xDEA3;

      // The CPU is in Thread mode (main context).
      jump_to_addr(new_msp, reset_handler); // Jump directly to the App&amp;#39;s Reset Handler.
 }



 void boot_to_app(void)
 {

     uint32_t address = MBR_SIZE;
     NVIC-&amp;gt;ICER[0] = 0xFFFFFFFF;
     NVIC-&amp;gt;ICPR[0] = 0xFFFFFFFF;
     NVIC-&amp;gt;ICER[1] = 0xFFFFFFFF;
     NVIC-&amp;gt;ICPR[1] = 0xFFFFFFFF;

     // nrf_dfu_mbr_irq_forward_address_set();
     *(uint32_t *)(MBR_IRQ_FORWARD_ADDRESS_ADDRESS) = address;
     // nrf_bootloader_app_start_final(start_addr);
     app_start(address);
 }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For debugging I am writing to the memory&amp;nbsp;at address 0x20008000. Below is the output of the same for your reference.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;:10800000A4DE0000D00C0020598A0100ADDE000083&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you please take a look and let me know if I am missing on something here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Branch from non softdevice bootloader to the application with softdevice</title><link>https://devzone.nordicsemi.com/thread/473267?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2024 15:45:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8188e186-1da9-4fc5-b702-02c051daa632</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;HI!&lt;/p&gt;
&lt;p&gt;It should be possible to do this similar to how it&amp;#39;s done in the regular DFU code example, i.e. SDK_folder\examples\dfu\secure_bootloader\pca10040e_s112_ble\&lt;/p&gt;
&lt;p&gt;Take a look at the function&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;nrf_bootloader_app_start() in&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span&gt;SDK_folder&lt;/span&gt;\components\libraries\bootloader\nrf_bootloader_app_start.c&lt;/p&gt;
&lt;p&gt;and&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;nrf_bootloader_app_start_final() in&amp;nbsp;SDK_folder\components\libraries\bootloader\nrf_bootloader_app_start_final.c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>