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

how pstorage_register insure same address between startup?

it register a handler, what about restart and run pstorage_register again, how it insure everytime we get the same address for our content in the flash? before pstorage_register, we use flash_io, which we know the address, so no problem to access the right place in flash, so pstorage_register ensures the correct address by order of calling pstorage_register?

and PSTORAGE_MAX_APPLICATIONS, seems not for application, but defines how many pages we use? is there a max number of pages we can use? how to find out this number for nrf51822-xxaa-s110? as I recalled, 16k for softdevice, and size of app(how to find the size of app in the device?) anything else will take space?

Thanks!

  • I wish one of the Nordic employees would sit down and write a quick one page app note on how to use PSTORAGE with the new SDKs that also make use of it. I know there are examples but some of the terminology in the code is non-intuitive. The Nordic developers do a great job of writing code that is highly configurable but that brings with it a complexity that isn't always well explained solely through sample projects.

    Reflash timing and just the idea of writing into your own program space is one of those things I always want to double-check that I've done correctly on an embedded system, and one that works just fine... until the day that it stops working fine. :)

    Just my 2 cents. Dan Danknick

  • I second you on that. It's very risky as we all know bad pointers happen. Why don't Nordic just add a small serial eprom inside for data storage ?

  • if we change the data size, do we need to clear the system, and flash softdevice?

  • Have you read the official pstorage documentation which is included in the SDK, and also available here? https://devzone.nordicsemi.com/documentation/nrf51/5.2.0/html/a00131.html

  • Torbjørn,

    I apologize for missing this description in the SDK. The step by step instructions worked perfectly for me - after I changed PSTORAGE_MAX_APPLICATIONS from 2 to 3 in pstorage_platform.h

    I am not clear on why I needed to do that, honestly. The bond manager is the only other application it seems that uses the PStorage services. So it plus my user app = 2 (not 3).

    For all other developers please be mindful that if you have already run your app with with SDK and then you increase PSTORAGE_MAX_APPLICATIONS to now support your own NV storage needs, the bond manager code will likely hard fault when retrieving an illegal bond table. You must force a clear; in the ble_hrs demo this is accomplished by setting bonds_delete=true before calling the function in ble_bondmngr.c:

       // Erase all stored centrals if specified.
        if (m_bondmngr_config.bonds_delete)
        {
    ...
    

    Thank you for your excellent assistance, Dan Danknick

1 2