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

nrf52832 SDK12.3 FDS fds_stat problem

I use nrf52832 SDK12.3,S132.

I used to test "fds_record_write"function,when there is no flash space,it will return error--"FDS_ERR_NO_SPACE_IN_FLASH",then I call a fds_gc() when freeable_words>0. It used to work very well.I configured the FDS size to be 64KB.

record_write function code like this:

fds_write_flag = 0;
ret_code_t err_code = fds_record_write(&record_desc, &record);
fds_stat(&g_fdsState);
if (err_code != FDS_SUCCESS)
{
fds_write_flag = 1;
//fds_stat(&g_fdsState);
if(FDS_ERR_NO_SPACE_IN_FLASH == err_code )
{
if(g_fdsState.freeable_words > 0)
{
// call the garbage collector to empty them, don't need to do this all the time, this is just for demonstration
fds_gc_flag = 0;
err_code = fds_gc();
if (err_code != FDS_SUCCESS)
{
NRF_LOG_ERROR("fds_gc error=%d\r\n",err_code);
return err_code;
}
fds_wait_gc_finished();
err_code = fds_record_write(&record_desc, &record);
return err_code;//
}


But,recently I received a problem product,I got the fds_stat massage as follows:

first,it should have run out of space:

valid_records:"2216",dirty_records:"0",words_used:"38761",largest_contig:"43081",freeable_words:"0",allSpace_worlds:"16384"

sencond,i deleted 2000 records:

valid_records:"232",dirty_records:"1965",words_used:"38628",largest_contig:"43081",freeable_words:"13600",allSpace_worlds:"16384"

then,i deleted more,and write some records:

valid_records:"14",dirty_records:"2185",words_used:"38636",largest_contig:"43081",freeable_words:"15017",allSpace_worlds:"16384"

the value of "words_used" and "largest_contig" is impossible,

1.why "words_used" and "largest_contig" value can be the impossible value?

2.how can i flash the FDS flash space and reinitialize it with FDS API?

Related