<?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>Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17319/fstorage-read-and-write-at-sdk11</link><description>I want to use fstorage to write data to a file. The File with three records: 0x1111=&amp;quot;Tablet1&amp;quot;, 0x2222=&amp;quot;data: abcdef&amp;quot;, 0x3333=&amp;quot;26&amp;quot;. How to implement it? Can anyone guide me?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Apr 2017 11:37:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17319/fstorage-read-and-write-at-sdk11" /><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66547?ContentTypeID=1</link><pubDate>Wed, 19 Apr 2017 11:37:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dbc1c31-bac8-4a68-90cc-c8fc5d8f5ab3</guid><dc:creator>Waqar Ahmed</dc:creator><description>&lt;p&gt;i have compile your code but it only show at segger rtt only the start and erasing a flash page at adresss0x7900 .neither writing nor reading the data&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66537?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2016 08:41:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1f60b20-0f67-410a-a9a3-7848b040ba4b</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;If you call flash storage function from an interrupt handler you can not wait for the callback in the interrupt handler, because then you will block the callback which has the same priority. You need instead to call the flash storage function from main context. There are primarily two ways to do that. One way is to use the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/lib_scheduler.html?cp=4_0_1_3_22"&gt;scheduler&lt;/a&gt;. Another way is to call the flash storage function conditionally in the main loop, where you only call it when a specific flag is true. Then you set that flag true in the interrupt handler (ancs interrupt handler)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66546?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2016 03:38:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abb1dda3-8b4d-41b1-b15a-0c5855f481f9</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;System seems halt when I call the function of fds_record_write from BLE ancs profile. Can I not access fstorage from BLE ancs profile? Is it correct? Do you know how to do it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66539?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 10:55:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74978909-73b5-4aef-8688-811f42ecd304</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;I think the problem might be with your conversion from byte to words. The string &amp;quot;data: abcdef&amp;quot; is 12 characters long, plus the implicit string terminator character &amp;#39;\0&amp;#39;, that&amp;#39;s a total of 13 bytes. When you set length_words field of the chunk like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;record_chunk.length_words = (sizeof(device_data)+1)/4;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;My guess is that sizeof(device_data) will be 13 + 1 (which you add manually) / 4 equals to 3.5, which gets rounded down to 3, which is wrong since the string is 12 characters long but you need the 13th character (string terminator) to print correctly.&lt;/p&gt;
&lt;p&gt;It works with &amp;quot;data abcdef&amp;quot; because that&amp;#39;s one character shorter, thus 12 + 1 / 4 = 3,25 which gets rounded down to 3, which is right in this case because that&amp;#39;s exactly the length of the string including the terminator character (implicit).&lt;/p&gt;
&lt;p&gt;If you want approximate you should add 3. I would try like this:
&lt;code&gt;length_words = (sizeof(data) + 3) / 4&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66545?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 10:50:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:565f1fc1-fe98-4f55-a185-66f7e09db5f4</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Write hexadecimal code semms successfully. But write ASCII  string include specail characters will cause fail. Can you test it with special characters like &amp;quot;~!@#$%^&amp;amp;*()_+-=&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66543?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 09:13:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9131c88-6e56-4293-baa9-5c385407787d</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I print it by hexadecimal code, because it cannot print non-ASCII data.
If I set the second data to 0x2222=&amp;quot;data: abcdef&amp;quot;. I got the message as follows.
Writing Record ID = 1
set write_flag
Writing Record ID = 2
set write_flag
Writing Record ID = 3
set write_flag
Start searching...
Found Record ID = 1
Tablet1
Found Record ID = 2
Data = ??
Found Record ID = 3
Data = 0x0000001a&lt;/p&gt;
&lt;p&gt;If I set the second data to 0x2222=&amp;quot;data abcdef&amp;quot;. I got the message as follows.
Writing Record ID = 1
set write_flag
Writing Record ID = 2
set write_flag
Writing Record ID = 3
set write_flag
Start searching...
Found Record ID = 1
Tablet1
Found Record ID = 2
Data = data abcdef
Found Record ID = 3
Data = 0x0000001a&lt;/p&gt;
&lt;p&gt;The two strings are only different at a character of &amp;#39;:&amp;#39; .&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_pstorge_5F00_1.c"&gt;ble_pstorge_1.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66544?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 08:39:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d86fb3fa-f044-43ea-bd67-ee69bda8dde0</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;There is &lt;a href="https://devzone.nordicsemi.com/question/90746/how-to-use-fstorage-on-nrf51-with-sdk10/"&gt;fstorage example code available here for SDK 10&lt;/a&gt;. There is also available &lt;a href="https://github.com/hubuhubu/nRF52-fds-example"&gt;simple fds code here for SDK 11&lt;/a&gt;. Discussion on the &lt;a href="https://devzone.nordicsemi.com/question/79459/difference-between-persistent-storage-libraries/"&gt;difference between pstorage, fstorage and fds is briefly discussed here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 26.10.2016&lt;/strong&gt;
Below is fstorage example for SDK 11.0.0. The example writes two words to flash and then reads the flash contents. Result is printed on UART (UART settings: 115200 BAUD, 8N1, hardware flow control disabled)&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5165.ble_5F00_app_5F00_template_5F00_with_5F00_fstorage_5F00_operations.zip"&gt;ble_app_template_with_fstorage_operations.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Capture-_2D00_-fstorage-example-UART-output-SDK-11.JPG" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 2  26.10.2016&lt;/strong&gt;
I attach another SDK 11.0.0 example with the following UART output&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_template_5F00_with_5F00_fstorage_5F00_operations_5F00_ascii.zip"&gt;ble_app_template_with_fstorage_operations_ascii.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Capture-_2D00_-fstorage-example-UART-output-SDK-11-_2D00_-ascii.JPG" alt="image description" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66542?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 07:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cc3edd6-b8f3-4ee3-b856-699f6401c431</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;You are printing it as a hex number instead of a string. If your string is null terminated, simply use %s in NRF_LOG_PRINT().
Something like this:
&lt;code&gt;char * p_data; p_data = flash_record.p_data; NRF_LOG_PRINTF(&amp;quot;Data: %s\r\n&amp;quot;, (uint32_t)p_data);&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66541?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 03:28:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:305728eb-cc4c-4d37-b557-27c9590f77b6</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;It seems some wrong at the function of fds_record_write(). It cannot write special character like ASCII 0x21 to 0x2f etc. How to fix it if I say correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66540?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 02:51:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65397378-5f6a-49d9-9d6d-f56c7e119929</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;My source code at attach file.&lt;/p&gt;
&lt;p&gt;print messages as follows:
Writing Record ID = 1
set write_flag
Writing Record ID = 2
set write_flag
Writing Record ID = 3
set write_flag
Start searching...
Found Record ID = 1
Data = 0x6c626154 0x  317465
Found Record ID = 2
Data = 0x    8fb5 0x20002bf0 0xfffffff9
Found Record ID = 3
Data = 0x      1a&lt;/p&gt;
&lt;p&gt;Second data (0x2222=&amp;quot;data: abcdef&amp;quot;) is always error. Can you guide me what it is?&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_pstorge.c"&gt;ble_pstorge.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66538?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 12:50:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f83b824-050f-477a-9c4b-e232a670d7bc</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;I think you might want to use the &amp;#39;fds&amp;#39; library for that.
Have a look here: &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.0.0%2Flib_fds_usage.html"&gt;infocenter.nordicsemi.com/index.jsp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fstorage read and write at SDK11</title><link>https://devzone.nordicsemi.com/thread/66536?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 09:48:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4095d87b-57db-406d-8efe-dd2e4df5718d</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Can the third parameter change to 26 (uint8_t)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>