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

Flash write works, but when i do hard/soft reset data is lost ?

Hi, i'm using a code to save 4 bytes on the flash memory and it works. In, fact i checked the data address concerned using the keil and i see the changes when i write and it works well (data address 0x0003F400 ). I used this method before on another project (using another SDK and SD 130 0.9alpha) and now i'm using s130_nrf51_2.0.0-7.alpha_softdevice and another SDK of course.. It 's really strange, every thing is ok, i can write and change data values , only when i reset, every thing become FF FF FF FF :( Any idea please to check my code ?

  • you said "use the page that is not used by pstorage or other modules." : is that any way to know how to have a page that it's not used, i don't even know how that the address 0x0003f400 was chosen. In anther project , i did month ago, the chosen address was 0x0003f800 :/ . this the code of bonding, that erases the flash :

     static void device_manager_init(bool erase_bonds)
        {
        uint32_t               err_code;
        dm_init_param_t        init_param = {.clear_persistent_data = erase_bonds};
        dm_application_param_t register_param;
    
    // Initialize persistent storage module.
    err_code = pstorage_init();
    APP_ERROR_CHECK(err_code);
    
    err_code = dm_init(&init_param);
    APP_ERROR_CHECK(err_code);
    
    memset(&register_param.sec_param, 0, sizeof(ble_gap_sec_params_t));
    
    register_param.sec_param.bond         = SEC_PARAM_BOND;
    register_param.sec_param.mitm         = SEC_PARAM_MITM;
    register_param.sec_param.io_caps      = SEC_PARAM_IO_CAPABILITIES;
    register_param.sec_param.oob          = SEC_PARAM_OOB;
    register_param.sec_param.min_key_size = SEC_PARAM_MIN_KEY_SIZE;
    register_param.sec_param.max_key_size = SEC_PARAM_MAX_KEY_SIZE;
    register_param.evt_handler            = device_manager_evt_handler;
    register_param.service_type           = DM_PROTOCOL_CNTXT_GATT_SRVR_ID;
    
    err_code = dm_register(&m_app_handle, &register_param);
    APP_ERROR_CHECK(err_code);
    

    }

Related