Skip to content

Commit

Permalink
applications: protocols_serialization: refactor snippets
Browse files Browse the repository at this point in the history
...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 <[email protected]>
  • Loading branch information
Damian-Nordic authored and rlubos committed Aug 5, 2024
1 parent 61c5f84 commit 52afdb8
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 55 deletions.
28 changes: 24 additions & 4 deletions applications/protocols_serialization/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions applications/protocols_serialization/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions applications/protocols_serialization/snippets/debug/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion applications/protocols_serialization/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <nrf_rpc.h>

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)
{
Expand Down
20 changes: 13 additions & 7 deletions samples/nrf_rpc/ps_client/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
9 changes: 6 additions & 3 deletions samples/nrf_rpc/ps_client/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
17 changes: 2 additions & 15 deletions samples/nrf_rpc/ps_client/snippets/debug/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion samples/nrf_rpc/ps_client/snippets/log_rpc/log_rpc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_LOG=y
CONFIG_LOG_FORWARDER_RPC=y
7 changes: 3 additions & 4 deletions samples/nrf_rpc/ps_client/snippets/openthread/openthread.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions subsys/logging/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 52afdb8

Please sign in to comment.