Assistance with FDS

schef gravatar image

asked 2017-02-06 12:53:29 +0100

Hi, I am testing https://github.com/hubuhubu/nRF52-fds...

I am on nrf52832 with sdk 12.2.0. I can't seem to make it work. What i have done:

  • Separated FDS stuff to separate file
  • Exposed the functions which are used by main file
  • Added files to my Makefile

And now i'm testing it in main.c with this code:

  c = SEGGER_RTT_WaitKey(); // will block until data is available
  if(c == 'r'){
    SEGGER_RTT_WriteString(0, "Resetting..\n");
  else if(c == '1')
    SEGGER_RTT_printf(0, "1\n");
    err_code = fds_test_init();
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  else if(c == '2')
    SEGGER_RTT_printf(0, "2\n");
    err_code = fds_test_find_and_delete();
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  else if(c == '3')
    SEGGER_RTT_printf(0, "3\n");
    err_code =fds_test_write();
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  else if(c == '4')
    SEGGER_RTT_printf(0, "4\n");
    err_code = fds_read();
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);

All functions return 0 as a result. But fds_read() does not find anything. Suggestions?

edit retag flag offensive close delete report spam

1 answer

Sort by ยป oldest newest most voted
Kristin gravatar image

answered 2017-02-06 13:50:13 +0100

updated 2017-02-07 14:26:45 +0100

Which error code does fds_read() return?

Update 07.02.2017: fds_read() should not return NRF_SUCCESS unless it successfully found the record, if it doesn't find the record, the error code should be returned.

static ret_code_t fds_read(void)
    #define FILE_ID     0x1111
    #define REC_KEY     0x2222
    fds_flash_record_t  flash_record;
    fds_record_desc_t   record_desc;
    fds_find_token_t    ftok ={0};//Important, make sure you zero init the ftok token
    uint32_t *data;
    uint32_t err_code;

    NRF_LOG_INFO("Start searching... \r\n");
    // Loop until all records with the given key and file ID have been found.
    while (fds_record_find(FILE_ID, REC_KEY, &record_desc, &ftok) == FDS_SUCCESS)
            err_code = fds_record_open(&record_desc, &flash_record);
            if ( err_code != FDS_SUCCESS)
                return err_code;        

            NRF_LOG_INFO("Found Record ID = %d\r\n",record_desc.record_id);
            NRF_LOG_INFO("Data = ");
            data = (uint32_t *) flash_record.p_data;
            for (uint8_t i=0;i<flash_record.p_header->tl.length_words;i++)
                NRF_LOG_INFO("0x%8x ",data[i]);
            // Access the record through the flash_record structure.
            // Close the record when done.
            err_code = fds_record_close(&record_desc);
            if (err_code != FDS_SUCCESS)
                return err_code;    
    return NRF_SUCCESS;     

When fds_record() is running, does it print the starting string, "start searching"?

Could you test the example I have been using for the testing, so that it is easier to compare your results with my results? It is the example from github placed in ble_app_hrs (SDK 12.2),to be used with S132 v. 3.0.0: ble_app_hrs-fds-test-github.zip

In the sdk_config.h file, you can change the logging module to use RTT instead of UART.

edit flag offensive delete publish link more


It returns 0.

schef ( 2017-02-06 14:08:04 +0100 )editconvert to answer

If you have a look at the fds_read() and the other fds test functions, they will return NRF_SUCCESS upon a successful operation/when it works correctly.

NRF_SUCCESS is defined the following way:

#define NRF_ERROR_BASE_NUM      (0x0)       ///< Global error base
#define NRF_SUCCESS                           (NRF_ERROR_BASE_NUM + 0)  ///< Successful command

It means that when fds_read returns '0', it returns NRF_SUCCESS.

Kristin ( 2017-02-06 14:15:57 +0100 )editconvert to answer

Yes. This is the issue. That it did not find the KEY/ID. If you look at the code https://github.com/hubuhubu/nRF52-fds... you can see that it returns 0 and does not print the data if data is not found.

schef ( 2017-02-06 14:32:03 +0100 )editconvert to answer

How do you check if the KEY/ID was found or not?

Kristin ( 2017-02-06 14:33:59 +0100 )editconvert to answer

In the code is a while loop. If it finds anything it enters the loop and prints out the content? Isn't that the procedure?

schef ( 2017-02-06 14:38:37 +0100 )editconvert to answer

Am i doing something wrong? When i write i got Writing Record ID = 1 message. But it does not read anything. I have #define FILE_ID 0x0022 and #define REC_KEY 0x0022as it is described on http://infocenter.nordicsemi.com/inde...

schef ( 2017-02-07 08:44:51 +0100 )editconvert to answer

I have updated my answer.

Kristin ( 2017-02-07 14:27:06 +0100 )editconvert to answer

For some reason you code doesn't execute to end, i have turned on the DEBUG flag and waiting for the breakpoint but there is none. I will try to add your code to my project.

schef ( 2017-02-07 16:06:50 +0100 )editconvert to answer

As it is put in a BLE example, it needs to be run with a softdevice present, S132 v.3.0.0.

Kristin ( 2017-02-08 11:44:16 +0100 )editconvert to answer

Yes i have tryed. I did't have to time to go deep into this problem. I wil come back when i grab some extra time. Thanks.

schef ( 2017-02-08 16:19:18 +0100 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower


Asked: 2017-02-06 12:53:29 +0100

Seen: 671 times

Last updated: feb. 07