<?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>How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82039/how-to-jump-into-app-from-bootloader-52833</link><description>I wrote a bootloader code. The flash space range of bootloader is 0x27000-0x3b000, and the flash space of app is 0x3b000-0x80000, but the app doesn&amp;#39;t work. What&amp;#39;s the problem? 
 My project consists of STM32 + 4G + nrf52833. When the 52833 firmware needs</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Nov 2021 09:23:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82039/how-to-jump-into-app-from-bootloader-52833" /><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340855?ContentTypeID=1</link><pubDate>Fri, 26 Nov 2021 09:23:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0e76e51-75af-470f-9e4b-fca07855b064</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please take a look at the&amp;nbsp;nrf_bootloader_app_start() implementation from SDK 14.2 again. You are missing some important parts, and the order is wrong. This function does &lt;em&gt;exactly&lt;/em&gt; what you need in this case,&amp;nbsp;and so&amp;nbsp;you should do the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340837?ContentTypeID=1</link><pubDate>Fri, 26 Nov 2021 08:47:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7890b546-3ea1-456c-91e7-ea42ddfe5ee7</guid><dc:creator>can23</dc:creator><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;Referring to the example of [nrf5_sdk_17.0.2_52833 \ nrf5_sdk_17.0.2_d674dde \ examples \ DFU] nrf_bootloader_app_start() api, I added the following code to the bootloader code,&amp;nbsp; the app code that enables the ble function cannot work.&lt;/p&gt;
