<?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 trace back hard fault handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7575/how-to-trace-back-hard-fault-handler</link><description>What&amp;#39;s the proper way to debug what&amp;#39;s causing my eval board to reset? I&amp;#39;m assuming I need to put a breakpoint in the hard fault handle, but how do I trace that back to the source of the error? Or should I modify the handler? 
 I also noticed that the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 13 Jun 2015 06:54:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7575/how-to-trace-back-hard-fault-handler" /><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27011?ContentTypeID=1</link><pubDate>Sat, 13 Jun 2015 06:54:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c88cd209-5aec-4fbe-8773-1e5822082257</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;the compiler is tricky in the way it generates debug info, if you really want to make sure that compiler must at all times produce debug info for some variable, then temporarily declare it volatile while debugging.
if this solved your problem then please accept this answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27010?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 15:46:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36ee2f3f-f607-42bc-8259-6e9e469f6196</guid><dc:creator>danbujak</dc:creator><description>&lt;p&gt;That appears to work. What do you do when the local variable isn&amp;#39;t assigned to anything?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27009?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 15:42:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4a42c73-9279-461d-9f87-9cb86ff2bbf3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;set the breakpoint little later in the function where error_code is assigned to a global variable. At that point debugger should have known its info.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27008?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 14:17:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c9fd2a5-b193-4519-ab7f-48b128d1749f</guid><dc:creator>danbujak</dc:creator><description>&lt;p&gt;Optimization is set to level 0. I&amp;#39;ve attached the screenshot in the original post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27007?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 08:48:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0d62fbb-a6d8-4730-9bbb-82fa8275a01c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;when optimizations are set to level0, your local variables should be in scope when you are stepping the the function where these variables are defined. Can you give me a snapshot of not_in_scope thing that you see?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27006?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 20:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14905c92-b1ea-49e7-9aa8-b7669ea4142f</guid><dc:creator>danbujak</dc:creator><description>&lt;p&gt;You&amp;#39;re right, I realize now that it is in fact the soft reset that&amp;#39;s occurring be cause I did not have the DEBUG define enabled and the APP_ERROR_CHECK was actually calling a reset by default.&lt;/p&gt;
&lt;p&gt;When I check what called the NVIC_SystemReset I discovered that it was the APP_ERROR_CHECK in the notif_enable() function. Now that I&amp;#39;ve added added the &amp;#39;DEBUG&amp;#39; define I&amp;#39;m trying to step through app_error_handler() but all the variables in here (error_code, line_num, p_file_name) are all shown as not in scope in Keil.&lt;/p&gt;
&lt;p&gt;I have all optimizations disabled now- how can I find out what the error is and how to fix it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27005?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 17:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ce19b4c-ace7-46ef-a931-7ba0969d4f11</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You said that something causes your eval board to reset. Hardfault handler given by Nordic SDK does not cause reset. Search your project for NVIC_SystemReset and put a breakpoint there. You should see the call stack in Keil to tell you how it ended up there. If the call stack isn&amp;#39;t pointing to anything sensible then check go to memory (after hitting th breakpoint) and type &amp;#39;SP+0x14&amp;#39; It will give you exact code address of the function (stack push operation of LR register) that caused it. &lt;a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/Babefdjc.html"&gt;infocenter.arm.com/.../index.jsp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;once you get the code address from the memory (value at SP+0x14) you can look into .map file generated for you application and find out which function is located at that code address&lt;/p&gt;
&lt;p&gt;If there are no soft reset in your project then check if the board is getting enough power. There is a register NRF_POWER-&amp;gt;RESETREAS, which should tell you the reason of current reset.&lt;/p&gt;
&lt;p&gt;If you are using softdevice, then you cannot step through the code without doing some tricks. below are the search results for more information on that. &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/477/can-i-debug-ble-program"&gt;This one&lt;/a&gt;, and &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/17/how-can-i-debug-a-softdevice-application"&gt;this one&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to trace back hard fault handler</title><link>https://devzone.nordicsemi.com/thread/27004?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 15:18:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3a0faf7-8f5f-4432-8081-26f98c865392</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;I don&amp;#39;t know if this is proper method, but my method of checking what causes hardfault is just by setting breakpoint on hardfault handler. When it triggers, I just check call stack to check which function caused it... Can you find exact line of code that causes hardfault? Or is it in SD?&lt;/p&gt;
&lt;p&gt;Edit. Try turning optimization off and debug again. Or maybe it&amp;#39;s some time-related problem... Can You check call stack when you get in hardfault handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>