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

Parents Reply Children
  • Hi Haakonsh,

    Thanks for your reply.We are using the SD Flash Api's only inside the wrapper functions we are calling the same SD Api's only.

    Coming to Concurrent multi protocol implementation is there any example code for reference, we will use the same concept for our design.

    Regards,

    Srinivas.V

  • Hi Haakonsh,

    Thanks for your reply.I have seen that exmaple, in that based on bsp button press there are deciding the running mode, but at a time only one module is running.

    My requirement is different ,we need the both the modules but only thing once in a while we update the flash data in that time it should not preempted by others.

    1. How to enalbe the SD scheduler which manages radio timeslots and priorities and sets up timers to grant time slots to peripherals.

    2. How to assign priorities to Flash API's.

    3. How to make atomic nature flash api's when they are running, means nobody will preempt at that time(10ms),once it is done we will come out from this atomic operation and execute as normal.

    Regards,

    Srinivas.V

    1. See sd_radio_requestsd_radio_session_open, and sd_radio_session_close.

    2. The SoftDevice's flash operation is run at IRQ priority 5, they are scheduled, but they can get interrupted. See Flash memory API for details.

    3. Use Timeslot API, disable interrupts, execute atomic operation, re-enable interrupts. 
  • Hi Haakonsh,

    Thanks for your reply.We have some more questions on FLASH API timing and other things.

    1. How to enable flash timing-event scheduling in any available time left between other timing-events.

    2. How to configure the code to run the Flash API in a low priority,in which file we need to do this activity.

    3. How to configure and use the Time slot Flash API's apart from Normal Flash API ,like "sd_flash_write" and "sd_flash_erase".

    4. Is there any way to know the Blue tooth is in  ideal state, in that slot we can execute this Flash API's.

    Flash is running at Fourth priority and we can't change this , my intention is how to implement or use  the above mentioned points in our Application,  is there any specific example for Flash timing api's and other things.I haven't found any specific api's for flash apart from i mentioned above.

    Fourth priority
    • Flash access
    • Radio Timeslot with normal priority

    Regards,

    Srinivas.V

Related