<?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>NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40825/nrf52840-using-the-cryptocell310-with-a-preemptive-os</link><description>Hi, 
 I need to use the cryptocell in a project with a preemptive OS. Are there any relevant code examples available, or at least some general guidelines and precautions (e.g., for the initialization of the cryptocell)? 
 
 Thanks, 
 Damian</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 May 2020 13:49:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40825/nrf52840-using-the-cryptocell310-with-a-preemptive-os" /><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/248213?ContentTypeID=1</link><pubDate>Tue, 05 May 2020 13:49:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acd1de1a-88fe-4859-9d8c-86dfe57fcf7a</guid><dc:creator>WilliamEriksson</dc:creator><description>&lt;p&gt;Hi, although a little late here is a snippet that worked for me to mask the basepri:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NVIC_EnableIRQ(CRYPTOCELL_IRQn);
NRF_CRYPTOCELL-&amp;gt;ENABLE = 1;

SaSi_LibInit();

/* First read the current basepri value */
uint32_t prevBasepri = __get_BASEPRI();

/* Mask (disable) all interrupts with priority greater or equal to 1 */
__set_BASEPRI( 1 &amp;lt;&amp;lt; ( 8 - __NVIC_PRIO_BITS) );

CRYS_RndInit(&amp;amp;state, &amp;amp;buf);

/* Restore the previous basepri */
__set_BASEPRI(prevBasepri);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Related reading where I also posted the snippet:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45500/nrf52840-and-cc310-random-number-generator-hanging/179450?focus=true"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/45500/nrf52840-and-cc310-random-number-generator-hanging/179450?focus=true&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/233289?ContentTypeID=1</link><pubDate>Fri, 07 Feb 2020 13:02:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3faf26b5-bbf1-4fc0-93f8-7066e1b31e4a</guid><dc:creator>Red_devil</dc:creator><description>&lt;p&gt;Hi Jean,&lt;/p&gt;
&lt;p&gt;I tried the&amp;nbsp;above mentioned solution. I am facing the same issue even after adding&amp;nbsp;&lt;span&gt;&amp;quot;no-interrupts&amp;quot; library.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/201262?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 13:14:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc661afc-f001-4530-82b1-2f9c3a388064</guid><dc:creator>Rudy U</dc:creator><description>&lt;p&gt;Thanks for your quick response, Jean-Marc. We have tried the no interrupt library and it seems to be working fine. I guess that why Nordic made this library for the Rtos. Hopefully they fix this interrupt issue in the future :-)&lt;/p&gt;
&lt;p&gt;yours sincerely,&lt;/p&gt;
&lt;p&gt;Rudy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/201213?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 11:33:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d06d6e4f-bff7-4ff7-bed9-7f64047eda07</guid><dc:creator>Jean-Marc Koller</dc:creator><description>&lt;p&gt;Some time after the initial post, I noticed that, in the SDK 15.3, another CC310 library made its appearance:&amp;nbsp;a new folder named &amp;quot;no-interrupts&amp;quot; with a .a file in it. After switching to this library, we didn&amp;#39;t experience any problems related to the CC310 and external interrupts. The backside might be that the current consumption might be a bit higher as the processor will actively wait for the crypto-cell to finish, but the CC310 operations are mostly quite short.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/201184?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 09:44:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aad3c7f-c0e7-46e6-b3fd-5b7dc57306dc</guid><dc:creator>Rudy U</dc:creator><description>&lt;p&gt;Hi Damian and Jean-Marc,&lt;/p&gt;
&lt;p&gt;We are facing the same problem with FreeRtos and the BLE stack. The CC310 is hanging in the&amp;nbsp;&lt;em&gt;SaSi_HalWaitInterrupt.&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;How did you manege&amp;nbsp;to mask the interrupts? Could you post a snippet of the code or point us in the right direction&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Rudy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/160179?ContentTypeID=1</link><pubDate>Tue, 04 Dec 2018 11:46:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:366c27a2-471c-4453-bb78-9bdad46ae1c8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You are right that this is not handled in a very good way, and your workaround is probably the best solution at this point. We hope to improve this in a future release of the CC310 runtime library, but that will not happen in the near future.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/160054?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 16:11:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d2af4ef-a6f9-4c8a-b8db-33264bb97c19</guid><dc:creator>Jean-Marc Koller</dc:creator><description>&lt;p&gt;The problem we did face (I&amp;#39;m a colleague of DamianV, by the way) is that the library did block on our pre-emptive OS.&lt;/p&gt;
&lt;p&gt;Trying for example to use the RNG functions&amp;nbsp;of the cryptocell library leads to the process calling to remain waiting forever within the&amp;nbsp;&lt;em&gt;SaSi_HalWaitInterrupt&lt;/em&gt; function. My suspicion is that this function may have not been foreseen so that other interrupts than the one coming from the cryptocell may resume from the &lt;em&gt;WFE&lt;/em&gt;, like a timer or a peripheral.&lt;/p&gt;
&lt;p&gt;I tried to modify our test application so that the interrupt priority mask prior to calling the problematic functions is set in order to only have the cryptocell interrupt enabled, and our application didn&amp;#39;t&amp;nbsp;block anymore!&lt;/p&gt;
&lt;p&gt;But, without confirmation that it has to be done this way, I&amp;#39;m a bit reluctant to do this systematically!&lt;/p&gt;
&lt;p&gt;I did not find any example within the SDK using the cryptocell and FreeRTOS, in order to check if special handling is required in the case of a pre-emptive OS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: Using the CryptoCell310 with a preemptive OS</title><link>https://devzone.nordicsemi.com/thread/159163?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 08:28:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:457221be-05d3-48de-98dc-366a0ed743a1</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Cryptocell is interfaced using the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_crypto.html?cp=4_0_0_3_11"&gt;cryptography library&lt;/a&gt; in our sdk. This is also where you can find most of the documentation. I do not see an issue in using this with a preemptive OS, as the cryptocell will interface ram using DMA. But it would make sense to make sure only one buss master access the AHB slave at the same time (see &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52840.ps/memory.html?cp=2_0_0_3_1"&gt;memory &lt;/a&gt;and &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52840.ps/ahbmultilayer.html?cp=2_0_0_3_6"&gt;AHB multilayer&lt;/a&gt; for details).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>