<?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>Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23879/usage-fault-in-app-scheduler</link><description>I&amp;#39;m using and NRF52 with S132 and SDK13.0. I&amp;#39;m using Keil as my IDE. 
 My application acts as a central for smart phones to connect to and also acts as a peripheral to conect to multiple other devices. 
 Currently my app works well with up to 2 smart</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Aug 2017 00:12:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23879/usage-fault-in-app-scheduler" /><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93965?ContentTypeID=1</link><pubDate>Mon, 07 Aug 2017 00:12:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa1079c9-c9a4-4c5e-a020-ca83871ee1a4</guid><dc:creator>goldwake</dc:creator><description>&lt;p&gt;I&amp;#39;ve managed to fix this. Turns out there was a potential pointer error in one of my events. Thanks for your help, I&amp;#39;ve definitely learnt a lot about debugging hardfaults etc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93964?ContentTypeID=1</link><pubDate>Wed, 02 Aug 2017 21:42:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c5c4900-f0fd-473d-82c8-9aefd69698ea</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;there you go - that MMD post did have it in it in a comment. It&amp;#39;s called Vector Catch (so I wasn&amp;#39;t that far off). Even googling that there&amp;#39;s not a lot of information. I must have read about it in the M4 debug and trace technical manual or something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93963?ContentTypeID=1</link><pubDate>Wed, 02 Aug 2017 21:34:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:316fae4b-aa65-4e8f-aafa-dffcd93566d9</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;no - not MMD. What I&amp;#39;m talking about it breakpoints on exceptions, which get taken before the fault handler is called. I never saw them on the nRF51 series, when I started working with the &amp;#39;52 they showed up enabled (I use Crossworks which is basically Segger Embedded Studio). It was confusing at first because they caused debug stops at points I didn&amp;#39;t expect and got turned off at some point. I just don&amp;#39;t remember the term for them and don&amp;#39;t have a board handy right now (been in Atmel land for a while recently which is mostly cortex M0 again).&lt;/p&gt;
