From f5587552bb88fe6e57f3be1b30b8fb93fd3e0c32 Mon Sep 17 00:00:00 2001 From: Christopher Friedt Date: Sat, 24 Sep 2022 13:39:42 -0400 Subject: [PATCH] logging: move backends to subdirectory This is mainly to reduce clutter in `subsys/logging`, but also to make backend management slightly easier. Signed-off-by: Christopher Friedt --- subsys/logging/CMakeLists.txt | 85 +--- subsys/logging/Kconfig | 2 +- subsys/logging/Kconfig.backends | 470 ------------------ subsys/logging/backends/CMakeLists.txt | 66 +++ subsys/logging/backends/Kconfig | 19 + subsys/logging/backends/Kconfig.adsp | 18 + subsys/logging/backends/Kconfig.adsp_hda | 52 ++ subsys/logging/backends/Kconfig.adsp_mtrace | 18 + subsys/logging/backends/Kconfig.efi_console | 18 + subsys/logging/backends/Kconfig.fs | 54 ++ subsys/logging/backends/Kconfig.native_posix | 18 + subsys/logging/backends/Kconfig.net | 66 +++ subsys/logging/backends/Kconfig.rtt | 108 ++++ subsys/logging/backends/Kconfig.spinel | 27 + subsys/logging/backends/Kconfig.swo | 31 ++ subsys/logging/backends/Kconfig.uart | 51 ++ subsys/logging/backends/Kconfig.xtensa_sim | 26 + .../logging/{ => backends}/log_backend_adsp.c | 0 .../{ => backends}/log_backend_adsp_hda.c | 0 .../{ => backends}/log_backend_adsp_mtrace.c | 0 .../{ => backends}/log_backend_efi_console.c | 0 .../logging/{ => backends}/log_backend_fs.c | 0 .../{ => backends}/log_backend_native_posix.c | 0 .../logging/{ => backends}/log_backend_net.c | 0 .../logging/{ => backends}/log_backend_rtt.c | 0 .../{ => backends}/log_backend_spinel.c | 0 .../logging/{ => backends}/log_backend_swo.c | 0 .../logging/{ => backends}/log_backend_uart.c | 0 .../{ => backends}/log_backend_xtensa_sim.c | 0 29 files changed, 584 insertions(+), 545 deletions(-) delete mode 100644 subsys/logging/Kconfig.backends create mode 100644 subsys/logging/backends/CMakeLists.txt create mode 100644 subsys/logging/backends/Kconfig create mode 100644 subsys/logging/backends/Kconfig.adsp create mode 100644 subsys/logging/backends/Kconfig.adsp_hda create mode 100644 subsys/logging/backends/Kconfig.adsp_mtrace create mode 100644 subsys/logging/backends/Kconfig.efi_console create mode 100644 subsys/logging/backends/Kconfig.fs create mode 100644 subsys/logging/backends/Kconfig.native_posix create mode 100644 subsys/logging/backends/Kconfig.net create mode 100644 subsys/logging/backends/Kconfig.rtt create mode 100644 subsys/logging/backends/Kconfig.spinel create mode 100644 subsys/logging/backends/Kconfig.swo create mode 100644 subsys/logging/backends/Kconfig.uart create mode 100644 subsys/logging/backends/Kconfig.xtensa_sim rename subsys/logging/{ => backends}/log_backend_adsp.c (100%) rename subsys/logging/{ => backends}/log_backend_adsp_hda.c (100%) rename subsys/logging/{ => backends}/log_backend_adsp_mtrace.c (100%) rename subsys/logging/{ => backends}/log_backend_efi_console.c (100%) rename subsys/logging/{ => backends}/log_backend_fs.c (100%) rename subsys/logging/{ => backends}/log_backend_native_posix.c (100%) rename subsys/logging/{ => backends}/log_backend_net.c (100%) rename subsys/logging/{ => backends}/log_backend_rtt.c (100%) rename subsys/logging/{ => backends}/log_backend_spinel.c (100%) rename subsys/logging/{ => backends}/log_backend_swo.c (100%) rename subsys/logging/{ => backends}/log_backend_uart.c (100%) rename subsys/logging/{ => backends}/log_backend_xtensa_sim.c (100%) diff --git a/subsys/logging/CMakeLists.txt b/subsys/logging/CMakeLists.txt index d1aa406b0cb..7af7a1f54ef 100644 --- a/subsys/logging/CMakeLists.txt +++ b/subsys/logging/CMakeLists.txt @@ -32,90 +32,27 @@ if(NOT CONFIG_LOG_MODE_MINIMAL) endif() endif() - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_UART - log_backend_uart.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_FS - log_backend_fs.c - ) - zephyr_sources_ifdef( CONFIG_LOG_CMDS log_cmds.c ) - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_NATIVE_POSIX - log_backend_native_posix.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_XTENSA_SIM - log_backend_xtensa_sim.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_NET - log_backend_net.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_RTT - log_backend_rtt.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_SWO - log_backend_swo.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_MIPI_SYST_ENABLE - log_output_syst.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_ADSP - log_backend_adsp.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_ADSP_HDA - log_backend_adsp_hda.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_ADSP_MTRACE - log_backend_adsp_mtrace.c - ) - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_EFI_CONSOLE - log_backend_efi_console.c - ) - - if(CONFIG_LOG_BACKEND_SPINEL) - zephyr_library_include_directories( - ${ZEPHYR_BASE}/subsys/net/lib/openthread/platform/ - ) - endif() - - zephyr_sources_ifdef( - CONFIG_LOG_BACKEND_SPINEL - log_backend_spinel.c - ) - zephyr_sources_ifdef( CONFIG_LOG_FRONTEND_DICT_UART log_frontend_dict_uart.c ) - if(CONFIG_LOG_DICTIONARY_SUPPORT) - zephyr_sources(log_output_dict.c) - endif() + zephyr_sources_ifdef( + CONFIG_LOG_DICTIONARY_SUPPORT + log_output_dict.c + ) + + zephyr_sources_ifdef( + CONFIG_LOG_MIPI_SYST_ENABLE + log_output_syst.c + ) + + add_subdirectory(backends) else() zephyr_sources(log_minimal.c) diff --git a/subsys/logging/Kconfig b/subsys/logging/Kconfig index fc87548b78f..269357bd7fc 100644 --- a/subsys/logging/Kconfig +++ b/subsys/logging/Kconfig @@ -24,7 +24,7 @@ rsource "Kconfig.formatting" if !LOG_FRONTEND_ONLY -rsource "Kconfig.backends" +rsource "backends/Kconfig" endif # !LOG_FRONTEND_ONLY diff --git a/subsys/logging/Kconfig.backends b/subsys/logging/Kconfig.backends deleted file mode 100644 index f495676be13..00000000000 --- a/subsys/logging/Kconfig.backends +++ /dev/null @@ -1,470 +0,0 @@ -# Copyright (c) 2021 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -menu "Backends" - -config LOG_BACKEND_UART - bool "UART backend" - depends on UART_CONSOLE - default y if !SHELL_BACKEND_SERIAL - select LOG_OUTPUT - help - When enabled backend is using UART to output logs. - -if LOG_BACKEND_UART - -config LOG_BACKEND_UART_ASYNC - bool "Use UART Asynchronous API" - depends on UART_ASYNC_API - depends on !LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX - -config LOG_BACKEND_UART_BUFFER_SIZE - int "Number of bytes to buffer in RAM before flushing" - default 32 if LOG_BACKEND_UART_ASYNC - default 1 - help - Sets the number of bytes which can be buffered in RAM before log_output_flush - is automatically called on the backend. - -backend = UART -backend-str = uart -source "subsys/logging/Kconfig.template.log_format_config" - -if LOG_BACKEND_UART_OUTPUT_DICTIONARY - -choice - prompt "Dictionary mode output format" - default LOG_BACKEND_UART_OUTPUT_DICTIONARY_BIN - -config LOG_BACKEND_UART_OUTPUT_DICTIONARY_BIN - bool "Dictionary (binary)" - help - Dictionary-based logging output in binary. - -config LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX - bool "Dictionary (hexadecimal)" - help - Dictionary-based logging output in hexadecimal. Supported only for UART backend. - -endchoice - -endif # LOG_BACKEND_UART_OUTPUT_DICTIONARY - -endif # LOG_BACKEND_UART - -config LOG_BACKEND_SWO - bool "Serial Wire Output (SWO) backend" - depends on HAS_SWO - select LOG_OUTPUT - help - When enabled, backend will use SWO for logging. - -if LOG_BACKEND_SWO - -config LOG_BACKEND_SWO_FREQ_HZ - int "Set SWO output frequency" - default 0 - help - Set SWO output frequency. Value 0 will select maximum frequency - supported by the given MCU. Not all debug probes support high - frequency SWO operation. In this case the frequency has to be set - manually. - - SWO value defined by this option will be configured at boot. Most SWO - viewer programs will configure SWO frequency when attached to the - debug probe. Such configuration will persist only until the device - reset. To ensure flawless operation the frequency configured here and - by the SWO viewer program has to match. - -backend = SWO -backend-str = swo -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_SWO - -config LOG_BACKEND_RTT - bool "Segger J-Link RTT backend" - depends on USE_SEGGER_RTT - default y if !SHELL_BACKEND_RTT - select SEGGER_RTT_CUSTOM_LOCKING - select LOG_OUTPUT - help - When enabled, backend will use RTT for logging. This backend works on a per - message basis. Only a whole message (terminated with a carriage return: '\r') - is transferred to up-buffer at once depending on available space and - selected mode. - In panic mode backend always blocks and waits until there is space - in up-buffer for a message and message is transferred to host. - -if LOG_BACKEND_RTT - -choice LOG_BACKEND_RTT_MODE - prompt "Logger behavior" - default LOG_BACKEND_RTT_MODE_BLOCK - -config LOG_BACKEND_RTT_MODE_DROP - bool "Drop messages that do not fit in up-buffer." - help - If there is not enough space in up-buffer for a message, drop it. - Number of dropped messages will be logged. - Increase up-buffer size helps to reduce dropping of messages. - -config LOG_BACKEND_RTT_MODE_BLOCK - bool "Block until message is transferred to host." - help - Waits until there is enough space in the up-buffer for a message. - -config LOG_BACKEND_RTT_MODE_OVERWRITE - bool "Overwrite messages if up-buffer full" - help - If there is not enough space in up-buffer for a message overwrite - oldest one. - -endchoice - -backend = RTT -backend-str = rtt -source "subsys/logging/Kconfig.template.log_format_config" - -config LOG_BACKEND_RTT_MESSAGE_SIZE - int "Size of internal buffer for storing messages." - range 32 256 - default 128 - depends on LOG_BACKEND_RTT_MODE_DROP - help - This option defines maximum message size transferable to up-buffer. - -if LOG_BACKEND_RTT_MODE_BLOCK - -config LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE - int "Size of the output buffer" - default 16 - help - Buffer is used by log_output module for preparing output data (e.g. - string formatting). - -config LOG_BACKEND_RTT_RETRY_CNT - int "Number of retries" - default 4 - help - Number of TX retries before dropping the data and assuming that - RTT session is inactive. - -config LOG_BACKEND_RTT_RETRY_DELAY_MS - int "Delay between TX retries in milliseconds" - default 5 - help - Sleep period between TX retry attempts. During RTT session, host pulls - data periodically. Period starts from 1-2 milliseconds and can be - increased if traffic on RTT increases (also from host to device). In - case of heavy traffic data can be lost and it may be necessary to - increase delay or number of retries. - -endif # LOG_BACKEND_RTT_MODE_BLOCK - -config LOG_BACKEND_RTT_BUFFER - int "Buffer number used for logger output." - range 0 SEGGER_RTT_MAX_NUM_UP_BUFFERS - default 0 - help - Select index of up-buffer used for logger output, by default it uses - terminal up-buffer and its settings. - -config LOG_BACKEND_RTT_BUFFER_SIZE - int "Size of reserved up-buffer for logger output." - default 1024 - depends on LOG_BACKEND_RTT_BUFFER > 0 - help - Specify reserved size of up-buffer used for logger output. - -# Enable processing of printk calls using log if terminal buffer is used. -# Same buffer is used by RTT console. If printk would go through RTT console -# that will lead to corruption of RTT data which is not protected against being -# interrupted by an interrupt. -config LOG_BACKEND_RTT_FORCE_PRINTK - bool - default y if LOG_BACKEND_RTT_BUFFER = 0 && RTT_CONSOLE - select LOG_PRINTK - -endif # LOG_BACKEND_RTT - -config LOG_BACKEND_SPINEL - bool "OpenThread dedicated Spinel protocol backend" - depends on !LOG_BACKEND_UART - depends on NET_L2_OPENTHREAD - select LOG_OUTPUT - help - When enabled, backend will use OpenThread dedicated SPINEL protocol for logging. - This protocol is byte oriented and wraps given messages into serial frames. - Backend should be enabled only to OpenThread purposes and when UART backend is disabled - or works on another UART device to avoid interference. - -if LOG_BACKEND_SPINEL - -config LOG_BACKEND_SPINEL_BUFFER_SIZE - int "Size of reserved up-buffer for logger output." - default 64 - help - Specify reserved size of up-buffer used for logger output. - -backend = SPINEL -backend-str = spinel -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_SPINEL - -config LOG_BACKEND_NATIVE_POSIX - bool "Native backend" - depends on ARCH_POSIX - default y if !SERIAL - select LOG_OUTPUT - help - Enable backend in native_posix - -if LOG_BACKEND_NATIVE_POSIX - -backend = NATIVE_POSIX -backend-str = native_posix -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_NATIVE_POSIX - -config LOG_BACKEND_XTENSA_SIM - bool "Xtensa simulator backend" - depends on SOC_XTENSA_SAMPLE_CONTROLLER || SOC_FAMILY_INTEL_ADSP - default y if SOC_XTENSA_SAMPLE_CONTROLLER - select LOG_OUTPUT - help - Enable backend in xtensa simulator - -config LOG_BACKEND_XTENSA_OUTPUT_BUFFER_SIZE - int "Size of the output buffer" - default 16 - depends on LOG_BACKEND_XTENSA_SIM - help - Buffer is used by log_output module for preparing output data (e.g. - string formatting). - -if LOG_BACKEND_XTENSA_SIM - -backend = XTENSA_SIM -backend-str = xtensa_sim -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_XTENSA_SIM - -# Immediate mode cannot be used with network backend as it would cause the sent -# rsyslog message to be malformed. -config LOG_BACKEND_NET - bool "Networking backend" - depends on NETWORKING && NET_UDP && !LOG_MODE_IMMEDIATE - select NET_CONTEXT_NET_PKT_POOL - select LOG_OUTPUT - help - Send syslog messages to network server. - See RFC 5424 (syslog protocol) and RFC 5426 (syslog over UDP) - specifications for details. - -if LOG_BACKEND_NET - -config LOG_BACKEND_NET_SERVER - string "Syslog server IP address" - help - This can be either IPv4 or IPv6 address. - Server listen UDP port number can be configured here too. - Following syntax is supported: - 192.0.2.1:514 - 192.0.2.42 - [2001:db8::1]:514 - [2001:db8::2] - 2001:db::42 - -config LOG_BACKEND_NET_MAX_BUF - int "How many network buffers to allocate for sending messages" - range 3 256 - default 3 - help - Each syslog message should fit into a network packet that will be - sent to server. This number tells how many syslog messages can be - in transit to the server. - -config LOG_BACKEND_NET_MAX_BUF_SIZE - int "Max syslog message size" - range 64 1180 - default 1180 if NET_IPV6 - default 480 if NET_IPV4 - default 256 - help - As each syslog message needs to fit to UDP packet, set this value - so that messages are not truncated. - The RFC 5426 recommends that for IPv4 the size is 480 octets and for - IPv6 the size is 1180 octets. As each buffer will use RAM, the value - should be selected so that typical messages will fit the buffer. - -config LOG_BACKEND_NET_AUTOSTART - bool "Automatically start networking backend" - default y if NET_CONFIG_NEED_IPV4 || NET_CONFIG_NEED_IPV6 - help - When enabled automatically start the networking backend on - application start. If no routes to the logging server are available - on application startup, this must be set to n and the backend must be - started by the application later on. Otherwise the logging - thread might block. - -backend = NET -backend-str = net -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_NET - -config LOG_BACKEND_ADSP - bool "Intel ADSP buffer backend" - depends on SOC_FAMILY_INTEL_ADSP - select LOG_OUTPUT - help - Enable backend for the host trace protocol of the Intel ADSP - family of audio processors - -if LOG_BACKEND_ADSP - -backend = ADSP -backend-str = adsp -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_ADSP - -config LOG_BACKEND_ADSP_HDA - bool "Intel ADSP HDA backend" - depends on SOC_FAMILY_INTEL_ADSP && DMA && DMA_INTEL_ADSP_HDA_HOST_OUT - select LOG_OUTPUT - help - Provide a logging backend which writes to a buffer and - periodically flushes to hardware using ringbuffer like - semantics provided by DMA_INTEL_ADSP_HDA. - -if LOG_BACKEND_ADSP_HDA - -backend = ADSP_HDA -backend-str = adsp_hda -source "subsys/logging/Kconfig.template.log_format_config" - -config LOG_BACKEND_ADSP_HDA_SIZE - int "Size of ring buffer" - range 128 8192 - default 4096 - help - Sets the ring buffer size cAVS HDA uses for logging. Effectively - determines how many log messages may be written to in a period of time. - The period of time is decided by how often to inform the hardware of - writes to the buffer. - -config LOG_BACKEND_ADSP_HDA_FLUSH_TIME - int "Time in milliseconds to periodically flush writes to hardware" - range 1 10000 - default 500 - help - The Intel ADSP HDA backend periodically writes out its buffer contents - to hardware by informing the DMA hardware the contents of the ring - buffer. - -config LOG_BACKEND_ADSP_HDA_CAVSTOOL - bool "Log backend is to be used with cavstool" - help - Use cavstool understood IPC messages to inform setup and logging of - HDA messages. - -config LOG_BACKEND_ADSP_HDA_PADDING - bool "Log backend should pad the buffer with \0 characters when flushing" - help - HDA requires transfers be 128 byte aligned such that a partial message may - never make it across unless padded with \0 characters to the next 128 byte - aligned address. This may or may not work depending on the log format - being used but should certainly work with text based logging. - -endif # LOG_BACKEND_ADSP_HDA - -config LOG_BACKEND_ADSP_MTRACE - bool "Intel ADSP mtrace backend" - depends on SOC_FAMILY_INTEL_ADSP - select LOG_OUTPUT - help - Provide a logging backend which writes to SRAM window - using the SOF Linux driver mtrace buffer layout. - -if LOG_BACKEND_ADSP_MTRACE - -backend = ADSP_MTRACE -backend-str = adsp_mtrace -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_ADSP_MTRACE - -config LOG_BACKEND_FS - bool "File system backend" - depends on FILE_SYSTEM - select LOG_OUTPUT - help - When enabled, backend is using the configured file system to output logs. - As the file system must be mounted for the logging to work, it must be - either configured for auto-mount or manually mounted by the application. - Log messages are discarded as long as the file system is not mounted. - -if LOG_BACKEND_FS - -backend = FS -backend-str = fs -source "subsys/logging/Kconfig.template.log_format_config" - -config LOG_BACKEND_FS_OVERWRITE - bool "Old log files overwrite" - default y - help - When enabled backend overwrites oldest log files. - In other case, when memory is full, new messages are dropped. - -config LOG_BACKEND_FS_FILE_PREFIX - string "Log file name prefix" - default "log." - help - User defined name of log files saved in the file system. - The prefix is followed by the number of log file. - -config LOG_BACKEND_FS_DIR - string "Log directory" - default "/lfs1" - help - Directory to which log files will be written. - -config LOG_BACKEND_FS_FILE_SIZE - int "User defined log file size" - default 4096 - range 128 1073741824 - help - Max log file size (in bytes). - -config LOG_BACKEND_FS_FILES_LIMIT - int "Max number of files containing logs" - default 10 - help - Limit of number of files with logs. It is also limited by - size of file system partition. - -endif # LOG_BACKEND_FS - -config LOG_BACKEND_EFI_CONSOLE - bool "EFI_CONSOLE backend" - depends on X86_EFI_CONSOLE - select LOG_OUTPUT - default y if !UART_CONSOLE - help - When enabled backend is using EFI CONSOLE to output logs. - -if LOG_BACKEND_EFI_CONSOLE - -backend = EFI_CON -backend-str = efi_console -source "subsys/logging/Kconfig.template.log_format_config" - -endif # LOG_BACKEND_EFI_CONSOLE - -endmenu diff --git a/subsys/logging/backends/CMakeLists.txt b/subsys/logging/backends/CMakeLists.txt new file mode 100644 index 00000000000..cdadfa16dc5 --- /dev/null +++ b/subsys/logging/backends/CMakeLists.txt @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_ADSP + log_backend_adsp.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_ADSP_HDA + log_backend_adsp_hda.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_ADSP_MTRACE + log_backend_adsp_mtrace.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_EFI_CONSOLE + log_backend_efi_console.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_FS + log_backend_fs.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_NATIVE_POSIX + log_backend_native_posix.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_NET + log_backend_net.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_RTT + log_backend_rtt.c +) + +zephyr_include_directories_ifdef( + CONFIG_LOG_BACKEND_SPINEL + ${ZEPHYR_BASE}/subsys/net/lib/openthread/platform/ +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_SPINEL + log_backend_spinel.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_SWO + log_backend_swo.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_UART + log_backend_uart.c +) + +zephyr_sources_ifdef( + CONFIG_LOG_BACKEND_XTENSA_SIM + log_backend_xtensa_sim.c +) diff --git a/subsys/logging/backends/Kconfig b/subsys/logging/backends/Kconfig new file mode 100644 index 00000000000..7d60b19e936 --- /dev/null +++ b/subsys/logging/backends/Kconfig @@ -0,0 +1,19 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +menu "Backends" + +rsource "Kconfig.adsp" +rsource "Kconfig.adsp_hda" +rsource "Kconfig.adsp_mtrace" +rsource "Kconfig.efi_console" +rsource "Kconfig.fs" +rsource "Kconfig.native_posix" +rsource "Kconfig.net" +rsource "Kconfig.rtt" +rsource "Kconfig.spinel" +rsource "Kconfig.swo" +rsource "Kconfig.uart" +rsource "Kconfig.xtensa_sim" + +endmenu diff --git a/subsys/logging/backends/Kconfig.adsp b/subsys/logging/backends/Kconfig.adsp new file mode 100644 index 00000000000..d64735fa17a --- /dev/null +++ b/subsys/logging/backends/Kconfig.adsp @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_ADSP + bool "Intel ADSP buffer backend" + depends on SOC_FAMILY_INTEL_ADSP + select LOG_OUTPUT + help + Enable backend for the host trace protocol of the Intel ADSP + family of audio processors + +if LOG_BACKEND_ADSP + +backend = ADSP +backend-str = adsp +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_ADSP diff --git a/subsys/logging/backends/Kconfig.adsp_hda b/subsys/logging/backends/Kconfig.adsp_hda new file mode 100644 index 00000000000..e384f43222e --- /dev/null +++ b/subsys/logging/backends/Kconfig.adsp_hda @@ -0,0 +1,52 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_ADSP_HDA + bool "Intel ADSP HDA backend" + depends on SOC_FAMILY_INTEL_ADSP && DMA && DMA_INTEL_ADSP_HDA_HOST_OUT + select LOG_OUTPUT + help + Provide a logging backend which writes to a buffer and + periodically flushes to hardware using ringbuffer like + semantics provided by DMA_INTEL_ADSP_HDA. + +if LOG_BACKEND_ADSP_HDA + +backend = ADSP_HDA +backend-str = adsp_hda +source "subsys/logging/Kconfig.template.log_format_config" + +config LOG_BACKEND_ADSP_HDA_SIZE + int "Size of ring buffer" + range 128 8192 + default 4096 + help + Sets the ring buffer size cAVS HDA uses for logging. Effectively + determines how many log messages may be written to in a period of time. + The period of time is decided by how often to inform the hardware of + writes to the buffer. + +config LOG_BACKEND_ADSP_HDA_FLUSH_TIME + int "Time in milliseconds to periodically flush writes to hardware" + range 1 10000 + default 500 + help + The Intel ADSP HDA backend periodically writes out its buffer contents + to hardware by informing the DMA hardware the contents of the ring + buffer. + +config LOG_BACKEND_ADSP_HDA_CAVSTOOL + bool "Log backend is to be used with cavstool" + help + Use cavstool understood IPC messages to inform setup and logging of + HDA messages. + +config LOG_BACKEND_ADSP_HDA_PADDING + bool "Log backend should pad the buffer with \0 characters when flushing" + help + HDA requires transfers be 128 byte aligned such that a partial message may + never make it across unless padded with \0 characters to the next 128 byte + aligned address. This may or may not work depending on the log format + being used but should certainly work with text based logging. + +endif # LOG_BACKEND_ADSP_HDA diff --git a/subsys/logging/backends/Kconfig.adsp_mtrace b/subsys/logging/backends/Kconfig.adsp_mtrace new file mode 100644 index 00000000000..2be80638544 --- /dev/null +++ b/subsys/logging/backends/Kconfig.adsp_mtrace @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_ADSP_MTRACE + bool "Intel ADSP mtrace backend" + depends on SOC_FAMILY_INTEL_ADSP + select LOG_OUTPUT + help + Provide a logging backend which writes to SRAM window + using the SOF Linux driver mtrace buffer layout. + +if LOG_BACKEND_ADSP_MTRACE + +backend = ADSP_MTRACE +backend-str = adsp_mtrace +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_ADSP_MTRACE diff --git a/subsys/logging/backends/Kconfig.efi_console b/subsys/logging/backends/Kconfig.efi_console new file mode 100644 index 00000000000..13d873dfc8e --- /dev/null +++ b/subsys/logging/backends/Kconfig.efi_console @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_EFI_CONSOLE + bool "EFI_CONSOLE backend" + depends on X86_EFI_CONSOLE + select LOG_OUTPUT + default y if !UART_CONSOLE + help + When enabled backend is using EFI CONSOLE to output logs. + +if LOG_BACKEND_EFI_CONSOLE + +backend = EFI_CON +backend-str = efi_console +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_EFI_CONSOLE diff --git a/subsys/logging/backends/Kconfig.fs b/subsys/logging/backends/Kconfig.fs new file mode 100644 index 00000000000..f722dc75512 --- /dev/null +++ b/subsys/logging/backends/Kconfig.fs @@ -0,0 +1,54 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_FS + bool "File system backend" + depends on FILE_SYSTEM + select LOG_OUTPUT + help + When enabled, backend is using the configured file system to output logs. + As the file system must be mounted for the logging to work, it must be + either configured for auto-mount or manually mounted by the application. + Log messages are discarded as long as the file system is not mounted. + +if LOG_BACKEND_FS + +backend = FS +backend-str = fs +source "subsys/logging/Kconfig.template.log_format_config" + +config LOG_BACKEND_FS_OVERWRITE + bool "Old log files overwrite" + default y + help + When enabled backend overwrites oldest log files. + In other case, when memory is full, new messages are dropped. + +config LOG_BACKEND_FS_FILE_PREFIX + string "Log file name prefix" + default "log." + help + User defined name of log files saved in the file system. + The prefix is followed by the number of log file. + +config LOG_BACKEND_FS_DIR + string "Log directory" + default "/lfs1" + help + Directory to which log files will be written. + +config LOG_BACKEND_FS_FILE_SIZE + int "User defined log file size" + default 4096 + range 128 1073741824 + help + Max log file size (in bytes). + +config LOG_BACKEND_FS_FILES_LIMIT + int "Max number of files containing logs" + default 10 + help + Limit of number of files with logs. It is also limited by + size of file system partition. + +endif # LOG_BACKEND_FS diff --git a/subsys/logging/backends/Kconfig.native_posix b/subsys/logging/backends/Kconfig.native_posix new file mode 100644 index 00000000000..bde09c9f244 --- /dev/null +++ b/subsys/logging/backends/Kconfig.native_posix @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_NATIVE_POSIX + bool "Native backend" + depends on ARCH_POSIX + default y if !SERIAL + select LOG_OUTPUT + help + Enable backend in native_posix + +if LOG_BACKEND_NATIVE_POSIX + +backend = NATIVE_POSIX +backend-str = native_posix +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_NATIVE_POSIX diff --git a/subsys/logging/backends/Kconfig.net b/subsys/logging/backends/Kconfig.net new file mode 100644 index 00000000000..6823c760ba7 --- /dev/null +++ b/subsys/logging/backends/Kconfig.net @@ -0,0 +1,66 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +# Immediate mode cannot be used with network backend as it would cause the sent +# rsyslog message to be malformed. +config LOG_BACKEND_NET + bool "Networking backend" + depends on NETWORKING && NET_UDP && !LOG_MODE_IMMEDIATE + select NET_CONTEXT_NET_PKT_POOL + select LOG_OUTPUT + help + Send syslog messages to network server. + See RFC 5424 (syslog protocol) and RFC 5426 (syslog over UDP) + specifications for details. + +if LOG_BACKEND_NET + +config LOG_BACKEND_NET_SERVER + string "Syslog server IP address" + help + This can be either IPv4 or IPv6 address. + Server listen UDP port number can be configured here too. + Following syntax is supported: + 192.0.2.1:514 + 192.0.2.42 + [2001:db8::1]:514 + [2001:db8::2] + 2001:db::42 + +config LOG_BACKEND_NET_MAX_BUF + int "How many network buffers to allocate for sending messages" + range 3 256 + default 3 + help + Each syslog message should fit into a network packet that will be + sent to server. This number tells how many syslog messages can be + in transit to the server. + +config LOG_BACKEND_NET_MAX_BUF_SIZE + int "Max syslog message size" + range 64 1180 + default 1180 if NET_IPV6 + default 480 if NET_IPV4 + default 256 + help + As each syslog message needs to fit to UDP packet, set this value + so that messages are not truncated. + The RFC 5426 recommends that for IPv4 the size is 480 octets and for + IPv6 the size is 1180 octets. As each buffer will use RAM, the value + should be selected so that typical messages will fit the buffer. + +config LOG_BACKEND_NET_AUTOSTART + bool "Automatically start networking backend" + default y if NET_CONFIG_NEED_IPV4 || NET_CONFIG_NEED_IPV6 + help + When enabled automatically start the networking backend on + application start. If no routes to the logging server are available + on application startup, this must be set to n and the backend must be + started by the application later on. Otherwise the logging + thread might block. + +backend = NET +backend-str = net +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_NET diff --git a/subsys/logging/backends/Kconfig.rtt b/subsys/logging/backends/Kconfig.rtt new file mode 100644 index 00000000000..144e30be59e --- /dev/null +++ b/subsys/logging/backends/Kconfig.rtt @@ -0,0 +1,108 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_RTT + bool "Segger J-Link RTT backend" + depends on USE_SEGGER_RTT + default y if !SHELL_BACKEND_RTT + select SEGGER_RTT_CUSTOM_LOCKING + select LOG_OUTPUT + help + When enabled, backend will use RTT for logging. This backend works on a per + message basis. Only a whole message (terminated with a carriage return: '\r') + is transferred to up-buffer at once depending on available space and + selected mode. + In panic mode backend always blocks and waits until there is space + in up-buffer for a message and message is transferred to host. + +if LOG_BACKEND_RTT + +choice LOG_BACKEND_RTT_MODE + prompt "Logger behavior" + default LOG_BACKEND_RTT_MODE_BLOCK + +config LOG_BACKEND_RTT_MODE_DROP + bool "Drop messages that do not fit in up-buffer." + help + If there is not enough space in up-buffer for a message, drop it. + Number of dropped messages will be logged. + Increase up-buffer size helps to reduce dropping of messages. + +config LOG_BACKEND_RTT_MODE_BLOCK + bool "Block until message is transferred to host." + help + Waits until there is enough space in the up-buffer for a message. + +config LOG_BACKEND_RTT_MODE_OVERWRITE + bool "Overwrite messages if up-buffer full" + help + If there is not enough space in up-buffer for a message overwrite + oldest one. + +endchoice + +backend = RTT +backend-str = rtt +source "subsys/logging/Kconfig.template.log_format_config" + +config LOG_BACKEND_RTT_MESSAGE_SIZE + int "Size of internal buffer for storing messages." + range 32 256 + default 128 + depends on LOG_BACKEND_RTT_MODE_DROP + help + This option defines maximum message size transferable to up-buffer. + +if LOG_BACKEND_RTT_MODE_BLOCK + +config LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE + int "Size of the output buffer" + default 16 + help + Buffer is used by log_output module for preparing output data (e.g. + string formatting). + +config LOG_BACKEND_RTT_RETRY_CNT + int "Number of retries" + default 4 + help + Number of TX retries before dropping the data and assuming that + RTT session is inactive. + +config LOG_BACKEND_RTT_RETRY_DELAY_MS + int "Delay between TX retries in milliseconds" + default 5 + help + Sleep period between TX retry attempts. During RTT session, host pulls + data periodically. Period starts from 1-2 milliseconds and can be + increased if traffic on RTT increases (also from host to device). In + case of heavy traffic data can be lost and it may be necessary to + increase delay or number of retries. + +endif # LOG_BACKEND_RTT_MODE_BLOCK + +config LOG_BACKEND_RTT_BUFFER + int "Buffer number used for logger output." + range 0 SEGGER_RTT_MAX_NUM_UP_BUFFERS + default 0 + help + Select index of up-buffer used for logger output, by default it uses + terminal up-buffer and its settings. + +config LOG_BACKEND_RTT_BUFFER_SIZE + int "Size of reserved up-buffer for logger output." + default 1024 + depends on LOG_BACKEND_RTT_BUFFER > 0 + help + Specify reserved size of up-buffer used for logger output. + +# Enable processing of printk calls using log if terminal buffer is used. +# Same buffer is used by RTT console. If printk would go through RTT console +# that will lead to corruption of RTT data which is not protected against being +# interrupted by an interrupt. +config LOG_BACKEND_RTT_FORCE_PRINTK + bool + default y if LOG_BACKEND_RTT_BUFFER = 0 && RTT_CONSOLE + select LOG_PRINTK + +endif # LOG_BACKEND_RTT diff --git a/subsys/logging/backends/Kconfig.spinel b/subsys/logging/backends/Kconfig.spinel new file mode 100644 index 00000000000..6174abb6122 --- /dev/null +++ b/subsys/logging/backends/Kconfig.spinel @@ -0,0 +1,27 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_SPINEL + bool "OpenThread dedicated Spinel protocol backend" + depends on !LOG_BACKEND_UART + depends on NET_L2_OPENTHREAD + select LOG_OUTPUT + help + When enabled, backend will use OpenThread dedicated SPINEL protocol for logging. + This protocol is byte oriented and wraps given messages into serial frames. + Backend should be enabled only to OpenThread purposes and when UART backend is disabled + or works on another UART device to avoid interference. + +if LOG_BACKEND_SPINEL + +config LOG_BACKEND_SPINEL_BUFFER_SIZE + int "Size of reserved up-buffer for logger output." + default 64 + help + Specify reserved size of up-buffer used for logger output. + +backend = SPINEL +backend-str = spinel +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_SPINEL diff --git a/subsys/logging/backends/Kconfig.swo b/subsys/logging/backends/Kconfig.swo new file mode 100644 index 00000000000..8dcbf3f0285 --- /dev/null +++ b/subsys/logging/backends/Kconfig.swo @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_SWO + bool "Serial Wire Output (SWO) backend" + depends on HAS_SWO + select LOG_OUTPUT + help + When enabled, backend will use SWO for logging. + +if LOG_BACKEND_SWO +config LOG_BACKEND_SWO_FREQ_HZ + int "Set SWO output frequency" + default 0 + help + Set SWO output frequency. Value 0 will select maximum frequency + supported by the given MCU. Not all debug probes support high + frequency SWO operation. In this case the frequency has to be set + manually. + + SWO value defined by this option will be configured at boot. Most SWO + viewer programs will configure SWO frequency when attached to the + debug probe. Such configuration will persist only until the device + reset. To ensure flawless operation the frequency configured here and + by the SWO viewer program has to match. + +backend = SWO +backend-str = swo +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_SWO diff --git a/subsys/logging/backends/Kconfig.uart b/subsys/logging/backends/Kconfig.uart new file mode 100644 index 00000000000..45f1596d0bd --- /dev/null +++ b/subsys/logging/backends/Kconfig.uart @@ -0,0 +1,51 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_UART + bool "UART backend" + depends on UART_CONSOLE + default y if !SHELL_BACKEND_SERIAL + select LOG_OUTPUT + help + When enabled backend is using UART to output logs. + +if LOG_BACKEND_UART + +config LOG_BACKEND_UART_ASYNC + bool "Use UART Asynchronous API" + depends on UART_ASYNC_API + depends on !LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX + +config LOG_BACKEND_UART_BUFFER_SIZE + int "Number of bytes to buffer in RAM before flushing" + default 32 if LOG_BACKEND_UART_ASYNC + default 1 + help + Sets the number of bytes which can be buffered in RAM before log_output_flush + is automatically called on the backend. + +backend = UART +backend-str = uart +source "subsys/logging/Kconfig.template.log_format_config" + +if LOG_BACKEND_UART_OUTPUT_DICTIONARY + +choice + prompt "Dictionary mode output format" + default LOG_BACKEND_UART_OUTPUT_DICTIONARY_BIN + +config LOG_BACKEND_UART_OUTPUT_DICTIONARY_BIN + bool "Dictionary (binary)" + help + Dictionary-based logging output in binary. + +config LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX + bool "Dictionary (hexadecimal)" + help + Dictionary-based logging output in hexadecimal. Supported only for UART backend. + +endchoice + +endif # LOG_BACKEND_UART_OUTPUT_DICTIONARY + +endif # LOG_BACKEND_UART diff --git a/subsys/logging/backends/Kconfig.xtensa_sim b/subsys/logging/backends/Kconfig.xtensa_sim new file mode 100644 index 00000000000..3704baa09bc --- /dev/null +++ b/subsys/logging/backends/Kconfig.xtensa_sim @@ -0,0 +1,26 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LOG_BACKEND_XTENSA_SIM + bool "Xtensa simulator backend" + depends on SOC_XTENSA_SAMPLE_CONTROLLER || SOC_FAMILY_INTEL_ADSP + default y if SOC_XTENSA_SAMPLE_CONTROLLER + select LOG_OUTPUT + help + Enable backend in xtensa simulator + +config LOG_BACKEND_XTENSA_OUTPUT_BUFFER_SIZE + int "Size of the output buffer" + default 16 + depends on LOG_BACKEND_XTENSA_SIM + help + Buffer is used by log_output module for preparing output data (e.g. + string formatting). + +if LOG_BACKEND_XTENSA_SIM + +backend = XTENSA_SIM +backend-str = xtensa_sim +source "subsys/logging/Kconfig.template.log_format_config" + +endif # LOG_BACKEND_XTENSA_SIM diff --git a/subsys/logging/log_backend_adsp.c b/subsys/logging/backends/log_backend_adsp.c similarity index 100% rename from subsys/logging/log_backend_adsp.c rename to subsys/logging/backends/log_backend_adsp.c diff --git a/subsys/logging/log_backend_adsp_hda.c b/subsys/logging/backends/log_backend_adsp_hda.c similarity index 100% rename from subsys/logging/log_backend_adsp_hda.c rename to subsys/logging/backends/log_backend_adsp_hda.c diff --git a/subsys/logging/log_backend_adsp_mtrace.c b/subsys/logging/backends/log_backend_adsp_mtrace.c similarity index 100% rename from subsys/logging/log_backend_adsp_mtrace.c rename to subsys/logging/backends/log_backend_adsp_mtrace.c diff --git a/subsys/logging/log_backend_efi_console.c b/subsys/logging/backends/log_backend_efi_console.c similarity index 100% rename from subsys/logging/log_backend_efi_console.c rename to subsys/logging/backends/log_backend_efi_console.c diff --git a/subsys/logging/log_backend_fs.c b/subsys/logging/backends/log_backend_fs.c similarity index 100% rename from subsys/logging/log_backend_fs.c rename to subsys/logging/backends/log_backend_fs.c diff --git a/subsys/logging/log_backend_native_posix.c b/subsys/logging/backends/log_backend_native_posix.c similarity index 100% rename from subsys/logging/log_backend_native_posix.c rename to subsys/logging/backends/log_backend_native_posix.c diff --git a/subsys/logging/log_backend_net.c b/subsys/logging/backends/log_backend_net.c similarity index 100% rename from subsys/logging/log_backend_net.c rename to subsys/logging/backends/log_backend_net.c diff --git a/subsys/logging/log_backend_rtt.c b/subsys/logging/backends/log_backend_rtt.c similarity index 100% rename from subsys/logging/log_backend_rtt.c rename to subsys/logging/backends/log_backend_rtt.c diff --git a/subsys/logging/log_backend_spinel.c b/subsys/logging/backends/log_backend_spinel.c similarity index 100% rename from subsys/logging/log_backend_spinel.c rename to subsys/logging/backends/log_backend_spinel.c diff --git a/subsys/logging/log_backend_swo.c b/subsys/logging/backends/log_backend_swo.c similarity index 100% rename from subsys/logging/log_backend_swo.c rename to subsys/logging/backends/log_backend_swo.c diff --git a/subsys/logging/log_backend_uart.c b/subsys/logging/backends/log_backend_uart.c similarity index 100% rename from subsys/logging/log_backend_uart.c rename to subsys/logging/backends/log_backend_uart.c diff --git a/subsys/logging/log_backend_xtensa_sim.c b/subsys/logging/backends/log_backend_xtensa_sim.c similarity index 100% rename from subsys/logging/log_backend_xtensa_sim.c rename to subsys/logging/backends/log_backend_xtensa_sim.c