<?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>Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25645/flash-write-read-basic-way</link><description>Im using sdk 14.0 and s132 When i add flashwrite codes to my project which has bluetooth communication ,it does not work I wanna send data to flash and i wanna read/write it What is the simplest way to do this 
 Im using NRF52832. 
 Thank you</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Oct 2017 18:40:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25645/flash-write-read-basic-way" /><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101048?ContentTypeID=1</link><pubDate>Fri, 13 Oct 2017 18:40:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee0f08d4-8597-4301-aaeb-de4584cfc44a</guid><dc:creator>superpak</dc:creator><description>&lt;p&gt;Hi Syuan, I think it is the address that you defined in the NRF_FSTORAGE_DEF macro. Can I see what address you put in there?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101047?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 06:46:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ca95bf7-8e05-4150-b6b9-1cc087a8d4a6</guid><dc:creator>Syuan</dc:creator><description>&lt;p&gt;I test the code when run the
ret_code_t rc = nrf_fstorage_erase(
&amp;amp;m_fs,                  /* The instance to use. &lt;em&gt;/
m_fs.start_addr,            /&lt;/em&gt; The address of the flash pages to erase. &lt;em&gt;/
pages_to_erase,         /&lt;/em&gt; The number of pages to erase. &lt;em&gt;/
NULL);                  /&lt;/em&gt; Optional parameter, backend-dependent. */
it shows  Address must be aligned to a page boundary.&lt;/p&gt;
&lt;p&gt;Can you help me slove the problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101046?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2017 18:08:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a08a4a98-18f5-40bb-be45-05896c98a37d</guid><dc:creator>superpak</dc:creator><description>&lt;p&gt;Yes, you are correct. But if you are just storing small amounts of data, then FDS can be overkill. However, I just wanted to provide them with this option as well just in case it suits their needs! Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101045?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2017 06:31:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:449f6585-7eb4-43b1-859c-c43896762a39</guid><dc:creator>shibshab</dc:creator><description>&lt;p&gt;Note that garbage collection and other mundane tasks will have to be handled in a live system. FDS makes this a lot simpler for the developer compared to using fstorage directly :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101044?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2017 18:45:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40dc8763-bea9-4c1c-96f4-be32766c912c</guid><dc:creator>superpak</dc:creator><description>&lt;p&gt;Hi, you can use Fstorage with the SoftDevice backend for simple read, write and erase operations. Here is a simple example that I wrote. Make sure you have the correct include files. You can change the start_addr and end_addr to any free space you have on your chip. I believe this code should work. This just erases a page and then writes some data in that page. You can read the data using nrf_fstorage_read(....). You can also verify that the data is written by using nrfjprog.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void fs_event_handler(nrf_fstorage_evt_t * evt){
    if (evt-&amp;gt;result != NRF_SUCCESS){
        NRF_LOG_ERROR(&amp;quot;Flash error&amp;quot;);

    } else {
        NRF_LOG_INFO(&amp;quot;Flash event success&amp;quot;);
    }
}

NRF_FSTORAGE_DEF(nrf_fstorage_t m_fs) =
{
    .evt_handler = fs_event_handler,
    .start_addr = 0x0007F000,
    .end_addr = 0x000FF000,
};

int main(void){
	uint32_t err_code;
	static uint32_t number = 123;
	static uint32_t pages_to_erase = 1;
	
	err_code = nrf_fstorage_init(&amp;amp;m_fs, &amp;amp;nrf_fstorage_sd, NULL);
    APP_ERROR_CHECK(err_code);

			

				
	ret_code_t rc = nrf_fstorage_erase(
                    &amp;amp;m_fs,   				/* The instance to use. */
                    m_fs.start_addr,     		/* The address of the flash pages to erase. */
                    pages_to_erase, 		/* The number of pages to erase. */
                    NULL);       			/* Optional parameter, backend-dependent. */

	if (rc == NRF_SUCCESS)
	{
			/* The operation was accepted.
				 Upon completion, the NRF_FSTORAGE_ERASE_RESULT event
				is sent to the callback function registered by the instance. */
			
			NRF_LOG_INFO(&amp;quot;ERASE SUCCESSFUL&amp;quot;);
	}
	else
	{
			NRF_LOG_INFO(&amp;quot;ERASE UNSUCCESFUL &amp;quot;);
				/* Handle error.*/
	}



    rc = nrf_fstorage_write(&amp;amp;m_fs, m_fs.start_addr, &amp;amp;number, 4, NULL);      //Write data to memory address. Check it with command: nrfjprog --memrd addr --n 32
	if (rc == NRF_SUCCESS)
	{
		
				NRF_LOG_INFO(&amp;quot;WRITE SUCCESSFUL&amp;quot;);
	}
	else
	{
			NRF_LOG_INFO(&amp;quot;WRITE UNSUCCESFUL &amp;quot;);
				/* Handle error.*/
	}


}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101049?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2017 11:01:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56576b52-1399-4ed4-bd61-95d3964bf645</guid><dc:creator>shibshab</dc:creator><description>&lt;p&gt;Updated my answer to include something which actually exists :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101043?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2017 08:56:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a62a08ca-be8c-4392-b7d7-229468796695</guid><dc:creator>Syuan</dc:creator><description>&lt;p&gt;hi，thanks your answer,but I cant find  fds example in examples/peripheral/flash_fds.@@&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Write/Read Basic Way</title><link>https://devzone.nordicsemi.com/thread/101042?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2017 08:13:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:208394ca-674b-4143-8b18-9a528ac11f6a</guid><dc:creator>shibshab</dc:creator><description>&lt;p&gt;I would use fds.c (short for Flash Data Storage). You can a relative simple use in &lt;code&gt;components/libraries/eddystone/es_flash.c&lt;/code&gt; Other examples also use FDS.&lt;/p&gt;
&lt;p&gt;Using flash is not trivial, and fds.c (in cooperation with fstorage.c) will hide away all the nasty stuff required to do it correctly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>