<?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>I can&amp;#39;t write data to flash.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52679/i-can-t-write-data-to-flash</link><description>Hi, 
 I have an application which has 2 services and 3 characteristics. I want to keep the value of characteristics when the characteristic value changed. I tried FDS and i can not make it so i tried Flash Storage and it didn&amp;#39;t work. I looked all examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Oct 2019 10:20:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52679/i-can-t-write-data-to-flash" /><item><title>RE: I can't write data to flash.</title><link>https://devzone.nordicsemi.com/thread/212771?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 10:20:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db2ceeb1-3d4b-4015-82a4-44480b4df49f</guid><dc:creator>Caner Celiktas</dc:creator><description>&lt;p&gt;I made it !! Thank you Einar !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I can't write data to flash.</title><link>https://devzone.nordicsemi.com/thread/212724?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 07:37:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27daeef5-6892-4916-ad96-14cbb7625248</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;FDS usage is not that complicated, you just need to understand the basics. FDS organizes records by file ID and record ID, and you can search for those. So when you store a record you provide the file and record ID, and when you want to read it you need to search for the same record ID. You can see a good description of this under &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_fds_usage.html?cp=5_1_3_55_3"&gt;Usage&lt;/a&gt; in the FDS documentation.&lt;/p&gt;
&lt;p&gt;So you need to fix this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write your records with whatever you select as record and file id(s)&lt;/li&gt;
&lt;li&gt;To read, search for the record(s) using&amp;nbsp;fds_record_find() as shown in the page I linked to.&lt;/li&gt;
&lt;li&gt;Open the record you have found with&amp;nbsp;fds_record_open() to read the actual data.&lt;/li&gt;
&lt;li&gt;Close the record with&amp;nbsp;fds_record_close() when you are don reading it.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I can't write data to flash.</title><link>https://devzone.nordicsemi.com/thread/212588?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2019 12:26:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa2b57e8-fd81-4513-9663-037987e437df</guid><dc:creator>Caner Celiktas</dc:creator><description>&lt;p&gt;I&amp;#39;m trying FDS and i think i can succesfully write flash. Here is my code and output(I cut the &lt;span&gt;irrelevant parts&lt;/span&gt;);&lt;/p&gt;
&lt;p&gt;My aim is still same. I want to keep characteristic value in flash and keep it safe when power lost. But i can&amp;#39;t assign the data in flash to my variable (&lt;strong&gt;uint16_t number&lt;/strong&gt;) when DK restart. When i cut power and restart DK, i checked the FDS stats and it said &amp;quot;2 valid 1 dirty record found&amp;quot;. I think i can write to the flash but i can not read the value from it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;

#include &amp;quot;our_service.h&amp;quot;
#include &amp;quot;fds_config.h&amp;quot;


#define SCHED_MAX_EVENT_DATA_SIZE       sizeof(app_button_cfg_t)
#define SCHED_QUEUE_SIZE                20        


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
fds_record_desc_t   record_desc;
fds_record_t        record;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                            /**&amp;lt; Advertising module instance. */


#define DEAD_BEEF                       0xDEADBEEF                              /**&amp;lt; Value used as error code on stack dump, can be used to identify stack location on stack unwind. */


int button_value;
uint16_t number;

static bool button_1;
static bool button_2;
static bool button_3;
static bool button_4;

static int TIME_COUNTER=0;





// Declare an app_timer id variable and define our timer interval and define a timer interval
APP_TIMER_DEF(m_our_char_timer_id);
APP_TIMER_DEF(m_our_char_timer_id_2);
APP_TIMER_DEF(m_our_char_timer_id_3);



int gpio_set(void)
{
  nrf_gpio_cfg_output(LED_1);
  nrf_gpio_cfg_output(LED_2);
  nrf_gpio_cfg_output(LED_3);
  nrf_gpio_cfg_output(LED_4);
  nrf_gpio_pin_set(LED_1);
  nrf_gpio_pin_set(LED_2);
  nrf_gpio_pin_set(LED_3);
  nrf_gpio_pin_set(LED_4);
}


