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

wait_for_flash_ready(&fstorage); The cycle is here.

Hi:

I use nRF5_SDK_15.0.0_a53641a\examples\ble_peripheral\ble_app_buttonless_dfu.

I want to add flash operation.

The code is as follows.

mian()

{

...............

..............

#if FLASH_ENABLED
uint8_t i;
uint32_t uc[6];
uint32_t rc;
static uint32_t pages_to_erase = 1;
nrf_fstorage_api_t * p_fs_api;
p_fs_api = &nrf_fstorage_sd;

rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL);
APP_ERROR_CHECK(rc);

rc = nrf_fstorage_erase(
&fstorage, /* The instance to use. */
0x51000, /* The address of the flash pages to erase. */
pages_to_erase, /* The number of pages to erase. */
NULL /* Optional parameter, backend-dependent. */
);
if (rc == NRF_SUCCESS)
{
NRF_LOG_INFO("nrf_fstorage_erase success.");
}
else
{
NRF_LOG_INFO("nrf_fstorage_erase error.");
}
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");

for(i=0;i<6;i++)
{
uc[i]=(uint32_t)m_password[i];
}
rc = nrf_fstorage_write(&fstorage, 0x51200, uc, sizeof(uc), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
NRF_LOG_INFO("Done.");

for(i=0;i<6;i++)
{
uc[i]=0x0000;
}
rc = nrf_fstorage_read(&fstorage, 0x51200, uc,6*4);
APP_ERROR_CHECK(rc);

for(i=0;i<6;i++)
{
NRF_LOG_INFO("%d",(uint8_t)uc[i]);
}

#endif

...................

...................

}

void wait_for_flash_ready(nrf_fstorage_t const * p_fstorage)
{
/* While fstorage is busy, sleep and wait for an event. */
while (nrf_fstorage_is_busy(p_fstorage))
{
power_manage();
}
}

But stayed at wait_for_flash_ready() all the time.(I refer to nRF5_SDK_15.0.0_a53641a\examples\peripheral\flash_fstorage.I don't know where there is difference.)

  • I can neither compile your project in SES or KEIL since there are so many errors. The reason I asked you to attach the project is to shorten the time for me to replicate the problem you have. 

    In SES

    missing include file in projects. I could add them, but like I said, I want exactly same as your project settings.

    In Keil

    *** Using Compiler 'V5.06 update 4 (build 422)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'nrf52832_xxaa'
    compiling nrfx_saadc.c...
    "no source": Error: #5: cannot open source input file "..\..\..\..\..\..\..\..\nRF5_SDK_15.0.0_a53641a\modules\nrfx\drivers\src\nrfx_saadc.c": No such file or directory
    ..\..\..\..\..\..\..\..\nRF5_SDK_15.0.0_a53641a\modules\nrfx\drivers\src\nrfx_saadc.c: 0 warnings, 1 error
    linking...
    .\_build\nrf52832_dfu_freeRTOS.axf: error: L6002U: Could not open file .\_build\nrfx_saadc.o: No such file or directory
    Finished: 0 information, 0 warning, 0 error and 1 fatal error messages.
    ".\_build\nrf52832_dfu_freeRTOS.axf" - 1 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed: 00:00:01

Related