ERROR 4 [NRF_ERROR_NO_MEM] at app_timer2.c

The following error occurred after BLE APP connects to nRF52832 device. How can debug this issue?

<error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\..\..\..\components\libraries\timer\app_timer2.c:184

Log messages of nRF52832 device:

SEGGER J-Link RTT Viewer V7.66a Terminal Log File
# Compiled: 15:21:19 on May 19 2022
# Logging started @ 08 Aug 2022 09:27:38
00> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
00>
00> <info> app: BLE_GAP_EVT_CONNECTED
00>
00>
00> <debug> app: state=1
00>
00>
00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested a data length of 251 bytes.
00>
00> <debug> nrf_ble_gatt: Updating data length to 27 on connection 0x0.
00>
00> <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
00>
00> <debug> nrf_ble_gatt: max_rx_octets: 27
00>
00> <debug> nrf_ble_gatt: max_tx_octets: 27
00>
00> <debug> nrf_ble_gatt: max_rx_time: 2120
00>
00> <debug> nrf_ble_gatt: max_tx_time: 2120
00>
00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 527 bytes.
00>
00> <debug> nrf_ble_gatt: Updating ATT MTU to 185 bytes (desired: 185) on connection 0x0.
00>
00> <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).
00>
00> <debug> app: _securityRequestHandler
00>
00>
00> <info> app: BLE_GAP_EVT_SEC_PARAMS_REQUEST
00>
00>
00> <info> app: Received data from BLE NUS. Writing data on UART.
00>
00> <debug> app:  54 49 4D 45 32 30 32 32|TIME2022
00>
00> <debug> app:  30 38 30 38 30 39 32 37|08080927
00>
00> <debug> app:  35 36                  |56      
00>
00> <debug> app: length=18
00>
00> <debug> app: data[0]=0x54 T
00>
00> <debug> app: data[1]=0x49 I
00>
00> <debug> app: data[2]=0x4D M
00>
00> <debug> app: data[3]=0x45 E
00>
00> <debug> app: data[4]=0x32 2
00>
00> <debug> app: data[5]=0x30 0
00>
00> <debug> app: data[6]=0x32 2
00>
00> <debug> app: data[7]=0x32 2
00>
00> <debug> app: data[8]=0x30 0
00>
00> <debug> app: data[9]=0x38 8
00>
00> <debug> app: data[10]=0x30 0
00>
00> <debug> app: data[11]=0x38 8
00>
00> <debug> app: data[12]=0x30 0
00>
00> <debug> app: data[13]=0x39 9
00>
00> <debug> app: data[14]=0x32 2
00>
00> <debug> app: data[15]=0x37 7
00>
00> <debug> app: data[16]=0x35 5
00>
00> <debug> app: data[17]=0x36 6
00>
00> <debug> app: state=2
00>
00>
00> <debug> app: 2 2
00>
00>
00> <debug> app: 0 0
00>
00>
00> <debug> app: 2 2
00>
00>
00> <debug> app: 2 2
00>
00>
00> <debug> app: 8 8
00>
00>
00> <debug> app: 0 0
00>
00>
00> <debug> app: 8 8
00>
00>
00> <debug> app: 0 0
00>
00>
00> <debug> app: 9 9
00>
00>
00> <debug> app: 0 0
00>
00>
00> <debug> app: 7 7
00>
00>
00> <debug> app: 2 2
00>
00>
00> <debug> app: 6 6
00>
00>
00> <debug> app: 5 5
00>
00>
00> <debug> app: datetime sync
00>
00> <debug> app: 2022-8-8 9:27:56
00>
00> <info> app:
00>
00>
00>
00> <info> app: Received data from BLE NUS. Writing data on UART.
00>
00> <debug> app:  4D 45 41 53 55 52 45   |MEASURE
00>
00> <debug> app: length=7
00>
00> <debug> app: data[0]=0x4D M
00>
00> <debug> app: data[1]=0x45 E
00>
00> <debug> app: data[2]=0x41 A
00>
00> <debug> app: data[3]=0x53 S
00>
00> <debug> app: data[4]=0x55 U
00>
00> <debug> app: data[5]=0x52 R
00>
00> <debug> app: data[6]=0x45 E
00>
00> <debug> app: state=4
00>
00>
00> <info> app:
00>
00>
00>
00> <debug> app: record measure begin
00>
00>
00> <debug> app: offsetStart=0x0
00>
00>
00> <debug> app: offsetEnd=0x0
00>
00>
00> <debug> app: timeStart
00>
00> <debug> app: 2022-8-8 9:28:0
00>
00> <debug> app: timeEnd
00>
00> <debug> app: 2022-8-8 9:28:0
00>
00> <debug> app: endAddr=0x7FFFF
00>
00> <debug> app: startAddr=0x7F000
00>
00> <debug> app: type=0, addr=0x7F000
00>
00>
00> <debug> app: START E, state=0
00>
00>
00> <warning> app: nrf_fstorage_erase() e
00>
00>
00> <warning> app: nrf_fstorage_erase() x
00>
00>
00> <debug> app: START x, state=1
00>
00>
00> <debug> app: fstate=1
00>
00>
00> <debug> app: Evt e
00>
00>
00> <debug> app: Evt er
00>
00>
00> <debug> app: NRF_FSTORAGE_EVT_ERASE_RESULT ok
00>
00> <debug> app: Evt x
00>
00>
00> <debug> app: record measure begin
00>
00>
00> <debug> app: offsetStart=0x0
00>
00>
00> <debug> app: offsetEnd=0x0
00>
00>
00> <debug> app: timeStart
00>
00> <debug> app: 2022-8-8 9:28:0
00>
00> <debug> app: timeEnd
00>
00> <debug> app: 2022-8-8 9:28:0
00>
00> <debug> app: endAddr=0x7FFFF
00>
00> <debug> app: startAddr=0x7F000
00>
00> <debug> app: type=0, addr=0x7F000
00>
00>
00> <debug> app: START E, state=2
00>
00>
00> <debug> app: record
00>
00>
00> <debug> app: offsetStart=0x0
00>
00>
00> <debug> app: offsetEnd=0x0
00>
00>
00> <debug> app: timeStart
00>
00> <debug> app: 2022-8-8 9:28:0
00>
00> <debug> app: timeEnd
00>
00> <debug> app: 2022-8-8 9:28:0
00>
00> <debug> app: nrf_fstorage_write() e
00>
00>
00> <debug> app: nrf_fstorage_write() x
00>
00>
00> <debug> app: START x, state=3
00>
00>
00> <debug> app: fstate=3
00>
00>
00> <debug> app: Evt e
00>
00>
00> <debug> app: Evt w
00>
00>
00> <debug> app: NRF_FSTORAGE_EVT_WRITE_RESULT ok
00>
00> <debug> app: Evt x
00>
00>
00> <debug> app: record measure begin
00>
00>
00> <debug> app: offsetStart=0x0
00>
00>
00> <debug> app: offsetEnd=0x0
00>
00>
00> <debug> app: timeStart
00>
00> <debug> app: 2022-8-8 9:28:1
00>
00> <debug> app: timeEnd
00>
00> <debug> app: 2022-8-8 9:28:1
00>
00> <debug> app: endAddr=0x7FFFF
00>
00> <debug> app: startAddr=0x7F000
00>
00> <debug> app: type=0, addr=0x7F000
00>
00>
00> <debug> app: START E, state=4
00>
00>
00> <debug> app: START x, state=4
00>
00>
00> <debug> app: fstate=4
00>
00>
00> <debug> app: state=5
00>
00>
00> <debug> app: _extFlashWriteData(0x0, 182)
00>
00>
00> <debug> app: buf
00>
00>
00> <debug> app: pData[0]=0xEE
00>
00>
00> <debug> app: pData[1]=0xED
00>
00>
00> <debug> app: pData[2]=0x23
00>
00>
00> <debug> app: pData[3]=0xFA
00>
00>
00> <debug> app: pData[4]=0x0
00>
00>
00> <debug> app: pData[5]=0x4
00>
00>
00> <debug> app: pData[6]=0x33
00>
00>
00> <debug> app: pData[7]=0x40
00>
00>
00> <debug> app: pData[8]=0x6
00>
00>
00> <debug> app: pData[9]=0x87
00>
00>
00> <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\..\..\..\components\libraries\timer\app_timer2.c:184
00>
00> PC at: 0x00039F33
00>
00> <error> app: End of error report
00>

