<?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>Erasing page between .isr_vector and .text</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36801/erasing-page-between-isr_vector-and-text</link><description>Hello. I&amp;#39;m developing an application with a custom bootloader and I&amp;#39;m using &amp;quot;settings&amp;quot; data structure placed in FLASH. Because we can erase only full pages, the first page of FLASH is for isr_vector, the second for &amp;quot;settings&amp;quot; and the third is for bootloader</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Jul 2018 12:40:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36801/erasing-page-between-isr_vector-and-text" /><item><title>RE: Erasing page between .isr_vector and .text</title><link>https://devzone.nordicsemi.com/thread/141682?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 12:40:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:710477be-9fb6-47dd-8cde-f83b3e79b564</guid><dc:creator>dpeplinski</dc:creator><description>&lt;p&gt;Thank you for response.&lt;/p&gt;
&lt;p&gt;Here is the code:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;bootloader_set_t new_set = settings;
// Erase settings page
nrf_nvmc_page_erase((uint32_t)&amp;amp;_flash_settings);

uint8_t *dst = (uint8_t *)&amp;amp;_flash_settings;
uint32_t *src = (uint32_t *)&amp;amp;new_set;
// Enable write
NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;
while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {}
// Write to flash
for (uint32_t i = 0; i &amp;lt; sizeof(new_set); i += 4, dst += 4, src += 1) {
	((uint32_t *)dst)[0] = 0xFFFFFFFFUL &amp;amp; *src;
	while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {}
}
// Disable write
NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;
while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {}

// check result
if(memcmp(&amp;amp;_flash_settings, &amp;amp;new_set, sizeof(new_set)) != 0) {
	Bootloader_SaveSettings();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve replaced &amp;quot;_flash_settings&amp;quot; with other addresses and it worked for pages different than .isr_vector to .text.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT: So I created some example project to show the problem. I spent some time with the example and I found that some problems&amp;nbsp;were with the linker scripts and/or with a memory monitor in my Eclipse. I used direct nrfjprog&amp;nbsp;memory reading and it turned out that everything was working correctly. Excuse me for taking Your time and thank you for a concern &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing page between .isr_vector and .text</title><link>https://devzone.nordicsemi.com/thread/141667?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 11:59:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64fa6952-217c-4021-90c5-b60d1cab1ecf</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Unless the BPROT peripheral has been explicitly enabled to block those pages for flash writes, then you should be able to use the NVMC to erase any flash page. Could you attatch the code snippet you&amp;#39;re using to erase and write to the flash pages?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>