<?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>Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37743/problem-with-fds-flash-read-write-delete-calling-that-function-using-android-phone</link><description>Hello to all, 
 I am using nRF52832 DK with sd132, v6.0.0 and sdk 15.0.0, segger embedded studio. We want to achieve change application timer time (APP_TIMER_TICKS(update_time)) using android phone. We have a sensor devices it will wake up as per app</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Jul 2019 10:31:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37743/problem-with-fds-flash-read-write-delete-calling-that-function-using-android-phone" /><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/196231?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2019 10:31:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2415710-9e5b-4c05-94d5-5fb7c723fae1</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Actually, you shouldn&amp;#39;t call fds_gc() after each delete. You should do it as few times as possibly. only when you try to write or update a record, and it returns&amp;nbsp;FDS_ERR_NO_SPACE_IN_FLASH, you should run fds_gc().&lt;/p&gt;
&lt;p&gt;The reason you don&amp;#39;t want to do this too often. The reason for this is that fds_gc() will shuffle around the valid record, and delete the entire old flash page. The flash on the nRF has ~10000 write cycles. This means that after you write to the same address in flash 10000 times, it is not guaranteed to work. (However, it will probably work for 40-50 000, but the &amp;quot;guarantee&amp;quot; is 10 000).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So the FDS handles &lt;a href="https://en.wikipedia.org/wiki/Wear_leveling" rel="noopener noreferrer" target="_blank"&gt;flash wear leveling&lt;/a&gt;&amp;nbsp;by spreading out the records, and marking them as &amp;quot;deleted&amp;quot; and write it in another address rather than deleting and writing to the same place. Therefore, you should only call fds_gc() when you need to. Calling fds_gc() every time you delete a record will &amp;quot;beat up&amp;quot; the flash, making the lifetime a lot shorter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/196224?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2019 10:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65f20a5b-7543-4053-aaeb-6558ec1344e5</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Thanks for quick response..!&lt;/p&gt;
&lt;p&gt;I have also set f&lt;span&gt;ds_delete_flag = false; after delete_all_reading_process().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Just one question Is it necessary to&amp;nbsp;call&amp;nbsp;fds_gc(); after each delete record event?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t fds_delete_file(uint16_t file_ID) {
  ret_code_t ret = fds_file_delete(file_ID);
  if (ret != FDS_SUCCESS) {
    return ret;
  }
  wait_for_next_delete(); /* wait for this stored file successfully deleted*/
  /* Call garbage collector to clean dummpy data from flash*/
  ret = fds_gc(); 
  if (ret != FDS_SUCCESS) {
    return ret;
  }
  return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What will happen if not call fds_gc(); after delete event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/196209?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2019 09:34:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f4091c6-2493-4df2-b871-4d301e515549</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Yes. That looks good.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="vishal.borle"]I have set fds_delete_flag = false; when last flash operation success.[/quote]
&lt;p&gt;&amp;nbsp;If I were to suggest one change, maybe set the fds_delete_flag = false directly after calling delete_all_reading_process(); so that it doesn&amp;#39;t attempt to run delete_all_reading_process() several times. You can rather set it back to true if the delete event is called with result != success to try again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/196197?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2019 09:08:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dad58ab3-3623-4b8f-92e9-883a13913125</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;As per you suggested above program snippet this is working and we are able to sent response after completion of flash process.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is my below is this correct shall we go ahead?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  for (;;) {
    if (fds_delete_flag == true) {
      delete_all_reading_process();
    }
    if (sleep_mode_enable == true) {
      sleep_mode_enter();
      sleep_mode_enable = false;
    }
    idle_state_handle();
  }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have set fds_delete_flag = false; when last flash operation success.&lt;/p&gt;
&lt;p&gt;Now every thing is working fine.&lt;/p&gt;
&lt;p&gt;Thanks for the your suggestion.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194887?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 13:00:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b09319d4-023c-498b-9793-b67f8ff651f5</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok. You are calling it from the nus_data_handler. This is a softdevice interrupt, so it will not allow the FDS to start before you exit this interrupt.&lt;/p&gt;
&lt;p&gt;You need to exit this function (let it run to the end) before you start your FDS operations. Very simplified, it will look something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//near top of main.c:
static volatile bool fds_delete_flag = false;


nus_data_handler()
{

... 
    case &amp;#39;8&amp;#39;:
    fds_delete_flag = true;
    break;
...
}


