<?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>Hard fault - memset and printf</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74406/hard-fault---memset-and-printf</link><description>Hi, 
 I&amp;#39;m using NRF52840 and having a lot of issues with hard fault. 
 From time to time, I get an application crash with the following log: 
 HARD FAULT at 0x00000000 R0: 0x00000010 R1: 0x00000000 R2: 0x20007848 R3: 0x00000000 R12: 0x20012FCC LR: 0x00031F27</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 May 2021 21:07:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74406/hard-fault---memset-and-printf" /><item><title>RE: Hard fault - memset and printf</title><link>https://devzone.nordicsemi.com/thread/308021?ContentTypeID=1</link><pubDate>Mon, 03 May 2021 21:07:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ba76847-fc6a-409e-b380-0a9a11761d58</guid><dc:creator>Sigurd</dc:creator><description>[quote user=""]HARD FAULT at 0x00000000[/quote]
&lt;p&gt;&amp;nbsp;Is it always 0? I would have expected a valid PC value here, pointing to the code that is causing the hardfault.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Did you try turning off optimization?&lt;/p&gt;
&lt;p&gt;I.e. in the makefile change &amp;quot;OPT = -O3 -g3&amp;quot; to &amp;quot;OPT = -O0 -g3&amp;quot;.&lt;/p&gt;
&lt;p&gt;If you are using SES, change from &amp;quot;Release&amp;quot; build to &amp;quot;Debug&amp;quot; build.&lt;/p&gt;
[quote user=""]and a log which is implemented with printf.[/quote]
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;If you are using e.g. NRF_LOG other places in your code, you should use NRF_LOG instead of printf&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault - memset and printf</title><link>https://devzone.nordicsemi.com/thread/307769?ContentTypeID=1</link><pubDate>Sat, 01 May 2021 20:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6016a6aa-9701-4e2b-ab13-0cad69a9e5c0</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for you answer!&lt;/p&gt;
&lt;p&gt;After disabling all logs, hard fault still occurs.&lt;/p&gt;
&lt;p&gt;I already have&amp;nbsp;&lt;span&gt;hardfault_implementation.c and&amp;nbsp;hardfault_handler_gcc.c in my project, and&amp;nbsp;HARDFAULT_HANDLER_ENABLED set to 1.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However - DEBUG_NRF isn&amp;#39;t defined in my project. Can you please explain how will it help?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault - memset and printf</title><link>https://devzone.nordicsemi.com/thread/306778?ContentTypeID=1</link><pubDate>Mon, 26 Apr 2021 11:45:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e551df23-2d17-4250-a798-7ab53337357f</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I recommend using the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_nrf_log.html"&gt;nrf_log module&lt;/a&gt; for logging. If you use deferred&amp;nbsp;mode, the log&amp;nbsp;processing is then&amp;nbsp;shifted to idle stage.&lt;/p&gt;
&lt;p&gt;If you are still experiencing hardfaults after switching to the nrf_log module, then make sure that the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_hardfault.html"&gt;hardfault library&lt;/a&gt; is used.&lt;/p&gt;
&lt;p&gt;Add these to your projects:&lt;/p&gt;
&lt;p&gt;$(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c&lt;br /&gt;$(SDK_ROOT)/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And set HARDFAULT_HANDLER_ENABLED to 1 in sdk_config.h, and add DEBUG_NRF in your preprocessor definitions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault - memset and printf</title><link>https://devzone.nordicsemi.com/thread/306641?ContentTypeID=1</link><pubDate>Sat, 24 Apr 2021 23:06:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97370f9f-c56b-4ee3-ae80-e3a757ba22b0</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;printf does not work well with softdevice. &amp;nbsp;Use uart instead&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>