<?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 to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35293/how-to-use-hardfault-exception-library</link><description>Hi, 
 I&amp;#39;m using nrf52832 and sdk14.2 and need to handle hardfaults in my code. From what I&amp;#39;ve found on the forums and infocenter, I need to modify the &amp;quot;void HardFault_process(HardFault_stack_t * p_stack);&amp;quot; function in hardfault_implementation.c file.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Jun 2018 08:22:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35293/how-to-use-hardfault-exception-library" /><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/137818?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 08:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:462fd5b7-76e8-47f7-9269-5a98665deac5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Unfortunately, it is going to require changes to the interrupt forwarding implementation inside the softdevice. However,&amp;nbsp;this problem only seems to occur when some specific condition(s) are met, I haven&amp;#39;t experienced it before I tried&amp;nbsp;hardfault_genhf_invalid_fp() that branches to address 0. So&amp;nbsp;the fault exception should be forwarded to the application in most cases.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/137765?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 21:11:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0641e66-f46a-4d92-87e2-c210577f567b</guid><dc:creator>dlip</dc:creator><description>&lt;p&gt;Is there a workaround for this that will allow the application to process hardfaults?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/136859?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 08:28:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48269550-d6c1-4250-a2b8-e63bbb57f6c2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve replicated the behavior you saw with&amp;nbsp;hardfault_genhf_invalid_fp(). The softdevice&amp;nbsp;should forward hardfault exceptions to the application, which it&amp;#39;s not working in this particular case. The forwarding mechanism&amp;nbsp;triggers another hardfault inside the fault handler that leads to a CPU lockup reset. This has been reported as a bug internally.&amp;nbsp; Note that lockup reset is disabled while the device is in debug interface mode, that is why the program hangs inside the softdevice when you try to debug it (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=2_1_0_17_7#fnsrc_2"&gt;lockup reset&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;quot;Also, how did you know the program is stuck in soft device&amp;#39;s handle&amp;quot;&lt;/p&gt;
&lt;p&gt;It was based on the CPU registers&amp;nbsp;from your screenshot:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c77fb52d75f34fe6afb811504782ce4e/Untitled.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the example I used for test:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c77fb52d75f34fe6afb811504782ce4e/ble_5F00_app_5F00_hrs_5F00_hf_5F00_test.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_hrs_5F00_hf_5F00_test.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/136830?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 05:19:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fffc4c92-c1d5-44ba-9755-127b2461016e</guid><dc:creator>Salman Azmat</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using hardfault_genhf_invalid_fp() function to generate the hardfault as shown in the picture in my previous comment. Also, how did you know the program is stuck in soft device&amp;#39;s handler ? Also, I&amp;#39;m generating the fault before initializing the ble_stack and other modules.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/136050?ContentTypeID=1</link><pubDate>Thu, 14 Jun 2018 07:03:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c26d893e-25f8-4bd7-8dc9-c338a5bfc5d2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Did you write to address 0x80000000 to trigger this hardfault? Your screenshot shows the program being stuck in the softdevice&amp;#39;s hardfault handler. This may happen if the app returns from&amp;nbsp;app_error_fault_handler() after a softdevice assert.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/135887?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 10:44:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5f6b70d-464a-4b55-954d-4798285838ac</guid><dc:creator>Salman Azmat</dc:creator><description>&lt;p&gt;Hi, I tried disbaling all the V7M breakpoints, but still it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1528886650370v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/135844?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 07:39:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f2ac644-8882-4dc8-9467-97b986497416</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Segger Embedded studio halts the CPU when a fault exception occurs (shown as &amp;quot;vector catch&amp;quot; in console window). Maybe that is why the program is not reaching the hardfault handler in your application. You can disable&amp;nbsp;vector catch for hardfault in the breakpoint view (press ctrl + alt + b to open)&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c77fb52d75f34fe6afb811504782ce4e/breakpoint.PNG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/135826?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 06:18:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a439b65d-590c-4abd-8d69-56b1d68845a7</guid><dc:creator>Salman Azmat</dc:creator><description>&lt;p&gt;Hi, I included the gcc file as I&amp;#39;m using seggers embedded studio. But still the handlers don&amp;#39;t get invoked. Currently my project path contains hardfault_handler_gcc.c and hardfault_implmenetation.c files, and I did &amp;quot;#include &amp;quot;hardfault.h&amp;quot;&amp;quot; in my main.c.&lt;/p&gt;
&lt;p&gt;Though, I was able to generate hardfaults with &amp;quot;hardfault_genhf_invalid_fp()&amp;quot; function after doing #include &amp;quot;hardfault_genhf.h&amp;quot;. But still no luck with the handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/135595?ContentTypeID=1</link><pubDate>Mon, 11 Jun 2018 13:05:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c268aca-817f-4504-bb87-f3455d65fcb2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;hardfault_handler_&amp;lt;toolchain&amp;gt;.c needs to be included&amp;nbsp;in order for&amp;nbsp;HardFault_c_handler() to be invoked on a fault exception. Did you include one of the handler files from&amp;nbsp;&amp;nbsp;\components\libraries\hardfault\nrf52\handler (different versions depending on toolchain)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use hardfault exception library ?</title><link>https://devzone.nordicsemi.com/thread/135576?ContentTypeID=1</link><pubDate>Mon, 11 Jun 2018 12:33:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7e6de08-ad7b-4878-8145-4718af2f5ee2</guid><dc:creator>Salman Azmat</dc:creator><description>&lt;p&gt;Also, according to following link, a hardfault_handler is called upon the fault, which has a while(forever), and we can modify it to reset the chip or get the stack pointer, where is this handler implemented(in some .c file, I don&amp;#39;t think I&amp;#39;ll be able to modify the .s file) ?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/b/blog/posts/an-introduction-to-error-handling-in-nrf5-projects"&gt;devzone.nordicsemi.com/.../an-introduction-to-error-handling-in-nrf5-projects&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>