Skip to content

Commit 94ae61f

Browse files
nordic-krchgalak
authored andcommitted
logging: Force LOG_PRINTK option if RTT backend is used
Log RTT backed is using mutex for locking access to RTT data. RTT console (which by default is used by printk) writes to RTT data directly and it cannot use mutex because it can be called from any context (including interrupt). If both modules access RTT buffer 0, data can be corrupted. This patch forces LOG_PRINTK option if RTT backend is used to ensure single point of access to RTT buffer 0 data. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 75be0cc commit 94ae61f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

subsys/logging/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,17 @@ config LOG_BACKEND_RTT_BUFFER_SIZE
431431
Specify reserved size of up-buffer used for logger output.
432432

433433
endif # LOG_BACKEND_RTT_BUFFER
434+
435+
436+
# Enable processing of printk calls using log if terminal buffer is used.
437+
# Same buffer is used by RTT console. If printk would go through RTT console
438+
# that will lead to corruption of RTT data which is not protected against being
439+
# interrupted by an interrupt.
440+
config LOG_BACKEND_RTT_FORCE_PRINTK
441+
bool
442+
default y if LOG_BACKEND_RTT_BUFFER = 0
443+
select LOG_PRINTK
444+
434445
endif # LOG_BACKEND_RTT
435446

436447
config LOG_BACKEND_NATIVE_POSIX

0 commit comments

Comments
 (0)