<?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>Doing stack dump with nRF51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9430/doing-stack-dump-with-nrf51</link><description>Is it possible to get the state of the uC without being connected to it at the moment of crash?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 08 Oct 2015 21:24:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9430/doing-stack-dump-with-nrf51" /><item><title>RE: Doing stack dump with nRF51</title><link>https://devzone.nordicsemi.com/thread/34810?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2015 21:24:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edaf37f2-a9c3-4fe8-8651-1081361f06a4</guid><dc:creator>andrey</dc:creator><description>&lt;p&gt;Could you go into the second part a bit more? How exactly do I &amp;quot;connect&amp;quot;? Just starting a new debug session restarts the processor.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Doing stack dump with nRF51</title><link>https://devzone.nordicsemi.com/thread/34809?ContentTypeID=1</link><pubDate>Sun, 27 Sep 2015 04:04:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d42b5b99-9901-455b-b84e-0844808b60ed</guid><dc:creator>RK</dc:creator><description>&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;There&amp;#39;s quite a few online - it&amp;#39;s usually a bit of assembler jumping to a piece of C. All it&amp;#39;s really doing is figuring out which stack was in-use at the time of the fault and pulling the registers from there in order. Google ARM Hardfault Handler to start with. They all need a bit of customization but the principal is simple.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Connect. Break. See where you are. With JLink from the command line that&amp;#39;s as easy as typing &lt;code&gt;halt&lt;/code&gt; followed by &lt;code&gt;regs&lt;/code&gt;. A full IDE debugger will do a little better but the principle is the same.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Doing stack dump with nRF51</title><link>https://devzone.nordicsemi.com/thread/34808?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2015 18:58:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc706dea-ca39-47a1-b7f1-6b5d344d5559</guid><dc:creator>andrey</dc:creator><description>&lt;ol&gt;
&lt;li&gt;Is there sample code somewhere for getting the state of the registers and stack state out from a hardfault?&lt;/li&gt;
&lt;li&gt;How exactly can I see where the code is being executed when connecting to an already-running uC?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Doing stack dump with nRF51</title><link>https://devzone.nordicsemi.com/thread/34807?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2015 05:04:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bec214ae-671b-4898-a3fb-d695d52eb39c</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;That rather depends by what you mean by crash. If you&amp;#39;re going to your error handler or ending up in the hardfault handler, then yes you just implement an error handler or hardfault handler which finds the stack, gets the registers and dumps the last state of them to&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;RAM if the chip will stay powered for long enough for you to put a debugger on it&lt;/li&gt;
&lt;li&gt;flash if you&amp;#39;re going to power it down and reconnect to it later.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you have a loop-forever error handler, you may not even need to save state, you can connect to the chip whilst it&amp;#39;s busy-looping and read the state right from where it left off.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re going to write state to flash then you don&amp;#39;t want to use ANY of the library code, just write the registers to clear the pages you want and write them again to dump the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>