<?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>What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32208/what-should-i-start-in-order-to-use-the-maximum-memory-space-in-fstorage</link><description>Hello everybody, 
 I just started using fStorage. When I examine the example, it starts from write address 0x3e000. 
 err_code = nrf_fstorage_write(&amp;amp;fstorage, 0x3e000, m_hello_world, sizeof(m_hello_world), NULL); APP_ERROR_CHECK(err_code); 
 Q-1 How is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Dec 2020 13:37:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32208/what-should-i-start-in-order-to-use-the-maximum-memory-space-in-fstorage" /><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/283330?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 13:37:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e834f19-38f7-41ae-904d-d084717653de</guid><dc:creator>Katie Newell</dc:creator><description>&lt;p&gt;Hi Kristin,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for sharing this, it is very clear and helpful.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am struggling to write uint8 or uint16 into the Flash using your fds_write function. I am getting this FDS error &lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;FDS_ERR_UNALIGNED_ADDR.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Could you help me understand why please?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Many thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/125086?ContentTypeID=1</link><pubDate>Tue, 20 Mar 2018 05:49:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ed2187e-73b1-476e-a81e-206d0672b1a3</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;After Kristin&amp;#39;s help, I finally get the solution.&lt;/p&gt;
&lt;p&gt;I do not know exactly why, If you want to record a sequence directly, it gives an error.&amp;nbsp;So I have defined external an array( m_deadbeef[10] ) in the fds_write function.&amp;nbsp;Then I copied the array that I want to save into m_deadbeef.&amp;nbsp;And the problem is solved.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ret_code_t kls_fds_write(uint32_t write_file_id, uint32_t write_record_key , uint8_t write_data[])
{		
		static uint8_t m_deadbeef[10] = {0};
		
		memcpy(m_deadbeef, write_data, sizeof(m_deadbeef));
		
		fds_record_t        record;
		fds_record_desc_t   record_desc;
	
		// Set up record.
		record.file_id              = write_file_id;
		record.key              		= write_record_key;
		record.data.p_data       		= &amp;amp;m_deadbeef;
		record.data.length_words   	= sizeof(m_deadbeef)/sizeof(uint8_t);
				
		ret_code_t ret = fds_record_write(&amp;amp;record_desc, &amp;amp;record);
		if (ret != FDS_SUCCESS)
		{
				return ret;
		}
		 NRF_LOG_INFO(&amp;quot;Writing Record ID = %d \r\n&amp;quot;,record_desc.record_id);
		return NRF_SUCCESS;
	
}
	
