<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Logging via SWO</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/127742/logging-via-swo</link><description>Hi, 
 I am trying to configure SWO logging in a sample project based on zephyr/samples/hello_world (source and config at the end). 
 I run this application on two targets: nRF54L15-DK and nRF52-DK. 
 On nRF54L15-DK: I cannot see any logs when using SEGGER</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 Apr 2026 14:42:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/127742/logging-via-swo" /><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/565408?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2026 14:42:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:345b4a41-ca27-4ebe-a085-f9bce4ff3166</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Since you are debugging I don&amp;#39;t expect current consumption is much important, does enabling&amp;nbsp;&lt;span&gt;CONFIG_SOC_NRF_FORCE_CONSTLAT=y help? Then you should be able to use k_msleep() instead of&amp;nbsp;spin_wait_ms().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/565140?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2026 06:47:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e964dd49-cd11-4e02-ac50-3c7a3dd449aa</guid><dc:creator>dp-hqv</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;1. I use the config&lt;span&gt;&amp;nbsp;CONFIG_LOG_MODE_IMMEDIATE=y. The thing is that the logs are not truncated, they are sent among other random bytes (not printable), it can be seen in the `hello_world_sleep.sal` attached to my previous comment.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. I get it, thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards,&lt;br /&gt;Damian&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/565068?ContentTypeID=1</link><pubDate>Thu, 16 Apr 2026 19:28:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0bb01e8-3783-439c-aafc-0f6271c52823</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Damian,&lt;/p&gt;
&lt;p&gt;1. It is likely caused by the HF clock being turned off when k_msleep() is called. The logging module uses deferred logging, so when LOG_INF() is called, the message is not sent immediately. Instead, it is queued and sent later by the logging thread. After the logging thread finishes writing all the bytes into the ITM FIFO (with &lt;code&gt;ITM_SendChar()&lt;/code&gt;), the CPU goes to sleep. But the TPIU is still slowly serializing those bytes out over the SWO wire, and when the CPU sleeps, HFCLK is gated, cutting power to the TPIU mid-transmission, causing the message to be truncated.&lt;/p&gt;
&lt;p&gt;With a spin wait, the CPU stays awake, and HFCLK stays on, so the TPIU always finishes transmitting before sleep.&lt;/p&gt;
&lt;p&gt;I recommend using deferred logging, but you can log immediately instead of queuing logs by enabling&amp;nbsp;CONFIG_LOG_MODE_IMMEDIATE.&lt;/p&gt;
&lt;p&gt;2. No, this is not possible.&amp;nbsp;CONFIG_LOG_BACKEND_SWO must be enabled at build time to include the backend code. This includes&amp;nbsp;&lt;code&gt;log_backend_swo_init()&lt;/code&gt;, which enables ITM and TPIU on boot.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/564984?ContentTypeID=1</link><pubDate>Wed, 15 Apr 2026 12:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76582b98-c6a4-43a2-9ee3-8f8535fae797</guid><dc:creator>dp-hqv</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;The debugger I use is SEGGER J-Link Base.&lt;/p&gt;
&lt;p&gt;The reason behind using SWO is that in our project we would like to have two builds: release and test. Release one uses SWO log backend but the application does not enable SWO. It can be enabled and set up by the attached debugger when needed.&lt;br /&gt;Test build which is used for measuring power consumption. Here the enables SWO by itself. No debugger is attached, only one wire to the SWO pin to gather the logs.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I have an update regarding the logs in&amp;nbsp;&lt;span&gt;SEGGER J-Link SWO Viewer, I can get the logs, I just had to power cycle the target device. So after the reboot the logs are received. Setting `CONFIG_LOG_BACKEND_SWO=y` was enough. My apologies, it was my mistake.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Nevertheless, the logs look corrupted. When running the simple application (from the code snippet above) every couple of lines of logs the ending of the line is incorrect.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v3.2.1-d8887f6f32df ***

*** Using Zephyr OS v4.2.99-ec78104f1569 ***

Hello World! hcm200/nrf54l10/app

Hello World! hcm200/nrf54l10/cpuapp

Hello World! hcm200/nrf54l10/app

Hello World! hcm200/nrf54l10/p

Hello World! hcm200/nrf54l10/cuapp

Hello World! hcm200/nrf54l10/uapp

