<?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>nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25073/nrf52-simple-spi-bootloader-problems</link><description>Hi, 
 I&amp;#39;ve managed to code an app for nRF52382 (S132, SDK14) which works properly. Also, I&amp;#39;ve taken &amp;quot;bootloader_secure_serial&amp;quot; and removed a lot of stuff to code a simple SPI bootloader which reads data from external SPI data flash. 
 So in short, what</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Feb 2020 11:25:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25073/nrf52-simple-spi-bootloader-problems" /><item><title>RE: nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/thread/233238?ContentTypeID=1</link><pubDate>Fri, 07 Feb 2020 11:25:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f126e2f-1ddc-4de8-9fdb-bbeaacc95ab2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see you have posted another question about this as well, so I suggest we continue there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/thread/232862?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 14:19:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3869ddd3-0c85-4c4c-9157-c6b1190bd443</guid><dc:creator>danchug</dc:creator><description>&lt;p&gt;I am creating a custom bootloader for NRF52832 that will update my application that uses S132 V3.1.&amp;nbsp; My bootloader project uses SDK 16.0, S132 V3.1 headers, and Segger Studio.&amp;nbsp; Here is sequence/intent:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;Device boot into bootloader via uicr_bootloader_start_address set at bootloader vector @0x6C000.&amp;nbsp; This works perfectly.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Bootloader overwrite flash using NVMC. (Not yet implemented).&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Bootloader verify flash. (Not yet implemented).&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Bootloader calls SD_MBR_COMMAND_INIT_SD (the failure is that the return code is 1 (NRF_ERROR_SVC_HANDLER_MISSING).&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Bootloader calls sd_softdevice_disable.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Bootloader calls sd_softdevice_vector_table_base_set (also, the failure is that the return code is 1 (NRF_ERROR_SVC_HANDLER_MISSING).&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Bootloader calls nrf_bootloader_app_start_impl(0x1F000) from SDK 12.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Currently, the bootloader does nothing other than jumping into the application that&amp;#39;s preloaded via J-Link @0x1F000.&amp;nbsp; MBR and SoftDevice V3.1 is also preloaded. The problem seems to be calling SD_MBR_COMMAND_INIT_SD and sd_softdevice_vector_table_base_set.&amp;nbsp; Both function returns 1 for some reason.&amp;nbsp; And when nrf_bootloader_app_start_impl is called, it results in HardFault_Handler.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_assert.h&amp;quot;
#include &amp;quot;nrf_sdm.h&amp;quot;  //from s132nrf52310
#include &amp;quot;nrf_mbr.h&amp;quot;  //from s132nrf52310


volatile uint32_t m_uicr_bootloader_start_address  __attribute__ ((section(&amp;quot;.uicr_bootloader_start_address&amp;quot;))) = 0x6C000;
volatile uint32_t m_uicr_mbr_params_page  __attribute__ ((section(&amp;quot;.uicr_mbr_params_page&amp;quot;))) = 0x7e000;

