My app (SDK12.3.0 + S130 v2.0.1) is being prevented from advertising because flash_access_in_progress() is true (m_queue.count != 0) on ble_advertising_start (ble_advertising.c library from SDK). It sets m_advertising_pending = true but never recovers (do not see any call to sys_event_dispatch(); i.e. any sys_event to fs):
NOTE: NVM Protection (CLENR0 != 0 and MPU.PROTENSET0|1 = 0xFFFFFFFF) is enabled.
On init (after reset), why is there a flash access in progress? in other words, why is m_queue.count != 0?
EDIT: Flash operations counter (m_queue.count) seems to get incremented (at least after power-up gets 1) after:
ble_init() > peer_manager_init() > pm_init() > pds_init() > fds_init() > queue_start() in fds.c.
EDIT2: If memory protection is disabled (UICR.CLENR0 = 0 and MPU.PROTENSET0|1 = 0) then m_queue.count=0.