Parents
  • Hello again,

    00> <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\..\..\..\components\libraries\timer\app_timer2.c:184

    This error message indicates that the APP_ERROR_CHECK on line 184 of app_timer2.c returned with the NRF_ERROR_NO_MEM error code. Which function returned the error code that was checked on line 184 of app_timer2.c in your project?

    Best regards,
    Karl

  • line 184 of app_timer2.c is

    APP_ERROR_CHECK(err_code);

  • snowuyl said:
    Is it possible to get timer ID from app_timer_t?

    I am not sure that I understand what you are asking about here, please elaborate.
    Which ID are you looking for?

    Best regards,
    Karl

  • I use APP_TIMER_DEF() macro to define timer ID. But parameter type of timer_expire() is app_timer_t.

    How can I know which timer is expired?

    APP_TIMER_DEF(m_button_scan_id);

    static bool timer_expire(app_timer_t * p_timer) {

    ...

    }

  • The timer_expire function is a static function to the app_timer2.c which your application should not need to call upon. What is it that you are trying to achieve?

    Best regards,
    Karl

  • Since I would like to check APP_ERROR_CHECK(err_code) failed (line 184 of app_timer2.c). If I can get timer ID from app_timer_t  structure, I can guess which timer cause this issue.

    static bool timer_expire(app_timer_t * p_timer)
    {
        ASSERT(p_timer->handler);
        bool ret = false;

        if ((m_global_active == true) && (p_timer != NULL) && (p_timer->active))
        {
            if (get_now() >= p_timer->end_val) {
                /* timer expired */
                if (p_timer->repeat_period == 0)
                {
                    p_timer->active = false;
                }
        #if APP_TIMER_CONFIG_USE_SCHEDULER
                app_timer_event_t timer_event;

                timer_event.timeout_handler = p_timer->handler;
                timer_event.p_context       = p_timer->p_context;
                uint32_t err_code = app_sched_event_put(&timer_event,
                                                        sizeof(timer_event),
                                                        scheduled_timeout_handler);
                if (err_code != NRF_SUCCESS) {
                    NRF_LOG_WARNING("app_sched_event_put() failed 0x%x\n", err_code);
                }    
                APP_ERROR_CHECK(err_code);
        #else

    ..

    }

  • To do so you could just add more logging to the timer_expire function, but it still would come back to that the scheduler queue is full, and this is likely because tasks are being scheduled faster than they are being processed, which likely if the root of your issue (unless you plan on having a very high number of expired timers' actions pending, in which case you could increase the queue size and see if it resolves the issue).

    Best regards,
    Karl

Reply
  • To do so you could just add more logging to the timer_expire function, but it still would come back to that the scheduler queue is full, and this is likely because tasks are being scheduled faster than they are being processed, which likely if the root of your issue (unless you plan on having a very high number of expired timers' actions pending, in which case you could increase the queue size and see if it resolves the issue).

    Best regards,
    Karl

Children
No Data
Related