void button_handler(uint8_t pin_no, uint8_t button_action)
{
    NRF_LOG_INFO(&amp;quot;Button press detected \r\n&amp;quot;);
    if(button_action == APP_BUTTON_PUSH)
    {
        switch(pin_no)
        {
            case BUTTON_1:
                nrf_gpio_pin_toggle(LED_1);
                NRF_LOG_INFO(&amp;quot;Button 1 pressed \r\n&amp;quot;);
                button_1 = true;
                break;
            case BUTTON_2:
                nrf_gpio_pin_toggle(LED_2);
                NRF_LOG_INFO(&amp;quot;Button 2 pressed \r\n&amp;quot;);
                button_2 = true;
                break;
            case BUTTON_3:
                nrf_gpio_pin_toggle(LED_3);
                NRF_LOG_INFO(&amp;quot;Button 3 pressed \r\n&amp;quot;);
                button_3 = true;
                break;
            case BUTTON_4:
                nrf_gpio_pin_toggle(LED_4);
                NRF_LOG_INFO(&amp;quot;Button 4 pressed \r\n&amp;quot;);
                button_4 = true;  
                break;
            default:
                break;
        }
    }
}

int buttons_init(void)
{
 static  app_button_cfg_t p_buttons[4] = {{BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                      {BUTTON_2, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                      {BUTTON_3, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                      {BUTTON_4, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}};
 app_button_init(p_buttons, 4, 5);

 app_button_enable();
}


// This is a timer event handler
static void timer_timeout_handler(void * p_context)
{
    // Update temperature characteristic and voltage characteristic value.
//    int32_t temperature = 0;   
//    sd_temp_get(&amp;amp;temperature);
    voltage = 0;
    voltage = saadc_measure();

      if(voltage &amp;lt; 0)   //don&amp;#39;t let adc value negative
         voltage = 0;

    our_voltage_characteristic_update(&amp;amp;m_our_service, &amp;amp;voltage);
    our_temperature_characteristic_update_2(&amp;amp;m_our_service, &amp;amp;number);

    if(button_value == 1)
    {
      nrf_gpio_pin_toggle(LED_4);
      number = 0x3132;
//      enter_Scheduler_flag = true;
//      app_sched_event_put(&amp;amp;saklanacak_deger, sizeof(saklanacak_deger), timer_scheduler_event_handler);
    }

}


static void timer_timeout_handler_2(void * p_context)
{
  ++TIME_COUNTER;

                
}
static void timer_timeout_handler_3(void * p_context)
{

}




/**@brief Function for the Timer initialization.
 *
 * @details Initializes the timer module. This creates and starts application timers.
 */
static void timers_init(void)
{
    // Initialize timer module.
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    app_timer_create(&amp;amp;m_our_char_timer_id, APP_TIMER_MODE_REPEATED, timer_timeout_handler);
                    
    app_timer_create(&amp;amp;m_our_char_timer_id_2, APP_TIMER_MODE_REPEATED, timer_timeout_handler_2);
//
    app_timer_create(&amp;amp;m_our_char_timer_id_3, APP_TIMER_MODE_REPEATED, timer_timeout_handler_3);
    
}




/**@brief Function for starting timers.
 */
static void application_timers_start(void)
{

    // Start our timer
    app_timer_start(m_our_char_timer_id, OUR_CHAR_TIMER_INTERVAL, NULL);     
                   
    app_timer_start(m_our_char_timer_id_2, APP_TIMER_TICKS(500), NULL);   
                       
    app_timer_start(m_our_char_timer_id_3, APP_TIMER_TICKS(5000), NULL);          

}








/**@brief Function for the Event Scheduler initialization.
 */
static void scheduler_init(void)
{
    APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
}


static void fds_evt_handler(fds_evt_t const * p_evt)
{
    NRF_LOG_INFO(&amp;quot;Event: %s received (%s)&amp;quot;,
                  fds_evt_str[p_evt-&amp;gt;id],
                  fds_err_str[p_evt-&amp;gt;result]);

    switch (p_evt-&amp;gt;id)
    {
        case FDS_EVT_INIT:
            if (p_evt-&amp;gt;result == FDS_SUCCESS)
            {
                m_fds_initialized = true;
            }
            break;

        case FDS_EVT_WRITE:
        {
            if (p_evt-&amp;gt;result == FDS_SUCCESS)
            {
                NRF_LOG_INFO(&amp;quot;Record ID:\t0x%04x&amp;quot;,  p_evt-&amp;gt;write.record_id);
                NRF_LOG_INFO(&amp;quot;File ID:\t0x%04x&amp;quot;,    p_evt-&amp;gt;write.file_id);
                NRF_LOG_INFO(&amp;quot;Record key:\t0x%04x&amp;quot;, p_evt-&amp;gt;write.record_key);
            }
        } break;

        case FDS_EVT_DEL_RECORD:
        {
            if (p_evt-&amp;gt;result == FDS_SUCCESS)
            {
                NRF_LOG_INFO(&amp;quot;Record ID:\t0x%04x&amp;quot;,  p_evt-&amp;gt;del.record_id);
                NRF_LOG_INFO(&amp;quot;File ID:\t0x%04x&amp;quot;,    p_evt-&amp;gt;del.file_id);
                NRF_LOG_INFO(&amp;quot;Record key:\t0x%04x&amp;quot;, p_evt-&amp;gt;del.record_key);
            }
            m_delete_all.pending = false;
        } break;

        default:
            break;
    }
}

/**@brief   Sleep until an event is received. */
static void power_manage(void)
{
#ifdef SOFTDEVICE_PRESENT
    (void) sd_app_evt_wait();
#else
    __WFE();
#endif
}

/**@brief   Wait for fds to initialize. */
static void wait_for_fds_ready(void)
{
    while (!m_fds_initialized)
    {
        power_manage();
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**@brief Function for application main entry.
 */
int main(void)
{   
    

    bool erase_bonds;
    // Initialize.
    log_init();
    
    ret_code_t ret;
    ret_code_t err_code;
    ret_code_t rc;
    gpio_set();
    timers_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    buttons_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    saadc_init();
    services_init();
    advertising_init();
    conn_params_init();
    peer_manager_init();
     
    // Start execution.
    NRF_LOG_INFO(&amp;quot;OurCharacteristics tutorial started.&amp;quot;);

    application_timers_start();
    advertising_start(erase_bonds);
    
    /* Register first to receive an event when initialization is complete. */
    (void) fds_register(fds_evt_handler);
    rc = fds_init();
    APP_ERROR_CHECK(rc);
    
  /* Wait for fds to initialize. */
     wait_for_fds_ready();
     
   // Set up record.
      record.file_id           = 0x0002;
      record.key               = 0x1002;
      record.data.p_data       = &amp;amp;number;
      record.data.length_words = (sizeof(number)+3)/sizeof(uint32_t);   /* one word is four bytes. */
 

     NRF_LOG_INFO(&amp;quot;FDS_REGISTER complete.&amp;quot;);


    // Enter main loop.
    for (;;)
    {
        idle_state_handle(); 
        //app_sched_execute();
        
        if(TIME_COUNTER&amp;gt;2)
        {
          TIME_COUNTER = 9;

          if(button_1 == true)
          {
            nrf_gpio_pin_toggle(LED_2);
            delete_all_begin();
            delete_all_process();

            button_1 = false;
          }
          else if(button_2 == true)
          {
                ret_code_t rc; 

           /* System config not found; write a new one. */
              NRF_LOG_INFO(&amp;quot;Writing config file...&amp;quot;);

              rc = fds_record_write(&amp;amp;record_desc, &amp;amp;record);
              APP_ERROR_CHECK(rc);

              button_2 = false;
          }
          else if (button_3 == true)
          {
                ret_code_t ret = fds_gc();
                APP_ERROR_CHECK(ret);
                NRF_LOG_INFO(&amp;quot;garbage collection returned %s\r\n&amp;quot;, fds_err_str[rc]);
                 button_3 = false;
          }
          else if(button_4 == true)
          {
                fds_stat_t stat = {0};

                rc = fds_stat(&amp;amp;stat);
                APP_ERROR_CHECK(rc);

                NRF_LOG_INFO(&amp;quot;Found %d valid records.&amp;quot;, stat.valid_records);
                NRF_LOG_INFO(&amp;quot;Found %d dirty records (ready to be garbage collected).&amp;quot;, stat.dirty_records);
    

                  fds_record_desc_t desc = {0};
                  fds_find_token_t  tok  = {0};

                  rc = fds_record_find(CONFIG_FILE, CONFIG_REC_KEY, &amp;amp;desc, &amp;amp;tok);
                  if (rc == FDS_SUCCESS)
                    {
                        /* A config file is in flash. Let&amp;#39;s update it. */
                        fds_flash_record_t config = {0};

                        /* Open the record and read its contents. */
                        rc = fds_record_open(&amp;amp;desc, &amp;amp;config);
                        APP_ERROR_CHECK(rc);

                        /* Copy the configuration from flash into m_dummy_cfg. */
                        memcpy(&amp;amp;record, config.p_data, sizeof(number));

                        NRF_LOG_INFO(&amp;quot;Config file found, updating boot count to %d.&amp;quot;, m_dummy_cfg.boot_count);

           

                        /* Close the record when done reading. */
                        rc = fds_record_close(&amp;amp;desc);
                        APP_ERROR_CHECK(rc);

//                        /* Write the updated record to flash. */
//                        rc = fds_record_update(&amp;amp;desc, &amp;amp;m_dummy_record);
//                        APP_ERROR_CHECK(rc);
                    }
//                    else
//                    {
//                        /* System config not found; write a new one. */
//                        NRF_LOG_INFO(&amp;quot;Writing config file...&amp;quot;);
//
//                        rc = fds_record_write(&amp;amp;desc, &amp;amp;m_dummy_record);
//                        APP_ERROR_CHECK(rc);
//                    }
            button_4 = false;
          }
        
        }
        
    }
}


/**
 * @}
 */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;fds_config.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;fds.h&amp;quot;
#include &amp;quot;nrf_fstorage.h&amp;quot;
#include &amp;quot;nrf_fstorage_sd.h&amp;quot;

#define CONFIG_FILE     0x0001
#define CONFIG_REC_KEY  0x1000


/* Keep track of the progress of a delete_all operation. */
static struct
{
    bool delete_next;   //!&amp;lt; Delete next record.
    bool pending;       //!&amp;lt; Waiting for an fds FDS_EVT_DEL_RECORD event, to delete the next record.
} m_delete_all;



/* A dummy structure to save in flash. */
typedef struct
{
    uint32_t boot_count;
    char     device_name[16];
    bool     config1_on;
    bool     config2_on;
} configuration_t;


/* Array to map FDS return values to strings. */
char const * fds_err_str[] =
{
    &amp;quot;FDS_SUCCESS&amp;quot;,
    &amp;quot;FDS_ERR_OPERATION_TIMEOUT&amp;quot;,
    &amp;quot;FDS_ERR_NOT_INITIALIZED&amp;quot;,
    &amp;quot;FDS_ERR_UNALIGNED_ADDR&amp;quot;,
    &amp;quot;FDS_ERR_INVALID_ARG&amp;quot;,
    &amp;quot;FDS_ERR_NULL_ARG&amp;quot;,
    &amp;quot;FDS_ERR_NO_OPEN_RECORDS&amp;quot;,
    &amp;quot;FDS_ERR_NO_SPACE_IN_FLASH&amp;quot;,
    &amp;quot;FDS_ERR_NO_SPACE_IN_QUEUES&amp;quot;,
    &amp;quot;FDS_ERR_RECORD_TOO_LARGE&amp;quot;,
    &amp;quot;FDS_ERR_NOT_FOUND&amp;quot;,
    &amp;quot;FDS_ERR_NO_PAGES&amp;quot;,
    &amp;quot;FDS_ERR_USER_LIMIT_REACHED&amp;quot;,
    &amp;quot;FDS_ERR_CRC_CHECK_FAILED&amp;quot;,
    &amp;quot;FDS_ERR_BUSY&amp;quot;,
    &amp;quot;FDS_ERR_INTERNAL&amp;quot;,
};

/* Array to map FDS events to strings. */
static char const * fds_evt_str[] =
{
    &amp;quot;FDS_EVT_INIT&amp;quot;,
    &amp;quot;FDS_EVT_WRITE&amp;quot;,
    &amp;quot;FDS_EVT_UPDATE&amp;quot;,
    &amp;quot;FDS_EVT_DEL_RECORD&amp;quot;,
    &amp;quot;FDS_EVT_DEL_FILE&amp;quot;,
    &amp;quot;FDS_EVT_GC&amp;quot;,
};

/* Dummy configuration data. */
static configuration_t m_dummy_cfg =
{
    .config1_on  = false,
    .config2_on  = true,
    .boot_count  = 0x0,
    .device_name = &amp;quot;dummy&amp;quot;,
};

/* A record containing dummy configuration data. */
static fds_record_t const m_dummy_record =
{
    .file_id           = CONFIG_FILE,
    .key               = CONFIG_REC_KEY,
    .data.p_data       = &amp;amp;m_dummy_cfg,
    /* The length of a record is always expressed in 4-byte units (words). */
    .data.length_words = (sizeof(m_dummy_cfg) + 3) / sizeof(uint32_t),
};

/* Flag to check fds initialization. */
static bool volatile m_fds_initialized;


bool record_delete_next(void)
{
    fds_find_token_t  tok   = {0};
    fds_record_desc_t desc  = {0};

    if (fds_record_iterate(&amp;amp;desc, &amp;amp;tok) == FDS_SUCCESS)
    {
        ret_code_t rc = fds_record_delete(&amp;amp;desc);
        if (rc != FDS_SUCCESS)
        {
            return false;
        }

        return true;
    }
    else
    {
        /* No records left to delete. */
        return false;
    }
}


/**@brief   Begin deleting all records, one by one. */
void delete_all_begin(void)
{
    m_delete_all.delete_next = true;
}


/**@brief   Process a delete all command.
 *
 * Delete records, one by one, until no records are left.
 */
void delete_all_process(void)
{
    if (   m_delete_all.delete_next
        &amp;amp; !m_delete_all.pending)
    {
        NRF_LOG_INFO(&amp;quot;Deleting next record.&amp;quot;);

        m_delete_all.delete_next = record_delete_next();
        if (!m_delete_all.delete_next)
        {
            NRF_LOG_INFO(&amp;quot;No records left to delete.&amp;quot;);
        }
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Output:&lt;/p&gt;
&lt;p&gt;Button 1 : Delete record one by one.(i think it deletes last one am i right?)&lt;/p&gt;
&lt;p&gt;Button 2 : Write variable&amp;nbsp;&lt;strong&gt;number&lt;/strong&gt; to flash.&lt;/p&gt;
&lt;p&gt;Button 3 : Run GC.&lt;/p&gt;
&lt;p&gt;Button 4 : Show stats.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: OurCharacteristics tutorial started.
&amp;lt;info&amp;gt; app: Fast advertising.
&amp;lt;info&amp;gt; app: Event: FDS_EVT_INIT received (FDS_SUCCESS)
&amp;lt;info&amp;gt; app: FDS_REGISTER complete.

&amp;lt;info&amp;gt; app: Button press detected
&amp;lt;info&amp;gt; app: Button 2 pressed
&amp;lt;info&amp;gt; app: Writing config file...
&amp;lt;info&amp;gt; app: Event: FDS_EVT_WRITE received (FDS_SUCCESS)
&amp;lt;info&amp;gt; app: Record ID:  0x0001
&amp;lt;info&amp;gt; app: File ID:    0x0002
&amp;lt;info&amp;gt; app: Record key: 0x1002
&amp;lt;info&amp;gt; app: Button press detected

&amp;lt;info&amp;gt; app: Button press detected
&amp;lt;info&amp;gt; app: Button 4 pressed
&amp;lt;info&amp;gt; app: Found 1 valid records.
&amp;lt;info&amp;gt; app: Found 1 dirty records (ready to be garbage collected).
&amp;lt;info&amp;gt; app: Button press detected


&amp;lt;info&amp;gt; app: Button press detected
&amp;lt;info&amp;gt; app: Button 3 pressed
&amp;lt;info&amp;gt; app: garbage collection returned FDS_ERR_NOT_FOUND
&amp;lt;info&amp;gt; app: Event: FDS_EVT_GC received (FDS_SUCCESS)
&amp;lt;info&amp;gt; app: Button press detected

&amp;lt;info&amp;gt; app: Button press detected
&amp;lt;info&amp;gt; app: Button 4 pressed
&amp;lt;info&amp;gt; app: Found 1 valid records.
&amp;lt;info&amp;gt; app: Found 0 dirty records (ready to be garbage collected).
&amp;lt;info&amp;gt; app: Button press detected

&amp;lt;info&amp;gt; app: Button press detected
&amp;lt;info&amp;gt; app: Button 1 pressed
&amp;lt;info&amp;gt; app: Deleting next record.
&amp;lt;info&amp;gt; app: Event: FDS_EVT_DEL_RECORD received (FDS_SUCCESS)
&amp;lt;info&amp;gt; app: Record ID:  0x0001
&amp;lt;info&amp;gt; app: File ID:    0x0002
&amp;lt;info&amp;gt; app: Record key: 0x1002
&amp;lt;info&amp;gt; app: Button press detected
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How fds retrieve value ?Does it copy the data inside of flash to &lt;strong&gt;record.data.p_data&lt;/strong&gt; ?&lt;/p&gt;
&lt;p&gt;I am very confused...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I can't write data to flash.</title><link>https://devzone.nordicsemi.com/thread/212554?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2019 11:42:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cba04c0b-4ce6-4782-9a1f-55de18b80cf0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not immediately see the problem, but I have a few questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In what way does it not work? Please explain in detail.
&lt;ul&gt;
&lt;li&gt;Do you get some error returned from a function call?&lt;/li&gt;
&lt;li&gt;Do you not get the expected events?&lt;/li&gt;
&lt;li&gt;Do you not read back valid data?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Can you upload the log from running your app? (I see you have logging in the fstorage event handler). Before that, it would be useful to add logging in your&amp;nbsp;fstorage_write(),&amp;nbsp;fstorage_read() and&amp;nbsp;fstorage_erase() functions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the way, I recommend you go back to using FDS. Since you need to update the data, FDS is probably what you want, as that gives you all the functionality you need for free.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>