<?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>Can&amp;#39;t get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67792/can-t-get-ram-based-secure-entry-functions-to-work</link><description>I&amp;#39;m having trouble getting the Secure Entry gateway functions to work out of RAM. The nRF9160 datasheet has RAMNSC configurations, so it should be possible. We&amp;#39;re able to get flash-based ones to work. Has anyone been able to have RAM-based Secure Entry</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Feb 2021 02:07:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67792/can-t-get-ram-based-secure-entry-functions-to-work" /><item><title>RE: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/293658?ContentTypeID=1</link><pubDate>Wed, 10 Feb 2021 02:07:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4244d84-b81d-4f68-8392-e644732f0f9d</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;I finally got a chance to revisit this, and was able to get it all working with a bit of fussing with linker scripts and setting up my own veneer functions with some assembly. So, I can confirm RAM-based NSC is working on the nRF9160!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/280138?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 14:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0fee265-9c85-4786-bfcb-cacee8f41e96</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Could you share a bit more details related to where your veneers are located, what the content on those RAM addresses are, and&amp;nbsp;how your RAMNSC[] register content is setup?&lt;/p&gt;
&lt;p&gt;Do all NSC calls fail, even the&amp;nbsp;spm_busy_wait_nse() function?&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: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/279951?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2020 14:56:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e622522-be70-437f-8ab3-a021839a2790</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;I&amp;#39;ve been able to work around these issues with some adjustments. I can confirm from my debugger (and nrfjprog.exe, for that matter) that the instructions are getting set up at our RAM locations. It&amp;#39;s just that the system gives a Secure Fault when they&amp;#39;re used, hence the questions about configuring RAMNSC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/279950?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2020 14:55:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5988e5b0-9d24-4be5-a1ca-576a5dd1ea9c</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;Were you able to confirm *NSC[n].REGION is every 4K/8K/16K? We&amp;#39;ll be using the smallest size for *NSC[n].SIZE (32 bytes) anyway, so I&amp;#39;m not worried about the size limit for it. But I want to make sure the region I&amp;#39;m selecting is actually getting set correctly.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m quite certain it can&amp;#39;t be every 4K for the region selections, since the register won&amp;#39;t hold more than 5 bits (confirmed after trying to put 63 in the register, but only reading back 31 after the write). But I want to make sure it&amp;#39;s not a silicon bug where only the first half of RAM can be used for NSC entries or something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/279777?ContentTypeID=1</link><pubDate>Thu, 12 Nov 2020 15:05:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dae0a587-815a-4b55-8c74-2c6d7c2584d6</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;I have been in contact with several low-level developers, and I have some bad news. I am afraid that we do not have any example that shows how to use non-secure callable RAM located functions using RAMNSC. It was considered, and looked into, but it was not viable at the time.&lt;/p&gt;
&lt;p&gt;The reason for this is due to the zephyr build environment and the&amp;nbsp;features of the gnu linker (see this:&amp;nbsp;&lt;a href="https://answers.launchpad.net/gcc-arm-embedded/+question/478082"&gt;https://answers.launchpad.net/gcc-arm-embedded/+question/478082&lt;/a&gt;).&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: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/279313?ContentTypeID=1</link><pubDate>Tue, 10 Nov 2020 14:48:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ddbf53e-a1e5-4a41-a8cd-4937e903be34</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Erik,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My apologies for the long waiting time.&amp;nbsp;&lt;/p&gt;
[quote user=""]I&amp;#39;ve confirmed the configuration of RAMNSC as well as RAMREGION in the SPU. It looks like the nRF9160 documentation has an error, however: it says the RAMNSC regions are 8K each, but there are only enough bits for 16K. Can anyone confirm if that&amp;#39;s an error? Or perhaps it just doesn&amp;#39;t support the full RAM range as NSC?[/quote]
&lt;p&gt;After a bit of back-and-forth, I can confirm that the *NSC[n].SIZE registers can be configured up to 4k each.&lt;/p&gt;
&lt;p&gt;Each NSC function will generate a 2 word veneer (see linker symbols __sg_start / __sg_end), placed in section &amp;quot;sgstubs&amp;quot; (&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/arch/arm/core/aarch32/cortex_m/tz/secure_entry_functions.ld"&gt;linker script found here&lt;/a&gt;). Here&amp;#39;s an example from secure_services:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; .gnu.sgstubs.__stub
                0x0000000000007fe0       0x18 linker stubs
                0x0000000000007fe0                spm_firmware_info_nse
                0x0000000000007fe8                spm_request_random_number_nse
                0x0000000000007ff0                spm_request_read_nse
                0x0000000000008000                __sg_end = .
                0x0000000000000020                __sg_size = (__sg_end - __sg_start)
                0x0000000000008000                . = ALIGN (0x8000)
                0x0000000000000020                __nsc_size = (. - __sg_start)
                0x0000000000000001                ASSERT (((__sg_size == 0x0) || ((((0x1 &amp;lt;&amp;lt; LOG2CEIL ((0x8000 - (__sg_start % 0x8000)))) == (0x8000 - (__sg_start % 0x8000))) &amp;amp;&amp;amp; ((0x8000 - (__sg_start % 0x8000)) &amp;gt;= 0x20)) &amp;amp;&amp;amp; ((0x8000 - (__sg_start % 0x8000)) &amp;lt;= 0x1000))), The Non-Secure Callable region size must be a power of 2 between 32 and 4096 bytes.)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is a limiting factor on the total amount of NSCallable functions,&amp;nbsp;where its&amp;nbsp;maximum allocation is&amp;nbsp;512 functions (4096 / 8 bytes) per region.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]The only real difference I&amp;#39;ve noticed (beyond the annoying wrangling to get GCC to do what I want it to) is that there are &amp;quot;veneer&amp;quot; function calls for RAM functions that aren&amp;#39;t used when calling the flash counterparts. In particular, it looks like the branch to the SG instruction in flash is a BL, while the branch to the SG instruction in RAM from the veneer is BX. I haven&amp;#39;t been able to find any documentation on whether or not various branching methods work or don&amp;#39;t work with TrustZone transitions. Is there any info on if BX will work?[/quote]
&lt;p&gt;I am sorry, but I do not have an update for this issue yet. I&amp;#39;m still checking internally. Consider this item still open from our 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&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/278428?ContentTypeID=1</link><pubDate>Wed, 04 Nov 2020 11:47:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4609126-7f36-4b84-9ea9-ccf47b29f30a</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;H&amp;aring;kon, no worries. Thanks for the update!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/278316?ContentTypeID=1</link><pubDate>Tue, 03 Nov 2020 15:28:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f721d5d-6f22-4c89-9b94-7049a66cd919</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;My apologies for the late response.&lt;/p&gt;
&lt;p&gt;I am in contact with key personnel in R&amp;amp;D related to your questions, and I hope to give you a response within a few working days, and if not; a status on the progress.&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: Can't get RAM-based Secure Entry functions to work</title><link>https://devzone.nordicsemi.com/thread/277678?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 18:09:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38d5808f-666a-4084-bd71-05e50d25b07f</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;Two updates:&lt;/p&gt;
&lt;p&gt;1) Looks like RAMNSC will hold more than 4 bits. I would assume the documentation (and the &amp;quot;mask&amp;quot; in nrf9160.h) is incorrect that it only holds 4 bits, but rather it holds 5 and is in increments of 8K still?&lt;/p&gt;
&lt;p&gt;2) I made a manual &amp;quot;veneer&amp;quot; RAM function that used BX to jump to the SG instruction in flash, but that succeeded, unlike when in RAM. So, it seems like there&amp;#39;s no limitation on BL versus BX. Which means I&amp;#39;ve now run out of ideas as to what&amp;#39;s going on.&lt;/p&gt;
&lt;p&gt;Hopefully either someone in the community or at least at Nordic has accomplished this at some point...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>