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

Storing Data to flash memory

Hi

I am using the Nordic NRF52840_dk with SDK 16.

I want to store data to flash memory with Ble and uart enabled. I am using a external UART peripheral to receive data which, I then parse and broadcast via a ble advertisement.

However, I wish to store this data locally along with a start time for the logging. The data is received once per second. I want this stored inside a log which, I can later send to a mobile application.

I therefore, presume I need to use the flashwrite example. And my code is based on RTT.

I have a value stored as a string that comes in from a UART. I need to store this string in flash memory. I am presuming having a String array is a poor way to do it. Given that I have a requirement for logging for a day meaning 86400 entries of data.

What I want to happen is a command to be sent from the android app to start a log. And then a command to stop it.

Also for transmitting the data that is stored on Nordic board(when working). I am not sure if the nordic board is capable of making a bluetooth connection and, if not will making a Gatt connection.

  • I think it might be because I am always reading the same data? Which, is set by the code before mine. The dummy code. Therefore for reading the data how do I point it to the latest data inside of the flash storage?

    Also are multiple configurations allowed in the fds_example.h?

  • I don't know what to read out of your snippets. Is it the lines in the log saying "reading data dummy" that you refer to?

    Beause the only place I can see that you print that is from the line:

    NRF_LOG_INFO("Reading data %s.", m_sensor_cfg.device_name);//Print out the configurations bootcount member variable

    What do you expect it to say? Where does "dummy" come from, and where do you update it?

  • That is the line of code that should pull the data. I want that line of code to output the latest data I have entered into my flash storage.

    The line of code you highlighted always prints "Reading data dummy" even though the data I am pointing at in the line of code is the m_sensor_cfg. This has a device name set to "Sensor" not "dummy" thus my confusion.

    I am writing a new entry via my flash_storage_write_data function. This is the data I wish to read (latest).

  • What does p_data look like in the flash_storage_read_data() function right before you copy it over to the m_sensor_cfg?

    Try to set a breakpoint and watch that data.

    Did you wait for the write complete event before you read it?

  • When I place a breakpoint on  memcpy(&m_sensor_cfg, config.p_data, sizeof(configuration_t));

    I run over it and, it goes to NRF_BREAKPOINT_COND.

    So I am not sure how to test it.

    I presume I am writing the information incorrectly and reading it incorrectly.

    Given the aforementioned line of code should print out "sensor" as this is what I believe I write to the configuration file.

    However, I don't want to read the configuration file. I want to read the latest data.

    But, I can't find an example of where to do that in the sdk example code. Or the documentation.

Related