Hello!
We decided to switch from NCS 1.8.0 to 2.7.0 for our products and at the beggining of everything, noticed something very strange.
Prepared very simple example of application where cpu load reported by builtin module is around 75%!
For NCS 1.8.0 cpu load is as expected 0-1%
#include <debug/cpu_load.h> #include <ncs_version.h> #include <string.h> #if NCS_VERSION_NUMBER == 0x10800 #include <device.h> #include <drivers/uart.h> #include <kernel.h> #else #include <zephyr/device.h> #include <zephyr/drivers/uart.h> #include <zephyr/kernel.h> #endif static const struct device *const UartDev = DEVICE_DT_GET(DT_ALIAS(debug_uart)); bool uart_init(void) { if (!device_is_ready(UartDev)) { return (false); } return (true); } void uart_send(const char *data) { for (size_t i = 0; i < strlen(data); i++) { uart_poll_out(UartDev, data[i]); } } int main(void) { char print_buffer[128]; uart_init(); uart_send("/*****************************************************/\n"); uart_send("/* build time: " __DATE__ " " __TIME__ "\n"); cpu_load_init(); while (1) { k_sleep(K_MSEC(4000)); int cpu_load = cpu_load_get() / 1000; sprintf(print_buffer, "CPU LOAD: %d\n", cpu_load); uart_send(print_buffer); cpu_load_reset(); } }
CONFIG_SIZE_OPTIMIZATIONS=y CONFIG_COMPILER_OPT="-DNDEBUG" CONFIG_MAIN_STACK_SIZE=2048 CONFIG_MAIN_THREAD_PRIORITY=10 CONFIG_SERIAL=y CONFIG_CPU_LOAD=y CONFIG_REBOOT=y