<?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>How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87206/how-can-one-debug-a-zephyr-rtos-application-which-crashes-only-with-the-debugger-detached</link><description>This is a cross-post from my question on StackOverflow here . This might be a more appropriate channel for this question. 
 
 I have a custom board using the u-blox BMD-350 (Nordic nRF52382) chipset (as well as the u-blox development board, the problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 May 2022 14:53:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87206/how-can-one-debug-a-zephyr-rtos-application-which-crashes-only-with-the-debugger-detached" /><item><title>RE: How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/thread/366035?ContentTypeID=1</link><pubDate>Tue, 03 May 2022 14:53:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19f4334c-18fa-430f-ae1c-a2997237d7d2</guid><dc:creator>Anthony W</dc:creator><description>&lt;p&gt;In fact, before removing the peripheral UART code, that &amp;quot;lfclk_spinwait&amp;quot; is exactly where I found it getting stuck, so something similar was going on I bet. Thanks for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/thread/365522?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 07:48:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6aca1a5-7baf-4144-bfa3-1f3cb439979a</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Great!&lt;/p&gt;
&lt;p&gt;I do not have a good explanation for why the presence off the UART code would be a problem, but&amp;nbsp;I have actually seen this being the case before. &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/85416/initialization-problem/362722#362722"&gt;A quick search gave me for instance this case here, which looks very similar.&lt;/a&gt;&lt;/p&gt;
[quote user="Anthony W"] but I suspect it might be because the UART was not initialized (or even present on the custom board) and somehow this non-existent UART was otherwise interfering with BT operation. [/quote]
&lt;p&gt;That might be. But in any case, I am glad you figured it out.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/thread/365480?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2022 17:03:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e91f982-395d-4b7b-837d-8fced92cfe5b</guid><dc:creator>Anthony W</dc:creator><description>&lt;p&gt;Actually, I finally found the issue yesterday, so I can (somewhat) fill in here. You&amp;#39;re correct, the BMD-350 module does not have an external LF clock source, but both the dev board and the custom board do, accurate to 20ppm (on mine, not sure about the dev board). But that wasn&amp;#39;t the issue. I based my code off of the peripheral uart sample actually, but I wasn&amp;#39;t using UART at all. I removed all of the UART-specific implementation code (basically, just initialized BT and NUS) and the problem went away. I didn&amp;#39;t debug exactly why that code was causing a failure (since it was unused in my application anyway and I don&amp;#39;t care to keep it around) but I suspect it might be because the UART was not initialized (or even present on the custom board) and somehow this non-existent UART was otherwise interfering with BT operation. It seems like a stretch, and none of the code I removed should have been reached in operation, but removing it fixed the issue. So I guess it will remain a partial mystery for now.&lt;/p&gt;
&lt;p&gt;Thank you for your advice though, in particular pointing out the clock source. While it wasn&amp;#39;t necessarily applicable to this issue I do have a greater appreciation for the importance of the clocks on BT operation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/thread/365473?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2022 16:15:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcec4800-599e-4b81-81a5-30b36602325f</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hi Anthony, sorry about the wait.&lt;/p&gt;
[quote user="Anthony W"]However, both the development kit and my custom board have crystal oscillators onboard. I did try other clock sources anyway, all yield the same behavior.[/quote]
&lt;p&gt;Did you try both high and low frequency clocks? It seems to me that the BMD-350 doesn&amp;#39;t have an external low-frequency one. If your project isn&amp;#39;t configured to use the internal RC, it might be an issue. You can do this by adding CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y to your&amp;nbsp;configuration file.&lt;/p&gt;
&lt;p&gt;If that doesn&amp;#39;t help, have you tried our other examples as well? Does it for instance stop you from testing the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.6.1/nrf/samples/bluetooth/peripheral_uart/README.html#testing"&gt;peripheral uart sample&lt;/a&gt;?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-2680f2894edd40aeb56185e63a94c3cc/zephyr.hex"&gt;devzone.nordicsemi.com/.../zephyr.hex&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If it occurs there as well, could you provide me a sniffer trace?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/thread/364522?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 15:19:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d291d638-30be-4ca7-ae15-83ec88a08276</guid><dc:creator>Anthony W</dc:creator><description>&lt;p&gt;I was really hoping this would work, easy fix. However, both the development kit and my custom board have crystal oscillators onboard. I did try other clock sources anyway, all yield the same behavior.&lt;/p&gt;
&lt;p&gt;The UART has also not been helpful. It will also stop after this failure mode. But I can still connect and disconnect from Bluetooth, there&amp;#39;s just no longer bluetooth activity. It almost seems like the device is being put to sleep or something, but attempting to connect via RTT doesn&amp;#39;t correct this issue. And again, with the RTT or debugger (SWD) connected in the first place, this issue will not arise.&lt;/p&gt;
&lt;p&gt;There doesn&amp;#39;t seem to be a way (at least in VSCode or through west) to attach a debugger to chipset already running without restarting the MCU and losing that error state. Although if it is just putting itself to sleep, I might not see the error state anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can one debug a Zephyr RTOS application which crashes only with the debugger detached?</title><link>https://devzone.nordicsemi.com/thread/364423?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 10:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b245d7f-1747-4d86-ab68-82d55814f30a</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello Anthony,&lt;/p&gt;
[quote user=""]Any thoughts as to how one might go about debugging a bug like this?[/quote]
&lt;p&gt;You could try outputting something on the UART in order to get an understanding of the problem.&lt;/p&gt;
&lt;p&gt;But in this case I have a theory already:&amp;nbsp;BMD-350 doesn&amp;#39;t have a crystal on it. You need to configure the nRF52832 to use the internal RC.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>