<?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>debugging hard faults in NCS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72582/debugging-hard-faults-in-ncs</link><description>Hi Nordic Community, 
 
 I have been experimenting with samples in NCS and making modifications. 
 Sometimes adding some code causes a hardfault during runtime. I can often find the root cause, e.g de-referencing a struct in memory that doesn&amp;#39;t exist</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Mar 2021 14:44:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72582/debugging-hard-faults-in-ncs" /><item><title>RE: debugging hard faults in NCS</title><link>https://devzone.nordicsemi.com/thread/299055?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 14:44:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e410241-c9d1-4102-8785-9a2d91e62ee5</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;First, try setting CONFIG_DEBUG_OPTIMIZATIONS=y in the prj.conf file.&lt;/p&gt;
&lt;p&gt;Could you try to press continue (green arrow) and see if you end up in &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/6bc4a6cda158a7f8013fb59975d00617ed623ea7/arch/arm/core/aarch32/cortex_m/fault.c#L552"&gt;secure_fault()&lt;/a&gt;&amp;nbsp;and/or &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/6bc4a6cda158a7f8013fb59975d00617ed623ea7/arch/arm/core/aarch32/fatal.c#L49"&gt;esf_dump()&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Also, could you try to enable this in prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_LOG=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then you should be able to see more information about the hard fault. Open a serial terminal like Termite to see the log.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>