This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Retrieve saved info on restard with pstorage module

Hello,

I need to store some app configuration on the FLASH and I'd like to use the features of pstorage module. I don't understand the following thing ...

When the application starts, it uses the pstorage_register (after the pstorage_init of course) to register itself to the pstorage module and then uses it with load and store feature. On restart I can't read what I stored on the previous execution. How for each reboot of application the pstorage knows what's my app FLASH area with my saved info ? I can't find this information ...

Thanks. Paolo.

rgr_cfg.c rgr_cfg.h

  • Hi ... I discovered that if I comment the device manager initialization function in the main ...

    // device_manager_init(erase_bonds);

    Now my code works fine I can save and retrieve data on reboot. What could be the reason my code doesn't work with device manager activated ?

    Thanks, Paolo.

  • it should work fine, did you reserve enough pages in pstorage_platform.h file for both device_manager and your application? which SDK version are you using? if the pstorage_registration of device manager and your app has both succeeded then I do not see how it could fail. can you please post your pstorage_platform.h file contents?

  • I modified my answer attaching the pstorage_platform.h and part of function I'm using for testing. However now it seems not working (it's driving me crazy) ... following output on console :

    After init and register ...
    pstorage_block_identifier_get err_code = 0
    block_handle.block_id = 259072
    
    Saving ...
    pstorage_store err_code = 0
    block_handle.block_id p_handle=536885712, op_code=2, result=0, p_data=536889912,
     data_len=4
    p_data[0] = 16
    p_data[1] = 32
    p_data[2] = 48
    p_data[3] = 64
    = 259072
    
    Reading ...
    pstorage_block_identifier_get err_code = 0
    block_handle.block_id = 259072
    p_handle=536889896, op_code=3, result=0, p_data=536889904, data_len=4
    p_data[0] = 16
    p_data[1] = 0
    p_data[2] = 0
    p_data[3] = 0
    pstorage_load err_code = 0
    p_data[0] = 16
    p_data[1] = 0
    p_data[2] = 0
    p_data[3] = 0
    

    As you can see only first byte is valid (16) the others are 0 !

  • I just changed my code defining data as static and 4 bytes aligned but the result is the same ..

    static uint8_t data[4] attribute((aligned(4)));

  • are you doing pstorage_init twice? in device_manager_init and in your code? it should be done only once. pstorage register can be done multiple times if possible please post your main.c, you can delete the file after we solve this issue

Related