How to use nRF9160's internal flash to store data

Hi,

I use the nRF9160dk and I want to use nRF9160's internal flash which has 1MB flash to store a few data. But I cannot find any guideline about using nRF9160's internal flash.

So how to use this 1MB flash to store data?

board: nrf9160dk
SDK: v2.5.0

Thanks,

Liza

Parents
  • Hi,

    Can you look at this blog post? It lists some storing alternatives available in Zephyr,

    regards

    Jared

  • Hi Jared,

    I study the NVS sample. I want to ask how to read the stored data instead of the Number of bytes read?

    Thanks,

    Liza

  • Hi Liza,

    As in the sample you would use the nvs_read() function to read the store data, after you have written it to NVS. The function takes in the ID and the data buffer the buffer where the data should be temporary stored in. Do you have any question related to this function?

    regards

    Jared 

  • Hi Jared,

    I write int data = 1000 to NVS, and then read from NVS reading = 1000. But after resetting the device, the reading becomes 232. I don't know what's wrong. 

    Best regards,

    Liza

Reply
  • Hi Jared,

    I write int data = 1000 to NVS, and then read from NVS reading = 1000. But after resetting the device, the reading becomes 232. I don't know what's wrong. 

    Best regards,

    Liza

Children
  • Hi Liza,

    Could you share your code?

    regards
    Jared 

  • Hi Jared,

    This is the source code:

    Best regards,

    Liza

  • Hi,

    You have an overflow in your code.uint8_t type can only hold values from 0 to 255. If you assign this 1000 then you get an overflow, which results in an incorrect value being stored.

    Try changing this to for example 250 and see if that fixes your issue,

    regards

    Jared 

  • Hi Jared,

    Thanks for your remind! I fix the problem.

    Best regards,

    Liza

  • Hi Jared,

    I notice that the default storage_partition=32KB. Could I configure the size to like 100KB?

    Best regards,

    Liza