<?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>DIY bootloader for nRF5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115278/diy-bootloader-for-nrf5340</link><description>I&amp;#39;m writing my own lightweight bootloader for nRF5340 (which may or may not turn out to be a good idea). I have something similar that I&amp;#39;m using successfully on nRF52832 based on a minimal Zephyr application. 
 The bootloader doesn&amp;#39;t use TF-M so it has</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Oct 2024 20:49:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115278/diy-bootloader-for-nrf5340" /><item><title>RE: DIY bootloader for nRF5340</title><link>https://devzone.nordicsemi.com/thread/505636?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 20:49:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84c5bb0f-4958-476a-a3b8-93257b1866ff</guid><dc:creator>Frog</dc:creator><description>&lt;p&gt;I believe I&amp;#39;ve resolved this - it seems that there are two vector tables, one in the secure area of the application and one in the non-secure area.&amp;nbsp; The solution is to jump to the reset vector in the secure partition.&amp;nbsp; I copied a few lines from bl_boot.c, resulting in this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;__STATIC_INLINE void app_start(uint32_t vector_table_addr)
{
    struct arm_vector_table *vt = (void *)vector_table_addr;
	printk(&amp;quot;Inspect vector table at %08x\n&amp;quot;, vector_table_addr);
	printk(&amp;quot;Stack pointer %08x\n&amp;quot;, vt-&amp;gt;msp);
	printk(&amp;quot;Reset vector %08x\n&amp;quot;, (uint32_t)vt-&amp;gt;reset);

	// Shut down hardware as needed
	//nrfx_qspi_uninit();
	nrf_clock_int_disable(NRF_CLOCK, 0xFFFFFFFF);

    irq_lock();

	/* Allow any pending interrupts to be recognized */
	__ISB();
	__disable_irq();

	NVIC_Type *nvic = NVIC;

	/* Disable NVIC interrupts */
	for (uint8_t i = 0; i &amp;lt; ARRAY_SIZE(nvic-&amp;gt;ICER); i++) 
	{
		nvic-&amp;gt;ICER[i] = 0xFFFFFFFF;
	}

	/* Clear pending NVIC interrupts */
	for (uint8_t i = 0; i &amp;lt; ARRAY_SIZE(nvic-&amp;gt;ICPR); i++) 
	{
		nvic-&amp;gt;ICPR[i] = 0xFFFFFFFF;
	}

	SysTick-&amp;gt;CTRL = 0;

	/* Disable fault handlers used by the bootloader */
	SCB-&amp;gt;ICSR |= SCB_ICSR_PENDSTCLR_Msk;

	/* Activate the MSP if the core is currently running with the PSP */
	if (CONTROL_SPSEL_Msk &amp;amp; __get_CONTROL()) 
	{
		__set_CONTROL(__get_CONTROL() &amp;amp; ~CONTROL_SPSEL_Msk);
	}

	__DSB(); /* Force Memory Write before continuing */
	__ISB(); /* Flush and refill pipeline with updated permissions */

	__set_PSPLIM(0);
	__set_MSPLIM(0);

	__set_MSP(vt-&amp;gt;msp);
	__set_PSP(0);

	vt-&amp;gt;reset();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Although at the time of writing I&amp;#39;m still having an issue that appears to be to do with timers, k_sleep seems to return almost immediately and I think that&amp;#39;s causing spurious timeouts elsewhere in the application code.&amp;nbsp; I&amp;#39;ll investigate further and may raise that as a new ticket if appropriate.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DIY bootloader for nRF5340</title><link>https://devzone.nordicsemi.com/thread/505174?ContentTypeID=1</link><pubDate>Mon, 07 Oct 2024 12:15:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe69656d-0075-48df-8b8a-dcd20070c404</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not able to pinpoint the issue in your implementation. However, I wonder if you could just use the implementation from the nRF Immutable bootlaoder, particularily the&amp;nbsp;bl_boot() implementation from &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.7.0/subsys/bootloader/bl_boot/bl_boot.c"&gt;bl_boot.c&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>