int main(void)
{
    ret_code_t err_code;
    init_everything();
    ...
    
    for (;;)
    {
        if (fds_delete_flag == true)
        {
            err_code = fds_delete_file();
            if (err_code == NRF_SUCCESS)
            {
                fds_delete_flag = false;
            }
        }
        power_manage();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The point is to exit the nus_data_handler() before you call the FDS functions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194869?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 12:06:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c16ac774-9faf-4d6d-bedd-888d182e96c1</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;I am calling&amp;nbsp;&lt;span&gt;&amp;nbsp;fds_delete_file() from main here is below snippet:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void nus_data_handler(ble_nus_evt_t *p_evt) {
  if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA) {
//    uint32_t err_code;
    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);
    switch (p_evt-&amp;gt;params.rx_data.p_data[0]) {
    ...
    case &amp;#39;8&amp;#39;: // To detach configured machine info.
      NRF_LOG_INFO(&amp;quot;8 cmd received&amp;quot;);
      delete_all_reading_process();
      ...

/* This function is used for delete all stored reading availble in flash even if any not available then clean flash for that file number*/
void delete_all_reading_process() {
  uint16_t file_no;
  ret_code_t ret;
  ret = fds_find_and_delete(FILE_ID_FRONT_REAR_VAL, REC_KEY_FRONT_REAR_VAL);
  if (ret == FDS_SUCCESS) {
    NRF_LOG_INFO(&amp;quot;Deleted front &amp;amp; rear value&amp;quot;);
  }
  for (file_no = 1; file_no &amp;lt;= READINGS_STORE; file_no++) {
    NRF_LOG_INFO(&amp;quot;Deleting File no:%d&amp;quot;, file_no);
    ret = fds_delete_file(file_no);
  }
  if (ret != FDS_SUCCESS) {
    ble_nus_data_send(&amp;amp;m_nus, DETACH_MACH_FAILED, &amp;amp;msg_code_len, m_conn_handle); // send message to connected phone
  }
  detached_machine_info();
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If this wrong how I can set flag from the SD interrupt. I am not understand how i can check this is it inside a soft-device&amp;nbsp;interrupt.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am calling this function from nus_data_handler(..);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194842?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 10:46:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d592ba24-ddae-4d3a-a8e9-dec8a0ca1428</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;From where are you calling the&amp;nbsp;fds_delete_file()? Is it inside a softdevice interrupt? If so, you may block the FDS. You should set a flag from the SD interrupt, and then call the FDS functions from the main context.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194818?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 09:20:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b7c7997-4082-4625-bb2f-a79c7de5e8f3</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;I have tried min and max to 100ms, but still same problem.&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/37743/problem-with-fds-flash-read-write-delete-calling-that-function-using-android-phone/194756"]Can you try to do the delete function without being in a connection and without advertising? Does it work then?[/quote]
&lt;p&gt;Yes actually if i have called this function without any BLE activity it has worked and also got all fds event.&lt;/p&gt;
&lt;p&gt;Why this happening only when BLE advertising OR with connected?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194756?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 06:48:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67543399-4916-4021-8004-1c7f7862f092</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Can you try to increase the connection interval even more? E.g. try to set both min and max to 100.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you try to do the delete function without being in a connection and without advertising? Does it work then?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194695?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 14:21:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb4e0e2c-0480-48f1-85c0-82dee88c96e8</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Yes, the connection state is connected when i call to delete function,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define APP_BLE_CONN_CFG_TAG 1                           /**&amp;lt; A tag identifying the SoftDevice BLE configuration. */
#define DEVICE_NAME &amp;quot;Device_test&amp;quot;                         /**&amp;lt; Name of device. Will be included in the advertising data. */
#define NUS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**&amp;lt; UUID type for the Nordic UART Service (vendor specific). */

#define APP_BLE_OBSERVER_PRIO 3 /**&amp;lt; Application&amp;#39;s BLE observer priority. You shouldn&amp;#39;t need to modify this value. */
#define APP_ADV_INTERVAL 64     /**&amp;lt; The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */

#define APP_ADV_DURATION 0   /* Set 0 for contineous advertisng time &amp;amp; handle their timeout by sperate app timer.*/ 

#define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS)   //20           /**&amp;lt; Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS)   //75           /**&amp;lt; Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY 0                                      /**&amp;lt; Slave latency. */
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)     /**&amp;lt; Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000) /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(90000) /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT 3                       /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please note I have already tried with connection interval below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS)   //20           /**&amp;lt; Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(75, UNIT_1_25_MS)   //75 &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194678?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 13:31:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0763821b-eb50-4536-94e5-15c2adcc8e9d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;The priority is lower for FDS than for BLE, yes, but it has to be that way. The BLE will not block you all the time. Only short interrupts.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your connection state when you try to delete? I assume it is connected? If so, what is your connection interval?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194673?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 13:16:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2846fe2-a1e3-4364-b5f0-c1be2d3b23f6</guid><dc:creator>vishal</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/37743/problem-with-fds-flash-read-write-delete-calling-that-function-using-android-phone/194663"]Do you get the return value NRF_SUCCESS (= 0) from fds_file_delete()? And you are sure that the wait_for_next_delete() function is hit?[/quote]
&lt;p&gt;Yes I got NRF_SUCESS from fds_file_delete(), and sure bout wait_for_next_delete() function hit.&lt;/p&gt;
&lt;p&gt;I have check by set break point with&amp;nbsp;&lt;span&gt;FDS_EVT_DEL_RECORD and FDS_EVT_DEL_FILE but nothing get.&lt;/span&gt;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/37743/problem-with-fds-flash-read-write-delete-calling-that-function-using-android-phone/194663"]Also, can you try to remove the idle_state_handle(); from inside the while loop in the wait_for_next_delete() function?[/quote]
&lt;p&gt;&lt;span&gt;this already i have tried.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This happening only when if used&amp;nbsp;wait_for_next_delete() If I comment this then got all event and also clean flash. Here is my below logs without wait for next delete:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;debug&amp;gt; app: Received data from BLE NUS. Writing data on UART.
&amp;lt;debug&amp;gt; app:  38                     |8       
&amp;lt;info&amp;gt; app: 8 cmd received
&amp;lt;info&amp;gt; app: Deleted record ID: 8 

&amp;lt;info&amp;gt; app: Deleted front &amp;amp; rear value
&amp;lt;info&amp;gt; app: Deleting File no:1
&amp;lt;info&amp;gt; app: Deleting File no:2
&amp;lt;info&amp;gt; app: Deleting File no:3
&amp;lt;info&amp;gt; app: Deleting File no:4
&amp;lt;info&amp;gt; app: Deleting File no:5
&amp;lt;info&amp;gt; app: Deleting File no:6
&amp;lt;info&amp;gt; app: Deleting File no:7
&amp;lt;info&amp;gt; app: Deleting File no:8
&amp;lt;info&amp;gt; app: Deleted record ID: 1 

&amp;lt;info&amp;gt; app: FDS mach-ID delete success
&amp;lt;info&amp;gt; app: Deleted record ID: 2 

&amp;lt;info&amp;gt; app: FDS Cron-Sch delete success
&amp;lt;info&amp;gt; app: Deleted record ID: 30 

&amp;lt;info&amp;gt; app: FDS Any Stored ERROR delete success
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Disconnected
&amp;lt;debug&amp;gt; app: Started Advertisng timeout timer
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data File deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data record deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data record deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data record deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed
&amp;lt;info&amp;gt; app: Flash data record deleted
&amp;lt;info&amp;gt; app: Garbage Collection completed&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have read some ques and answer from Nordic forum&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/46471/calling-fds_write-within-a-ble_evt_handler-gets-the-sd-or-app-stuck/182940#182940"&gt;link here&lt;/a&gt; someone suggest the intrrupt priority of FDS module is lower than BLE priority is this correct?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If yes how I can change&amp;nbsp;the priority to get fds event with ble connected to device?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.......&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194663?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 12:59:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f60376e4-eb7c-4f6a-9ee1-8dd188c79f69</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Do you get the return value NRF_SUCCESS (= 0) from fds_file_delete()? And you are sure that the wait_for_next_delete() function is hit?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Maybe you get the FDS_EVT_DEL_FILE event with&amp;nbsp;p_fds_evt-&amp;gt;result != FDS_SUCCESS? Can you check this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also, can you try to remove the idle_state_handle(); from inside the while loop in the wait_for_next_delete() function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194655?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 12:42:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:232f117c-fe6e-4b5b-be65-e268c2a66ea3</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Thanks for quick response..!!!&lt;/p&gt;
&lt;p&gt;I have made changes as you suggested and error code is 0 means NRF_SUCCESS&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0574.error.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;But still same issue.. it continuous in forever loop.&lt;/p&gt;
&lt;p&gt;Any other suggestion please...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194642?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 12:14:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb188da7-e612-488a-bb62-65a90b935998</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok. so two issues, then:&lt;/p&gt;
&lt;p&gt;1:&amp;nbsp;fds_file_delete() will trigger the&amp;nbsp;FDS_EVT_DEL_RECORD event, which will set fds_delete_success = true. You are waiting for the fds_write_success to become true. It&amp;nbsp;never will.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2: In your&amp;nbsp;fds_delete_file(). If one of the function calls inside here returns ret != NRF_SUCCESS, your FDS operations aren&amp;#39;t queued.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So let us say that inside fds_delete_files() returns e.g.&amp;nbsp;FDS_ERR_NO_SPACE_IN_QUEUES, then fds_delete_file() returns FDS_ERR_NO_SPACE_IN_QUEUE, but your delete operation is not queued, and you will never get the FDS_EVT_DEL_RECORD (or the FDS_EVT_WRITE, for that matter. See issue 1.)&lt;/p&gt;
&lt;p&gt;However, you wait for this event (the wrong one) before you check the return value of fds_file_delete();&lt;/p&gt;
&lt;p&gt;You should check the return value before you wait for the event. Something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t fds_delete_file(uint16_t file_ID)
{
    ret_code_t ret = fds_file_delete(file_ID);
    if (ret != FDS_SUCCESS)
    {
        return ret;
    }
    wait_for_next_delete(); // PLEASE NOTE THIS CHANGE. not wait_for_next_write()
    ...
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194627?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 11:37:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0143a0b1-ca13-4493-a76a-fa6f19d53115</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;I am waiting for the&amp;nbsp;&lt;span&gt;FDS_EVT_DEL_RECORD&amp;nbsp;OR&amp;nbsp;FDS_EVT_DEL_FILE but nothing get only when connected with BLE activity.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this any priority issue?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is my below updated functions:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void fds_evt_handler(fds_evt_t const *const p_fds_evt) {
  switch (p_fds_evt-&amp;gt;id) {
  case FDS_EVT_INIT:
    if (p_fds_evt-&amp;gt;result != FDS_SUCCESS) {
      // Initialization failed.
    }
    m_fds_init_success = true;
    break;
  case FDS_EVT_WRITE:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash Write event generated&amp;quot;);
      fds_write_success = true;
    }
    fds_allocation_for_write(0);
    break;
  case FDS_EVT_DEL_RECORD:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash data record deleted&amp;quot;);
      fds_delete_success = true;
    }
    break;
  case FDS_EVT_DEL_FILE:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash data File deleted&amp;quot;);
      fds_delete_success = true;
    }
    break;
  case FDS_EVT_UPDATE:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash data updated&amp;quot;);
      fds_write_success = true;
    }
    fds_allocation_for_write(0);
    break;
  case FDS_EVT_GC:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Garbage Collection completed&amp;quot;);
    }
    break;
  default:
    break;
  }
}

void wait_for_next_delete(void) {
  while (!fds_delete_success) {
    idle_state_handle();
  }
  fds_delete_success = false;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194614?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 10:56:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c757d56f-c9dd-424c-a5d1-bfaa0b339592</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Are you waiting for the fds_write_success after you deleted a record? Wouldn&amp;#39;t that give the&amp;nbsp;FDS_EVT_DEL_RECORD event, which will set&amp;nbsp;m_fds_delete_success = true? At least if you haven&amp;#39;t changed anything since the snippets that you sent 7 months ago.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/194597?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 10:30:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:920e4723-d4c3-4b75-a6a9-26f24ba471fb</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Sorry for very late reply, we have released our product.&lt;/p&gt;
&lt;p&gt;Will you please help me with below issue:&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say in my device flash stored some data in 8 files. I want to delete this file once command received from mobile app with connected.&lt;/p&gt;
&lt;p&gt;Here is my below function for deleting files while app connected:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t fds_delete_file(uint16_t file_ID) {
  ret_code_t ret = fds_file_delete(file_ID);
  wait_for_next_write(); /* wait for this stored file successfully deleted*/
  if (ret != FDS_SUCCESS) {
    return ret;
  }
  /* Call garbage collector to clean dummpy data from flash*/
  ret = fds_gc(); 
  if (ret != FDS_SUCCESS) {
    return ret;
  }
  return NRF_SUCCESS;
}

void wait_for_next_write(void) {
  while (!fds_write_success) {
    idle_state_handle();
  }
  fds_write_success = false;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But now problem getting when i connect device and send command to call this function it will continuous waiting for&amp;nbsp;fds_evt_handler();&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But fds_evt_handler(); is not generated. If I comment to wait_for_next_write() function that time fds event getting but got success response before flash clean.&lt;/p&gt;
&lt;p&gt;I want to get success response once flash data successfully deleted with ble connected with app.&lt;/p&gt;
&lt;p&gt;Looking forward your response..!!!&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/163846?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 20:35:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35f083e5-4fa1-42eb-8e3c-a73310fa44b3</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Regarding mentioning names with spaces, I&amp;#39;ve made a Backstage thread for that:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/backstage/f/welcome-to-the-devzone/42127/how-to-mention-names-with-spaces"&gt;https://devzone.nordicsemi.com/backstage/f/welcome-to-the-devzone/42127/how-to-mention-names-with-spaces&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/158306?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 07:56:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73696672-9f08-49c5-9adc-064e5235aec7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;This seems correct, but it is not the same as in your previous reply, so I am a bit confused.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To the left is your last snippet, and to the right is the snippet from your previous reply:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-9d9a832108af4931b61361aca33de246/pastedimage1542787007517v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;So did it work after you added the waiting?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/158251?ContentTypeID=1</link><pubDate>Tue, 20 Nov 2018 16:26:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32f0947e-97a8-4069-834d-9b6b81760ff2</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Thanks for quick response,&lt;/p&gt;
&lt;p&gt;Here is bellow wait for update or write event:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ret_code_t fds_write(uint16_t file_ID, uint16_t rec_key) {
  NRF_LOG_INFO(&amp;quot;In flashing: %s&amp;quot;, (uint32_t)fds_write_buff);
  ret_code_t err_code;
  fds_record_t record;
  fds_record_desc_t record_desc;
  fds_find_token_t ftoken;
  memset(&amp;amp;ftoken, 0x00, sizeof(fds_find_token_t));
  // Set up record.
  record.file_id = file_ID;
  record.key = rec_key;
  record.data.p_data = &amp;amp;fds_write_buff;
  record.data.length_words = (sizeof(fds_write_buff) + 3) / 4; //sizeof(m_deadbeef)/sizeof(uint8_t);

  if (fds_record_find(file_ID, rec_key, &amp;amp;record_desc, &amp;amp;ftoken) == FDS_SUCCESS) {
    err_code = fds_record_update(&amp;amp;record_desc, &amp;amp;record);
    APP_ERROR_CHECK(err_code);
	while(!m_fds_update_success)
    {
        // wait
    }
    m_fds_update_success = false;
  }
  else
  {
    err_code = fds_record_write(&amp;amp;record_desc, &amp;amp;record);
    APP_ERROR_CHECK(err_code);
	while(!m_fds_write_success)
    {
        // wait
    }
    m_fds_write_success = false;
  }
  return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;set this flag true in fds event :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  case FDS_EVT_WRITE:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      m_fds_write_success = true;
      NRF_LOG_INFO(&amp;quot;Flash Write event generated&amp;quot;);
    }
    break;
  case FDS_EVT_DEL_RECORD:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash data record deleted&amp;quot;);
      m_fds_delete_success = true;
    }
  case FDS_EVT_DEL_FILE:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash data File deleted&amp;quot;);
    }
  case FDS_EVT_UPDATE:
    if (p_fds_evt-&amp;gt;result == FDS_SUCCESS) {
      NRF_LOG_INFO(&amp;quot;Flash data updated&amp;quot;);
      m_fds_update_success = true;
    }&lt;/pre&gt;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/37743/problem-with-fds-flash-read-write-delete-calling-that-function-using-android-phone/158223"]&amp;nbsp;How do you wait in your application?[/quote]
