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

s130 pstorage problem

Hi,

I am trying to save/restore some configuration variables to/from the flash storage. If I do it using S110, it works perfectly fine and I can both store and read values. When I use S130 (using the example app_s130_demo codebase), I don't get any errors, I can read values if there is anything written on the flash storage, but I cannot store/update new values (the event callback is never called).

Any suggestion or comment would be highly appreciated.

Best,

Parents
  • The reason is that app_s130 demo was not written with pstorage in mind. It did not use softdevice_handler.c module and it has also overwritten SD_EVT_IRQHandler which softdevice_handler module needs to get events from nrf_soc module.

    your read works well because that does not make calls to softdevice and calls the registered callback from pstorage module itself.

    you can fix this by

    1. removing the overwritten SD_EVT_IRQHandler function in main.c
    2. adding softdevice_handler.c module and its dependencies to Keil
    3. Registering for system events and passing them on to pstorage module using the pstorage_sys_event_handler is mandatory for the module to function as expected. Code snippet below demonstrates what application needs to do for this.
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        pstorage_sys_event_handler(sys_evt);
    }
    
    void ble_ant_stack_init(void)
    {
    
        SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM,> false);
        
        uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
        
        err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    }
    

    you will then get your registered event callback from softdevice->softdevice_handler->pstorage->your app

Reply
  • The reason is that app_s130 demo was not written with pstorage in mind. It did not use softdevice_handler.c module and it has also overwritten SD_EVT_IRQHandler which softdevice_handler module needs to get events from nrf_soc module.

    your read works well because that does not make calls to softdevice and calls the registered callback from pstorage module itself.

    you can fix this by

    1. removing the overwritten SD_EVT_IRQHandler function in main.c
    2. adding softdevice_handler.c module and its dependencies to Keil
    3. Registering for system events and passing them on to pstorage module using the pstorage_sys_event_handler is mandatory for the module to function as expected. Code snippet below demonstrates what application needs to do for this.
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        pstorage_sys_event_handler(sys_evt);
    }
    
    void ble_ant_stack_init(void)
    {
    
        SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM,> false);
        
        uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
        
        err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    }
    

    you will then get your registered event callback from softdevice->softdevice_handler->pstorage->your app

Children
Related