nRFConnect SDK VSCode not thread aware?

I'm using the latest nRFConnect SDK w/ VSCode with a custom board connected to via a J-LINK.  When I look at the call stack it only shows the current thread.  I can see thread info manually from the debug terminal (via "p *_kernel.threads", etc).  I have the following prj.conf options:

CONFIG_NO_OPTIMIZATIONS=y
CONFIG_EXTRA_EXCEPTION_INFO=y
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_THREAD_MONITOR=y
CONFIG_THREAD_STACK_INFO=y
CONFIG_THREAD_NAME=y

Should this be thread aware by default?  Or do I need to add some additional configuration to make it thread aware?

  • Hi Denis,

    Did you refer to any document or tutorial to set those configurations?

    I assume you want to analyze stack usage and runtime statistics in each thread of your application. Thread analyzer seems to be the correct choice for the current NCS1.7.0 samples. 

    Best regards,

    Charlie

  • I found those options when I was trying to setup SES to be thread aware a while back, before it was released by Segger.  I assumed that VSCode would be setup for thread awareness by the Nordic extensions.  But that doesn't seem to be the case.  What I am looking for is to be able to browse all the threads in VSCode.  Not just see the call stack of the current thread.

  • Hi Denis,

    SES and nRF Connect for VS Code Extensions are just Integrated Development Environment(IDE) for editing, compiling, flashing firmware, debugging, and so on.

    The debug options in your codes decide which kind of debugging information will print out. I did not find similar configurations from any Zephyr or NCS documents. Please turn to use the thread analyzer.

    Best regards,

    Charlie

  • I checked into Thread Analyzer.  It doesn't seem to be what I'm looking for.  I added the following and still do not see thread info in the VSCode debugger:

    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_ANALYZER_AUTO=y
    VSCode does support thread awareness.  I have set it up before when using Zephyr, VSCode, PlatformIO, and JLink.  In that case my platformio.ini had:
    debug_server =
    JLinkGDBServer
    -singlerun
    -if
    SWD
    -select
    USB
    -device
    nRF52840_xxAA
    -port
    2331
    -rtos
    GDBServer/RTOSPlugin_Zephyr
    Is there somewhere to put this for the NCS setup in VSCode so that thread aware debugging is configured in VSCode?
  • Hi Denis Bohm,

    1) PlatformIO for VScode is not a Nordic delivery, and as such is not supported by us. The main forum for PlatformIO support seems to be this one unless you can justify using their paid system: https://community.platformio.org/

    2) No mether which IDE you are using. The debug options in your codes decide which kind of debugging information will print out. For thread analyzer enabling, I follow the official document and tested zephyr\samples\basic\threads and zephyr\samples\samples/synchronization/ which use multiple threads, with the following configurations, both of them can print out thread inforamtions.

    Thread Analyzer Configurations:

    CONFIG_THREAD_ANALYZER=y 
    CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    CONFIG_THREAD_ANALYZER_AUTO=y 
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5  

    threads sample log:

    *** Booting Zephyr OS build v2.6.99-ncs1  ***
    
    Toggled led0; counter=0
    
    Toggled led1; counter=0
    
    Thread analyze:
    
     0x20000340          : STACK: unused 752 usage 272 / 1024 (26 %); CPU: 46 %
    
     0x200003e0          : STACK: unused 624 usage 400 / 1024 (39 %); CPU: 0 %
    
     0x200002a0          : STACK: unused 776 usage 248 / 1024 (24 %); CPU: 0 %
    
     0x20000200          : STACK: unused 776 usage 248 / 1024 (24 %); CPU: 0 %
    
     0x20000480          : STACK: unused 288 usage 32 / 320 (10 %); CPU: 0 %
    
    Toggled led0; counter=1
    
    Toggled led0; counter=2
    
    Toggled led0; counter=3
    
    Toggled led0; counter=4
    
    Toggled led0; counter=5
    
    Toggled led0; counter=6
    
    Toggled led0; counter=7
    
    Toggled led0; counter=8
    
    Toggled led0; counter=9
    
    Toggled led1; counter=1
    
    Toggled led0; counter=10
    
    Toggled led0; counter=11
    
    Toggled led0; counter=12
    
    Toggled led0; counter=13
    
    Toggled led0; counter=14
    
    Toggled led0; counter=15
    
    Toggled led0; counter=16
    
    Toggled led0; counter=17
    
    Toggled led0; counter=18
    
    Toggled led0; counter=19
    
    Toggled led1; counter=2
    
    Toggled led0; counter=20
    
    Toggled led0; counter=21
    
    Toggled led0; counter=22
    
    Toggled led0; counter=23
    
    Toggled led0; counter=24
    
    Toggled led0; counter=25
    
    Toggled led0; counter=26
    
    Toggled led0; counter=27
    
    Toggled led0; counter=28
    
    Toggled led0; counter=29
    
    Toggled led1; counter=3
    
    Toggled led0; counter=30
    
    Toggled led0; counter=31
    
    Toggled led0; counter=32
    
    Toggled led0; counter=33
    
    Toggled led0; counter=34
    
    Toggled led0; counter=35
    
    Toggled led0; counter=36
    
    Toggled led0; counter=37
    
    Toggled led0; counter=38
    
    Toggled led0; counter=39
    
    Toggled led1; counter=4
    
    Toggled led0; counter=40
    
    Toggled led0; counter=41
    
    Toggled led0; counter=42
    
    Toggled led0; counter=43
    
    Toggled led0; counter=44
    
    Toggled led0; counter=45
    
    Toggled led0; counter=46
    
    Toggled led0; counter=47
    
    Toggled led0; counter=48
    
    Toggled led0; counter=49
    
    Toggled led1; counter=5
    
    Toggled led0; counter=50
    
    Thread analyze:
    
     0x20000340          : STACK: unused 752 usage 272 / 1024 (26 %); CPU: 2 %
    
     0x200003e0          : STACK: unused 624 usage 400 / 1024 (39 %); CPU: 0 %
    
     0x200002a0          : STACK: unused 776 usage 248 / 1024 (24 %); CPU: 0 %
    
     0x20000200          : STACK: unused 776 usage 248 / 1024 (24 %); CPU: 0 %
    
     0x20000480          : STACK: unused 248 usage 72 / 320 (22 %); CPU: 96 %
    
    Toggled led0; counter=51
    
    Toggled led0; counter=52
    
    Toggled led0; counter=53
    

    Best regards,

    Charlie

Related