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

  • Already checked ... always the same

  • did you wait for your pstorage_callback to return success? if you have restarted your chip before the pstorage_store operation is complete, then it wont be in the flash. pstorage_store

  • Also i am assuming that you have done this

        // Register with the SoftDevice handler module for BLE events.
        err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    
    
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        pstorage_sys_event_handler(sys_evt);
         .......
    }
    

    else you will not get pstorage callbacks and you cannot know if you have finished flash write succesfully or not. This info is given here

  • The SoftDevice handler is registered in the main.c and it works for device manager too. I don't shutdown the board immediately and I can see on the serial console the information I print out inside the pstorage callback. The info said me that the store operation is successful.

  • Here in the first execution I have the opcode 2 in the callback (STORE) with right data. I wrote 0x10 0x20 0x30 0x40 just for test and read first two bytes from the p_data.

    pstorage_register err_code = 0
    m_storage_handle.block_id = 260096
    pstorage_block_identifier_get err_code = 0
    block_handle.block_id = 260096
    block_handle.block_id err_code = p_handle=536885720, op_code=2, result=0, p_data
    =536889984, data_len=4
    p_data[0] = 16, p_data[1] = 32
    260096
    
    On restart I have the opcode 3 in the callback (LOAD) but p_data return me 0x00 for the first two bytes.
    
    pstorage_register err_code = 0
    m_storage_handle.block_id = 260096
    pstorage_block_identifier_get err_code = 0
    block_handle.block_id = 260096
    p_handle=536889976, op_code=3, result=0, p_data=536889984, data_len=2
    p_data[0] = 0, p_data[1] = 0
    pstorage_load err_code = 0
    
Related