<?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>Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61149/crash-in-secure-fault-handler-when-spm-logging-is-enabled</link><description>Hi, 
 I was tracking down a bug that resulted in a secure fault exception. To save some time tracking it down I enabled logging in the spm. However this resulted in an escalated exception in the spm fault handler. As far as I can see the MCU is in non</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Mar 2021 15:52:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61149/crash-in-secure-fault-handler-when-spm-logging-is-enabled" /><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/301513?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 15:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff32b7e1-96a4-43e9-8c45-70291f11ee6d</guid><dc:creator>loumay</dc:creator><description>&lt;p&gt;Awesome! Thanks for the quick response.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/301493?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 14:59:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3761660e-2fd6-4ed1-9c42-2335a8061a2e</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/loumay"&gt;loumay&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;There is an open PR that will let you dump non-secure logs from secure faults: &lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/3933"&gt;https://github.com/nrfconnect/sdk-nrf/pull/3933&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/301488?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 14:47:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e08c7f8e-c5b9-4992-85f5-d33c42f5e9d5</guid><dc:creator>loumay</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;br /&gt;Is there news on this topic?&lt;/p&gt;
&lt;p&gt;I would be interested to understand why the secure firmware (e.g SPM) can&amp;#39;t access a peripheral configured as non-secure.&lt;/p&gt;
&lt;p&gt;I only have one UART (configured as NS and used by the NS application) in my setup and it would be useful to print the fault info with it.&lt;/p&gt;
&lt;p&gt;Would it be feasible to change the security attribute in the fault back to secure?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/253319?ContentTypeID=1</link><pubDate>Thu, 04 Jun 2020 13:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9f74bcd-79a6-488f-a50c-29c384226d4e</guid><dc:creator>ante</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
&lt;p&gt;no worries. We solved the bug long ago so this is not crucial for us. But&amp;nbsp;if it is possible to get some kind of fix in the future I think it&amp;nbsp;would help a lot of people.&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;
&lt;p&gt;/Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/252984?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2020 12:03:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0097e91f-72fc-46b8-b2f5-bddfd07694ed</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi, and sorry for this taking some time.&lt;/p&gt;
&lt;p&gt;It does not look like there is an easy solution to this, so there will probably not be a fix any time soon. Here is what one of our developers has said:&lt;/p&gt;
&lt;p&gt;&amp;quot;There is no good solution to this other than creating a debug output in the secure side and return this information to the non-secure domain, probably in a non-volatile memory. Secure code should be resetting the SoC in a SecureFault (IMHO, no-matter-what)&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;And that should only be done for debug purpose, because it is a security leak, i believe.&amp;quot;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/249549?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 16:15:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61630110-7cb2-4e0e-a420-229b38afe4f5</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Ok, I see what you mean now.&lt;/p&gt;
&lt;p&gt;While I am not an expert on TrustZone myself, my understanding at the moment, after going through your modified gps sample with a debugger is this:&lt;/p&gt;
&lt;p&gt;When the secure fault exception is triggered, the core changes from non-secure to secure mode. Part of the log output is a timestamp, so the fault handler has to access RTC1 to get the current count. However, RTC1 has been configured as non-secure by the SPM, which means that it cannot be accessed from secure state.&lt;/p&gt;
&lt;p&gt;I have asked our developers to take a look.&lt;/p&gt;
&lt;p&gt;In the meantime, one suggestion that might help (I have not tried it myself yet) is to enable &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/master/subsys/logging/Kconfig#L13"&gt;minimal logging&lt;/a&gt;. That will remove timestamps from the log output, which might let you get the output you are after without triggering a new exception.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/249013?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 15:39:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfc4af9e-3081-4eb1-9ba9-c861578d8075</guid><dc:creator>ante</dc:creator><description>&lt;p&gt;Our application is just setting up GPS more or less. So the sequence is:&lt;/p&gt;
&lt;p&gt;1. Device successfully boots spm (nrf/sample/nrf9160/spm)&lt;/p&gt;
&lt;p&gt;2. Our application starts but crashes (this bug I will track down, so I am not asking about what is happening here)&lt;/p&gt;
&lt;p&gt;3. The fault handler in the secure area (again&amp;nbsp;&lt;span&gt;nrf/sample/nrf9160/spm) gets called. I can see that the exception is a secure fault.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;4.&amp;nbsp;When the fault handler in the secure area tries to printout the stack frame (which I need to track down the bug in step 2) it crashes since it can&amp;#39;t access&amp;nbsp;RTC1_S. So I don&amp;#39;t get the&amp;nbsp;dump of the crash in my application - instead I get the dump of the crash inside the fault handler in the secure area.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So one way to reproduce the problem is to use one of the sample application. I just tried with gps&amp;nbsp;nrf/sample/nrf9160/gps. And then:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1. Enable log in the sample spm application (nrf/sample/nrf9160/spm) by adding this line to prj.conf:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_LOG=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;Add this line at the first line in main function of the gps sample application:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;volatile uint32_t dummy = *((uint32_t *)0x5000F000);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This should trigger a secure fault in the secure area. So if you load &amp;lt;build_dir&amp;gt;/spm/zephyr/zephyr.elf and set a breakpoint z_arm_fault() you should see that the execution will not get passed this line:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;esf = get_esf(msp, psp, exc_return, &amp;amp;nested_exc);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The get_esf() will try to print out the stack frame but instead an elevated exception is triggered.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in secure fault handler when spm logging is enabled</title><link>https://devzone.nordicsemi.com/thread/248996?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 14:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:123e35ea-0cc6-4178-9a09-db05e8a42eed</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Could you explain a bit more about what your application is doing?&lt;/p&gt;
&lt;p&gt;I assume this happens after your application has started, i.e. after the SPM has finished, and jumped to the main application?&lt;/p&gt;
&lt;p&gt;Or does the fault happen in the SPM?&lt;/p&gt;
&lt;p&gt;Are you using the secure_service library? If so, what services are you using?&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>