&lt;p&gt;#if 1&lt;br /&gt; sd_mbr_command_t command =&lt;br /&gt; {&lt;br /&gt; .command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,&lt;br /&gt; .params.irq_forward_address_set.address = FLASH_APP1_ADDR,&lt;br /&gt; };&lt;/p&gt;
&lt;p&gt;sd_mbr_command(&amp;amp;command);&lt;br /&gt;#endif&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
void jump_app(void)
{
	const uint32_t current_isr_num = (__get_IPSR() &amp;amp; IPSR_ISR_Msk);
	
	// The app&amp;#39;s Stack Pointer is found as the first word of the vector table.
	const uint32_t new_msp		   = *((uint32_t *)(FLASH_APP1_ADDR));		

	// The app&amp;#39;s Reset Handler is found as the second word of the vector table.
	const uint32_t reset_handler   = *((uint32_t *)(FLASH_APP1_ADDR + sizeof(uint32_t))); 


	__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.


	NVIC-&amp;gt;ICER[0]=0xFFFFFFFF;
	NVIC-&amp;gt;ICPR[0]=0xFFFFFFFF;
////    NVIC-&amp;gt;ICER[1]=0xFFFFFFFF;
////    NVIC-&amp;gt;ICPR[1]=0xFFFFFFFF;
////
////	// If this is triggered, the CPU is currently in an interrupt.
////	ASSERT(current_isr_num == 0); 


#if 1
	sd_mbr_command_t command =
	{
		.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
		.params.irq_forward_address_set.address = FLASH_APP1_ADDR,
	};

	sd_mbr_command(&amp;amp;command);
#endif


	// The CPU is in Thread mode (main context).
	// Jump directly to the App&amp;#39;s Reset Handler.
	jump_to_addr(new_msp, reset_handler); 
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In devzone, I see many people have the same problem, but unfortunately, there is no solution.&lt;/p&gt;
&lt;p&gt;thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340526?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 11:52:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e33acf9-5c10-4743-8c95-b121dbd58790</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The way you jump to your application looks fine, but before you do this you must configure interrupt forwarding in the SoftDevice. What you need to do here is essentially what is done by&amp;nbsp;nrf_bootloader_app_start() in &amp;lt;SDK14.2&amp;gt;\components\libraries\bootloader\nrf_bootloader_app_start.c, so I suggest you download SDK 14.2 and look at that (just for reference, as this specific part is done differently in a way that does not fit your needs in SDK &amp;gt;= 15.0.0). Essentially you need to do exactly the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340521?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 11:25:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c4a9499-f320-439f-9c29-aea0a2b4d9d9</guid><dc:creator>can23</dc:creator><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;thanks for your reply!&lt;/p&gt;
&lt;p&gt;This problem has puzzled me for several days. I read your post. My code is as follows. How to use SD_ MBR_ COMMAND_ IRQ_ FORWARD_ ADDRESS_ Set (nrf_dfu_mbr_irq_forward_address_set()) to set interrupt forwarding?&lt;/p&gt;
&lt;p&gt;sdk is&amp;nbsp;nRF5_SDK_17.0.2&lt;/p&gt;
&lt;p&gt;chip:52833&lt;/p&gt;
&lt;p&gt;bootloader code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;typedef  void (*iapfun)(void);				
#define FLASH_APP1_ADDR		0x3B000			//app code start address
iapfun jump2app;
__asm void MSR_MSP(uint32_t addr) 
{
	MSR MSP, r0 							//set Main Stack value
	BX r14
}

//Jump to application segment
//appxaddr:app code start address
void iap_load_app(uint32_t appxaddr)
{
	jump2app=(iapfun)*(uint32_t*)(appxaddr+4);			//The second word in the user code area is the program start address (reset address)	

	#if 0
		MSR_MSP(*(uint32_t*)appxaddr);					//Initialize the app stack pointer ,(the first word in the user code area is
	#else												//used to store the stack top address)
		__set_MSP(appxaddr);
	#endif
	
	jump2app();									    	//jump to APP.
}		 


/**@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);
    ((void (*)(void))addr)();
}


// After 3 seconds, jump to app
void handle_period_event(void)
{
	static uint32_t jump_to_app_timer = 0;


	if(++jump_to_app_timer &amp;gt; 300)
	{
		jump_to_app_timer=0;
	
		{	 
			printf(&amp;quot;jump to app,0x3B000=%08x\n&amp;quot;,*(uint32_t*)(FLASH_APP1_ADDR));
			nrf_delay_ms(100);

			// Turn off the peripherals used 
			uart_close(0);
			uart_close(1);
			sk_timer_set(0);

			#if 1
				// Disable and clear interrupts
				const uint32_t current_isr_num = (__get_IPSR() &amp;amp; IPSR_ISR_Msk);
				const uint32_t new_msp		   = *((uint32_t *)(FLASH_APP1_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 *)(FLASH_APP1_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.

	
			    NVIC-&amp;gt;ICER[0]=0xFFFFFFFF;
			    NVIC-&amp;gt;ICPR[0]=0xFFFFFFFF;
			    NVIC-&amp;gt;ICER[1]=0xFFFFFFFF;
			    NVIC-&amp;gt;ICPR[1]=0xFFFFFFFF;

////				 ASSERT(current_isr_num == 0); // If this is triggered, the CPU is currently in an interrupt.

			    // 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.
			#else
				iap_load_app(FLASH_APP1_ADDR);	
			#endif
		}

		// This information will not be printed if it works properly
		printf(&amp;quot;***err to jump app\n&amp;quot;);
	}
}






**@brief Application main function.
 */
int main(void)
{
	ret_code_t ret;
    bool erase_bonds;
	
	NRF_UICR-&amp;gt;NFCPINS = 0; 				//config NFC to GPIO mode

	gpio_output_voltage_setup_3v3();

	uart_app_init(1000000);
 	UART_Init();
	
    log_init();

	ret = nrf_drv_clock_init();
	APP_ERROR_CHECK(ret);
	nrf_drv_clock_lfclk_request(NULL);

	printf(&amp;quot;---bootloader--\n&amp;quot;);
	printf(&amp;quot;---SCB-&amp;gt;VTOR=%08x--\n&amp;quot;,SCB-&amp;gt;VTOR);

    for (;;)
    {
        nrf_delay_ms(10);

		handle_period_event();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;app code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;



// Print a string of information indicating that the app works
void handle_period_event(void)
{
	static uint32_t printf_period = 0, printf_num = 0;

	printf_period++;
	if(printf_period &amp;gt; 100)
	{
		printf_period = 0;

		printf_num++;
		printf(&amp;quot;[%s][%d] app num =%d\n&amp;quot;,__func__,__LINE__,printf_num);
	}

}

/**@brief Application main function.
 */
int main(void)
{
	ret_code_t ret;
    bool erase_bonds;
	
	gpio_output_voltage_setup_3v3();
	
	SCB-&amp;gt;VTOR =  0x3B000;				// remap interrupt vector table address
	
	NRF_UICR-&amp;gt;NFCPINS = 0; 				//config NFC to GPIO mode
	uart_app_init(1000000);
 	UART_Init();
    log_init();

	ret = nrf_drv_clock_init();
	APP_ERROR_CHECK(ret);
	nrf_drv_clock_lfclk_request(NULL);

#if 1 									// If this part of the code is enabled, it will not run
	power_management_init();
	ble_stack_init();
	
	gap_params_init();
	gatt_init();
	services_init();
	advertising_init();
	conn_params_init();
	// Start execution.
	printf(&amp;quot;\r\nUART started.\r\n&amp;quot;);
	NRF_LOG_INFO(&amp;quot;Debug logging for UART over RTT started.&amp;quot;);
	advertising_start();
#endif

	printf(&amp;quot;---app --\n&amp;quot;);

    for (;;)
    {	
        nrf_delay_ms(10);
		handle_period_event();
    }
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340505?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 10:17:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aac415ee-74f8-47bd-9690-4dfbd54fa707</guid><dc:creator>Einar Thorsrud</dc:creator><description>[quote user="can23"]&lt;p&gt;In the app code, after disabling the functions related to ble, jump from bootload to app, and it can work.&lt;/p&gt;
&lt;p&gt;But with the related functions enabled, it won&amp;#39;t work anymore.&lt;/p&gt;
&lt;p&gt;What&amp;#39;s the problem?&lt;/p&gt;[/quote]
&lt;p&gt;In this part you enable the SoftDevice, and if you have not changed the way you start your application like I suggested (like &lt;em&gt;not&lt;/em&gt; using VTOR) this&amp;nbsp;&lt;em&gt;will&lt;/em&gt; fail. You need to do as suggested in the post I linked to in my previous post when you use a SoftDevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340501?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 10:15:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bb9f962-7013-45b0-8145-eae20a94c326</guid><dc:creator>can23</dc:creator><description>&lt;p&gt;In the app code, after disabling the functions related to ble, jump from bootload to app, and it can work.&lt;/p&gt;
&lt;p&gt;But with the related functions enabled, it won&amp;#39;t work anymore.&lt;/p&gt;
&lt;p&gt;What&amp;#39;s the problem?&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/app_5F00_main.png" /&gt;&lt;/p&gt;
&lt;p&gt;app main code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Application main function.
 */
int main(void)
{
	ret_code_t ret;
    bool erase_bonds;
	
	gpio_output_voltage_setup_3v3();
	
	SCB-&amp;gt;VTOR =  0x3B000;				// remap interrupt vector table address
	
	NRF_UICR-&amp;gt;NFCPINS = 0; 				//config NFC to GPIO mode
	uart_app_init(1000000);
 	UART_Init();
    log_init();

	ret = nrf_drv_clock_init();
	APP_ERROR_CHECK(ret);
	nrf_drv_clock_lfclk_request(NULL);


	timers_init();

#if 0 									// If this part of the code is enabled, it will not run
	power_management_init();
	ble_stack_init();
	
	gap_params_init();
	gatt_init();
	services_init();
	advertising_init();
	conn_params_init();
	// Start execution.
	printf(&amp;quot;\r\nUART started.\r\n&amp;quot;);
	NRF_LOG_INFO(&amp;quot;Debug logging for UART over RTT started.&amp;quot;);
	advertising_start();
#endif

	sk_timer_init();
	sk_timer_set(1);

	printf(&amp;quot;---app --\n&amp;quot;);

    for (;;)
    {	
		handle_period_event();
    }
}

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to jump into app from bootloader ，52833？</title><link>https://devzone.nordicsemi.com/thread/340486?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 09:52:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06ada8b3-1d15-411b-9a1d-4d28b3c876d1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Normally the SoftDevice assumes that the application is located immediately after the SoftDevice. It is possible to locate the application elsewhere though, but in that case you need to Configure the SoftDevice to forward interrupts properly (just jumping to the application like it seems you do is not enough). Please see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/66938/bootloader-with-2-or-3-applications/274379#274379"&gt;this post&lt;/a&gt;&amp;nbsp;for details. Note that interrupts must go via SoftDevice, so using VTOR will not work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>