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

Turn off and on nrf51dk to test fds with what tool to view output

Hi,

I managed to get fds to store some information in nrf51dk for persistent data storage. I would like to check if the data is still available in the chip after power off and on. I have been using SEGGER RTT viewer and Eclipse IDE to compile the code to and run.

Since I will be doing a power off then turn back on, what/how/where can I view the printing output at? Previously I've been running the code from Eclipse IDE with SEGGER RTT at the same time but now that I am turning the chip off first, I'm not sure where can I view the printed output at?

Thank you.

  • Hi,

    When you store data to flash using the FDS module, you store your data with a FILE_ID and one or several keys where records are stored. E.g. File 1 with two records: 0x1111="Phone1", 0x2222="data: 12345". Before you store your data you define these IDs and keys:

    #define FILE_ID 0x0001 /* The ID of the file to write the records into. */
    #define RECORD_KEY_1 0x1111 /* A key for the first record. */
    #define RECORD_KEY_2 0x2222 /* A key for the second record. */
    

    When you turn off/on your device, you can use these keys to retrieve the data you stored. This can be done like this:

    #define FILE_ID     0x1111
    #define RECORD_KEY  0x2222
    fds_flash_record_t  flash_record;
    fds_record_desc_t   record_desc;
    fds_find_token_t    ftok;
    /* It is required to zero the token before first use. */
    memset(&ftok, 0x00, sizeof(fds_find_token_t));
    /* Loop until all records with the given key and file ID have been found. */
    while (fds_record_find(FILE_ID, RECORD_KEY, &record_desc, &ftok) == FDS_SUCCESS)
    {
        if (fds_record_open(&record_desc, &flash_record) != FDS_SUCCESS)
        {
            /* Handle error. */
        }
        /* Access the record through the flash_record structure. */
    
        //Here you can print your data with Segger RTT or over UART
        /* Close the record when done. */
        if (fds_record_close(&record_desc) != FDS_SUCCESS)
        {
            /* Handle error. */
        }
    }
    

    You can also take a look at how it's done here.

  • Yes I know. What I meant is, how can I check that the data is stored in the fds without having to be running it at the same time with the code? If I were to power off Nordic chip then turn back on, SEGGER RTT will not be able to display the printed output as it did previously when I run the code before it was turn off. So how can I view the printed output after I do a power off then on again?

  • Try to close the Segger RTT viewer, and start it again, and connect with it again. When you re-connect with Segger RTT the output should be printed. Then you can have a function that prints the fds data after fds initialization.

Related