<?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>Flash data in Hardfault handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49958/flash-data-in-hardfault-handler</link><description>Hello Nordic, 
 
 I&amp;#39;m developing app with nrf52840, SDK15.3.0 and s340. 
 The work almost has done, so we need to test ourdoor. 
 The problem is that we don&amp;#39;t find out the crash location. 
 We can find out the crash location indoor because of JLink. </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jul 2019 13:20:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49958/flash-data-in-hardfault-handler" /><item><title>RE: Flash data in Hardfault handler</title><link>https://devzone.nordicsemi.com/thread/199306?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 13:20:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07f13371-b85d-46fc-bae5-0df7aa50163d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I would just hard code a pointer to an unused part of RAM since this for debugging. You can check the *.map file in your build directory to find a free area between the globals and heap/stack&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash data in Hardfault handler</title><link>https://devzone.nordicsemi.com/thread/199292?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 12:56:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b9515ca-d62a-4d2c-af17-1f83bd48bfac</guid><dc:creator>hongpal</dc:creator><description>&lt;p&gt;Thank for your answer.&lt;/p&gt;
&lt;p&gt;However, I am using eclipse with gcc.&lt;/p&gt;
&lt;p&gt;Would you re-write the way ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash data in Hardfault handler</title><link>https://devzone.nordicsemi.com/thread/199290?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 12:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65f424f8-8029-4ff2-b26e-c7e5a0388855</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Depending on the fault it may be difficult to reliably write the crash log to flash. I think it&amp;#39;s easier to write the information to a non-initialized section of RAM, perform a reset, then on subsequent boot, check the RAM content and write it to flash.&lt;/p&gt;
&lt;p&gt;If you use Segger embedded Studio you can use the &amp;quot;.non_init&amp;quot; section to place the data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;e.g.,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static char error_info[128] __attribute__((section(&amp;quot;.non_init&amp;quot;)));
static uint16_t crc __attribute__((section(&amp;quot;.non_init&amp;quot;)));

/* Call this function on startup to see if there is any new error 
 *  information available
 */
void check_error_info()
{
    uint32_t len;
    
    if ( crc == crc16_compute(error_info, sizeof(error_info), NULL))
    {
        crc = 0;
        len = strlen(error_info);
        if (len &amp;gt; sizeof(error_info)) len = sizeof(error_info);
        //store error information to flash
        //TODO: write error info to flash 
        NRF_LOG_INFO(&amp;quot;%s&amp;quot;, error_info);
    }
}

/*Read error information from flash */
void get_error_info(uint32_t * p_data)
{  
    *p_data = (uint32_t) error_info;
    memset(error_info, 0, sizeof(error_info));
    // flash_read(p_data, p_src)
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>