Hi,
I am using nrfsdk11 nrf52 and s132 soft device. In my code,I am doing this in main();
void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result)
{
if (result != FS_SUCCESS)
{
// bsp_indication_set(BSP_INDICATE_FATAL_ERROR);
APP_ERROR_CHECK(result);
}
else
{
fs_callback_flag = 0;
}
}
FS_REGISTER_CFG( fs_config_t fs_config) =
{
.callback = fs_evt_handler, // Function for event callbacks.
.num_pages = 1, // Number of physical flash pages required.
.priority = 0xFE // Priority for flash usage.
};
void fstorage_init(void)
{
fs_ret = fs_init();
if (fs_ret != FS_SUCCESS)
{
APP_ERROR_CHECK(fs_ret);
}
// Erase one page (page 0).
fs_callback_flag = 1;
fs_ret = fs_erase(&fs_config, fs_config.p_start_addr, 1);
if (fs_ret != FS_SUCCESS)
{
APP_ERROR_CHECK(fs_ret);
}
while(fs_callback_flag == 1)
{ power_manage(); }
data = 0x62006200;
fs_callback_flag = 1;
fs_ret = fs_store(&fs_config, fs_config.p_start_addr, &data,1); //Write data to memory address 0x0003F00. Check it with command: nrfjprog --memrd 0x0003F000 --n 16
if (fs_ret != FS_SUCCESS)
{
APP_ERROR_CHECK(fs_ret);
}
while(fs_callback_flag == 1) { power_manage(); }
uint32_t *addr1;
addr1=fs_config.p_start_addr;
}
There is separete function on_adv_report above main in which I am doing lyk this:
if((uint32_t)*addr1)>>8 ==0xFFFFFFFF)
{stored_key[0]= ((uint32_t)*(addr1) >> 8);
stored_key[1]= ((uint32_t)*(addr1) >> 24);}
else
{
stored_key[0]= ((uint32_t)*(addr1+1) >> 8);
stored_key[1]= ((uint32_t)*(addr1+1) >> 24);
}
//
uint8_t key_encrypt[16] = {stored_key[0],stored_key[1],0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30};
based upon the value of stored key, key_encrypt happens and further action is also according to it.
I am facing two problems:
-
when we are in debug window and put the breakpoint on stored_key,it will correctly store the value but the breakpoint wont stop for any other command after that.
-
it always shows error 31:illegal qualifier.
We require fstorage to constantly store and read values at different point in program.I have made FS_Config refister global for this purpose.
Please suggest how fstorage can be used at different places in program to read from the same location and store the value in same+1 location.Is it required that fs_init has to be called everytime whenever the value is reading or writing? How fstorage can be used at different places /fuctions in program??
REply asap.