<?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 set the address for user data?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47792/how-to-set-the-address-for-user-data</link><description>I use nrf52832 sdk 14.0 
 SD+ boot(for ota）+app 
 In the applicaiton there are some user data to save. I used two pages ( one pages start from 0x6E000 and the other start from 0x6F000). 
 
 my user data want to save about 6000 bytes. 
 on pure circuit</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 May 2019 03:57:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47792/how-to-set-the-address-for-user-data" /><item><title>RE: how to set the address for user data?</title><link>https://devzone.nordicsemi.com/thread/190150?ContentTypeID=1</link><pubDate>Fri, 31 May 2019 03:57:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:991ed624-dc36-47f2-a4d3-ce0a2b52c67b</guid><dc:creator>zk017</dc:creator><description>&lt;p&gt;I have solved the problem by using the fstorage module! thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to set the address for user data?</title><link>https://devzone.nordicsemi.com/thread/189901?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 13:31:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3271a088-8fcc-4356-9bfb-b00189cb2e12</guid><dc:creator>zk017</dc:creator><description>&lt;p&gt;thank you very much, Vidar Berg. I used the SDK14.0,&amp;nbsp;&lt;span&gt;S132 v5.0.x) bootloader address:0x78000.&lt;/span&gt; After many times test, I found it&amp;#39;s the sd_flash_write function sometime return &lt;a class="el" title="Busy." href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v3.0.0/group__nrf__error.html#ga5d2d8608f6d6a0329f58961a969e946e"&gt;NRF_ERROR_BUSY&lt;/a&gt;, which result the data lost. and increase the delay time after sd_flash_erase and sd_flash_write, also return NRF_ERROR_BUSY sometime.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define USER_DATA_ADDR2  (0x06F000)
#define FLASH_PAGE_SIZE  (0x1000)   //==4096

typedef __packed struct 
{
	uint32_t m_flag;  		//------------------------------------------4
	uint8_t  m_batchID[3];	// ------------------------------------3

	uint8_t m_pn_mark[2];	//------------------------------------------2
	uint8_t m_level[3];		//------------------------------------------3
	uint8_t m_pn_name[8];	// ---------------------------------8
	uint8_t m_pn_dat[8][500];//-----------------------------4000
	uint8_t m_rev[4];		//------------------------------------------4
	
}TM_CONFIG2; //---------------------4024bytes

uint32_t refresh_flash_config_data(void)
{
	TM_CONFIG2 sector2;
	uint32_t err_code = NRF_SUCCESS;
	uint8_t i = 0;
	
	memcpy(&amp;amp;sector2, (uint32_t *)USER_DATA_ADDR2, sizeof(TM_CONFIG2));

	//------------------------------------------------------------
	err_code = sd_flash_page_erase( USER_DATA_ADDR2/FLASH_PAGE_SIZE );  //
	nrf_delay_ms(300);
	if(err_code!=NRF_SUCCESS)
	{
		NRF_LOG_PRINTF(&amp;quot;erase Flash 2 fail!\n&amp;quot;)
	}
	
        //some code here, modify the content of sector2
        //...

	err_code = sd_flash_write( (uint32_t *)USER_DATA_ADDR2, (const uint32_t *)(&amp;amp;sector2), sizeof(TM_CONFIG2)&amp;gt;&amp;gt;2 );  //### sometime return NRF_ERROR_BUSY ###
	nrf_delay_ms(400);
	if(NRF_SUCCESS == err_code )
	{
		NRF_LOG_PRINTF(&amp;quot;Write Flash 2 OK!\n&amp;quot;)
	}
	else
	{
		NRF_LOG_PRINTF(&amp;quot;Write Flash 2 error! code=0x%x!\n&amp;quot;, err_code);//sometime print here, code=0x11
	}
	
    //...
	
	return err_code;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to set the address for user data?</title><link>https://devzone.nordicsemi.com/thread/189583?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 10:56:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90871c06-86b7-4e19-9fe1-9b6fbb96f216</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What is the start address of your bootloader, and did the data get lost after an OTA update? User data should be placed just below the bootloader&amp;nbsp;as shown &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_bootloader.html?cp=5_1_3_5_0_7#lib_bootloader_memory"&gt;here&lt;/a&gt;, and you need to set the APP_DATA_RESERVED define in your bootloader to reserve the region for app data.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>