&lt;p&gt;means this is same as above right if not can you please provide program snippet for wait in application.&lt;/p&gt;
&lt;p&gt;Thanks you.....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/158223?ContentTypeID=1</link><pubDate>Tue, 20 Nov 2018 14:55:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a54d3cc-4e0e-48d5-9696-83a0f82dd2e5</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I meant that you could test the project I attached to see how to do it, not port your current project.&lt;/p&gt;
&lt;p&gt;Are you waiting for the udate or write event BEFORE you read the data from flash again?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="vishal.borle"]Another problem is if i set flag on each write &amp;amp; update record data event for wait that time BLE is hang not worked another functionality need to reset. So i removed wait flash in my fds_write function.[/quote]
&lt;p&gt;&amp;nbsp;How do you wait in your application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/158202?ContentTypeID=1</link><pubDate>Tue, 20 Nov 2018 13:59:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94331716-0aeb-4b49-aac7-15aafdb4ff00</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;I am not test my current project with new sdk due not having much time.&lt;/p&gt;
&lt;p&gt;So i have modify my fds_write function as like bellow:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ret_code_t fds_write(uint16_t file_ID, uint16_t rec_key) {
  NRF_LOG_INFO(&amp;quot;In flashing: %s&amp;quot;, (uint32_t)fds_write_buff);
  ret_code_t err_code;
  fds_record_t record;
  fds_record_desc_t record_desc;
  fds_find_token_t ftoken;
  memset(&amp;amp;ftoken, 0x00, sizeof(fds_find_token_t));
  // Set up record.
  record.file_id = file_ID;
  record.key = rec_key;
  record.data.p_data = &amp;amp;fds_write_buff;
  record.data.length_words = (sizeof(fds_write_buff) + 3) / 4; //sizeof(m_deadbeef)/sizeof(uint8_t);

  if (fds_record_find(file_ID, rec_key, &amp;amp;record_desc, &amp;amp;ftoken) == FDS_SUCCESS) {
    err_code = fds_record_update(&amp;amp;record_desc, &amp;amp;record);
    APP_ERROR_CHECK(err_code);
  }
  else
  {
    err_code = fds_record_write(&amp;amp;record_desc, &amp;amp;record);
    APP_ERROR_CHECK(err_code);
  }
  return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this function got another issue which is:&lt;/p&gt;
&lt;p&gt;When i erase complete chip and flash my program then using android phone call command and store required config. in flash this is worked.&lt;/p&gt;
&lt;p&gt;Now after when i connect phone read flash data is correct and that same time i call command to update flash data updated event got. but not get this data.&lt;/p&gt;
&lt;p&gt;When i disconnect BLE connection and call update flash data then got correct data. Means i am trying to say before send command flash data update first disconnect and connect again then send this command That way got flash config. data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Another problem is if i set flag on each write &amp;amp; update record data event for wait that time BLE is hang not worked another functionality need to reset. So i removed wait flash in my fds_write function.&lt;/p&gt;
&lt;p&gt;Will you please tell me why this happen, If i disconnect BLE connection and connect then send flash update command to device that time flash data successfully updated and also got updated flash data.&lt;/p&gt;
&lt;p&gt;Waiting for your response..&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks....!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/155280?ContentTypeID=1</link><pubDate>Wed, 31 Oct 2018 10:08:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1aeab411-b7c6-4314-a671-2047f7dad02e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Try the attached project with SDK15.2.0 (&lt;a href="http://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/"&gt;download here&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I used the Keil IDE, so if you want to use something else, e.g. Segger Embedded Studio, please add the files:&lt;/p&gt;
&lt;p&gt;fds.c&lt;/p&gt;
&lt;p&gt;nrf_fstorage.c&lt;/p&gt;
&lt;p&gt;nrf_fstorage_sd.c&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-9d9a832108af4931b61361aca33de246/ble_5F00_app_5F00_uart_5F00_fds.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart_5F00_fds.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with fds: Flash read, write, delete calling that function using android phone.</title><link>https://devzone.nordicsemi.com/thread/155198?ContentTypeID=1</link><pubDate>Tue, 30 Oct 2018 15:39:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c61bfcd-9625-404e-9f6b-b3190b4a4e7d</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;I have tried this above method but still getting same problem. One think is in there when i call fds_write(..);&lt;/p&gt;
&lt;p&gt;got successfully flash also getting deleted ID of previous. Before turn off dev board when i send fds_read(...);&amp;nbsp; getting correct buffer as flashed not getting empty. But when i switch off and ON board that time getting empty read from flash.&lt;/p&gt;
&lt;p&gt;Still i am finding the solution not working. the flash read write method is very irritated sometime work sometime not. Please can you provide other way for fix this issue.&lt;/p&gt;
&lt;p&gt;Thanks you..!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>