I have Inited the pstorage
err_code = pstorage_init();
APP_ERROR_CHECK(err_code);
Here PSTORAGE_NUM_OF_PAGES=2(1page for bonding ,1page for my application use )
.and register my page
param.block_size = sizeof (m_sys_data_store) ;//36bytes
param.block_count = 1;
param.cb = sys_updata_storage_cb_handler;
err_code = pstorage_register(¶m, &mp_sys_info_flash);
here param.block_size=36 bytes
.Mine flash operation like this
err_code=sys_info_clear_from_flash();//==pstorage_clear(&mp_sys_info_flash, sizeof(m_sys_data_store));
if (err_code != NRF_SUCCESS)
{
return ;
}
for(err_code=0;err_code<4800000;err_code++){;}//wait for flash operation finish
m_sys_data_store._flag=0xaabbccdd;
err_code=sys_info_updata_to_flash(&m_sys_data_store);
if (err_code != NRF_SUCCESS)
{
return ;
}
for(err_code=0;err_code<4800000;err_code++){;}
sometime the write result is 0xaabbccdd
,but somtime is0xffffffff
, 0x00000000
or others.
the function sys_info_updata_to_flash
show as follow:
uint32_t sys_info_updata_to_flash(sys_info_store_block_t * sys_data)
{
uint32_t err_code;
pstorage_handle_t dest_block;
// Get block pointer from base
err_code = pstorage_block_identifier_get(&mp_sys_info_flash,0,&dest_block);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code=sizeof(m_sys_data_store);//test
err_code = pstorage_store(&dest_block,(uint8_t *)sys_data,sizeof(m_sys_data_store),0);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
return NRF_SUCCESS;
}
The porject base on SDK9.0,S130.Why does the flash operation be so complex?I have no ideal to solute it,help me please.