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

NRF flash storage event handler issue with Bluetooth advertising.

Hi Team,

We are facing issue with Flash storage Handlers with ble handlers. When we add the fstorage to my application ble adversing is stopped suddenly.

We are having separate Event handlers for both. We have some concerns related to fstorage,

1. How to set the start and end addresses of an fstorage instance at runtime, at the end of current application usage.

fstorage example code we have found we below code snippet , but to use this macro and nowhere it is called in application                                            

                                    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
                                     {
                                       /* Set a handler for fstorage events. */
.                                           evt_handler = fstorage_evt_handler,

                                         /* These below are the boundaries of the flash space assigned to this instance of fstorage.
                                           * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
                                                 * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
                                                     * last page of flash available to write data. */
                                                  .start_addr = 0x4e000,
                                                 .end_addr = 0x4f000,
                                      };

2. Providing the fs Read/write functions code here for cross verification,

Fstorage Handler:

static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt)
{
if (p_evt->result != NRF_SUCCESS)
{
return;
}

switch (p_evt->id)
{
case NRF_FSTORAGE_EVT_WRITE_RESULT:
{
m_fs_Data_write = 1;
}
break;

case NRF_FSTORAGE_EVT_ERASE_RESULT:
{
m_fs_Data_erase = 1;
}
break;

case NRF_FSTORAGE_EVT_READ_RESULT:
{
m_fs_Data_read = 1;
}
break;

default:
break;
}
}

Write Function:

void Update_flash_Data(void)
{
ret_code_t rc;

rc = nrf_fstorage_erase(&fstorage, (uint32_t)(KEY_BASE_ADDR), 1, NULL);
APP_ERROR_CHECK(rc);

if(m_fs_Data_erase == 1)
{
m_fs_Data_erase = 0;
rc = nrf_fstorage_write(&fstorage, (uint32_t)KEY_BASE_ADDR, &m_sffl_data, sizeof(m_sffl_data), NULL);
APP_ERROR_CHECK(rc);
}

//wait_for_flash_ready(&fstorage);

}

Read Handler:

void Read_Flash_Data(void)
{
ret_code_t rc;

rc = nrf_fstorage_read(&fstorage, (uint32_t)KEY_BASE_ADDR, &m_sffl_data, sizeof(m_sffl_data));
APP_ERROR_CHECK(rc);

//wait_for_flash_ready(&fstorage);

}

Is there any modifications required in Event handler and Write/Read handlers.

Regards,

Srinivas.V

Related