static ret_code_t kls_fds_read(uint32_t read_file_id, uint32_t relevant_record_key , uint8_t read_data[])
{	
		fds_flash_record_t  flash_record;
		fds_record_desc_t   record_desc;
		fds_find_token_t    ftok ={0};//Important, make sure you zero init the ftok token
		uint8_t *data;
		uint32_t err_code;
		
		NRF_LOG_INFO(&amp;quot;Start searching... \r\n&amp;quot;);
		// Loop until all records with the given key and file ID have been found.
		while (fds_record_find(read_file_id, relevant_record_key, &amp;amp;record_desc, &amp;amp;ftok) == FDS_SUCCESS)
		{
				err_code = fds_record_open(&amp;amp;record_desc, &amp;amp;flash_record);
				if ( err_code != FDS_SUCCESS)
				{
					return err_code;		
				}
				
				NRF_LOG_INFO(&amp;quot;Found Record ID = %d\r\n&amp;quot;,record_desc.record_id);

				data = (uint8_t *) flash_record.p_data;
				for (uint8_t i=0;i&amp;lt;flash_record.p_header-&amp;gt;length_words;i++)
				{
					read_data[i] = data[i];
				}
			
		
				NRF_LOG_HEXDUMP_INFO(read_data, sizeof(read_data));
				// Access the record through the flash_record structure.
				// Close the record when done.
				err_code = fds_record_close(&amp;amp;record_desc);
				if (err_code != FDS_SUCCESS)
				{
					return err_code;	
				}
		}
		return NRF_SUCCESS;	
}

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124949?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 10:18:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9300b94f-ca01-4c7c-b8b2-c155bbb56720</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Should it be Const?&amp;nbsp;&amp;nbsp;Because I am trying to save the data from nus_data. The variable type here is uint8_t * p_data (Not const) as you know.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also I tried this one;&lt;/p&gt;
&lt;p&gt;static uint8_t const m_deadbeef[10] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10};&lt;/p&gt;
&lt;p&gt;and&amp;nbsp;Writing has not occurred.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;static uint8_t const m_deadbeef[8] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}; is working&lt;/p&gt;
&lt;p&gt;static uint8_t const m_deadbeef[10] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10}; is not working&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I have not changed anything(except m_deadbeef size) . Pretty odd! .&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124926?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 09:11:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb52eeff-f3f1-4dad-a438-cbd0d8551360</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The example works fine with longer arrays as well, the variable holding the data has to be declared the following way:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier, monospace;"&gt;static uint8_t &lt;strong&gt;const&lt;/strong&gt; m_deadbeef[xx ] = ...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124858?ContentTypeID=1</link><pubDate>Sat, 17 Mar 2018 10:48:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:066b606f-60cd-46fd-ad86-80e17f109b61</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;in fds_test_write function, it write 4 bytes not 10;&lt;br /&gt; &amp;quot;static uint8_t const m_deadbeef[4] = {0x1,0x2,0x3,0x4};&amp;quot;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The write function does not work when there are 8 or more bytes. For example I modified like this;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;static uint8_t m_deadbeef[8] = {0x41,0x30,0x31,0x31,0x30,0x30,0x30,0x34}; and it worked. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But I tried this;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;static uint8_t m_deadbeef[10] = {0x41,0x30,0x31,0x31,0x30,0x30,0x30,0x34,0x30,0x24}; and it did not work.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It does not work if it is bigger than eight.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124762?ContentTypeID=1</link><pubDate>Fri, 16 Mar 2018 12:38:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f24014c9-cb58-4f00-b42f-f2b5e569ca7a</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The function&amp;nbsp;fds_test_write() shows how to do that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124576?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 12:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:343f7698-01d1-47cf-9c45-e568d2d0b8a6</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Kristin, I learned a lot from your answer. If I can read and write a 10 byte uint8_t data(such as below), I will reach the purpose.&lt;br /&gt;&lt;br /&gt;static uint8_t m_deadbeef[10] = {0x41,0x30,0x31,0x31,0x30,0x30,0x30,0x34,0x30,0x24};&lt;/p&gt;
&lt;p&gt;Could you tell me how to write this &lt;span&gt;uint8_t m_deadbeef[10]&lt;/span&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124545?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 10:08:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0848f8e2-6032-4d12-8592-83652b8c8ffa</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;Okay, I see. So what you really want to do is to write a an array to flash and then retrieve it again? If so, you can do that the following way:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ret_code_t fds_read(void)
{

		fds_flash_record_t  flash_record;
		fds_record_desc_t   record_desc;
		fds_find_token_t    ftok ={0};//Important, make sure you zero init the ftok token
		uint8_t *data;
		uint32_t err_code;
		
		NRF_LOG_INFO(&amp;quot;Start searching... \r\n&amp;quot;);
		// Loop until all records with the given key and file ID have been found.
		while (fds_record_find(FILE_ID_FDS_TEST, REC_KEY_FDS_TEST, &amp;amp;record_desc, &amp;amp;ftok) == FDS_SUCCESS)
		{
				err_code = fds_record_open(&amp;amp;record_desc, &amp;amp;flash_record);
				if ( err_code != FDS_SUCCESS)
				{
					return err_code;		
				}
				
				NRF_LOG_INFO(&amp;quot;Found Record ID = %d\r\n&amp;quot;,record_desc.record_id);
				NRF_LOG_INFO(&amp;quot;Data = &amp;quot;);
				data = (uint8_t *) flash_record.p_data;
				for (uint8_t i=0;i&amp;lt;flash_record.p_header-&amp;gt;length_words;i++)
				{
					NRF_LOG_INFO(&amp;quot;0x%8x &amp;quot;,data[i]);
				}
				NRF_LOG_INFO(&amp;quot;\r\n&amp;quot;);
				// Access the record through the flash_record structure.
				// Close the record when done.
				err_code = fds_record_close(&amp;amp;record_desc);
				if (err_code != FDS_SUCCESS)
				{
					return err_code;	
				}
		}
		return NRF_SUCCESS;
		
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To easily test it, you can replace main.c in ble_app_hrs in SDK 14.2 by this file:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-657a13dd73d145ada8aaa4b7ae20c957/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124524?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 09:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4138fa72-35eb-43ba-b9c7-e675d4be51df</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Thanks for your answer, Kristin. Unfortunately,I could not use FDS. I tried so hard to use it, but I failed. If you want to look my question that is related to FDS, you can find in this&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/31990/how-to-write-uint8_t-some_array-via-fds"&gt;LINK&lt;/a&gt;&amp;nbsp;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What should I start in order to use the maximum memory space in fstorage?</title><link>https://devzone.nordicsemi.com/thread/124520?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 08:56:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85294b14-0429-4750-8a30-83946debf37d</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I would think that the address 0x3e000 is chosen arbitrary. If you want to store data to flash, I would recommend you to use the&amp;nbsp; &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Flib_fds.html&amp;amp;cp=4_0_0_3_50"&gt;FDS module (Flash Data Storage)&lt;/a&gt;. FDS provides an easy-to-use interface for storing and handling stored data. FDS uses fstorage.&lt;/p&gt;
&lt;p&gt;FDS stores data in the last flash pages available.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>