Hello World! hcm200/nrf54l10/puapp
 &lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The correct ending should be `cpuapp`.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have attached a logic analyzer to SWO pin to see what really is happening on the wire. It occurs, there is unexpected data sent via SWO. Here are the&amp;nbsp;waveforms:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/8103.nOK.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/hello_5F00_world_5F00_sleep.sal"&gt;devzone.nordicsemi.com/.../hello_5F00_world_5F00_sleep.sal&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I modified the application so that it does not use `k_msleep` function but a spin wait instead, like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void spin_wait_ms(int64_t duration_ms)
{
    const int64_t start_ms = k_uptime_get();

    while ((k_uptime_get() - start_ms) &amp;lt; duration_ms) {}
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After that the logs look correctly. The&amp;nbsp;waveforms:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/8308.OK.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/hello_5F00_world_5F00_spin.sal"&gt;devzone.nordicsemi.com/.../hello_5F00_world_5F00_spin.sal&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It has been run on a custom board with nRF54L10 SoC on it.&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I have the following questions:&lt;/p&gt;
&lt;p&gt;1. Do you know why the logs are corrupted when using a sleep function in the code?&lt;br /&gt;2. Is there a way to use SWO log backend in Zephyr/NCS but not enabling SWO? Only the debugger would enable it when attached. It would save some power when the debugger is not attached.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;br /&gt;Damian&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/564938?ContentTypeID=1</link><pubDate>Tue, 14 Apr 2026 17:01:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5da57bc8-7220-4159-95f8-4fa5632e985e</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Damian,&lt;/p&gt;
&lt;p&gt;What debugger are you using? The debugger must be SWO capable to work.&lt;/p&gt;
&lt;p&gt;Is there a specific reason for using SWO instead of RTT?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/564900?ContentTypeID=1</link><pubDate>Tue, 14 Apr 2026 08:19:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76299e00-b8bf-48d6-8299-db7341f49063</guid><dc:creator>dp-hqv</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks for clarifying how the board configurator works and what it does.&lt;/p&gt;
&lt;p&gt;I have added the above code snippet but it did not help. I still cannot see the logs in&amp;nbsp;&lt;span&gt;SEGGER J-Link SWO Viewer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Damian&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/564803?ContentTypeID=1</link><pubDate>Fri, 10 Apr 2026 17:48:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fb0e4ce-a6df-415e-923d-ce1a8886ea36</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Damian,&lt;/p&gt;
&lt;p&gt;The board configurator tool configures the board controller (interface MCU) on the DK itself, it does not configure the nRF54L chip.&amp;nbsp;This means what you want to replicate in firmware is the trace port enablement on the nRF54L chip itself, not the DK board controller configuration.&lt;/p&gt;
&lt;p&gt;For the nRF54L, the following sequence is required to enable SWO support:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
/* Trace configuration */
#define TRACE_PORT                  NRF_P2_S
#define TRACE_TRACECLK_PIN          (6ul)
#define TRACE_TRACEDATA0_PIN        (7ul)
#define TRACE_TRACEDATA1_PIN        (8ul)
#define TRACE_TRACEDATA2_PIN        (9ul)
#define TRACE_TRACEDATA3_PIN        (10ul)
#define TRACE_PIN_CONFIG            ((GPIO_PIN_CNF_DRIVE0_E0 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE0_Pos) \
| (GPIO_PIN_CNF_DRIVE1_E1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE1_Pos) \
| (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos))

#define TRACE_PIN_CLEAR             (~(GPIO_PIN_CNF_CTRLSEL_Msk | GPIO_PIN_CNF_DRIVE0_Msk | GPIO_PIN_CNF_DRIVE1_Msk | GPIO_PIN_CNF_DIR_Msk))
/* End Trace configuration */


// Enable trace and debug
NRF_TAD_S-&amp;gt;ENABLE = TAD_ENABLE_ENABLE_Msk;

// Configure trace port pads
TRACE_PORT-&amp;gt;PIN_CNF[TRACE_TRACECLK_PIN] &amp;amp;= TRACE_PIN_CLEAR;
TRACE_PORT-&amp;gt;PIN_CNF[TRACE_TRACEDATA0_PIN] &amp;amp;= TRACE_PIN_CLEAR;

TRACE_PORT-&amp;gt;PIN_CNF[TRACE_TRACECLK_PIN] |= TRACE_PIN_CONFIG;
TRACE_PORT-&amp;gt;PIN_CNF[TRACE_TRACEDATA0_PIN] |= TRACE_PIN_CONFIG;

// Configure trace port speed
NRF_TAD_S-&amp;gt;TRACEPORTSPEED = TAD_TRACEPORTSPEED_TRACEPORTSPEED_DIV2;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;However, this should automatically be set when you have SWO enabled with&amp;nbsp;&lt;code&gt;CONFIG_LOG=y&lt;/code&gt; and &lt;code&gt;CONFIG_LOG_BACKEND_SWO=y&lt;/code&gt; as you can see from these files:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/modules/hal_nordic/nrfx/CMakeLists.txt#L116"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/modules/hal_nordic/nrfx/CMakeLists.txt#L116&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nordicsemi/nrfx/blob/master/bsp/stable/mdk/system_nrf54l.c#L260-L278"&gt;https://github.com/nordicsemi/nrfx/blob/master/bsp/stable/mdk/system_nrf54l.c#L260-L278&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Since this is not working in your case, can you try manually enabling SWO using the code above? If this does not work, please let me know.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/564750?ContentTypeID=1</link><pubDate>Fri, 10 Apr 2026 06:08:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a563abb-0568-4847-8ffc-d5221302bdc9</guid><dc:creator>dp-hqv</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Unfortunately, the version of my DK is 0.9.1.&lt;/p&gt;
&lt;p&gt;Do you know how to enable SWO on a custom board with nRF54L10 SoC? I am asking about&amp;nbsp;&lt;span&gt;nRF54L10&amp;nbsp;since in our project we use our custom board with this SoC and we have exactly the same issue with SWO as described above for&amp;nbsp;nRF54L15-DK.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Damian&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging via SWO</title><link>https://devzone.nordicsemi.com/thread/564743?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2026 20:05:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d80d89e0-91cc-494a-bb16-ee5cd7529f9d</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Damian,&lt;/p&gt;
&lt;p&gt;You need to enable SWO control in the board configurator:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1775765063379v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Please note that this is only supported on nRF54L15 DK v1.0.0 and newer.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>