Problem with fstorage and ble active in Release mode

I'm using nRF52832 SoC with nRF5_SDK17.1.0 and SoftDevice v7.3.0. I'm using following code to write data into flash.

 err_code = nrf_fstorage_write(&g_fs, write_addr, buffer32, 128, NULL);

  wait_while_fs_busy(&g_fs);

/* Wait helper: sleep while fstorage is busy (write/erase are async). */
static void wait_while_fs_busy(nrf_fstorage_t const * p_fs)
{
    uint32_t waited_ms = 0;

    while (nrf_fstorage_is_busy(p_fs))
    {

      if ((p_fs->p_api == &nrf_fstorage_sd) && nrf_sdh_is_enabled())
      {
           __enable_irq();
           __set_BASEPRI(0);
           (void)sd_app_evt_wait();
      }
      else
      {
            __WFE();
      }

      (void)NRF_LOG_PROCESS();
      waited_ms++;
      if (waited_ms > 5000)
      {
         NRF_LOG_ERROR("fstorage wait timeout");
         break;
      }
      NRF_LOG_PROCESS();
   }
}

It works fine when compiled in debug mode.

Whenever it's compiled in release mode and fstorage is used while ble is connected, the code enters 2 to 3 times sd_app_evt_wait(); an then hangs in this function.

Whenever it's compiled in release mode and fstorage is used after ble is disconnected, the code enters sd_app_evt_wait(); and hangs in this function immediately.

--> I guess no event is generated any more or masked.

Why this is happening?

Parents
  • Hi Stephan

    No I did not, but I did just now on my end. Please see the readout from the address where the device names are here. Sorry for the weird names, but there are a lot of devices around the office, so I have to name them something I remember to find them when searching. Device name was changed from "ostepop" to "flexboi".

    PS C:\ncs\nrf-bm\v1.0.0> nrfutil device read --address 0x0007D000 --bytes 1000
    682030708
    0x0007D000: 6574736F 00706F70 00003041 00000000   |ostepop.A0......|
    0x0007D010: 00000000 00000000 00000000 00000000   |................|
    0x0007D020: 44414544 46454542 0C0B0A00 100F0E0D   |DEADBEEF........|
    0x0007D030: 14131211 18171615 1C1B1A19 201F1E1D   |............... |
    0x0007D040: 24232221 28272625 2C2B2A29 302F2E2D   |!"#$%&'()*+,-./0|
    0x0007D050: 34333231 38373635 3C3B3A39 403F3E3D   |123456789:;<=>?@|
    0x0007D060: 44434241 00000000 00000000 00000000   |ABCD............|
    0x0007D070: 00000000 00000000 00000000 01451401   |..............E.|
    0x0007D080: 78656C66 00696F62 00003041 00000000   |flexboi.A0......|
    0x0007D090: 00000000 00000000 00000000 00000000   |................|
    0x0007D0A0: 44414544 46454542 0C0B0A00 100F0E0D   |DEADBEEF........|
    0x0007D0B0: 14131211 18171615 1C1B1A19 201F1E1D   |............... |
    0x0007D0C0: 24232221 28272625 2C2B2A29 302F2E2D   |!"#$%&'()*+,-./0|
    0x0007D0D0: 34333231 38373635 3C3B3A39 403F3E3D   |123456789:;<=>?@|
    0x0007D0E0: 44434241 00000000 00000000 00000000   |ABCD............|
    0x0007D0F0: 00000000 00000000 00000000 01451401   |..............E.|
    0x0007D100: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|

    Best regards,

    Simon

Reply
  • Hi Stephan

    No I did not, but I did just now on my end. Please see the readout from the address where the device names are here. Sorry for the weird names, but there are a lot of devices around the office, so I have to name them something I remember to find them when searching. Device name was changed from "ostepop" to "flexboi".

    PS C:\ncs\nrf-bm\v1.0.0> nrfutil device read --address 0x0007D000 --bytes 1000
    682030708
    0x0007D000: 6574736F 00706F70 00003041 00000000   |ostepop.A0......|
    0x0007D010: 00000000 00000000 00000000 00000000   |................|
    0x0007D020: 44414544 46454542 0C0B0A00 100F0E0D   |DEADBEEF........|
    0x0007D030: 14131211 18171615 1C1B1A19 201F1E1D   |............... |
    0x0007D040: 24232221 28272625 2C2B2A29 302F2E2D   |!"#$%&'()*+,-./0|
    0x0007D050: 34333231 38373635 3C3B3A39 403F3E3D   |123456789:;<=>?@|
    0x0007D060: 44434241 00000000 00000000 00000000   |ABCD............|
    0x0007D070: 00000000 00000000 00000000 01451401   |..............E.|
    0x0007D080: 78656C66 00696F62 00003041 00000000   |flexboi.A0......|
    0x0007D090: 00000000 00000000 00000000 00000000   |................|
    0x0007D0A0: 44414544 46454542 0C0B0A00 100F0E0D   |DEADBEEF........|
    0x0007D0B0: 14131211 18171615 1C1B1A19 201F1E1D   |............... |
    0x0007D0C0: 24232221 28272625 2C2B2A29 302F2E2D   |!"#$%&'()*+,-./0|
    0x0007D0D0: 34333231 38373635 3C3B3A39 403F3E3D   |123456789:;<=>?@|
    0x0007D0E0: 44434241 00000000 00000000 00000000   |ABCD............|
    0x0007D0F0: 00000000 00000000 00000000 01451401   |..............E.|
    0x0007D100: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|

    Best regards,

    Simon

Children
  • Hi Simon - thanks for this.

    I assume this test has been done with the code compiled as Release and downloaded to the device with 'Build and Run'.
    Did you have to modify or exclude anything on my code to make it run? 

    Can you please confirm?

    This behavior is how I expect it should run. But on my device I have the issue described. Could it be that I have some conflicts with interrupts or modules which are active and lead to a 'hanging' in run-time? With my tests I can proof that not one byte is being written to the flash - if it is a 'hanging' then it happens right at the beginning.

    Thanks for your support  - I really need it.

    Stephan

Related