From 52afdb8b92c5dc035e8e213c830882d6425d0208 Mon Sep 17 00:00:00 2001 From: Damian Krolik Date: Fri, 2 Aug 2024 16:26:15 +0200 Subject: [PATCH] applications: protocols_serialization: refactor snippets ...to ease logging. Reorganize the protocols serialization client and server snippets to be able to test logging over RPC without verbose nRF RPC core & transport logging. In ps_client: 1. Enable logging by default. 2. Make "debug" snippet only enable nRF RPC logs and other debug features. In protocols_serialization: 1. Make "log_rpc" snippet enable logging over RPC and OpenThread logs. 2. Make "debug" snippet enable (addtionally) logging over UART console. Make other Kconfig adjustments to remove build warnings and reduce config duplication. Signed-off-by: Damian Krolik --- applications/protocols_serialization/Kconfig | 28 ++++++++++++++++--- applications/protocols_serialization/prj.conf | 2 -- .../snippets/debug/debug.conf | 17 +++-------- .../snippets/log_rpc/log_rpc.conf | 5 ++++ .../snippets/openthread/openthread.conf | 5 ---- .../protocols_serialization/src/main.c | 2 +- samples/nrf_rpc/ps_client/Kconfig | 20 ++++++++----- samples/nrf_rpc/ps_client/prj.conf | 9 ++++-- .../ps_client/snippets/debug/debug.conf | 17 ++--------- .../ps_client/snippets/log_rpc/log_rpc.conf | 1 - .../snippets/openthread/openthread.conf | 7 ++--- subsys/logging/Kconfig | 1 + 12 files changed, 59 insertions(+), 55 deletions(-) diff --git a/applications/protocols_serialization/Kconfig b/applications/protocols_serialization/Kconfig index 39b267863c2..5486ad55fa2 100644 --- a/applications/protocols_serialization/Kconfig +++ b/applications/protocols_serialization/Kconfig @@ -4,10 +4,30 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # +menu "Protocols serialization server" + +choice LOG_MODE + default LOG_MODE_DEFERRED +endchoice + +config LOG_BUFFER_SIZE + default 8192 + +config LOG_FUNC_NAME_PREFIX_DBG + default n + +config LOG_BACKEND_RTT + default n + +config LOG_BACKEND_UART + default n + +module = NRF_PS_SERVER +module-str = nrf_ps_server +source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" + +endmenu # "Protocols serialization server" + menu "Zephyr Kernel" source "Kconfig.zephyr" endmenu - -module = NRF_RPC_REMOTE -module-str = nrf_rpc_remote -source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" diff --git a/applications/protocols_serialization/prj.conf b/applications/protocols_serialization/prj.conf index e2be988bed9..47bf1d9badb 100644 --- a/applications/protocols_serialization/prj.conf +++ b/applications/protocols_serialization/prj.conf @@ -5,8 +5,6 @@ # CONFIG_HEAP_MEM_POOL_SIZE=4096 -CONFIG_THREAD_CUSTOM_DATA=y - CONFIG_NRF_RPC=y CONFIG_NRF_RPC_CBOR=y CONFIG_NRF_RPC_ZCBOR_BACKUPS=1 diff --git a/applications/protocols_serialization/snippets/debug/debug.conf b/applications/protocols_serialization/snippets/debug/debug.conf index eb649b51d6b..c48d0f3d279 100644 --- a/applications/protocols_serialization/snippets/debug/debug.conf +++ b/applications/protocols_serialization/snippets/debug/debug.conf @@ -4,27 +4,18 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -# Enable multithread support in gdb +# Reduce optimization level for easier debugging CONFIG_DEBUG=y # Enable asserts CONFIG_ASSERT=y -#CONFIG_ASSERT_NO_COND_INFO=y +# Enable UART console CONFIG_LOG=y - -# Use separate thread for logging -CONFIG_LOG_MODE_DEFERRED=y -CONFIG_LOG_BUFFER_SIZE=4096 -CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n -CONFIG_LOG_BACKEND_RTT=n CONFIG_LOG_BACKEND_UART=y -# Increase max log level to informative -CONFIG_LOG_MAX_LEVEL=4 - -CONFIG_NRF_RPC_REMOTE_LOG_LEVEL_DBG=y +# Enable verbose logging +CONFIG_NRF_PS_SERVER_LOG_LEVEL_DBG=y CONFIG_NRF_RPC_TR_LOG_LEVEL_DBG=y CONFIG_NRF_RPC_LOG_LEVEL_DBG=y CONFIG_NRF_RPC_OS_LOG_LEVEL_DBG=y -CONFIG_NET_L2_IEEE802154_LOG_LEVEL_ERR=y diff --git a/applications/protocols_serialization/snippets/log_rpc/log_rpc.conf b/applications/protocols_serialization/snippets/log_rpc/log_rpc.conf index 39e047235cd..9acc209a1ad 100644 --- a/applications/protocols_serialization/snippets/log_rpc/log_rpc.conf +++ b/applications/protocols_serialization/snippets/log_rpc/log_rpc.conf @@ -4,8 +4,13 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # +CONFIG_LOG=y CONFIG_LOG_BACKEND_RPC=y CONFIG_LOG_BACKEND_RPC_CRASH_LOG=y # nRF RPC requires slightly bigger stack than default CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=1024 + +# Enable OpenThread logs along with logging over RPC +CONFIG_OPENTHREAD_DEBUG=y +CONFIG_OPENTHREAD_LOG_LEVEL_INFO=y diff --git a/applications/protocols_serialization/snippets/openthread/openthread.conf b/applications/protocols_serialization/snippets/openthread/openthread.conf index 73a3dbb10c9..c50c6550c50 100644 --- a/applications/protocols_serialization/snippets/openthread/openthread.conf +++ b/applications/protocols_serialization/snippets/openthread/openthread.conf @@ -4,11 +4,6 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -CONFIG_OPENTHREAD_SHELL=y - -CONFIG_SHELL_ARGC_MAX=26 -CONFIG_SHELL_CMD_BUFF_SIZE=416 - # Enable OpenThread features set CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y CONFIG_OPENTHREAD_SOURCES=y diff --git a/applications/protocols_serialization/src/main.c b/applications/protocols_serialization/src/main.c index 5dedc69d0fa..da1ae74dac2 100644 --- a/applications/protocols_serialization/src/main.c +++ b/applications/protocols_serialization/src/main.c @@ -8,7 +8,7 @@ #include -LOG_MODULE_REGISTER(nrf_rpc_remote, CONFIG_NRF_RPC_REMOTE_LOG_LEVEL); +LOG_MODULE_REGISTER(nrf_ps_server, CONFIG_NRF_PS_SERVER_LOG_LEVEL); static void err_handler(const struct nrf_rpc_err_report *report) { diff --git a/samples/nrf_rpc/ps_client/Kconfig b/samples/nrf_rpc/ps_client/Kconfig index 88e10dc9e99..d4fbfd8ff3d 100644 --- a/samples/nrf_rpc/ps_client/Kconfig +++ b/samples/nrf_rpc/ps_client/Kconfig @@ -4,7 +4,14 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -mainmenu "Protocols serialization client" +menu "Protocols serialization client" + +config BT_CTLR + default n + +choice BT_NUS_LOG_LEVEL_CHOICE + default BT_NUS_LOG_LEVEL_DBG if DEBUG +endchoice config RPC_CRASH_LOG_READ_BUFFER_SIZE int "Crash log read buffer size" @@ -14,13 +21,12 @@ config RPC_CRASH_LOG_READ_BUFFER_SIZE Size of the stack buffer used for reading a single chunk of the crash log from the server device. -config BT_CTLR - default n +module = NRF_PS_CLIENT +module-str = nrf_ps_client +source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" + +endmenu # "Protocols serialization client" menu "Zephyr Kernel" source "Kconfig.zephyr" endmenu - -module = NRF_PS_CLIENT -module-str = nrf_ps_client -source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" diff --git a/samples/nrf_rpc/ps_client/prj.conf b/samples/nrf_rpc/ps_client/prj.conf index c290af9680f..a733c7089c6 100644 --- a/samples/nrf_rpc/ps_client/prj.conf +++ b/samples/nrf_rpc/ps_client/prj.conf @@ -5,8 +5,6 @@ # CONFIG_HEAP_MEM_POOL_SIZE=4096 -CONFIG_THREAD_CUSTOM_DATA=y - CONFIG_NRF_RPC=y CONFIG_NRF_RPC_CBOR=y CONFIG_NRF_RPC_ZCBOR_BACKUPS=1 @@ -18,4 +16,9 @@ CONFIG_UART_LINE_CTRL=y CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_SHELL=y -CONFIG_NET_SHELL=y +CONFIG_LOG=y +CONFIG_LOG_MODE_DEFERRED=y +CONFIG_LOG_BUFFER_SIZE=4096 +CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n +CONFIG_LOG_BACKEND_RTT=n +CONFIG_SHELL_LOG_BACKEND=y diff --git a/samples/nrf_rpc/ps_client/snippets/debug/debug.conf b/samples/nrf_rpc/ps_client/snippets/debug/debug.conf index a6a1c3ccf8d..32411813d57 100644 --- a/samples/nrf_rpc/ps_client/snippets/debug/debug.conf +++ b/samples/nrf_rpc/ps_client/snippets/debug/debug.conf @@ -4,27 +4,14 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -# Enable multithread support in gdb +# Reduce optimization level for easier debugging. CONFIG_DEBUG=y # Enable asserts CONFIG_ASSERT=y -#CONFIG_ASSERT_NO_COND_INFO=y - -CONFIG_LOG=y - -# Use separate thread for logging -CONFIG_LOG_MODE_DEFERRED=y -CONFIG_LOG_BUFFER_SIZE=4096 -CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n -CONFIG_LOG_BACKEND_RTT=n -CONFIG_SHELL_LOG_BACKEND=y - -# Increase max log level to informative -CONFIG_LOG_MAX_LEVEL=4 +# Enable verbose logging CONFIG_NRF_PS_CLIENT_LOG_LEVEL_DBG=y CONFIG_NRF_RPC_TR_LOG_LEVEL_DBG=y CONFIG_NRF_RPC_LOG_LEVEL_DBG=y CONFIG_NRF_RPC_OS_LOG_LEVEL_DBG=y -CONFIG_BT_NUS_LOG_LEVEL_DBG=y diff --git a/samples/nrf_rpc/ps_client/snippets/log_rpc/log_rpc.conf b/samples/nrf_rpc/ps_client/snippets/log_rpc/log_rpc.conf index c02d6b245ff..4059469a577 100644 --- a/samples/nrf_rpc/ps_client/snippets/log_rpc/log_rpc.conf +++ b/samples/nrf_rpc/ps_client/snippets/log_rpc/log_rpc.conf @@ -4,5 +4,4 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -CONFIG_LOG=y CONFIG_LOG_FORWARDER_RPC=y diff --git a/samples/nrf_rpc/ps_client/snippets/openthread/openthread.conf b/samples/nrf_rpc/ps_client/snippets/openthread/openthread.conf index 97b20663320..401b7c7ba06 100644 --- a/samples/nrf_rpc/ps_client/snippets/openthread/openthread.conf +++ b/samples/nrf_rpc/ps_client/snippets/openthread/openthread.conf @@ -4,12 +4,11 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -# Network shell -CONFIG_SHELL=y -CONFIG_NET_SHELL=y - CONFIG_OPENTHREAD_RPC=y CONFIG_OPENTHREAD_RPC_CLIENT=y CONFIG_NETWORKING=y CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5 + +# Enable networking shell to test the network interface operation +CONFIG_NET_SHELL=y diff --git a/subsys/logging/Kconfig b/subsys/logging/Kconfig index 346cbb95daf..2fe81d5e45d 100644 --- a/subsys/logging/Kconfig +++ b/subsys/logging/Kconfig @@ -24,6 +24,7 @@ menuconfig LOG_BACKEND_RPC depends on LOG_MODE_DEFERRED depends on LOG_PROCESS_THREAD depends on !LOG_FORWARDER_RPC + select LOG_OUTPUT select LOG_RPC help Enables Zephyr logging backend that sends log messages as nRF RPC events.