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

FDS not able to write in SDK 14

Dear all,

I'm struggling writing 32 bytes with FDS in SDK 14.

This is what I do:

Init

(void) fds_register(fds_evt_handler);
fds_init();
while(!is_init) {
    sd_app_evt_wait();
}

Write

fds_record_t        record;
fds_record_desc_t   record_desc = {0};

record.file_id              = FILE_ID;
record.key                  = key;
record.data.p_data        = data;
record.data.length_words      =  (length+3)/ sizeof(uint32_t);
fds_record_write(&record_desc, &record);

I do see that the header is written and on next startup fds_stat returns one more dirty record, but fds_evt_handler is never called with FDS_EVT_WRITE. It is called with FDS_EVT_INIT though, so it seems to basically work. I've read in other posts (mostly concerning older SDKs) that one should check that a soc_evt_handler forwards events to fds_evt_handler, but after

NRF_SDH_SOC_OBSERVER(m_soc_observer, APP_SOC_OBSERVER_PRIO, soc_evt_handler, NULL);

soc_evt_handler is never called.

Any help?

Parents
  • Chris's and Jukka's answer fixed me!  I just want to add my symptoms so this might come up earlier in searches:

    • An application run would either never get its FDS_EVT_INIT callback or would get it immediately.
    • Each time I started my application, my FDS pages (m_pages in fds.c) would be one state closer to inited.  So I could start->stop->start->stop->start->stop, and eventually they'd hit the `ALREADY_INSTALLED` return in fds_init(), which would get me my `FDS_EVT_INIT` callback and my app would start.
      • The fact the pages changed each time I started the app seemed to show that the writes were _happening_, just that some callbacks weren't happening
    • Further debugging in `nrf_fstorage_sd.c` (fstorage's softdevice implementation) seemed to show that it never got its `nrf_fstorage_sys_evt_handler` callback, which seemed likely to be needed in order for FDS to eventually get the callback it needed.  Since `nrf_fstorage_sys_evt_handler` is registered with `NRF_SDH_SOC_OBSERVER`, that's what got me on the scent of nrf_sdh_soc, and what led me to this answer.

    Fixed for me just by adding nrf_sdh_soc.c to my makefile - I didn't have to add a stub, but I also don't have any optimizations on.  I had missed adding it to my makefile while migrating from SDK 11.0.  Now I'm worried there's other files I've missed...

    I'm using Softdevice S332 5.0.0, API 14.2 (17b948a)

Reply
  • Chris's and Jukka's answer fixed me!  I just want to add my symptoms so this might come up earlier in searches:

    • An application run would either never get its FDS_EVT_INIT callback or would get it immediately.
    • Each time I started my application, my FDS pages (m_pages in fds.c) would be one state closer to inited.  So I could start->stop->start->stop->start->stop, and eventually they'd hit the `ALREADY_INSTALLED` return in fds_init(), which would get me my `FDS_EVT_INIT` callback and my app would start.
      • The fact the pages changed each time I started the app seemed to show that the writes were _happening_, just that some callbacks weren't happening
    • Further debugging in `nrf_fstorage_sd.c` (fstorage's softdevice implementation) seemed to show that it never got its `nrf_fstorage_sys_evt_handler` callback, which seemed likely to be needed in order for FDS to eventually get the callback it needed.  Since `nrf_fstorage_sys_evt_handler` is registered with `NRF_SDH_SOC_OBSERVER`, that's what got me on the scent of nrf_sdh_soc, and what led me to this answer.

    Fixed for me just by adding nrf_sdh_soc.c to my makefile - I didn't have to add a stub, but I also don't have any optimizations on.  I had missed adding it to my makefile while migrating from SDK 11.0.  Now I'm worried there's other files I've missed...

    I'm using Softdevice S332 5.0.0, API 14.2 (17b948a)

Children
No Data
Related