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

  • 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

  • Here my proj.config

    #
    # Startup sequence of CAF modules
    #
    # [main]
    #   |
    #   [orbitz_caf_monitor]
    #   |   |
    #   |   +- orbitz_caf_monitor_observer
    #   |
    #   [orbitz_caf_supervision] 
    #   |   |   |
    #   |   |   +-- orbitz_diag_checkpoint_missed_observer
    #   |   |
    #   |   +-- orbitz_diag_watchdog_adapter
    #   | 
    #   [app_main]
    #   |
    #   [startup_drivers]
    #   |   |   |   |
    #   |   |   |   +-- orbitz_caf_device
    #   |   |   |    
    #   |   |   +-- orbitz_caf_ui_led (part of user-interface)
    #   |   |   
    #   |   +-- orbitz_caf_ui_button (part of user-interface)
    #   |
    #   [startup_managers]
    #   |   |   |    |
    #   |   |   |   [measurement manager]
    #   |   |   |    |  |  |  |  |  |
    #   |   |   |    |  |  |  |  |  +-- lmT87 (env. temperature0
    #   |   |   |    |  |  |  |  +-- nRFx SoC: Die temperature
    #   |   |   |    |  |  |  |
    #   |   |   |    |  |  |  +-- Battery Charger: Capacity, USB, state (via Battery manager)
    #   |   |   |    |  |  +-- Battery Fuel Gauge: Capacity, state (via Battery manager)
    #   |   |   |    |  |
    #   |   |   |    |  +-- Motion/Orientation: Acceleration 3D/Magnetometer 3D
    #   |   |   |    |
    #   |   |   |    +-- modem bg9x: Location, Die Temperatur, RSSI, ...)
    #   |   |   |        (via connectivity manager)
    #   |   |   |
    #   |   |   |
    #   |   |   +--[battery manager]
    #   |   |  
    #   |   |  
    #   |   +--[connectivity manager]
    #   |   
    #   |   
    #   [report manager]
    
    
    # +==========================================================================+
    # |                                                                          |
    # | Zephyr (linux foundation)                                                |
    # |                                                                          |
    # +==========================================================================+
    
    
    # ----------------------------------------------------------------------------
    # Toolchain
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_HEAP_LISTENER=y
    CONFIG_SIZE_OPTIMIZATIONS=n
    CONFIG_WARN_EXPERIMENTAL=y
    
    # ----------------------------------------------------------------------------
    # kernel system
    
    # In order to correctly tune the stack sizes for the threads the following
    # Configurations can enabled to print the current use:
    #CONFIG_THREAD_NAME=y
    #CONFIG_THREAD_ANALYZER=y
    #CONFIG_THREAD_ANALYZER_AUTO=y
    #CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
    #CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    
    # General Kernel Options
    CONFIG_MAIN_STACK_SIZE=2560
    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_NAME=y
    CONFIG_THREAD_MONITOR=y
    CONFIG_THREAD_RUNTIME_STATS=y
    CONFIG_THREAD_STACK_INFO=y
    CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
    
    # System Monitoring Options
    #CONFIG_THREAD_ANALYZER_USE_PRINTK=y 
    CONFIG_THREAD_ANALYZER_USE_LOG=y
    #CONFIG_THREAD_ANALYZER_AUTO=y
    #CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
    
    # Enable show zephyr OS Build as boot or not.
    CONFIG_BOOT_BANNER=y
    
    # Enable the sys_reboot() API.
    CONFIG_REBOOT=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_STACK_SENTINEL=y
    
    # ----------------------------------------------------------------------------
    # Diagnostics support using thread awareness support
    CONFIG_DEBUG_THREAD_INFO=y
    CONFIG_DEBUG_INFO=y
    
    # ----------------------------------------------------------------------------
    # Diagnostics support using  extra exception debug information
    CONFIG_EXTRA_EXCEPTION_INFO=y
    
    # ----------------------------------------------------------------------------
    # Diagnostics support using  the fatal error handler defined for Nordic DKs.
    CONFIG_RESET_ON_FATAL_ERROR=y
    
    # ----------------------------------------------------------------------------
    # Diagnostics support using  the assert define
    CONFIG_ASSERT=n
    
    # ----------------------------------------------------------------------------
    # Diagnostics support using SEGGER SystemView Support
    
    # Enable Segger SystemView support
    CONFIG_SEGGER_SYSTEMVIEW=n
    # Enable Segger J-Link RTT libraries for platforms that support it.
    #CONFIG_USE_SEGGER_RTT=y (=default)
    
    # Enable system tracing. This requires a backend such as SEGGER Systemview to be enabled as well.
    CONFIG_TRACING=y
    # Use a ram buffer to output tracing data
    CONFIG_TRACING_BACKEND_RAM=y 
    # Enable for post-mortem tracing
    #CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE=n (=default)
    
    # ----------------------------------------------------------------------------
    # Diagnostics log module (Front-end and back-end)
    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=4
    
    # Log messages are buffered and processed later.
    CONFIG_LOG_MODE_DEFERRED=y
    
    # Drop oldest message when full
    CONFIG_LOG_MODE_OVERFLOW=y
    
    # PRINTK messages are formatted in place and logged unconditionally.
    CONFIG_LOG_PRINTK=y
    CONFIG_PRINTK_SYNC=y
    # Maximum string length supported by LOG_PRINTK
    #CONFIG_LOG_PRINTK_MAX_STRING_LENGTH=128 (=default)
    
    # log processing properties
    CONFIG_LOG_PROCESS_THREAD=y
    CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=20
    CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=10
    CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
    CONFIG_LOG_BUFFER_SIZE=2048
    #CONFIG_LOG_TIMESTAMP_64BIT=y (=default)
    
    #Prefer performance over size
    CONFIG_LOG_SPEED=y
    
    CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP=n
    CONFIG_LOG_BACKEND_RTT=n
    
    # choose RTT console
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    
    # ----------------------------------------------------------------------------
    # SHELL and Command Line Interface (via backend RTT )
    CONFIG_SHELL=y
    CONFIG_SHELL_HELP=y
    CONFIG_SHELL_CMDS=y
    CONFIG_SHELL_STATS=y
    CONFIG_SHELL_HISTORY=y
    CONFIG_SHELL_MINIMAL=y
    CONFIG_SHELL_VT100_COMMANDS=y
    CONFIG_SHELL_VT100_COLORS=n
    CONFIG_SHELL_STATS=n
    
    # backend will use the shell for logging.
    CONFIG_SHELL_LOG_BACKEND=y
    CONFIG_SHELL_BACKEND_SERIAL=n
    CONFIG_SHELL_BACKEND_RTT=y
    
    # This shell provides access to basic kernel data like version, uptime
    CONFIG_KERNEL_SHELL=n
    
    # This shell provides access to basic device data.
    CONFIG_DEVICE_SHELL=n
    
    # This shell provides access to date and time based on Unix time.
    CONFIG_DATE_SHELL=n
    
    # This shell command provides read/write access to physical memory.
    CONFIG_DEVMEM_SHELL=n
    
    # ----------------------------------------------------------------------------
    # State Machine Framework (SMF) 
    CONFIG_SMF=y
    
    # ----------------------------------------------------------------------------
    # Peripheral drivers
    
    # Options for saADC driver.
    CONFIG_ADC=y
    CONFIG_ADC_SHELL=n
    
    # Options for LED driver.
    CONFIG_LED=y
    CONFIG_LED_SHELL=n
    
    # Options for PWM driver.
    CONFIG_PWM=y
    CONFIG_PWM_SHELL=n
    
    # Options for clock driver.
    CONFIG_CLOCK_CONTROL_NRF_SHELL=n
    
    # ----------------------------------------------------------------------------
    # Persisted storage 
    
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_NVS=y
    CONFIG_NVS=y
    
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH=y
    CONFIG_FLASH_SHELL=n
    
    # Enable this to allow MPU RWX access to flash memory
    # CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    
    # +==========================================================================+
    # |                                                                          |
    # | Nordic Semiconductor                                                     |
    # |                                                                          |
    # +==========================================================================+
    
    
    # ----------------------------------------------------------------------------
    # nRF CAF 
    # ----------------------------------------------------------------------------
    CONFIG_CAF=y
    CONFIG_CAF_INIT_LOG_MODULE_STATE_EVENTS=y
    CONFIG_APP_EVENT_MANAGER_LOG_EVENT_TYPE=y
    CONFIG_APP_EVENT_MANAGER_SHOW_EVENTS=y
    CONFIG_APP_EVENT_MANAGER_TRACE_EVENT_DATA=n
    # ----------------------------------------------------------------------------
    # nRF CAF BUTTONS
    # ----------------------------------------------------------------------------
    CONFIG_CAF_BUTTONS=y
    CONFIG_CAF_BUTTON_EVENTS=y
    CONFIG_CAF_BUTTONS_POLARITY_INVERSED=y
    # Dependencies 
    CONFIG_PINCTRL=y
    
    # ----------------------------------------------------------------------------
    # nRF CAF LEDS
    # ----------------------------------------------------------------------------
    CONFIG_CAF_LEDS=y
    CONFIG_CAF_LEDS_PWM=y
    # Dependencies 
    CONFIG_LED_PWM=y
    
    # ----------------------------------------------------------------------------
    # System nrf_profiler
    # ----------------------------------------------------------------------------
    CONFIG_NRF_PROFILER=n
    CONFIG_NRF_PROFILER_MAX_NUMBER_OF_APP_EVENTS=100
    CONFIG_NRF_PROFILER_CUSTOM_EVENT_BUF_LEN=256
    CONFIG_NRF_PROFILER_NORDIC_START_LOGGING_ON_SYSTEM_START=y
    
    # +==========================================================================+
    # |                                                                          |
    # | Specific customer project settings                                       |
    # |                                                                          |
    # +==========================================================================+
    
    # <removed>

  • I do not know which app you are testing, but I tested this on peripheral_lbs aswell with the changes I gave 24 hours ago that I tested peripheral_uart example with. 

  • Hi Susheel 

    I use the thread analyzer within my client project and worked fine for months.
    Since the upgrade to ncs v2.1.1 is give me a build error.

    Like you mention you have changes some example and tested it .

    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

    What i try to say is 
    you did not the same as i did (hence we are comparing (apple versus peer)

    based on what you explain you call the thread analyzer different then how I do it.

    Can you please compile it without
    CONFIG_THREAD_ANALYZER_AUTO=y
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
    but with 
    CONFIG_THREAD_MONITOR=n


    Because having this settings CONFIG_THREAD_ANALYZER_AUTO=y   
    means a stand-alone thread run the analyzer and dumps the print in the log.
    This is a complete different behavior the  my project

    where i run the thread analyzer from the rtt with a custom shell command.
    #include <debug/thread_analyzer.h>

    #if IS_ENABLED(CONFIG_THREAD_ANALYZER)

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

    best regards,
       nRFxFanBoy


  • tried now with

    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
    CONFIG_THREAD_MONITOR=n

    changed the ble_write_thread to below in peripheral_uart example

    void ble_write_thread(void)
    {
    	/* Don't go any further until BLE is initialized */
    	k_sem_take(&ble_init_ok, K_FOREVER);
    
    	for (;;) {
    		// Run the thread analyzer and prints the output in standard form.
            thread_analyzer_print();
    
    		/* Wait indefinitely for data to be sent over bluetooth */
    		struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data,
    						     K_FOREVER);
    
    		if (bt_nus_send(NULL, buf->data, buf->len)) {
    			LOG_WRN("Failed to send data over BLE connection");
    		}
    
    		k_free(buf);
    	}
    }

    and get the stats when I press new line character in the serial terminal

    This means that the feature is working as it should and the auto refresh thing is disabled.

    I do not know what your setup is but have you tested this in the peripheral_uart (or any other sample) other than your setup?

    It seems like the errors you are seeing have some conflicting structs definitions of the thread analyzer which I am not able to reproduce.

Related