static void __attribute__ ((noinline)) nrf_bootloader_app_start_impl(uint32_t start_addr)
{
    __ASM volatile(
        &amp;quot;ldr   r0, [%0]\t\n&amp;quot;            // Get App initial MSP for bootloader.
        &amp;quot;msr   msp, r0\t\n&amp;quot;             // Set the main stack pointer to the applications MSP.
        &amp;quot;ldr   r0, [%0, #0x04]\t\n&amp;quot;     // Load Reset handler into R0.

        &amp;quot;movs  r4, #0xFF\t\n&amp;quot;           // Move ones to R4.
        &amp;quot;sxtb  r4, r4\t\n&amp;quot;              // Sign extend R4 to obtain 0xFFFFFFFF instead of 0xFF.

        &amp;quot;mrs   r5, IPSR\t\n&amp;quot;            // Load IPSR to R5 to check for handler or thread mode.
        &amp;quot;cmp   r5, #0x00\t\n&amp;quot;           // Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader.
        &amp;quot;bne   isr_abort\t\n&amp;quot;           // If not zero we need to exit current ISR and jump to reset handler of bootloader.

        &amp;quot;mov   lr, r4\t\n&amp;quot;              // Clear the link register and set to ones to ensure no return.
        &amp;quot;bx    r0\t\n&amp;quot;                  // Branch to reset handler of bootloader.

        &amp;quot;isr_abort:  \t\n&amp;quot;

        &amp;quot;mov   r5, r4\t\n&amp;quot;              // Fill with ones before jumping to reset handling. Will be popped as LR when exiting ISR. Ensures no return to application.
        &amp;quot;mov   r6, r0\t\n&amp;quot;              // Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR.
        &amp;quot;movs  r7, #0x21\t\n&amp;quot;           // Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21.
        &amp;quot;rev   r7, r7\t\n&amp;quot;              // Reverse byte order to put 0x21 as MSB.
        &amp;quot;push  {r4-r7}\t\n&amp;quot;             // Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR.

        &amp;quot;movs  r4, #0x00\t\n&amp;quot;           // Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers).
        &amp;quot;movs  r5, #0x00\t\n&amp;quot;           // Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers).
        &amp;quot;movs  r6, #0x00\t\n&amp;quot;           // Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers).
        &amp;quot;movs  r7, #0x00\t\n&amp;quot;           // Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers).
        &amp;quot;push  {r4-r7}\t\n&amp;quot;             // Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine.

        &amp;quot;movs  r0, #0xF9\t\n&amp;quot;           // Move the execution return command into register, 0xFFFFFFF9.
        &amp;quot;sxtb  r0, r0\t\n&amp;quot;              // Sign extend R0 to obtain 0xFFFFFFF9 instead of 0xF9.
        &amp;quot;bx    r0\t\n&amp;quot;                  // No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application.
        &amp;quot;.align\t\n&amp;quot;
        :: &amp;quot;r&amp;quot; (start_addr)             // Argument list for the gcc assembly. start_addr is %0.
        :  &amp;quot;r0&amp;quot;, &amp;quot;r4&amp;quot;, &amp;quot;r5&amp;quot;, &amp;quot;r6&amp;quot;, &amp;quot;r7&amp;quot; // List of register maintained manually.
    );
}
/*********************************************************************
*
*       main()
*
*  Function description
*   Application entry point.
*/
void main(void) {
  
    uint32_t         err_code;
    sd_mbr_command_t com;
    com.command = SD_MBR_COMMAND_INIT_SD;
    err_code = sd_mbr_command(&amp;amp;com);

    sd_softdevice_disable();
    err_code = sd_softdevice_vector_table_base_set(0x1F000);

    nrf_bootloader_app_start_impl(0x1F000);

  do {
  } while (1);
}
/*************************** End of file ****************************/
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/thread/232860?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 14:16:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c90ab69a-12dc-4286-8515-0ba7341aa6d3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you elaborate?&lt;/p&gt;
&lt;p&gt;Generally, you will get&amp;nbsp;NRF_ERROR_SVC_HANDLER_MISSING if using an invalid SVC number (without a handler). The typical reason for this is building against SoftDevice header files for a different SoftDevice version (including MBR) than what is actually used.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/thread/232852?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 13:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72b3b0a3-787f-4ab8-8d7a-99f00efcafe2</guid><dc:creator>danchug</dc:creator><description>&lt;p&gt;Hello, I am having a very similar issue. I get NRF_ERROR_SVC_HANDLER_MISSING when calling nrf_dfu_mbr_init_sd.&amp;nbsp; Is there a solution for this problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/thread/98758?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 10:57:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:171fd446-de92-4fdd-ac6e-19c9b78b4414</guid><dc:creator>mbozic</dc:creator><description>&lt;p&gt;I&amp;#39;ve created a support case in My page since it has a lot of code changes, would be hard to copy everything here. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 simple SPI bootloader problems</title><link>https://devzone.nordicsemi.com/thread/98757?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 10:27:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71f00e37-4882-4a8f-b014-753cde237463</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I do not see a reason why this should not work on the nRF52 as well, but I do not have a full overview of your bootloader (it seems you have made quite a few changes). Can you upload the code for your bootloader? If not, can you create a support case on My page and upload it there?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>