<?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 write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/31043/how-to-write-read-and-store-uint8_t-data_array-via-fds</link><description>Hello everybody, 
 I used SDK14.2.0 , S132 . 
 
 I keep the data from nus_data in the uint8_t array. Then I am trying to write the array with use fds_write. 
 My fds_write function; 
 
 I use my fds_write function by this way; 
 
 
 Then I am trying to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Mar 2018 09:44:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/31043/how-to-write-read-and-store-uint8_t-data_array-via-fds" /><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/125318?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 09:44:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e25c8d8a-e36c-4f22-bbb5-14b26bad0d0d</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;The const is not suitable for me because I saved the data from nus_data.&amp;nbsp;&lt;span&gt;So I do not record constant data. That&amp;#39;s why, when I compile, I get an error. Anyway, thanks for everything.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/125311?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 09:34:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26eedb7a-28e6-4101-99c3-43602964d755</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey purgoufr,&lt;/p&gt;
&lt;p&gt;This is strange. Maybe a compiler optimization issue or something. Have you tried declaring the&amp;nbsp;m_deadbeef array as a &amp;#39;const&amp;#39;?&lt;/p&gt;
&lt;p&gt;Anyway I&amp;#39;m glad that you got to move on with your development. I hate it when I get stuck on issues like these.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/125098?ContentTypeID=1</link><pubDate>Tue, 20 Mar 2018 08:21:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8ef09e8-c8b8-44a1-8b51-366d5a282739</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Hi Haakonsh,&lt;/p&gt;
&lt;p&gt;Thank you very much for your interest.&amp;nbsp;I reach the solution through another question.&amp;nbsp;But I learned a lot from your answers. So I wanted to share the situation with you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/32208/what-should-i-start-in-order-to-use-the-maximum-memory-space-in-fstorage"&gt;Solution Link&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/124895?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 06:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a9d5eeb-bc4d-4db2-a526-435af84ee85c</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Hi Haakonsh,&lt;br /&gt;&lt;br /&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] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}; and &lt;strong&gt;it worked.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&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 uint32_t const m_deadbeef[2] = {0xDEADBEEF,0xBAADF00D};
		static uint8_t m_deadbeef[8] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
		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;/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 &lt;strong&gt;it did not work.&amp;nbsp;&lt;/strong&gt;&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;p&gt;&lt;span&gt;Do you have any suggestion for that?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/123158?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2018 05:03:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc6ccb2e-f573-41f9-bd3b-d09c1eb34e52</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;I tried the memcpy function ;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ret_code_t kls_fds_read(uint32_t 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;
	/* It is required to zero the token before first use. */
	memset(&amp;amp;ftok, 0x00, sizeof(fds_find_token_t));
		
	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, 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);

		memcpy(read_data, flash_record.p_data, flash_record.p_header-&amp;gt;length_words * sizeof(uint32_t));
				
		NRF_LOG_INFO(&amp;quot;Data: %u, Length: %u&amp;quot;, read_data, flash_record.p_header-&amp;gt;length_words * sizeof(uint32_t));
				
		// 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;I sent nus_data&lt;strong&gt;&amp;quot;A01100040&amp;quot;&lt;/strong&gt; to write in fds&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 41 30 31 31 30 30 30 34|A0110004&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 30 00 |0.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Result;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;0&amp;gt; &amp;lt;info&amp;gt; app: Found Record ID = 1&lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Data: 536895120, Length: 4&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately, I still could not write the data I wanted, and then I could not get the data itself (in uint8_t format).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122927?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 05:28:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2763fdca-3772-4de0-bd7d-cd5093fea9f8</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;my write function;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ret_code_t kls_fds_write(uint32_t file_id, uint32_t record_key , uint8_t write_data[])
{		
	fds_record_t        record;
	fds_record_desc_t   record_desc;
	
	// Set up record.
	record.file_id           = file_id;
	record.key               = record_key;
	record.data.p_data       = &amp;amp;write_data;
	record.data.length_words = sizeof(write_data);   //(sizeof(write_data) + 3) / sizeof(uint32_t);
	
	ret_code_t rc;
	rc = fds_record_write(&amp;amp;record_desc, &amp;amp;record);
	if (rc != FDS_SUCCESS)
	{
			/* Handle error. */
			NRF_LOG_INFO(&amp;quot;FDS Write Handle error.&amp;quot;);
			return rc;
	}
	NRF_LOG_INFO(&amp;quot;Writing Record ID = %d \r\n&amp;quot;,record_desc.record_id);
	return NRF_SUCCESS;
	
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;my read function&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ret_code_t kls_fds_read(uint32_t 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;
		/* It is required to zero the token before first use. */
		memset(&amp;amp;ftok, 0x00, sizeof(fds_find_token_t));
		
		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, 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);
	

				uint8_t * pointer_to_record_data;
				pointer_to_record_data = (uint8_t *)flash_record.p_data;

				if(flash_record.p_header-&amp;gt;record_key == relevant_record_key)
				{
					for(uint8_t i = 0; i &amp;lt;flash_record.p_header-&amp;gt;length_words; i++)
					{
							read_data[i] = *pointer_to_record_data;
							pointer_to_record_data++;
					}
				}

				NRF_LOG_INFO(&amp;quot;Data = &amp;quot;);
				NRF_LOG_HEXDUMP_INFO(read_data, sizeof(read_data));
				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;&lt;/p&gt;
&lt;p&gt;I use my write function in save function&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void save_data( uint8_t *p_data)
{
	NRF_LOG_INFO(&amp;quot;save_data&amp;quot;);
	uint8_t source_data_0[10] ;			
	
	// assign source datas  ********************************	
	for (uint32_t i = 0; i &amp;lt; 10; i++)				
	{
		source_data_0[i] = p_data[i];
	}
	while (flag_write_fds == false);
	kls_fds_write(FILE_ID, RECORD_KEY ,source_data_0);
	
	NRF_LOG_HEXDUMP_INFO(source_data_0, sizeof(source_data_0));
	
	allow_advertisement = false;

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;save function used in nus_data_handler&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nus_data_handler(ble_nus_evt_t * p_evt)
{
	memset(nus_rx_data, 0, sizeof(nus_rx_data));
	
    if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
    {
        NRF_LOG_DEBUG(&amp;quot;Received data from BLE NUS. Writing data on UART.&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);
			
        for (uint8_t i = 0; i &amp;lt; p_evt-&amp;gt;params.rx_data.length; i++)
        {
			nus_rx_data[i]= p_evt-&amp;gt;params.rx_data.p_data[i];
		}

		save_data(nus_rx_data);

    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I want to;&lt;/p&gt;
&lt;p&gt;1- write &lt;strong&gt;&amp;quot;aaaaaaaaaa&amp;quot;&lt;/strong&gt; in nRF Toolbox-&amp;gt; UART&lt;/p&gt;
&lt;p&gt;2- store the &lt;strong&gt;&amp;quot;aaaaaaaaaa&amp;quot;&lt;/strong&gt;&lt;span&gt;&amp;nbsp;in &lt;strong&gt;static uint8_t nus_rx_data[16];&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;3- write this nus_rx_data array with save function; &lt;strong&gt;&amp;quot;save_ssn(nus_rx_data);&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;4- Read the saved data so that you can use the data again when the power of the device is turned off;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;uint8_t dest_data_0[16] = {0};&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;while (flag_write_fds == 0);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;kls_fds_read(FILE_ID, RECORD_KEY, dest_data_0);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122873?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 15:18:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec170848-0427-4863-9863-3717c045cea1</guid><dc:creator>haakonsh</dc:creator><description>[quote user="purgoufr"]&amp;quot;..\..\..\main.c(387): error:&amp;nbsp; #44: expression must have pointer type&amp;quot;[/quote]
&lt;p&gt;Can you share the relevant code, I do not know what you are referring to.&lt;br /&gt;&lt;br /&gt;The record you want to write needs only a pointer to an address in memory and the length in words(4bytes). You can store as many words in your record as long as you comply with the following requirement:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;length_in_words &lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span&gt; FDS_HEADER_SIZE &amp;gt;&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; FDS_PAGE_SIZE &lt;/span&gt;&lt;span&gt;-&lt;/span&gt;&lt;span&gt; FDS_PAGE_TAG_SIZE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;They way a C compiler accesses a given element in an array is to use the address of the initial element 0 and add the size of the array type multiplied by the element&amp;#39;s index number.&lt;br /&gt;&lt;br /&gt;Say an uint32_t my_array[5]; is located at address 0x2000B000:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you want to access element 3 of my_array the compiler will take the address of element 0(0x2000B000) and add 3 * size_of(uint32_t) = 0x2000B000 +&amp;nbsp; 0xC = 0x2000B00C.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This means that you can access any array&amp;#39;s elements as long as you have the starting address and the type size.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;// accesing the 3rd element of an array. 

uint32_t my_array[5] = {0x00, 0x01, 0x02, 0x03, 0x04};

// Referencing the the array:
uint32_t * p_array = &amp;amp;my_array; // p_array = address of element 0 of my_array

// Dereferencing the pointer that points to the array:
uint32_t data = *p_array[3];&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122855?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 14:33:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ad03a0f-dd57-455c-b3a4-7faf619a0f3c</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Hi haakonsh thanks for answer but unfortunately I got an error like this ;&lt;br /&gt;&amp;quot;..\..\..\main.c(387): error:&amp;nbsp; #44: expression must have pointer type&amp;quot;&lt;/p&gt;
&lt;p&gt;Also the missing part is: I want to write and read an array of 10 members, not just a one byte element. If I can not save it all in one go, I need to define something like a buffer.&amp;nbsp;I used pstorage at sdk 8 and it worked very well. But I can not migrate to FDS.&lt;/p&gt;
&lt;p&gt;I did this in SDK 8 as well;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void pstorage_save(uint8_t * p_data)
{
		pstorage_handle_t       handle;
		pstorage_handle_t		block_3_handle;
		pstorage_module_param_t param;
		uint8_t                 source_data_3[16] = {&amp;#39;\0&amp;#39;};		
		uint32_t                retval;
		
		retval = pstorage_init();
		if(retval != NRF_SUCCESS){
				bsp_indication_set(BSP_INDICATE_FATAL_ERROR);
		}
	     
		param.block_size  = 16;                   //Select block size of 16 bytes
		param.block_count = 53;                    //Select 32 blocks, total of 512 bytes
		param.cb          = example_cb_handler;   //Set the pstorage callback handler
			
		retval = pstorage_register(&amp;amp;param, &amp;amp;handle);
		if (retval != NRF_SUCCESS){
				bsp_indication_set(BSP_INDICATE_FATAL_ERROR);
		}
		
//		//Get block identifiers
		pstorage_block_identifier_get(&amp;amp;handle, 3, &amp;amp;block_3_handle);

// CLEAR ************************		 
		//Clear 16 bytes, starting from block 3
		pstorage_wait_handle = block_3_handle.block_id;            //Specify which pstorage handle to wait for
		pstorage_wait_flag = 1;
		pstorage_clear(&amp;amp;block_3_handle, 16);  
		while(pstorage_wait_flag) { power_manage(); }              //Sleep until clear operation is finished.		
// CLEAR ************************			

// assign source datas  ********************************	
		for (uint32_t i = 0; i &amp;lt; 6; i++)				
		{
			source_data_3[i] = p_data[i];
		}
// ******************************************************		
		// STORE DATA
		pstorage_wait_handle = block_3_handle.block_id;            //Specify which pstorage handle to wait for
		pstorage_wait_flag = 1;                                    //Set the wait flag. Cleared in the example_cb_handler
		pstorage_store(&amp;amp;block_3_handle, source_data_3, 16, 0);     //Write to flash, only one block is allowed for each pstorage_store command
		if(retval != NRF_SUCCESS)
		{
				bsp_indication_set(BSP_INDICATE_RCV_ERROR);
		}
		while(pstorage_wait_flag) { power_manage(); }              //Sleep until store operation is finished.
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I then entered any uint8_t some_array[] instead of p_data and it was done in SDK 8. But now I can not reach the data I write with FDS.&amp;nbsp;What I want is actually very simple, but I guess I can not tell because my English is weak.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122834?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 13:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:981c4678-face-4ef2-aacb-f0ac5b8c592f</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey Ugur,&lt;/p&gt;
&lt;p&gt;I spoke in error earlier when I said that the record descriptor was not used. It is clearly used in:&lt;br /&gt; while (fds_record_find(file_id, relevant_record_key, &amp;amp;record_desc, &amp;amp;ftok) == FDS_SUCCESS)&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I believe it&amp;#39;s the way you are accessing the&amp;nbsp;fds_flash_record_t flash_record afterwords.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t your_data[8] = {0};
uint8_t your_byte = 0;

for(uint8_t i = 0; i &amp;lt; flash_record-&amp;gt;p_header.length_words; i++){
    your_data[i] = flash_record-&amp;gt;p_data[0];
}

your_byte = (uint8_t)your_data[0];&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122735?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 06:41:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c8f97ac-40eb-4a62-889b-4d199808b2e0</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Another Experiment;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t *data ;
				
data = (uint32_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]);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I wrote;&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 41 30 31 31 30 30 30 34|A0110004&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 30 00 |0.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Result;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 0x 9731 &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 0x20005CB0 &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 0x20005CD0 &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 0x 971B &lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122734?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 06:26:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e63ba9dc-b932-49e8-a91f-541680f634cc</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Tried another experiment;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t *data ;

data = (uint32_t *) flash_record.p_data;
NRF_LOG_HEXDUMP_INFO(data, sizeof(data));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I write ;&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 41 30 31 31 30 30 30 34|A0110004&lt;br /&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 30 00 |0.&lt;/p&gt;
&lt;p&gt;Result;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;0&amp;gt; &amp;lt;info&amp;gt; app:&amp;nbsp; 31 97 00 00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |1&amp;mdash;..&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122732?ContentTypeID=1</link><pubDate>Mon, 05 Mar 2018 06:08:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfc9cd78-9d6d-4402-b6bc-9ce4e7349c78</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Also I tried this one;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t *data ;
data = (uint32_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_INFO(&amp;quot;Data = &amp;quot;);
NRF_LOG_HEXDUMP_INFO(read_data, sizeof(read_data));
NRF_LOG_INFO(&amp;quot;\r\n&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note: I defined&amp;nbsp;uint8_t read_data[] .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I write ;&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 41 30 31 31 30 30 30 34|A0110004&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 30 00 |0.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Result;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Data = &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 31 B0 D0 1B |1&amp;deg;Ğ. &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: &lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122610?ContentTypeID=1</link><pubDate>Fri, 02 Mar 2018 13:07:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e89f5b0-66e4-41e3-b800-622a10fa2767</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Before I wrote this post, I tried this;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t * pointer_to_record_data;
pointer_to_record_data = (uint8_t *)flash_record.p_data;

if(flash_record.p_header-&amp;gt;record_key == relevant_record_key)
{
    for(uint8_t i = 0; i &amp;lt; 10; i++)
    {
        read_data[i] = *pointer_to_record_data;
        pointer_to_record_data++;
    }
}

NRF_LOG_INFO(&amp;quot;Data = &amp;quot;);
NRF_LOG_HEXDUMP_INFO(read_data, sizeof(read_data));
NRF_LOG_INFO(&amp;quot;\r\n&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it&amp;nbsp;did not work either. Result like that;&lt;/p&gt;
&lt;p&gt;I wrote this&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 41 30 31 31 30 30 30 34|A0110004&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 30 00 |0. &lt;/p&gt;
&lt;p&gt;Result was&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: Data = &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 31 97 00 00 |1&amp;mdash;.. &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: &lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: dest_data_0 : &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 31 97 00 00 C8 5C 00 20|1&amp;mdash;..&amp;Egrave;\. &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: E8 5C |&amp;egrave;\ &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122608?ContentTypeID=1</link><pubDate>Fri, 02 Mar 2018 12:51:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44b089fc-67ef-4275-ba0e-508e068858b0</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;The problem is not the name of &amp;#39;record/&amp;#39;rec&amp;#39;, it&amp;#39;s that it is not used at all! No data is ever stored in the &amp;#39;record&amp;#39; instance of type fds_record_t.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122605?ContentTypeID=1</link><pubDate>Fri, 02 Mar 2018 12:38:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e7991af-996a-42d4-87ad-77327fcb1273</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;H&amp;aring;kon, Thanks for answering I refresh my code and changed the name of &amp;quot;record &amp;quot;with &amp;quot;rec&amp;quot;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Test Result;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: save_data&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Writing Record ID = 1 &lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 61 61 61 61 61 61 61 61|aaaaaaaa&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 61 61 |aa&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span&gt;tried to read and result is;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span&gt;0&amp;gt; &amp;lt;info&amp;gt; app: first_Setup Start&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Start searching... &lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Found Record ID = 1&lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Data = &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 00 04 00 20 |... &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: &lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: dest_data_0 : &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 00 04 00 20 E9 08 00 00|... &amp;eacute;...&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 7D 05 |}. &lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;strong&gt;Additionan Note;&amp;nbsp;&lt;/strong&gt;Interestingly, Whatever I write data is always the same result!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;For example;&lt;/p&gt;
&lt;p&gt;If I write different data ;&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: 78 68 6A 66 68 6B 67 67|xhjfhkgg&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 6A 6A |jj&lt;/p&gt;
&lt;p&gt;And I read same result;&lt;/p&gt;
&lt;p&gt;0&amp;gt; &amp;lt;info&amp;gt; app: Data = &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 00 04 00 20 |... &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: &lt;br /&gt; 0&amp;gt; &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: dest_data_0 : &lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 00 04 00 20 E9 08 00 00|... &amp;eacute;...&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: 7D 05 |}. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to write, read and store uint8_t data_array via FDS</title><link>https://devzone.nordicsemi.com/thread/122591?ContentTypeID=1</link><pubDate>Fri, 02 Mar 2018 10:22:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76c20ab9-4709-4b36-9018-764e7f65f60f</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey Ugur,&lt;/p&gt;
&lt;p&gt;I believe I found a bug:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
fds_record_t record; // Uninitialized variable

uint8_t * pointer_to_record_data;
pointer_to_record_data = (uint8_t *)record.data.p_data; // points to an address with unknown data

if(flash_record.p_header-&amp;gt;record_key == relevant_record_key)
{
	for(uint8_t i = 0; i &amp;lt; 10; i++)
	{
		read_data[i] = *pointer_to_record_data; // record has not been used
		pointer_to_record_data++;
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You never used the variable &amp;#39;record&amp;#39; and since it is uninitialized it&amp;#39;s content is in an unknown state. The compiler has probably reused the memory of other parts of the program that is no longer in the scope and you will therefore read garbage data.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>