<?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>nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38514/nrf52840-logging-crashes-in-freertos</link><description>Recently I have encountered a software hanging issue on one of our products. It was based on nRF52840, with FreeRTOS (Thread SDK v1.0). The issue was apparently related to NRF_LOG_* stuff - if I added lots of logs, software would hang very quickly (whole</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Oct 2018 20:20:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38514/nrf52840-logging-crashes-in-freertos" /><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/152121?ContentTypeID=1</link><pubDate>Mon, 08 Oct 2018 20:20:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f45668dc-38e8-4db8-b8d4-65978fcfc537</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Nopik,&lt;/p&gt;
&lt;p&gt;The flash corruption is clearly a bi-product of the high frequency reset. Please let me know of any other way of reproducing this issue other than this reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/152099?ContentTypeID=1</link><pubDate>Mon, 08 Oct 2018 16:27:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85e4f599-2199-4350-986b-ce310fc4675a</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;The high frequency reset was just a by-product of trying to revel the logging crash (which started this thread). I though I was able to reproduce easily it earlier, but apparently I wasn&amp;#39;t. But since I&amp;#39;ve realized, that in many cases logging is crashing mostly in first few milliseconds, I added quick resets to pinpoint the problem. It, however, uncovered the flash corruption problem, instead.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/152074?ContentTypeID=1</link><pubDate>Mon, 08 Oct 2018 13:24:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90253998-9af4-4829-98e4-8f7a9b5e724c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Nopik,&lt;/p&gt;
&lt;p&gt;What is your usecase exactly? why do you want to reset the hardware with such a high frequency?&lt;/p&gt;
&lt;p&gt;There is some flash activity(Read/Write) happening in the initialization phase and I am almost certain that such frequent resets would interrupt an ongoing flash activity. As the result of this the behavior of the thread stack would become unpredictable and eventually cause a hardfault. Looking at the call stack of when the hardfault occurs, it matches my theory that it happens when there is a flash read from a previous written (interrupted write, most probably, corrupting the flash).&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-a81facb34f424939bcb9cc4bb2484a04/pastedimage1539005064515v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/152050?ContentTypeID=1</link><pubDate>Mon, 08 Oct 2018 12:30:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:304e3814-d748-4a81-ad07-1c948b402901</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Nopik, This thread somehow skipped my queue, otherwise I would not miss this for so many days. Sorry about that. I just tried to test your code, I see what you see now. Very strange that the flash is getting corrupted. I am debugging this now. Will be back to you when i find something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/151997?ContentTypeID=1</link><pubDate>Mon, 08 Oct 2018 09:37:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afc53a65-bff9-42ad-8692-9426aa2d203b</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;Did you tried to reproduce the flash corruption issue, as I described here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150684?ContentTypeID=1</link><pubDate>Thu, 27 Sep 2018 11:56:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2af07283-d762-4713-9f85-2c35b4598736</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;Aryan - the setup is very simple:&lt;/p&gt;
&lt;p&gt;1) Regular PCA10056 board&lt;/p&gt;
&lt;p&gt;2) Thread SDK 1.0&lt;/p&gt;
&lt;p&gt;3) For&amp;nbsp;examples/thread/freertos_coap_server/main.c use the version I provided earlier (&lt;a href="https://gist.github.com/Nopik/d59d269032fa5fe4e3b2af5001dd4307"&gt;https://gist.github.com/Nopik/d59d269032fa5fe4e3b2af5001dd4307&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;4) Either replace lines 316-317 by `&lt;span&gt;NVIC_SystemReset();` call or add jumper wire between GPIO P1.11 and P0.18&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;5) Flash PCA10056 and run the software&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;6) Leds will be blinking for 13-14 seconds, then they will stop&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;7) Flash becomes corrupted, PCA10056 wont boot anymore without full erase&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150660?ContentTypeID=1</link><pubDate>Thu, 27 Sep 2018 10:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7b6c128-1b25-4446-bffd-e9096123caa0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Nopik,&lt;/p&gt;
&lt;p&gt;FreeRTOS does not do any flash operations by itself.&amp;nbsp;I would not correlate the flash corruption to FreeRTOS. Flash operations are application specific and could go wrong if you gave an uninitialized pointer to a flash operation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Adding a lot of logs seems to worsen the behavior, which indicates that there must be a timings issue too. It is really hard for us to narrow down the problem without getting your whole setup to replicate the issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150630?ContentTypeID=1</link><pubDate>Thu, 27 Sep 2018 08:37:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f541e01-7c5b-476b-924e-7cf6dbee1b0a</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;Also, using `NVIC_SystemReset();` instead of pinreset corrupts flash as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150495?ContentTypeID=1</link><pubDate>Wed, 26 Sep 2018 13:09:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84834a18-2eb5-4436-870d-37464a7ca968</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;For the record, Thread SDK v2.0.0 gives the same behaviour.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150482?ContentTypeID=1</link><pubDate>Wed, 26 Sep 2018 12:31:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d31621e-616e-4268-a279-ffffc86da184</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;Also, btw. the&amp;nbsp;replacing FreeRTOS.h with your version makes no difference.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150479?ContentTypeID=1</link><pubDate>Wed, 26 Sep 2018 12:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:344830b9-fe1f-45d4-996e-a83b5e7dced4</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;So, the problem is still there, though it seems to be much more buried. When I got your reply, I started with replicating the bug on my side, and indeed - it now happens to me much less often (more like 1 in 100, as you mentioned). I&amp;#39;m using the same bin file and same hardware as before, which is quite puzzling. Yet, the problem originates from our proprietary software (which is using FreeRTOS and Thread), on custom board.&lt;/p&gt;
&lt;p&gt;Earlier I&amp;#39;ve pinpointed the problem to the log output - when I&amp;#39;ve been putting tons of logs (just for troubleshooting purposes, stuff like `for( int i=0;i&amp;lt;100;i++ ) NRF_LOG(&amp;quot;foo&amp;quot;);`, the code was crashing almost instantly. Then, I reproduced it on PCA10056 and almost clean example, so that is what I reported. I will try to investigate it again on our code version.&lt;/p&gt;
&lt;p&gt;In meantime, I tried to speed up the crashes in the example you&amp;#39;ve been working on. Since often code was crashing quickly after start, I did something simple: if task looped for some time, then reset. I installed wire between some random gpio (P1.11 in my case) and P0.18 on my PCA10056, and&amp;nbsp;added to&amp;nbsp;the main task1&amp;nbsp;something like this:&lt;/p&gt;
&lt;p&gt;```&lt;/p&gt;
&lt;p&gt;if( cnt &amp;gt; 20 ) {&lt;br /&gt;&amp;nbsp; nrf_gpio_cfg_output(RESET_PIN);&lt;br /&gt;&amp;nbsp; nrf_gpio_pin_clear(RESET_PIN);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;```&lt;/p&gt;
&lt;p&gt;i.e. reset after roughly 100 logs.&lt;/p&gt;
&lt;p&gt;The results were just stunning, so different, that I&amp;#39;m afraid that I&amp;#39;ve uncovered some other problem.&lt;/p&gt;
&lt;p&gt;When I run this code, it runs for 13-14 seconds (100% constant), then crashes - by corrupting flash. After it crashes, it wont boot up anymore, until I do `nrfjprog -e` and flash the code again. UICR is intact, `nrfjprog --eraseuicr`&amp;nbsp;is not enough to recover. When I dumped flash before and after crash, indeed, some parts of it (but not the code itself) are overwritten by some repeating pattern.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure if the reset method is valid (though with external watchdog it is very similar to what would happen), but whatever happens, flash content shouldn&amp;#39;t be corrupted.&lt;/p&gt;
&lt;p&gt;If I extend the timer and reset only after `cnt` reaches 100 or 1000, it just happens slower, but also corrupts the flash.&lt;/p&gt;
&lt;p&gt;Can you confirm, that you can reproduce this problem? My current `main.c` is at:&amp;nbsp;&lt;a href="https://gist.github.com/Nopik/d59d269032fa5fe4e3b2af5001dd4307"&gt;https://gist.github.com/Nopik/d59d269032fa5fe4e3b2af5001dd4307&lt;/a&gt;&amp;nbsp;Is this reset method valid? I suspect that electrically the reset impulse is simply too short and causes some misbehavior, or something.&lt;/p&gt;
&lt;p&gt;PS. I&amp;#39;ve seen that Thread SDK v2.0 was released today, I will try it as well, and let you know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150246?ContentTypeID=1</link><pubDate>Tue, 25 Sep 2018 12:13:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03ae077f-11eb-482c-b6cd-9d9105a7f46e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I had a colleague look at this (who has worked with&amp;nbsp;our FreeRTOS stack).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I did manage to reproduce your issue, as I mentioned, but not nearly as often as you report. Maybe one in 100 times or so, so it took quite a while. My go-to was to just restart it unless LED3 didn&amp;#39;t blink at all.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, my colleague suggested some changes in the FreeRTOSConfig.h, and I haven&amp;#39;t been able to reproduce it after this.&lt;/p&gt;
&lt;p&gt;Could you please try to replace your FreeRTOSConfig.h file with the attached one, and see whether you are able to reproduce it with this version?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-a81facb34f424939bcb9cc4bb2484a04/FreeRTOSConfig.h"&gt;devzone.nordicsemi.com/.../FreeRTOSConfig.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/150231?ContentTypeID=1</link><pubDate>Tue, 25 Sep 2018 11:31:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcdce052-8aab-45af-bcf7-4550e8ca7eba</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;Any progress?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/149077?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2018 14:15:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:512dabbc-f994-402d-a7e6-981ed6223667</guid><dc:creator>Nopik</dc:creator><description>&lt;p&gt;Ok, thanks. Hopefully you&amp;#39;ll be able to pinpoint the reason soon. Good to know, that you&amp;#39;ve reproduced the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 logging crashes in FreeRTOS</title><link>https://devzone.nordicsemi.com/thread/149076?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2018 14:11:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96f6436d-f33a-4945-b7c1-51fc8e7b6967</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. I have been trying to reproduce this. That is, I have managed to reproduce it, but not while debugging, so I am having some problems to find the reason. I just wanted to let you know that your ticket is being handled. I will get back to you as soon as I know something more.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>