In my project, the softdevice I used was S110 I hope that some of the data can still be retained after OTA updates, in the Bootloader program code:
#define DFU_APP_DATA_RESERVED CODE_PAGE_SIZE * 4
And then within the application program code:
#define PSTORAGE_NUM_OF_PAGES 4 #define __AppReservedAddr PSTORAGE_DATA_START_ADDR
Write data in the following ways:
//------------------------------------------------------
{ static uint32_t temp[__MaxDevNameWordNum + 1] ;
uint8 i,h;
uint32_t err_code;
uint8 page_num;
uint16 flash_page_size;
flash_page_size = (uint16_t)NRF_FICR->CODEPAGESIZE;
page_num = __AppReservedAddr / flash_page_size;
err_code = sd_flash_page_erase(page_num);
nrf_delay_us(600000); //wait a moment
for(i=1 ; i<__MaxDevNameWordNum + 1; i++)
{
h = (i-1) * 4;
temp[i] = 0;
temp[i] += pDev->Name[h+0];
temp[i] += (uint32)pDev->Name[h+1] << 8;
temp[i] += (uint32)pDev->Name[h+2] << 16;
temp[i] += (uint32)pDev->Name[h+3] << 24;
}
err_code = sd_flash_write((uint32_t*)__AppReservedAddr,&temp[0], __MaxDevNameWordNum + 1);
}
//-------------------------------------------------
Read the data in the following ways:
//------------------------------------------------
{ uint32 *address = 0;
static uint32_t temp[__MaxDevNameWordNum + 1] ;
for(i=0; i<__MaxDevNameWordNum + 1; i++)
{
h = i * 4;
address = (uint32 *)(__AppReservedAddr + h);
temp[i] = (uint32)*(address);
}
}
//----------------------------------------------
Data can be written and read normally, but after OTA update application program code, the data is gone,
My question is:
-
where the actual position of the DFU_APP_DATA_RESERVED is located?
-
where the actual position of the PSTORAGE_DATA_START_ADDR is located?
What do I need to change to achieve my purpose?
Thanks!