This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How store large amount data 73Kbytes into flash using FDS?

We are using nRF52840 with sdk 15.0 version & segger embedded studio. We are able to store some small amount of configuration data into flash using FDS. But now we want to store large data array near about 73Kbytes into flash. I am writing example code for storing this data and created one dummy array of size 73728 bytes. But I getting following ERROR:

FDS_ERR_RECORD_TOO_LARGE

I am confused for configuration of FDS for storing 73Kbytes 

Here is bellow edited in sdk_config.h

FDS_VIRTUAL_PAGES 10

FDS_VIRTUAL_PAGE_SIZE 2048

FDS_OP_QUEUE_SIZE 4

Will you please help me how i use this above configuration for storing 73KB data. & how i fixed FDS_ERR_RECORD_TOO_LARGE ERROR?

Is it possible to store this data in one fds_record_write (...) call request?

Thanks in advanced..!!

Parents
  • The number that you give for the FDS_VIRTUAL_PAGE_SIZE is actually 4-byte words. So you can save at a maximum of (2048-5)*4 = 8172 bytes. So you will need to split up your data if you want to save more than that.

  • Ok, Is it possible to increase FDS_VIRTUAL_PAGE_SIZE as per required data storage above of 2048. If i increase this i got ERROR 11 i.e. NRF_ERROR_INVALID_DATA when fds_flash_init();

    We will split our data with smaller chunks with multiple of above maximum limit. But still confused for is it needed to change record key every request of that.

    here is bellow my sample code snippet for storing dummy array of 73728bytes.

     

    void fds_data_write() {
      uint32_t length = 74000;
      uint8_t data_write[length];
    //  memset(data_write,2,sizeof(data_write));
      for (int i = 0; i<=length; i++) {
       data_write[i] = i;
      }
    //  NRF_LOG_INFO("fds_data_write");
      ret_code_t ret = fds_write(FILE_ID_READING_1, REC_KEY_READING_1,(char *)data_write,length);
      if (ret == FDS_SUCCESS) {
        NRF_LOG_DEBUG("FDS data stored");
      } else {
        NRF_LOG_DEBUG("FDS failed error code:%d", ret);
      }
    }

    Will you please provide me program snippet for how i call multiple request for storing 73KB data with FILE-ID and REC_KEY. Because after stored this data we want to also retrieve this data as required time.

    Lets say from above whole array first 8172 bytes stored of 1 request with specific FILE_ID & RECKEY, Then i should need to call next chunk data for that is it necessary to change RECKEY.

    Because if KECKEY is not change for second call request it will overwritten data on old. Is any other way to store this large data with one FILEID & KECKEY?

    Thanks.....

  • Means what not understand properly, Will you please explain in little bit more

    don't sit in a blocking loop waiting for the event

    Thanks..

  • Hey,

    You should not be waiting for an event inside the nus_data_handler.

    Either start the write from the main context by setting a flag variable or don't wait for the event in a blocking loop(wait_for_write).

    Check here for more info

  • What are the connection parameters in this case? FDS will try to schedule flash operations between BLE events, but it might be difficult if you have a short connection interval.

  • Hi Ashish & Einar, 

    Yes i am using nrf_fstorage_sd.c lib 

    Sorry for this wrong library said, actually this lib included in my project not used for write data into flash. But for writing data into flash i am using fds.c & fds.h library. 

    Here is below screen shot of  our set connection parameter:

    #define NUS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the Nordic UART Service (vendor specific). */
    
    #define APP_BLE_OBSERVER_PRIO 3 /**< Application's BLE observer priority. You shouldn't need to modify this value. */
    #define APP_ADV_INTERVAL 64     /**< 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 & handle their timeout by sperate app timer.*/ 
    
    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS)   //20           /**< 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           /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
    #define SLAVE_LATENCY 0                                      /**< Slave latency. */
    #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)     /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
    #define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000) /**< 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) /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
    #define MAX_CONN_PARAMS_UPDATE_COUNT 3                       /**< Number of attempts before giving up the connection parameter negotiation. */
    
    #define DEAD_BEEF 0xDEADBEEF      /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
    #define BOOTLOADER_DFU_START 0xB1 // Bootloader DFU
    
    #define UART_TX_BUF_SIZE 2048 /**< UART TX buffer size. */
    #define UART_RX_BUF_SIZE 2048 /**< UART RX buffer size. */

    Thanks..

Reply Children
No Data
Related