This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AF_LTE socket and nrfxlib

After many hours of successful LTE connections and using the AF_LTE socket just fine (many creates, many send/receive, many closes), my application now hangs on a call to socket(AF_LTE,0,NPROTO_AT). Hung, as in the call to socket() does not return. I have no idea where to look to resolve this. Is the nrfxlib code available for review? I'll sign an NDA if I can get my eyes on it. I've spent way too much time trying to code around strange behavior in nrfxlib/nrf/zephyr.

This is running on nrf9160 DK, modem fw v1.1.1 and NCS v1.2.0

Mike

  • With your new code, I am able to reproduce the error, though it takes a lot longer than 1 minute to see the error. On my latest run, the error came after 17,5 minutes.

    In one of my traces, the modem reports that it is out of RAM used to communicate with the application. The trace also shows that you are not waiting for a response from the modem before you send a new command.

    In a real application (i.e. not one made to provoke an error), you should both take care not to send new commands before the previous one got a reply, and that you read back any data (this also goes for IP or GNSS sockets) fast enough.

    However, as the modem does crash at the end, I have informed the modem team and asked if they can take a look at it.

  • I'm glad you were finally able to reproduce the error. I'm curious why it took much longer for you though. My tests are running on 9160dk rev 0.8.2.

    Is there anything inherently wrong with the design of the code regarding how it accesses the modem? Your answer above suggests that perhaps a mutex would be needed when issuing AT commands.

  • The response from the modem team was mostly as I expected:

    You should wait for a response to the AT commands you send, and ensure that you read back the data sent from the modem so that you don't run out of memory used to communicate with the modem.

    This is also probably what causes the application to hang. As there is no more memory that can be used to communicate with the modem, the application is not able to open new sockets or sending new commands.

     

    miked531 said:
    Your answer above suggests that perhaps a mutex would be needed when issuing AT commands.

     Yes, using a mutex to restrict the access to the modem to only one thread at a time could solve some of your problems. The main point though is that you should wait for a reply before you send a new AT command.

    However, both of the traces show that the modem crashes at the end. Both the crashes are due to the same cause, for which the modem team already has a fix. Future releases of the modem firmware will have this fix, and will hopefully solve the problem you are seeing in your original application.

    I suggest that you take another look at your AT command library, and try to limit it to just sending one command at a time.

  • In my quick test that I just coded up, the mutex around the AT and response has apparently resolved the issue.

    Do you have an estimate as to when the modem fix will be released?

  • Great to hear that it seems to work now!

    I can not comment on future releases. For that, you should contact your Regional Sales Manager.

    If you do not know how to contact your RSM, you can send me a private message with your location, and I will provide you with the contact information.

Related