fds_gc() cause error:

I am using FDS as recommended in nRF datasheet as API for on-chip flash : https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fgroup__flash__data__storage.html

I can successfully read and write various sizes of data into flash, however, I find Nordic provided fds_gc() is causing unalignment when wiping memory as this error:

<error> nrf_fstorage: addr_is_page_aligned(p_fs, page_addr) check failed in nrf_fstorage_erase() with value 0x10.

I am pretty sure I am not the only one having this issue. The only time I called to fds_record_delete is here:

/*!
 *  @brief    find and delete data from non volatile flash memory on nrf52832.
 *
*  @param     file_id    : 1st tracking ID for stored data. User faced, not the real number being used in low level driver
                            record_key : 2nd tracking ID for stored data. User faced, not the real number being used in low level driver

 *
 *  @returns  ret_code_t
 */
 ret_code_t fds_test_find_and_delete (uint16_t file_id, uint16_t record_key)
{
        file_id++;
        fds_record_desc_t   record_desc;
        fds_find_token_t    ftok;

        ftok.page=0;
        ftok.p_addr=NULL;
        // Loop and find records with same ID and rec key and mark them as deleted.
        while (fds_record_find(file_id, record_key, &record_desc, &ftok) == NRF_SUCCESS)
        {
            ret_code_t ret = fds_record_delete(&record_desc);
                if (ret != NRF_SUCCESS)
                {
                        return ret;
                }
            NRF_LOG_INFO("Deleted record ID: %d",record_desc.record_id);
            ut_DelayMs(50);
        }
//      // call the garbage collector to empty them, don't need to do this all the time, this is just for demonstration
//      ret_code_t ret = fds_gc();
//      if (ret != NRF_SUCCESS)
//      {
//              return ret;
//      }
        return NRF_SUCCESS;
}

fds_record_delete marks this data as dirty, then fds_gc() later clears this data and reformats the flash.

Is there anything I can do to fix this issue?

Parents
  • We have not seen this issue before and it seems a bit drastic that the fds_gc is wiping the flash.

    Is it possible for you to help us reproduce this error at our end? Give is the full compilable project and the steps to reproduce it. I will have to allocate some time to debug this. You would not have issues like this when you use nRF Connect SDK. Is there any reason you are using old deprecated SDK for prototyping for your project?

  • Thanks for the reply!
    We later figured there is not enough time given for wiping the flash, after giving it 1 second to flash, it has been working good.

    We only have experience on Old SDK, is there a tutorial or some guidance on migrating existing project from nRF5 SDK to nRF Connect SDK?

    We have checked some documents around the comparison between nRF5 SDK and nRF connect. They are quite different on many level.

  • kc9999 said:
    Thanks for the reply!
    We later figured there is not enough time given for wiping the flash, after giving it 1 second to flash, it has been working good.

    Great that you found the reason to be more wait time. Erasing flash is a time consuming process if you are wiping all the pages in the flash.

    kc9999 said:
    We only have experience on Old SDK, is there a tutorial or some guidance on migrating existing project from nRF5 SDK to nRF Connect SDK?
    Migrating a project from nRF5 SDK to nRF Connect SDK can be a complex process as these SDKs are fundamentally different. Unfortunately, there isn't a direct migration guide available for this process. Depending on your project setup, it might be more efficient to start from scratch in the nRF Connect SDK. A modular project is generally easier to migrate than non-modular projects.
    If this is the first product you are making, then I am surprised that you started with such an old SDK. .
    However, the nRF Connect SDK provides migration guides for all major and minor releases, which can assist users in transitioning from the previous release.
    For example, if you are migrating your application from nRF Connect SDK v2.5.0 to nRF Connect SDK v2.6.0, you can refer to the Migration guide for nRF Connect SDK v2.6.0. Similarly, for migrating from nRF Connect SDK v2.6.0 to nRF Connect SDK v2.7.0, you can refer to the Migration guide for nRF Connect SDK v2.7.0.
    To answer your question in short, we do not have a migration guide to help that, we only have this statement about the difference.
Reply
  • kc9999 said:
    Thanks for the reply!
    We later figured there is not enough time given for wiping the flash, after giving it 1 second to flash, it has been working good.

    Great that you found the reason to be more wait time. Erasing flash is a time consuming process if you are wiping all the pages in the flash.

    kc9999 said:
    We only have experience on Old SDK, is there a tutorial or some guidance on migrating existing project from nRF5 SDK to nRF Connect SDK?
    Migrating a project from nRF5 SDK to nRF Connect SDK can be a complex process as these SDKs are fundamentally different. Unfortunately, there isn't a direct migration guide available for this process. Depending on your project setup, it might be more efficient to start from scratch in the nRF Connect SDK. A modular project is generally easier to migrate than non-modular projects.
    If this is the first product you are making, then I am surprised that you started with such an old SDK. .
    However, the nRF Connect SDK provides migration guides for all major and minor releases, which can assist users in transitioning from the previous release.
    For example, if you are migrating your application from nRF Connect SDK v2.5.0 to nRF Connect SDK v2.6.0, you can refer to the Migration guide for nRF Connect SDK v2.6.0. Similarly, for migrating from nRF Connect SDK v2.6.0 to nRF Connect SDK v2.7.0, you can refer to the Migration guide for nRF Connect SDK v2.7.0.
    To answer your question in short, we do not have a migration guide to help that, we only have this statement about the difference.
Children
No Data
Related