Hello, I'd like to store a large amount of data in flash and in a chosen area. As a start, I've chosen the area starting from 0x77000 and ending at 0x78000 Iv'e written this
const tGlobalData romData __attribute__((at(0x77000))) __attribute__((used));
static void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result);
FS_REGISTER_CFG(fs_config_t my_fs_config) =
{
.callback = fs_evt_handler, // Function for event callbacks.
.num_pages = 4, // Number of physical flash pages required.
.priority = 0xFE, // Priority for flash usage.
.p_start_addr = (uint32_t*)0x77000,
.p_end_addr = (uint32_t*)0x78000
};
static void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result)
{
switch(evt->id)
{
case FS_EVT_STORE:
if(result == FS_SUCCESS){
}
break;
case FS_EVT_ERASE:
// Handle erase event
break;
default:
//Do nothing
break;
}
}
void initROM()
{
//fs_ret_t ret = fs_init();
}
void saveROM()
{
volatile fs_ret_t fs_ret;
fs_ret= fs_erase(&my_fs_config,(uint32_t*)&romData,4,NULL);
fs_ret= fs_store(&my_fs_config,(uint32_t*)&romData,(uint32_t*)&globalData,(sizeof(tGlobalData)+1)/4,NULL);
}
void readROM()
{
memcpy(&globalData,&romData,sizeof(tGlobalData));
}
the erase operation fails. After debug, the start address at config is 0x7D000, so that &romData is out of range. The arear is welle allocated by the linker, so I should miss something.