<?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>K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68094/k_timer---hard_fault---data-access-violation---nrf9160</link><description>Hi, 
 
 Currently we working on a project that uses: 
 
 
 nRF9160 
 Zyphre OS 
 Segger Embedded Studio for Arm (Nordic Edition) V5.10d 
 SDK v1.4 
 
 
 We need to handle multiple timeouts, to handle our processes, but we have a problem that we think</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Dec 2020 09:29:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68094/k_timer---hard_fault---data-access-violation---nrf9160" /><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/283268?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 09:29:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81fd6467-269b-4cca-8157-c8b3ccdcee84</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Rene,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="ReneDelgado"]&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for you amazing support, I gees in the Verified answer that you give us&amp;nbsp; was solved de hard fault in the most of cases.&lt;/p&gt;[/quote]
&lt;p&gt;Always happy to help! Please let us know if anything pops up.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user="ReneDelgado"]We do no have more time to invest in this aproach, wi&amp;nbsp; will try another one.[/quote]
&lt;p&gt;No problem. Sorry I couldn&amp;#39;t help to catch this behavior!&lt;/p&gt;
&lt;p&gt;I hope you have a nice weekend&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/283227?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 03:01:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dde996ed-8ca4-4ae2-a794-1f2ac180b6fb</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for you amazing support, I gees in the Verified answer that you give us&amp;nbsp; was solved de hard fault in the most of cases.&lt;/p&gt;
&lt;p&gt;We do no have more time to invest in this aproach, wi&amp;nbsp; will try another one.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks Again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/281138?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 14:21:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:538cbdda-6472-4acf-bd18-f9e5a75ea620</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="ReneDelgado"]We noticed that the hard fault still occurs in some cases, it occurs less mainly while we debug step by step.[/quote]
&lt;p&gt;Is the source of the fault the same? Or does it occur in another function?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for the sources and headers.&lt;/p&gt;
&lt;p&gt;The only scenario I&amp;#39;m able to replicate a behavior that looks a bit like yours is if I call&amp;nbsp;countdown_ms() in a loop, ie. repeatedly starting the same timer instance. How often is countdown_ms called on your side?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/280984?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 20:11:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfec68c4-c96c-4299-b3f6-cb3507dd961b</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;Sure, at &lt;a href="https://github.com/dagtus/nordic-devZone/tree/main/Firmware/nrf9160/oasis/include/aws/aws-iot-device-sdk-embedded-C-3.1.1/platform/zephyr/timer_functions"&gt;this repository&lt;/a&gt; you can found the files that we are using, if is necessary give you access to more files just tell us.&lt;/p&gt;
&lt;p&gt;As note, We noticed that the hard fault still occurs in some cases, it occurs less mainly while we debug step by step.&lt;/p&gt;
&lt;p&gt;Also was added kconfig and prj.conf in case that it can help in something.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Ren&amp;eacute; D.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/280811?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 09:57:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a809cecd-c81c-4d2d-9886-01e98273235a</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi René,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Glad to hear that you handled the fault.&lt;/p&gt;
&lt;p&gt;Could you share the code in countdown_ms() so I can have a look?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/280717?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 22:45:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de06c3b7-2ebc-426e-b06c-a7838a38c3a1</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hello H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;I removed all the printk() and all printf() functions, an now we are using our own debug functions.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;And now, we are using LOG=y and LOG IMMEDIATE=n, with that changes, we do not have hard faults now.&lt;br /&gt;&lt;br /&gt;But, now we are in and infinity loop in timeout.c. &lt;span style="color:#ff0000;"&gt;It seems that the timers never ends.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1605739338753v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you any idea to how solve this behavior?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ren&amp;eacute; D.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/280281?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 09:41:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b75e363-a074-467c-8f62-65f21c856de4</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi René&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="ReneDelgado"]Sorry for the delay, I have the most popular virus from this year.[/quote]
&lt;p&gt;&amp;nbsp;I&amp;#39;m sorry to hear. I hope you and your closest are OK.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="ReneDelgado"]&lt;p&gt;Yes regarding to our sequence is like you mentioned, but regarding to &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/include/spinlock.h#L92"&gt;spinlock.h#L92&lt;/a&gt; we do not calling this function explicit neither we are using recursive functions. As note, we are using mutex as the documentation suggest.&lt;/p&gt;
&lt;p&gt;Also note that if I enable the segger system view this cracks earlier.&lt;/p&gt;[/quote]
&lt;p&gt;Aha. this is an issue I&amp;#39;ve also spent some time digging into.&lt;/p&gt;
&lt;p&gt;When you&amp;#39;re using RTT and no logger thread (ie. no context switch for logging), you can run into this scenario when printing in interrupts:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/11393"&gt;https://github.com/zephyrproject-rtos/zephyr/issues/11393&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you printing from the k_timer callback? if yes, can you check if the issue still occurs if you use LOG=y and LOG_IMMEDIATE=n?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/280205?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 20:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:deab52f3-e646-4aaf-91eb-d97107e69f99</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hello H&amp;aring;kon,&lt;br /&gt;&lt;br /&gt;Sorry for the delay, I have the most popular virus from this year.&lt;br /&gt;&lt;br /&gt;Yes regarding to our sequence is like you mentioned, but regarding to &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/include/spinlock.h#L92"&gt;spinlock.h#L92&lt;/a&gt; we do not calling this function explicit neither we are using recursive functions. As note, we are using mutex as the documentation suggest.&lt;/p&gt;
&lt;p&gt;Also note that if I enable the segger system view this cracks earlier.&lt;/p&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_SEGGER_SYSTEMVIEW&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_USE_SEGGER_RTT&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_TRACING&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you&amp;nbsp; want I&amp;nbsp; can send you an&amp;nbsp; email with a basic sample of the code.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ren&amp;eacute; D.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/279138?ContentTypeID=1</link><pubDate>Tue, 10 Nov 2020 08:26:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ead6a1d4-6c3a-4851-a00a-2e7cc00963bf</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi René,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From the logic that you posted, you&amp;#39;re doing something similar to this sequence:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/timing/timers.html#reading-timer-status"&gt;https://docs.zephyrproject.org/latest/reference/kernel/timing/timers.html#reading-timer-status&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Looking at the assert information, the second one is interesting:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/include/spinlock.h#L92"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/include/spinlock.h#L92&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This means that you have a nested (recursive) locking sequence somewhere, as per the documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/apidoc/latest/spinlock_8h_aac60da4347f5b29ff8c4e5f24c99b3bf.html"&gt;https://docs.zephyrproject.org/apidoc/latest/spinlock_8h_aac60da4347f5b29ff8c4e5f24c99b3bf.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there anything specific in the thread you&amp;#39;re calling this from that might call k_spin_lock()? Could you share a snippet or similar?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/279087?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 17:18:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da02e4e3-5a3e-437f-a9b7-f8e8fb0eaa65</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon, thanks for your prompt answer, this is the result from the address mentioned:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;PS C:\...\build_nrf9160dk_nrf9160ns\zephyr&amp;gt; arm-none-eabi-addr2line -e zephyr.elf 0x217e7&lt;br /&gt;C:/.../ncs/v1.4.0/zephyr/include/sys/&lt;span style="color:#ffcc00;"&gt;dlist.h:325&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PS C:\...\build_nrf9160dk_nrf9160ns\zephyr&amp;gt; arm-none-eabi-addr2line -e zephyr.elf 0x00021834&lt;br /&gt;C:/.../ncs/v1.4.0/zephyr/include/&lt;span style="color:#ffff00;"&gt;spinlock.h:92&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ffff00;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#000000;"&gt;Regarding your note, I don&amp;#39;t understand. &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;Our context:&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#000000;"&gt;We are calling &lt;/span&gt;&lt;span style="font-size:75%;"&gt;&lt;em&gt;k_timer_init(timer, NULL, NULL); &amp;amp; k_timer_start(timer, K_MSEC(timeout), K_NO_WAIT);&lt;/em&gt;&lt;/span&gt;&amp;nbsp; from a thread context without functions for callback, we set NULL in the k_timer_ini() function. We are not running nothing in any callback, We just verify if the timer has ended.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="color:#ffff00;"&gt;&lt;span style="color:#000000;"&gt;Could you expand your note a little more?&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color:#ffff00;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;Which callbacks are you referring to?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="color:#ffff00;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Ren&amp;eacute; D.&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ffff00;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ffff00;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/278945?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 09:38:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7482560-6f6b-44b2-905d-f059e0536300</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the assert message, you have two addresses that points out:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6574.pastedimage1604914513234v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;And:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7144.pastedimage1604914535722v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is located at these addresses? You can do a lookup using &amp;quot;arm-none-eabi-addr2line -e build-folder/zephyr/zephyr.elf 0xADDR&amp;quot;. If you have re-compiled or done any changes to application, these addresses will move.&lt;/p&gt;
&lt;p&gt;Note that all k_timer instances are running in interrupt context, so you should be very careful of what you&amp;#39;re calling in those callbacks. It is recommended to push tasks to a workqueue or similar instead.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: K_TIMER() - HARD_FAULT - Data Access Violation - nrf9160</title><link>https://devzone.nordicsemi.com/thread/278887?ContentTypeID=1</link><pubDate>Sun, 08 Nov 2020 08:41:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d67109a2-f32e-4a41-9f08-175c992cc1c4</guid><dc:creator>ReneDelgado</dc:creator><description>&lt;p&gt;Sorry, I forgot to attach this image:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/5305.HARD_2D00_FAULT.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>