How to debug lwm2m_client sample on Thingy91 development kit?

Our company is in the process of developing a new IoT product for LTE-M and NB-IoT. The sample application lwm2m_client runs fine on our devkits nRF9151DK & Thingy91 and connects fine with Leshan, AVSystems and nRFCloud. UART console of both devkits show a lot of shell outputs. So far so good.
Past days I had to debug an issue but depending on some conditions I didn't know some times I could easily SWD debug and sometimes not. In the end I found this out:

  • nRF9151DK both standard builds and debug-build configs run just fine on those boards, UART output is correct.
  • Thingy:91 (nRF9160):
    • standard builds work both via MCUBoot-Update and via SWD debugger. In the debugger I can single step and run and the app run fine.
    • debug builds for the Thingy/nRF9160ns target (-Og, -DCONFIG_DEBUG_THREAD_INFO=y) dont work, dont show UART outputs, even the blinky sample is doing nothing
    • debug builds for the Thingy/nRF9160 target (no ns, -Og, -DCONFIG_DEBUG_THREAD_INFO=y) work, show UART outputs, but this is only valid for very simple MCU-like applications. Using the no-ns build target is preventing applications which require the LTE modem (TP-M)

Currently I'm out of ideas how I can debug an application using the LTE modem on the Thingy91 platform. Whats the supposed way to go in May 2025?

Parents Reply
  • Hi, 

    Do you use VS Code for building and flashing? Do you see the same behavior if you do not use VS Code?

    Do you see the same problem if you do not use "Optimize for debugging (-Og)" but instead add both
    -DCONFIG_DEBUG_THREAD_INFO=y and -DCONFIG_DEBUG_OPTIMIZATIONS=y
    to your build command manually?

    Do you see the same result when using only -DCONFIG_DEBUG_THREAD_INFO=y (without optimization)?

    Best regards,
    Dejan

Children
  • Thanks for reaching out!

    I use VSCode like described in the tutorials and getting started and I use the blinky example for reproduction. I gave the console a short try but lots of issues for now, have to try later when I have time.

    * Blinky 
    on nrf9151DK_nrf9151ns: all versions work including debugging
    * Blinky on thingy91_nrf9160: all versions work including debugging
    * Blinky on thingy91_nrf9160ns:
    - standard build works
    - standard build with "optimize for debugging (-Og)" doesn't work
    standard build with "optimize for speed (-O2)" and Extra CMake arguments "-DCONFIG_DEBUG_THREAD_INFO=y" works, I can debug in VSCode.

    When I don't choose "Optimize for debugging (-Og)" but set -DCONFIG_DEBUG_THREAD_INFO=y and -DCONFIG_DEBUG_OPTIMIZATIONS=y as extra CMake arguments, blinky is not working. When I re-open the build settings with "Edit build configuration" my manual set Cmake arguments are gone and "Optimize for debugging (-Og)" is selected - so the gui just manages the translation to "-DCONFIG_DEBUG_OPTIMIZATIONS=y" - which seems to be the bad guy here.

    So how to proceed with that?

  • BTW - when I configure blinky for a debug build and launch the debug config, the debugger doens't halt in main but just runs. When I pause, the CPU mostly hangs in this assert:

  • Hi,

    cellular_iot said:
    I use VSCode like described in the tutorials and getting started and I use the blinky example for reproduction. I gave the console a short try but lots of issues for now

    Can you show which tutorial you followed?
    Which issues did you encounter when you used console? Can you share your build log?

    Best regards,
    Dejan

  • Maybe later, for now I need to the lwm2m_client sample fully working on the thingy91 we own - sensors are not working so I need to debug this urgently.

    For debugging I followed this tutorial: docs.nordicsemi.com/.../quick_debug.html

Related