Skip to content

logging: backend: add KConfig option for SWO sync packets #91745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/releases/release-notes-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ New APIs and options

* :c:func:`display_clear`

* Logging

* :kconfig:option:`CONFIG_LOG_BACKEND_SWO_SYNC_PACKETS`

* Networking:

* IPv4
Expand Down
9 changes: 9 additions & 0 deletions subsys/logging/backends/Kconfig.swo
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ config LOG_BACKEND_SWO_PROTOCOL_MANCHESTER

endchoice

config LOG_BACKEND_SWO_SYNC_PACKETS
bool "Synchronization packet transmission"
default y
help
Generate synchronization packets with a unique pattern in the bitstream.
If the SWO pin is used for simple UART text output on a generic terminal application,
these packets show up as special characters in regular intervals.
You can avoid that by disabling this setting.

backend = SWO
backend-str = swo
source "subsys/logging/Kconfig.template.log_format_config"
Expand Down
8 changes: 6 additions & 2 deletions subsys/logging/backends/log_backend_swo.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ static void log_backend_swo_init(struct log_backend const *const backend)
DWT->CTRL &= (DWT_CTRL_POSTPRESET_Msk | DWT_CTRL_POSTINIT_Msk | DWT_CTRL_CYCCNTENA_Msk);
DWT->CTRL |= (DWT_CTRL_POSTPRESET_Msk | DWT_CTRL_POSTINIT_Msk);
/* Configure Formatter and Flush Control Register */
TPI->FFCR = 0x00000100;
TPI->FFCR = TPI_FFCR_TrigIn_Msk;
/* Enable ITM, set TraceBusID=1, no local timestamp generation */
ITM->TCR = 0x0001000D;
uint32_t tcr = ITM_TCR_ITMENA_Msk | ITM_TCR_DWTENA_Msk | (1 << ITM_TCR_TRACEBUSID_Pos);
#if CONFIG_LOG_BACKEND_SWO_SYNC_PACKETS
tcr |= ITM_TCR_SYNCENA_Msk;
#endif
ITM->TCR = tcr;
/* Enable stimulus port used by the logger */
ITM->TER = 1 << ITM_PORT_LOGGER;

Expand Down