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

Debugging MQTT on nrf9160dk

Hi,

I'm having some difficulty debugging an issue with the mqtt library on the nrf9160dk.

I have written my own Cmqtt library class that wraps the Zephyr mqtt library. It all seems to work well, can connect, subscribe, publish however ..... when I try to publish two messages with the same topic back to back the CPU reboots. Like this

        message = "abc";
        mqtt.publish(pub_topic, message, Cmqtt::QOS_AT_MOST_ONCE);
        message = "def";
        mqtt.publish(pub_topic, message, Cmqtt::QOS_AT_MOST_ONCE);

Now I fully accept this is probably a bug in my code but debugging this seems extremely hard as I cannot get a clue as to what the problem is. I've connected and run under a debugger, but the code does not halt the debug session or give any clue why is rebooting. The only thing I have discovered is if I sleep for 100ms between the two calls then it does not reboot. So I'm wondering if a buffer is overflowing or there is some weird interleaving going on. I've also enabled a lot of debug logging in project configuration, so the logging framework is being used hard. Again I wondered if that was blowing up. But problem is still there without all the logging. So my questions are.

1. Is there a tutorial here on debugging with Zephyr/GDB ? What project config options are best ? Can I halt on error ? Currently I have set CONFIG_DEBUG=y .

2. Is there a way to enable synchronous logging? At the moment as logging is on another thread I do not see the last log message produced as it resets way before log buffer is flushed.

3. How can I set config to get stack probes or heap probes enabled to check for memory corruption ?

Regards,

Paul

Parents Reply Children
Related