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

data appending flash storage

Hello everyone,

I have trying to store my serial data in nrf52832 SDK15.2 fs flash storage i need to appending data one by one in same file. i have using fds_record_update() concet to appending data finaly i read file data using fds_record_open() this function only getting last updated data other data missing...???

How do i get all appending data get in single read function. please suggest any example code for appending one by one in nrf52 flash

Parents
  • i need to appending data one by one in same file

    Not quite sure what you mean by that, but appending data 1 byte at a time is probably not a great idea!

    It would probably be better to collect the data until you have a reasonable-sized block to write...

  • Hello awneil,

    I have received mac id serial one by one some interval duration. i need appending when mac id come serial get and store previous stored data in flash storage.

    I need example code for like this functionality

Reply
  • Hello awneil,

    I have received mac id serial one by one some interval duration. i need appending when mac id come serial get and store previous stored data in flash storage.

    I need example code for like this functionality

Children
  • Hello,

    If you use fds_record_update() it will replace the old record with the new one, so either you need to read, append and write a new record with all the data that you wish to store, or alternatively write a new record, instead of updating the old one.

  • I already try this function fds_record_update().  Record ID increase every appending but  i was read overall data using this function fds_record_open(). I got last appending mac id only. other mac id missing. How can i get writing all mac id...???

    This is my example function

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    struct {
    uint8_t value[1000];
    } __ALIGN(4) FS_data;
    bool Fs_write(const uint8_t *data, uint16_t len, uint16_t recordKey) {
    fds_record_desc_t record_desc;
    fds_find_token_t ftok = {0};
    ret_code_t rc;
    memcpy(&FS_data.value, data, len);
    if (fds_record_find(FILE_ID, recordKey, &record_desc, &ftok) == FDS_SUCCESS) {
    fds_record_t const rec = {
    .file_id = DATA_STORE_FILE_ID,
    .key = recordKey,
    .data.p_data = &FS_data,
    .data.length_words = (len + sizeof(uint32_t)-1) / sizeof(uint32_t)
    };
    rc = fds_record_update(&record_desc, &rec);
    return (rc == FDS_SUCCESS);
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Edvin said:
    If you use fds_record_update() it will replace the old record with the new one

     Yes. That is how it is intended to work. You have to use fds_record_write with a new record ID in order to add new data and keep the old one.