FDS CRC READ CHECK ERR

sdk:17.1
example: ble_app_uart+ secure_bootloader.

// <h> CRC - CRC functionality

//==========================================================
// <e> FDS_CRC_CHECK_ON_READ - Enable CRC checks.

// <i> Save a record's CRC when it is written to flash and check it when the record is opened.
// <i> Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened.
// <i> Additionally, they will not be garbage collected until they are deleted.
//==========================================================
#ifndef FDS_CRC_CHECK_ON_READ
#define FDS_CRC_CHECK_ON_READ 1
#endif
// <o> FDS_CRC_CHECK_ON_WRITE  - Perform a CRC check on newly written records.
 

// <i> Perform a CRC check on newly written records.
// <i> This setting can be used to make sure that the record data was not altered while being written to flash.
// <1=> Enabled 
// <0=> Disabled 

#ifndef FDS_CRC_CHECK_ON_WRITE
#define FDS_CRC_CHECK_ON_WRITE 0
#endif


Recently my device sometimes returns FDS_ERR_CRC_CHECK_FAILED in this code 'err_code = fds_record_open(&desc, &config);APP_ERROR_CHECK(err_code);'

when it switches on and off.Eventually it died in the bootloader and couldn't get out.

This is not an inevitable situation, but it does happen. He can't fix it by DFU another firmware, unless it's a DFU upgrade package that FDS_CRC_CHECK_ON_READ set 0.

So I want to know, if I set FDS_CRC_CHECK_ON_READ to 0, will it have any bad effect on my data storage? Or is there any other way to solve the read crc error?

  • Hi Vidar

    so the CRC will become invalid if the data is altered between the time the flash operation is scheduled and when it is complete.

    I don't understand this because, as you can see from the above code, every time I decide to write flash area data, I wait for 2s before writing the data. This 2s time is sufficient for the last update of flash data.

    Am I not waiting for the flash update data operation to complete before going to sleep, resulting in a CRC error?

    Best Regard 
    Kenyon

  • Hi Kenyon,

    kenyon said:
    I don't understand this because, as you can see from the above code, every time I decide to write flash area data, I wait for 2s before writing the data. This 2s time is sufficient for the last update of flash data.

    I was wondering if there were other places in the application that may update the 'gtPara' variable while the FDS update task is pending. I would recommend you inspect the FDS pages in flash and see if you can find the data record and see if the data is stored correctly or not, or if it contain corrupted values. The storage format is documented here: Storage format.

    kenyon said:
    Am I not waiting for the flash update data operation to complete before going to sleep, resulting in a CRC error?

    The File ID should also have been missing in that case, resulting in the data record not being found.

    Best regards,

    Vidar

Related