Hi,
I am trying to incorporate flash storage library to ble_app_uart_c example. I have added all necessary functions from ...\examples\peripheral\flash_fstorage.
When I am reading from flash it is not getting copied completely to the buffer which is passed. It is not even executing many of the lines in between.
<info> app: fstorage example started. <info> app: SoftDevice is present. <info> app: Initializing nrf_fstorage_sd implementation... <info> app: ========| flash info |======== <info> app: erase unit: 4096 bytes <info> app: program unit: 4 bytes <info> app: ============================== <info> app: got flash end addresses: -1, 4096, 128. <info> app: Writing "BADC0FFE" to flash. <info> app: --> Event received: wrote 4 bytes at address 0x3E000. <info> app: Done. . <info> app: Done. <info> app: Writing "hello world" to flash. <info> app: --> Event received: wrote 12 bytes at address 0x3F000. <info> app: Done. <info> app: Writing "abcdefg" to flash. <info> app: --> Event received: wrote 8 bytes at address 0x3E120. <info> app: Done. <info> app: initially data[i]: 0 <info> app: initially data[i]: 0 <info> app: initially data[i]: 0

As you can see in the above image (watch) it is not getting copied.
When I am putting break points it is getting copied.
hitting first break point:

After reading the data:

After running completely:

Why it is not executing completely? I am including my main too.
uint32_t data[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static uint32_t m_data = 0xBADC0FFE;
static char m_hello_world[] = "hello world";
static char m_hello[] = "abcdefg";
int main(void)
{
ret_code_t rc;
// Initialize.
log_init();
timer_init();
uart_init();
buttons_leds_init();
db_discovery_init();
power_management_init();
NRF_LOG_INFO("fstorage example started.");
nrf_fstorage_api_t * p_fs_api;
#ifdef SOFTDEVICE_PRESENT
NRF_LOG_INFO("SoftDevice is present.");
NRF_LOG_INFO("Initializing nrf_fstorage_sd implementation...");
/* Initialize an fstorage instance using the nrf_fstorage_sd backend.
* nrf_fstorage_sd uses the SoftDevice to write to flash. This implementation can safely be
* used whenever there is a SoftDevice, regardless of its status (enabled/disabled). */
p_fs_api = &nrf_fstorage_sd;
#else
NRF_LOG_INFO("SoftDevice not present.");
NRF_LOG_INFO("Initializing nrf_fstorage_nvmc implementation...");
/* Initialize an fstorage instance using the nrf_fstorage_nvmc backend.
* nrf_fstorage_nvmc uses the NVMC peripheral. This implementation can be used when the
* SoftDevice is disabled or not present.
*
* Using this implementation when the SoftDevice is enabled results in a hardfault. */
p_fs_api = &nrf_fstorage_nvmc;
#endif
rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL);
APP_ERROR_CHECK(rc);
print_flash_info(&fstorage);
/* It is possible to set the start and end addresses of an fstorage instance at runtime.
* They can be set multiple times, should it be needed. The helper function below can
* be used to determine the last address on the last page of flash memory available to
* store data. */
(void) nrf5_flash_end_addr_get();
/* Let's write to flash. */
NRF_LOG_INFO("Writing \"%x\" to flash.", m_data);
rc = nrf_fstorage_write(&fstorage, 0x3e000, &m_data, sizeof(m_data), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
#ifdef SOFTDEVICE_PRESENT
/* Enable the SoftDevice and the BLE stack. */
NRF_LOG_INFO("Enabling the SoftDevice.");
ble_stack_init();
m_data = 0xDEADBEEF;
NRF_LOG_INFO("Writing \"%x\" to flash.", m_data);
rc = nrf_fstorage_write(&fstorage, 0x3e100, &m_data, sizeof(m_data), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
#endif
NRF_LOG_INFO("Writing \"%s\" to flash.", m_hello_world);
rc = nrf_fstorage_write(&fstorage, 0x3f000, m_hello_world, sizeof(m_hello_world), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
NRF_LOG_INFO("Writing \"%s\" to flash.", m_hello);
rc = nrf_fstorage_write(&fstorage, 0x3E120, m_hello, sizeof(m_hello), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
for(int i = 0;i < 5; i++)
{
NRF_LOG_INFO("initially data[i]: %d", data[i]);
}
NRF_LOG_INFO("Reading from flash");
rc = nrf_fstorage_read(&fstorage, 0x3e100, data, 10);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");
NRF_LOG_INFO("error code: %d", rc);
NRF_LOG_INFO("Error");
for(int i = 0; i < 5; i++)
{
NRF_LOG_INFO("Reading from flash");
NRF_LOG_INFO("Reading from flash data[%d]: %0x", i, data[i]);
}
NRF_LOG_INFO("Reading from flash data: %0x", data[0]);
gatt_init();
nus_c_init();
scan_init();
// Start execution.
NRF_LOG_INFO("BLE UART central example started.");
scan_start();
// Enter main loop.
for (;;)
{
idle_state_handle();
}
}
Is it something related to the delay to read from the flash? What is the difference between FDS and fstorage libray?
SOC NRF52832, soft device s132 version 15.0.2
Windows 10, segger embedded studio

