1# Copyright (c) 2024 Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4DT_COMPAT_NORDIC_NRF_TBM := nordic,nrf-tbm
5
6config NRF_ETR
7	bool "Coresight ETR handler (with Nordic TBM)"
8	depends on $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_TBM))
9	select NRFX_TBM
10	imply UART_ASYNC_API
11	default y
12	help
13	  Module handles data stored in the ETR circular buffer (e.g. STM logging
14	  data). Busyness is tracked using TBM (Trace Buffer Monitor) peripheral
15	  which is specific to Nordic Semiconductor SoCs.
16
17if NRF_ETR
18
19config NRF_ETR_DECODE
20	bool "Decode ETR content"
21	default y if LOG_FRONTEND_STMESP_FSC
22	select MIPI_STP_DECODER
23	select CS_TRACE_DEFMT
24	select LOG_FRONTEND_STMESP_DEMUX
25	select LOG_OUTPUT
26	imply LOG_BACKEND_SHOW_COLOR
27	imply CBPRINTF_FP_SUPPORT
28	help
29	  In this mode, log messages stored by Coresight STM logging frontends are
30	  decoded and printed in the human readable form.
31
32config NRF_ETR_DECODE_DROP_PERIOD
33	int "Period of dropped messages notification"
34	default 5000
35	help
36	  Period (in milliseconds) how often it is checked if any dropped messages
37	  have occurred.
38
39config NRF_ETR_DEBUG
40	bool "Debug mode"
41	depends on !LOG_PRINTK
42	select MIPI_STP_DECODER
43	select CS_TRACE_DEFMT
44	help
45	  In debug mode STPv2 decoded data is printed.
46
47config NRF_ETR_STACK_SIZE
48	int "ETR thread stack size"
49	default 2048 if NRF_ETR_DECODE || NRF_ETR_DEBUG
50	default 1024
51
52config NRF_ETR_BACKOFF
53	int "Thread backoff time (ms)"
54	default 10
55	help
56	  Determines how often attempt to dump the data is performed.
57
58config NRF_ETR_FLUSH_TIMEOUT
59	int "Backoff time during flushing (ms)"
60	default 100
61	help
62	  When thread triggers flushing of ETR data, it periodically checks if
63	  there is still a pending ETR data. This option specifies how often
64	  thread is waking up to check. Given in milliseconds.
65
66config NRF_ETR_SYNC_PERIOD
67	int "Period of custom synchronization frame"
68	default 0 if NRF_ETR_DECODE
69	default 0 if NRF_ETR_DEBUG
70	default 16
71	help
72	  To help find the synchronization when decoding the ETR content
73	  by a host tool a synchronization pattern (16 bytes of 0xFF) can be
74	  sent on regular intervals. This frame is sent between Coresight formatter
75	  frames. Use 0 to disable.
76
77config NRF_ETR_SHELL
78	bool "Use shell"
79	select UART_ASYNC_API
80	select UART_ASYNC_RX_HELPER
81	select SHELL_LOG_BACKEND_CUSTOM
82	depends on NRF_ETR_DECODE
83	default y if SHELL
84	help
85	  Enable shell with Coresight STM logging support.
86
87if NRF_ETR_SHELL
88
89config NRF_ETR_SHELL_PROMPT
90	string "Displayed prompt name"
91	default "uart:~$ "
92	help
93	  Displayed prompt name for UART shell with Coresight STM logging.
94
95config NRF_ETR_SHELL_ASYNC_RX_BUFFER_SIZE
96	int "Size of the RX buffer"
97	default 16
98	help
99	  Size of a single RX buffer. Together with buffer count it defines the
100	  space that can hold RX data. It may be decreased if shell input is
101	  slow and may need to be increased if long messages are pasted directly
102	  to the shell prompt.
103
104config NRF_ETR_SHELL_ASYNC_RX_BUFFER_COUNT
105	int "Number of RX buffers"
106	default 4
107	range 2 64
108	help
109	  Number of RX buffers.
110
111endif # NRF_ETR_SHELL
112
113endif # NRF_ETR
114