Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Nordic serialisation: after 5 connections if I start advertisement again, it is giving Memory error from Application chip

I am using Nordic seriaization with nrf52480 as connectivity chip and a custom M4 board as Application chip.
After 5th connection, the advertisement is not starting. While trying to start advertisement, ble_gap_adv_set_configure_req_enc) function on application chip is returning [NRF_ERROR_NO_MEM] error.
Any idea why this is coming? Any possible reason? Or anything to specifically check from my side?

  • Hi Dhilshad, 

    Could you let me know the configuration of :

    NRF_SDH_BLE_TOTAL_LINK_COUNT

    NRF_SDH_BLE_CENTRAL_LINK_COUNT

    NRF_SDH_BLE_PERIPHERAL_LINK_COUNT

    in your application chip ? 

    Please make sure they can cover the maximum connections you plan to support. From what you describe there should be at least 6 concurrent connections. 

  • Hi,

    I am not talking about concurrent connection. What I am doing is. Connecting and disconnecting same phone. And Starting the advertisement after disconnection.
    Here after 5 th disconnection. When trying to start the advertisement again, this issue is coming

  • Hi Dhilshad, 

    Then it must be something wrong with the memory. Please try to step into the code and check what throwing NRF_ERROR_NO_MEM. As far as I can see ble_gap_adv_set_configure_req_enc() shouldn't return such error code. 
    Could you try to test using one of our example (ble_app_hrs with connectivity for example) in the SDK ? 

  • Then it must be something wrong with the memory. Please try to step into the code and check what throwing NRF_ERROR_NO_MEM. As far as I can see ble_gap_adv_set_configure_req_enc() shouldn't return such error code. 

    Yeah. I could find the root casue.

    app_ble_gap_adv_buf_register function is rerunning -1 (which means, there is no 
    m_ble_data_pool buffer available.)

    Seems like, this 
    m_ble_data_pool was only allocated but not freed.
    in function 
    app_ble_gap_adv_buf_register function, after 5 the disconnection , there was no buffer with 
    BLE_DATA_BUF_FREE state.

    Just for some experimentation, I made a change like this in app_ble_gap_adv_buf_register function:
    - if (m_ble_data_pool[i].state == BLE_DATA_BUF_FREE)
    + if (m_ble_data_pool[i].state == BLE_DATA_BUF_FREE || m_ble_data_pool[i].state == BLE_DATA_BUF_LAST_DIRTY)

    It is working now. But not sure whether this is proper change or not.

    Note: I am using nRF5_SDK_15.3.0_59ac345 

  • Hi Dhilshad,

    I'm sorry for late response. I was on vacation. 

    Could you send me the name of the file that has app_ble_gap_adv_buf_register () you were looking at ? 
    The only app_ble_gap_adv_buf_register () function I can find in the SDK was in app_ble_gap_sec_keys.c : 

    int app_ble_gap_adv_buf_register(void * p_buf)
    {
        uint32_t i;
    
        if (p_buf == NULL)
        {
            return 0;
        }
    
        for (i = 0; i < ARRAY_SIZE(m_ble_gap_adv_buf_addr_storage); i++)
        {
            if ((m_ble_gap_adv_buf_addr_storage[i] == NULL) ||
                (m_ble_gap_adv_buf_addr_storage[i] == p_buf))
            {
                m_ble_gap_adv_buf_addr_storage[i] = p_buf;
                return i+1;
            }
        }
    
        return -1;
    }

Related