nRF Connect SDK v2.1.1 build errors on thread_analyzer.c

Hello Community & Nordic support,

Observed behaviour:
my project build with nRF Connect SDk v2.1.1 was with errors

expected behaviour:
my project build with nRF Connect SDk v2.1.1 was OK

Description:
I recently switch fro
m nRF Connect SDK v2.0.2 to v2.1.1

The build with v2.0.2 went fine.
The build with v2.1.1 went bad see below:


My proj.conf (related to the issue)

CONFIG_THREAD_STACK_INFO=y
CONFIG_THREAD_NAME=y

CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_RUNTIME_STATS=y

I recently switch from nRF Connect SDK v2.0.2 to v2.1.1

The build with v2.0.2 went fine.
The build with v2.1.1 went bad see below:

MF zephyr\CMakeFiles\zephyr.dir\subsys\debug\thread_analyzer.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/subsys/debug/thread_analyzer.c.obj -c C:/cm/ncs/v2.1.1/zephyr/subsys/debug/thread_analyzer.c
C:/cm/ncs/v2.1.1/zephyr/subsys/debug/thread_analyzer.c: In function 'thread_analyze_cb':
C:\cm\ncs\v2.1.1\zephyr\subsys\debug\thread_analyzer.c:114:46: error: 'struct thread_analyzer_info' has no member named 'usage'
  114 |  if (k_thread_runtime_stats_get(thread, &info.usage) != 0) {
      |                                              ^
C:\cm\ncs\v2.1.1\zephyr\subsys\debug\thread_analyzer.c:122:27: error: 'struct thread_analyzer_info' has no member named 'usage'
  122 |   info.utilization = (info.usage.execution_cycles * 100U) /
      |                           ^
C:\cm\ncs\v2.1.1\zephyr\subsys\debug\thread_analyzer.c:123:16: error: 'k_thread_runtime_stats_t' {aka 'struct k_thread_runtime_stats'} has no member named 'execution_cycles'
  123 |    rt_stats_all.execution_cycles;
      |                ^
[35/269] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_cmds.c.obj

Parents
  • I did manage to compile, flash and run ncs\v2.1.1\nrf\samples\bluetooth\peripheral_uart\ with trace analyzer enabled without any problem.

    here is the extra configs that I added to the existing proj.conf file

    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    CONFIG_THREAD_ANALYZER_AUTO=y
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
    CONFIG_THREAD_STACK_INFO=y
    CONFIG_THREAD_NAME=y
    CONFIG_THREAD_RUNTIME_STATS=y

Reply
  • I did manage to compile, flash and run ncs\v2.1.1\nrf\samples\bluetooth\peripheral_uart\ with trace analyzer enabled without any problem.

    here is the extra configs that I added to the existing proj.conf file

    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    CONFIG_THREAD_ANALYZER_AUTO=y
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
    CONFIG_THREAD_STACK_INFO=y
    CONFIG_THREAD_NAME=y
    CONFIG_THREAD_RUNTIME_STATS=y

Children
  • Hi Susheel Nuguru,

    Thanks,

    in the file thread_analyzer.h there is this code:

    struct thread_analyzer_info {
        /** The name of the thread or stringified address of the thread handle
         * if name is not set.
         */
        const char *name;
        /** The total size of the stack*/
        size_t stack_size;
        /** Stack size in used */
        size_t stack_used;
    
    #ifdef CONFIG_THREAD_RUNTIME_STATS
        unsigned int utilization;
    #ifdef CONFIG_SCHED_THREAD_USAGE
        k_thread_runtime_stats_t  usage;
    #endif
    #endif
    };
    


    My question for you is can you build with the settings
    CONFIG_SCHED_THREAD_USAGE = n
    Because that was the value of the setting in my project

     
    I removed the CONFIG_SCHED_THREAD_USAGE from my proj.conf and 
    re-compile  it give me the 
    build error:
    C:\cm\ncs\v2.1.1\zephyr\include\zephyr\debug\thread_analyzer.h:36:2: error: unknown type name 'k_thread_runtime_stats_t'
    36 | k_thread_runtime_stats_t usage;
    | ^~~~~~~~~~~~~~~~~~~~~~~~
    When I change the setting to 
    CONFIG_SCHED_THREAD_USAGE = n in my proj.conf and 
    re-compile  it give me the build error:
    C:/cm/ncs/v2.1.1/zephyr/subsys/debug/thread_analyzer.c: In function 'thread_analyze_cb':
    C:\cm\ncs\v2.1.1\zephyr\subsys\debug\thread_analyzer.c:114:46: error: 'struct thread_analyzer_info' has no member named 'usage'
    114 | if (k_thread_runtime_stats_get(thread, &info.usage) != 0) {
    | ^
    C:\cm\ncs\v2.1.1\zephyr\subsys\debug\thread_analyzer.c:122:27: error: 'struct thread_analyzer_info' has no member named 'usage'
    122 | info.utilization = (info.usage.execution_cycles * 100U) /
    | ^
    C:\cm\ncs\v2.1.1\zephyr\subsys\debug\thread_analyzer.c:123:16: error: 'k_thread_runtime_stats_t' {aka 'struct k_thread_runtime_stats'} has no member named 'execution_cycles'
    123 | rt_stats_all.execution_cycles;
    I do not depend on
    CONFIG_THREAD_ANALYZER_AUTO=y
    but I call it manually from a shell command!
     
  • Hi Susheel Nuguru,

    From my custom application, I just did (as intended from the documentation)

    - step 1:
    #include <debug/thread_analyzer.h>

     - step 2:
    #if IS_ENABLED(CONFIG_THREAD_ANALYZER)

            // Run the thread analyzer and prints the output in standard form.
            thread_analyzer_print();
    #endif

    and then I got the compile errors ... can you please do this yourself as well to reproduce the issue as close as possible.

    best regards,
        nRFxFanBoy

     

  • I did exactly the same as you mentioned in the main.c but also added these in the proj.conf and it works fine at my end.

    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    CONFIG_THREAD_ANALYZER_AUTO=y
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
    CONFIG_THREAD_STACK_INFO=y
    CONFIG_THREAD_NAME=y
    CONFIG_THREAD_RUNTIME_STATS=y

  • Hi Susheel Nuguru,

    Thanks,

    you have the next settings (i do not have them)


    CONFIG_THREAD_ANALYZER_AUTO=y
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5

    It means your run the analyzer from a separate specific thread and timers

    I run the analyzer once, on-demand from shell cli


    best regards,
        nRFxFanBoy

  • Quesntion, 

    Can explain (if possible) the relevance of the following settings on the issue?:

    CONFIG_THREAD_RUNTIME_STATS
    CONFIG_SCHED_THREAD_USAGE
    CONFIG_SCHED_THREAD_USAGE_ANALYSIS
    CONFIG_SCHED_THREAD_USAGE_ALL
    CONFIG_MULTITHREADING
    CONFIG_THREAD_MONITOR

Related