&lt;p&gt;Nor has my google-fu turned up the term. Either way - on the M4 you should be able to take a breakpoint before the exception handler runs which is handy dandy for figuring out where you were without having to work backwards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93962?ContentTypeID=1</link><pubDate>Wed, 02 Aug 2017 21:27:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c29a3c18-a511-43f6-b19a-f3a36f8ca4ca</guid><dc:creator>goldwake</dc:creator><description>&lt;p&gt;@RK when you talked about catch points, where you referring to &lt;a href="https://devzone.nordicsemi.com/blogs/877/monitor-mode-debugging-revolutionize-the-way-you-d/"&gt;monitor mode debugging&lt;/a&gt;? I&amp;#39;ve sent away a PCB to be made so I can use the ETM on the Dev Kit.
@Hung Bui, its easy to reproduce but takes a couple of minutes to occur. I&amp;#39;ll try create a simplified demonstration&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93958?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 14:26:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:482075d6-e321-4aad-ac80-400c45e0d733</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@goldwake: Is it easy to reproduce ? Could you provide simplified source code (could be a SDK&amp;#39;s example) that we can run on the nRF5 DK and can reproduce the issue here ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93956?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 05:15:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94f7422f-e02a-49c8-9fb2-55e1ae98ab41</guid><dc:creator>goldwake</dc:creator><description>&lt;p&gt;Unfortunately it doesn&amp;#39;t look like its due to a small stack. Increasing the stack from 8192 to 18480, gives no improvement. Tomorrow I will have a look at trying to get ETM going with a ULink pro, maybe that can offer some insight. I&amp;#39;ll also look at the catch points you mentioned&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93957?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 04:14:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc7e866b-4e85-46e6-b101-427897f0383a</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;that may also explain the second trace, remember I said I didn&amp;#39;t understand the PC (it was 0x024f0a00) which meant nothing, if you have an event handler on your queue you&amp;#39;re jumping to and that is getting corrupted as you think .. that may be your issue.&lt;/p&gt;
&lt;p&gt;Do you have enough stack? wonder if you&amp;#39;re running the stack into your event queue or something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93961?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 04:11:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:541beb2a-c1fd-496e-8e3a-e75472d88904</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;yes I know r7 is the event handler - question I had was is it 0x00000000 and that &lt;code&gt;bl r7&lt;/code&gt; was jumping there, or is it making it to event_handler correctly and then indirecting to something else which is 0x0. Or perhaps I&amp;#39;m wrong about the PC on the stack trace being 0x0 (first stack trace) which indicates where it was when it faulted.&lt;/p&gt;
&lt;p&gt;Can you check that a couple more times, see if that is the address? If so then you can put an execute breakpoint on 0x0 and it should break before it runs the instruction which takes the exception. Then you have a stack.&lt;/p&gt;
&lt;p&gt;You&amp;#39;re on the nRF52 as well, it should be possible to set breakpoints (I can&amp;#39;t think what they are called now, catchpoints or something) on the exceptions which will drop into debug again BEFORE the exception is taken. I haven&amp;#39;t used them in a while but had at some point to turn them off to get my exception handlers called.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93960?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 04:01:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fcc4418-3e86-45bc-a090-87faef26514e</guid><dc:creator>goldwake</dc:creator><description>&lt;ul&gt;
&lt;li&gt;0&amp;gt; sched 58 //my app_sched_pull_evt()is processing evt 58&lt;/li&gt;
&lt;li&gt;0&amp;gt; ADDING 64 //My app is adding evt 64&lt;/li&gt;
&lt;li&gt;0&amp;gt; put 26 22FF5 // evt 64 has size 26 and handler addr 0x22FF5&lt;/li&gt;
&lt;li&gt;0&amp;gt; ADDING 58 //My app is adding evt 58&lt;/li&gt;
&lt;li&gt;0&amp;gt; put 26 22FF5 // evt 58 has size 26 and handler addr 0x22FF5&lt;/li&gt;
&lt;li&gt;0&amp;gt; sched done 7 //my app_sched_pull_evt() is finished processing evt 58. There are 6 (7 -1) elements in queue free&lt;/li&gt;
&lt;li&gt;0&amp;gt; h //exited my app_sched_pull_evt()&lt;/li&gt;
&lt;li&gt;0&amp;gt;sched 64 //my app_sched_pull_evt() is processing evt 64&lt;/li&gt;
&lt;li&gt;0&amp;gt; sched done 8 //my app_sched_pull_evt() is finished processing evt 58. There are 7 (8 -1) elements in queue free&lt;/li&gt;
&lt;li&gt;0&amp;gt; h //exited my app_sched_pull_evt()&lt;/li&gt;
&lt;li&gt;0&amp;gt;event_data_size 0 // unexpected data size in app_sched_execute&lt;/li&gt;
&lt;li&gt;0&amp;gt; event_handler 5EB0A01 // unexpected handler in app_sched_execute&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93959?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 04:01:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c7bebed-12db-4c23-888d-78fa863758f6</guid><dc:creator>goldwake</dc:creator><description>&lt;p&gt;Thanks RK.&lt;/p&gt;
&lt;p&gt;r7 is the event_handler.  I think I&amp;#39;m seeing the same problem manifest itself as usage and bus faults.
I&amp;#39;ve narrowed this down and it seems that somehow the m_queue_event_headers buffer is being corrupted. I see that the vaules for event_size and/or event_handler are being read differently to what I set them as. here is an example trace:&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93955?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 02:12:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6f36b32-90a7-41fe-b11c-79347b9f12f1</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;So lots of good information there. Going back to the original usage fault. You have a little more information, you know that the p_event_data was 0x20009b42 and the size of the event was 31 bytes (0x0000001f), that from the stacked R0 and R1 assuming they didn&amp;#39;t change before the fault occurred. If they make sense, it sounds like you didn&amp;#39;t get far after &lt;code&gt;bx r7&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You also have the PC at the point of the fault which according to that trace is 0x00000000. That doesn&amp;#39;t look good. (don&amp;#39;t understand the PC in the second image). So my first guess here would be you&amp;#39;ve jumped to 0x00000000, whatever is there (the initial stack pointer) disassembles as something which causes a usage fault, probably an invalid instruction.&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t see where r7 comes from, that I assume is the address of the event_handler which was loaded a little earlier from the event handling structure. If any of that code used but didn&amp;#39;t destroy r2, r3 or any of the other stacked registers, you might be able to see what r7 was loaded with. If that was zero, the &lt;code&gt;bx r7&lt;/code&gt; would have caused what you&amp;#39;re seeing.&lt;/p&gt;
&lt;p&gt;If that&amp;#39;s the case then something reset the event_handler to 0x00000000 (or you stomped over your memory). I don&amp;#39;t know what resets that to zero but possibly a de-registration of the event handler might. Are you deregistering the event handler anywhere whilst you still have events to process?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93953?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 14:17:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ff0c667-4eb7-4ee5-b2dc-a19f64f00988</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;If you don&amp;#39;t enable the SCB what would happens ? Where in the code the hardfault handler&amp;#39;s stack pointed to ? Please try to describe what you observed before you go in to debugging. What exactly happened when &amp;quot;it starts receiving usage faults.&amp;quot; ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93954?ContentTypeID=1</link><pubDate>Sun, 30 Jul 2017 21:04:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22b5a000-36a3-4eec-b367-5361221e4bad</guid><dc:creator>goldwake</dc:creator><description>&lt;p&gt;Hi Hung Bui, I have already got the app_error_handler defined and have been using it however, when I see this problem, it does not go into the error handler. It would go into the hard fault handler until I enabled the usage and bus fault handlers like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SCB-&amp;gt;SHCSR |= SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | SCB_SHCSR_MEMFAULTENA_Msk;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Usage Fault in App Scheduler</title><link>https://devzone.nordicsemi.com/thread/93952?ContentTypeID=1</link><pubDate>Fri, 28 Jul 2017 12:32:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24a50e16-b4bf-4993-871a-10784342d21a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I afraid you just over complicated the debugging process.
Could you describe what exactly happen when &amp;quot;it starts receiving usage faults.&amp;quot;
Please try to follow &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/#60126"&gt;this guide&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>