<?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 in SPM module</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78402/hard-fault-in-spm-module</link><description>Hi. 
 I&amp;#39;m trying to run an application using a custom SPM module in a nRF5340 where I get an error while running it. I&amp;#39;m using nRF Connect SDK. The terminal gives me this output: 
 [00:01:43.704,071] &amp;lt;err&amp;gt; os: Exception occurred in Secure State [00:01</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Aug 2021 14:11:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78402/hard-fault-in-spm-module" /><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324883?ContentTypeID=1</link><pubDate>Fri, 13 Aug 2021 14:11:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:507c21aa-443a-4928-b456-a733fa98e41e</guid><dc:creator>MarioDLH</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;It seems that the stack size is what was causing the problem. Now it works perfectly.&lt;/p&gt;
&lt;p&gt;Thank you for your assistance.&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324847?ContentTypeID=1</link><pubDate>Fri, 13 Aug 2021 12:33:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d3c3e54-35bd-463f-9646-bfd4dff2f038</guid><dc:creator>Didrik Rokhaug</dc:creator><description>[quote user="MarioDLH"]As for the question about what happens on the non-secure side, I don&amp;#39;t quite understand what you are referring to. As far as I know, non-secure side waits for the called function to finish before continuing, right?[/quote]
&lt;p&gt;&amp;nbsp;Not necesarily.&lt;/p&gt;
&lt;p&gt;E.g. if you have an interrupt happening on the non-secure side, which in turns causes the scheduler to switch to another thread.&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/60850/nrf9160-secure-services-causing-a-crash/253015#253015"&gt;this comment&lt;/a&gt; in an earlier ticket for a better explanation.&lt;/p&gt;
&lt;p&gt;Another suggestion raised in the same ticket is to increase the stack size of the SPM. You can see how to do that here: &lt;a href="https://github.com/nrfconnect/sdk-nrf/commit/2291ddb833869ba15f2705da7e6c13851440ad68"&gt;https://github.com/nrfconnect/sdk-nrf/commit/2291ddb833869ba15f2705da7e6c13851440ad68&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324712?ContentTypeID=1</link><pubDate>Thu, 12 Aug 2021 16:49:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ee1ccea-ef36-4504-a6d4-2251eda8d489</guid><dc:creator>MarioDLH</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Thanks for your response. I tried locking the scheduler but I still get the same error. Debugging the function I managed to find the instruction that leads to the hard fault, but it&amp;#39;s a complex macro which won&amp;#39;t show while debugging. This is the&amp;nbsp;&lt;a href="https://github.com/supranational/blst/blob/master/src/e2.c#L442"&gt;instruction&lt;/a&gt;&amp;nbsp;and it&amp;#39;s defined &lt;a href="https://github.com/supranational/blst/blob/master/src/ec_mult.h#L67"&gt;here&lt;/a&gt;, if it helps.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; As for the question about what happens on the non-secure side, I don&amp;#39;t quite understand what you are referring to. As far as I know, non-secure side waits for the called function to finish before continuing, right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324707?ContentTypeID=1</link><pubDate>Thu, 12 Aug 2021 15:32:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fd008d5-3ba4-4705-adca-43efa3bfb889</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Sorry for the late reply.&lt;/p&gt;
&lt;p&gt;We are a bit short on staff due to summer vacations, so it takes a bit longer to get through everything.&lt;/p&gt;
&lt;p&gt;What happens on the non-secure side while during the secure call?&lt;/p&gt;
&lt;p&gt;Could you try to lock the scheduler before you switch to the secure domain? See &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/subsys/nonsecure/secure_services_ns.c#L14-L24"&gt;https://github.com/nrfconnect/sdk-nrf/blob/master/subsys/nonsecure/secure_services_ns.c#L14-L24&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324567?ContentTypeID=1</link><pubDate>Thu, 12 Aug 2021 02:17:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4882778-53cf-458d-b210-41230a6181fa</guid><dc:creator>MarioDLH</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I just want to revive the post, as I still keep facing the same error and I don&amp;#39;t know how to proceed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324288?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 13:42:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f93ac42-94c1-4b21-ba09-eaf606346441</guid><dc:creator>MarioDLH</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;No, UART is not needed. Nevertheless, I tried setting it as secure, but I still get the same error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard fault in SPM module</title><link>https://devzone.nordicsemi.com/thread/324203?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 11:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69330e7d-d235-4602-8200-3acbea687b4e</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you using UART or other peripherals in your code?&lt;/p&gt;
&lt;p&gt;If so, you must ensure that they are configured as secure. If not, they can only be used by non-secure code.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>