<?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>Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected</link><description>I was developing application very similar to the basic ble_app_uart_pca10040_s132 example when I started getting random restarts and Segger Embedded Studio breaks at a strange location. Without SES the device just restarts without breaking after several</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Jan 2022 21:02:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected" /><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/349648?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 21:02:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4d9c4ef-2b7c-426f-83ff-f5a5ee854809</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I should have clarified that I was referring to the chip&amp;#39;s &lt;span&gt;&lt;a title="Debug Interface mode" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/dif.html?cp=4_2_0_15_3#debuginterfacemode"&gt;Debug Interface mode&lt;/a&gt;&lt;/span&gt;,&amp;nbsp; and not the FW&amp;#39;s build configuration. So as long as you are debugging the application, you will only be able to enter what&amp;#39;s called &amp;quot;&lt;span&gt;&lt;a title="Emulated System OFF mode" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=4_2_0_17_1_0#unique_1150026639"&gt;Emulated System OFF mode&lt;/a&gt;&amp;quot;. This is why sd_power_system_off() will return with an error instead of actually going to sleep if you try to debug the app.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/349624?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 17:03:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de4a1bf-302f-4d7a-9abb-a97329d51ad0</guid><dc:creator>viktor.kz</dc:creator><description>&lt;p&gt;I think we misunderstood each other here. There is no direct assert in sleep_mode_enter(), I was demonstrating it on the unmodified ble_app_uart example (which doesn&amp;#39;t have explict assert).&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected/348456#348456"]It&amp;#39;s however not possible to enter System OFF mode while the chip is in debug mode, so this will lead to an assertion and cause the program to reset in the default error handler.[/quote]
&lt;p&gt;Though this part is not what what is happening. Regardless whether Release or Debug configuration is chosen, both times sleep_mode_enter() ends up resetting without triggering any assert. I&amp;#39;ve tried this for s112 and s132 softdevices just to be sure. At least in the latest&amp;nbsp;SDK_17.1.0 and gcc toolchain used as compiler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/349436?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 08:20:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6249b96a-ea26-4d8e-aee4-9ee76c92e76b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Victor,&lt;/p&gt;
&lt;p&gt;Thanks for the update. But I am still puzzled as to why your program doesn&amp;#39;t appear to reach the app error handler when you get the assert in sleep_mode_enter(). app_error_fault_handler() is the only place where &lt;strong&gt;NVIC_System_Reset&lt;/strong&gt;() should get called from in the original example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And sd_power_system_off() will either make the device enter system OFF mode (wakeup from system off is a different reset source), or return with an error code. It will not access the &lt;strong&gt;SCB-&amp;gt;AIRCR&lt;/strong&gt; register.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/349371?ContentTypeID=1</link><pubDate>Mon, 24 Jan 2022 19:42:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf149288-4ab5-4be8-8a6f-65fa8b03d2ef</guid><dc:creator>viktor.kz</dc:creator><description>[quote userid="4240" url="~/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected/349258#349258"]Can you confirm that app_error_fault_handler() is only defined in app_error_weak.c and not redefined elsewhere in your project[/quote]
&lt;p&gt;Yes, I looked at linker ELF output and also tried to put symbolic breakpoint on&amp;nbsp;&lt;strong&gt;app_error_handler&lt;/strong&gt; and&amp;nbsp;&lt;strong&gt;app_error_fault_handler&lt;/strong&gt; so that it forces linker to lookup the symbol address instead of putting a breakpoint on specific line.&lt;/p&gt;
&lt;p&gt;I can trigger the handlers when I just comment out the &lt;strong&gt;uart_init&lt;/strong&gt; in the stock example by forcing an error when printf() is called and it writes out the error via RTT like expected.&lt;/p&gt;
&lt;p&gt;But not with call to sleep.&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected/349258#349258"]Can you search through the project for &amp;quot;NVIC_SystemReset()&amp;quot; and see if it may be called anywhere else in your code?[/quote]
&lt;p&gt;I tried this on the stock SDK ble_app_uart example with no modifications. There is no direct call to&amp;nbsp;&lt;strong&gt;NVIC_System_Reset&lt;/strong&gt;. I dug deeper and found out such call would expand to&amp;nbsp;&lt;strong&gt;__NVIC_System_Reset&lt;/strong&gt; which is static inline, so I had to put a breakpoint at the address of inlined code where write to &lt;strong&gt;SCB-&amp;gt;AIRCR&lt;/strong&gt;&amp;nbsp;register does the reset.&lt;/p&gt;
&lt;p&gt;Adding a call &lt;strong&gt;NVIC_SystemReset&lt;/strong&gt; to test it code does trigger it. Though finally I can see that there is&amp;nbsp;&lt;strong&gt;sd_power_system_off&lt;/strong&gt; call in&amp;nbsp;&lt;strong&gt;sleep_mode_enter&lt;/strong&gt; which also does the reset.&lt;/p&gt;
&lt;p&gt;So thanks, I think we can consider this resolved.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Viktor&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/349258?ContentTypeID=1</link><pubDate>Mon, 24 Jan 2022 12:57:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cd7b2f2-5395-4ebd-96bc-4dbb380bbeb7</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Viktor,&lt;/p&gt;
[quote user="viktor.kz"]I&amp;#39;ve been working with ARM-based CPUs for about 10 years, but never have I encountered one like nRF where you can&amp;#39;t use breakpoints/stepping since it causes softdevice to throw memory fault.[/quote]
&lt;p&gt;My experience is mostly with the nRF series. But I don&amp;#39;t think this is an uncommon limitation when dealing with protocol stacks that has real-time requirements. In any case, the Softdevice should invoke the application&amp;#39;s error handler when this happens, and then let the application handle the error. The Softdevice should never perform a soft reset by itself.&lt;/p&gt;
[quote user="viktor.kz"]I&amp;#39;ve tried to break on the&amp;nbsp;&lt;strong&gt;app_error_handler&lt;/strong&gt; or &lt;strong&gt;app_error_fault_handler&lt;/strong&gt;, but neither breakpoint is hit.[/quote]
&lt;p&gt;This is strange. Can you confirm that app_error_fault_handler() is only defined in app_error_weak.c and not redefined elsewhere in your project?&lt;/p&gt;
[quote user="viktor.kz"]Here is how it looks like when I use Debug configuration and also enable debug messages via RTT, still no crashlog:[/quote]
&lt;p&gt;Can you search through the project for &amp;quot;NVIC_SystemReset()&amp;quot; and see if it may be called anywhere else in your code?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/349066?ContentTypeID=1</link><pubDate>Sat, 22 Jan 2022 19:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:410bca86-f309-4b4b-b28f-8ef54d9b95ea</guid><dc:creator>viktor.kz</dc:creator><description>&lt;p&gt;Thank you very much!&lt;/p&gt;
&lt;p&gt;Wouldn&amp;#39;t have guesses that calling sleep actually resets the board. I&amp;#39;ve searched for any instances of call to reset or&amp;nbsp;&lt;strong&gt;NVIC_SystemReset&lt;/strong&gt;, but didn&amp;#39;t find any.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been working with ARM-based CPUs for about 10 years, but never have I encountered one like nRF where you can&amp;#39;t use breakpoints/stepping since it causes softdevice to throw memory fault.&lt;/p&gt;
&lt;p&gt;I wanted to make use of ARM ETM TRACE in Ozone with JTrace, but my board has incorrectly routed TRACE pins (needs new revision). Which would be very helpful in seeing where the program went before it reset/crashed.&lt;/p&gt;
&lt;p&gt;RTT or SystemView will get you only so far.&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected/348456#348456"]It&amp;#39;s however not possible to enter System OFF mode while the chip is in debug mode, so this will lead to an assertion and cause the program to reset in the default error handler.[/quote]
&lt;p&gt;I&amp;#39;ve tried to break on the&amp;nbsp;&lt;strong&gt;app_error_handler&lt;/strong&gt; or &lt;strong&gt;app_error_fault_handler&lt;/strong&gt;, but neither breakpoint is hit.&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/83799/spurious-restarts-on-nrf52832-with-ble_app_uart-example-if-no-ble-device-connected/348456#348456"]Note that you can use the &amp;quot;Debug&amp;quot; build configuration to get more error information from the fault handler (crashlog is printed out on RTT):[/quote]
&lt;p&gt;I was using Debug configuration, but I can&amp;#39;t see any crashlog printo into RTT, it just looks like this (can&amp;#39;t see any information like Ozone would show about fault handler, any idea why?):&lt;/p&gt;
&lt;p&gt;&lt;img alt="SES upon reset" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/nRF_5F00_breaks_5F00_05_5F00_orig_5F00_example_5F00_code.png" /&gt;&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;Here is how it looks like when I use Debug configuration and also enable debug messages via RTT, still no crashlog:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://i.imgur.com/nW1LKqv.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Viktor&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spurious restarts on nRF52832 with ble_app_uart example if no BLE device connected</title><link>https://devzone.nordicsemi.com/thread/348456?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 10:07:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a5c8c34-6173-4af7-a507-761b87c4f7cc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Do you see the same if you comment the call to sleep_mode_enter() here:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1642586431063v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;? &lt;/p&gt;
&lt;p&gt;It&amp;#39;s here the example tries to enter system OFF mode (deep sleep) after advertising has timed out after 3 minutes of inactivity. It&amp;#39;s however not possible to enter System OFF mode while the chip is in debug mode, so this will lead to an assertion and cause the program to reset in the default error handler.&lt;/p&gt;
&lt;p&gt;Note that you can use the &amp;quot;Debug&amp;quot; build configuration to get more error information from the fault handler (crashlog is printed out on RTT):&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1642586683598v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;And you can disable the &amp;quot;Reset&amp;quot; breakpoint if you don&amp;#39;t want the CPU to halt on the reset handler in the MBR (&lt;span&gt;&lt;a title="Master boot record" href="https://infocenter.nordicsemi.com/topic/sds_s132/SDS/s1xx/mbr_bootloader/mbr.html?cp=4_7_3_0_11_0"&gt;Master boot record&lt;/a&gt;&lt;/span&gt;):&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1642586789857v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>