ZBOSS NCP error code 22 "NO_MEMORY"

Hi, 

I am using an nRF52840 as a Zigbee NCP. I have built the firmware myself using nRF Connect, and I am also running MCUBoot. Sometimes after some usage, the chip starts returning error code 22 meaning "NO_MEMORY". From that point, it is not usable any more until i reset the module. I was not able to figure out a reliable way to recreate the issue. What is the cause, and what can be the solution to the problem?

Parents
  • Hello,

    Can you please provide a bit more information. What function is it that returns -22? 

    error code 22 meaning "NO_MEMORY"

    Usually -22 means EINVAL, but it may vary, based on what function returning it. ENOMEM is typically -12.

    But let me know what function that starts returning 22, and we can have a look at it. Preferably also some context/snippets describing how it is called, and with what parameters.

    Best regards,

    Edvin

Reply
  • Hello,

    Can you please provide a bit more information. What function is it that returns -22? 

    error code 22 meaning "NO_MEMORY"

    Usually -22 means EINVAL, but it may vary, based on what function returning it. ENOMEM is typically -12.

    But let me know what function that starts returning 22, and we can have a look at it. Preferably also some context/snippets describing how it is called, and with what parameters.

    Best regards,

    Edvin

Children
  • Normally, it works fine, there is a point from which a lot of different function calls start returning this error code. For example, when calling zb_zdo_mgmt_permit_joining_req like this

    void mgmt_permit_joining_req_cb(zb_uint8_t param)
    {
        zb_zdo_mgmt_permit_joining_resp_t *resp;
        resp = (zb_zdo_mgmt_permit_joining_resp_t*)zb_buf_begin(param);
        TRACE_MSG(TRACE_APP1, "mgmt_permit_joining_req_cb status: %hd", (FMT__H, resp->status));
        zb_buf_free(param);
    }
    void mgmt_permit_joining_req_p(zb_uint8_t param)
    {
        zb_zdo_mgmt_permit_joining_req_param_t *req_param = ZB_BUF_GET_PARAM(param, zb_zdo_mgmt_permit_joining_req_param_t);
        ZB_BZERO(req_param, sizeof(zb_zdo_mgmt_permit_joining_req_param_t));
        req_param->dest_addr = zb_get_short_address();
        req_param->permit_duration = ZB_BDBC_MIN_COMMISSIONING_TIME_S;
        req_param->tc_significance = ZB_TRUE;
        zb_zdo_mgmt_permit_joining_req(param, mgmt_permit_joining_req_cb);
    }

    The returned status is 22. But all other mgmt and APS calls also return 22 at this point, like trying to read or write an attribute.

    What I was able to find out is that the NCP itself is returning the error, and according to this document I found, it means NO_MEMORY: 
    ZBOSS_NCP_Serial_Protocol.pdf

    So my theory is that the memory of the NCP gets full after some time. But what was strange, is that I have tried running long-term tests also with a script, like reading and writing attributes on a device repeatedly, and then it did not occur. What I do not know, is what causes it to get stuck like that, or when it does get stuck, how is it possible to clean the memory for example, if that is the problem.

Related