fds_gc() garbage collect always causes a reset

Using SDK 17.1.0, SD s140_nrf52_7.2.0

I have FDS working - I can read/write records.  I am using it to store ongoing logs.

When I get to a FDS_ERR_NO_SPACE_IN_FLASH, I delete a certain number of records to make room.  Then call fds_gc().

fds_gc() always causes a reset.  After reset however, it seems to have done the needful, I have the expected amount of flash available again, and I can continue writing records until I hit a NO_SPACE error again.

Any ideas on what to do here ?

Thanks - Daraius

Parents
  • Hi,

    Calling fds_gc() in itself should not cause a reset. A reset is a typical mechanism used to recover from an error, for instance if a function call returns an unexpected error code, if an assert fails, or if a HardFault occurs in the chip, Do you have logging enabled in your application? The log normally tells you if there was an error, and if you build the application in Debug configuration, the log should tell you exactly where the error occured.

    You could also try to debug the application, by setting breakpoints at any calls to NVIC_SystemReset() and read out the call stack to see where the problem originated.

    Best regards,
    Jørgen

  • Hi Jorgen
    Thanks for your response.  Getting back to this.

    I added in a lot of serial debug messages and diagnostic commands to pursue this issue.
    I have a command that can generate a large number for records in FDS.  at some point an fds_record_write() results in a FDS_ERR_NO_SPACE_IN_FLASH error.  And then ...
    - Pick the N oldest records and proceed to delete them one by one
    - Run fds_gc()
    - Retry the write that failed and continue with the remaining writes.

    In this sequence of actions I see crashes during a Write and/or during fds_gc.
    But I have some general questions.

    1) Can you write multiple records (say 1000) in a hard for() loop back to back ?  I have been adding an nrf_delay_ms(2) in between each so that other tasks can run
    Same with Delete's can you run them back to back ?

    2) I am unclear how the fds_event handler works here.
    In your FDS example code with the SDK only 3 events are handled -
    FDS_EVT_INIT, _WRITE, _DEL_RECORD  and on the FDS_EVT_WRITE there are just NRF_LOG_INFO messages and no flag being set to indicate the operation is complete.
     
    There is no handling for FDS_EVT_DEL_FILE or FDS_EVT_GC
    Is it necessary to wait on the event handler for each operation ?

    Right now my crash is happening like this... in xPortSVHandler

    Earlier I have seen the Call stack show a series of Add Queue, Queue_Process calls before crashing.

    I have tried greatly increasing the FreeRTOS heap size and the task stack size during xTaskCreate()
    configMINIMAL_STACK_SIZE=360,  configTOTAL_HEAP_SIZE=32768

    None of that has helped.

Reply
  • Hi Jorgen
    Thanks for your response.  Getting back to this.

    I added in a lot of serial debug messages and diagnostic commands to pursue this issue.
    I have a command that can generate a large number for records in FDS.  at some point an fds_record_write() results in a FDS_ERR_NO_SPACE_IN_FLASH error.  And then ...
    - Pick the N oldest records and proceed to delete them one by one
    - Run fds_gc()
    - Retry the write that failed and continue with the remaining writes.

    In this sequence of actions I see crashes during a Write and/or during fds_gc.
    But I have some general questions.

    1) Can you write multiple records (say 1000) in a hard for() loop back to back ?  I have been adding an nrf_delay_ms(2) in between each so that other tasks can run
    Same with Delete's can you run them back to back ?

    2) I am unclear how the fds_event handler works here.
    In your FDS example code with the SDK only 3 events are handled -
    FDS_EVT_INIT, _WRITE, _DEL_RECORD  and on the FDS_EVT_WRITE there are just NRF_LOG_INFO messages and no flag being set to indicate the operation is complete.
     
    There is no handling for FDS_EVT_DEL_FILE or FDS_EVT_GC
    Is it necessary to wait on the event handler for each operation ?

    Right now my crash is happening like this... in xPortSVHandler

    Earlier I have seen the Call stack show a series of Add Queue, Queue_Process calls before crashing.

    I have tried greatly increasing the FreeRTOS heap size and the task stack size during xTaskCreate()
    configMINIMAL_STACK_SIZE=360,  configTOTAL_HEAP_SIZE=32768

    None of that has helped.

Children
No Data
Related