From d1be53e748098e87e0f1637c8cd73d5fe1565bf2 Mon Sep 17 00:00:00 2001 From: Xu Xingliang Date: Sun, 13 Nov 2022 20:45:17 +0800 Subject: [PATCH] drivers/segger: make RTT_MODE configurable CHAMPION-2373 To allow use NO_BLOCK mode, so the system keeps running when debugger disconnected. Signed-off-by: Xu Xingliang --- drivers/segger/Kconfig | 15 +++++++++++++++ drivers/segger/config/SEGGER_RTT_Conf.h | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/segger/Kconfig b/drivers/segger/Kconfig index faaf58ff24..88ebbbec89 100644 --- a/drivers/segger/Kconfig +++ b/drivers/segger/Kconfig @@ -62,6 +62,21 @@ config SEGGER_RTT_BUFFER_SIZE_DOWN ---help--- Size of the buffer for terminal input to target from host (Usually keyboard input) +choice + prompt "SEGGER_RTT_MODE" + default SEGGER_RTT_MODE_NO_BLOCK_SKIP + +config SEGGER_RTT_MODE_NO_BLOCK_SKIP + bool "Skip. Do not block, output nothing. (Default)" + +config SEGGER_RTT_MODE_NO_BLOCK_TRIM + bool "Trim: Do not block, output as much as fits." + +config SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + bool "Block: Wait until there is space in the buffer." + +endchoice # SEGGER_RTT_MODE + if SEGGER_SYSVIEW config SEGGER_SYSVIEW_RTT_BUFFER_SIZE diff --git a/drivers/segger/config/SEGGER_RTT_Conf.h b/drivers/segger/config/SEGGER_RTT_Conf.h index a336ab0bda..a84bab9e4e 100644 --- a/drivers/segger/config/SEGGER_RTT_Conf.h +++ b/drivers/segger/config/SEGGER_RTT_Conf.h @@ -63,7 +63,13 @@ /* Mode for pre-initialized terminal channel */ -#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL +#if defined(CONFIG_SEGGER_RTT_MODE_NO_BLOCK_TRIM) +# define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_TRIM +#elif defined(SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) +# define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL +#else +# define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP +#endif /* 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop */