<?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>Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92220/board-reboots-when-a-function-is-executed-in-tf-m</link><description>Hi, 
 I&amp;#39;m moving a project from SPM to TF-M. I have imported a static library and the board (nRF5340DK) restarts automatically every time the following mycli/main.c function is executed: signature. 
 
 More specifically, the problem occurs when executing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Dec 2022 10:09:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92220/board-reboots-when-a-function-is-executed-in-tf-m" /><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/398498?ContentTypeID=1</link><pubDate>Thu, 01 Dec 2022 10:09:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df1747bd-a041-446c-95f8-721fe9f48611</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;Your issue might be related to some kind of a bug in your project. I would suggest that you start with simple sample and start developing from there one step at the time. Make sure to test along the way and do not introduce many simultaneous changes into your project during the development.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/397401?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2022 12:13:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d10c9344-b2d7-457b-a37b-2de9478bcccb</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;I have made an internal inquiry related to your issue. I&amp;#39;ll come back to you when I get new information, hopefully till the end of next week.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/396894?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 12:21:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8634920d-8c17-418c-b559-3eb228130de1</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;Thank you for the clarification. However, my problem is not that alloca fails with a large number. As I commented in my previous post, when I increase stack_size the way you told me it doesn&amp;#39;t seem to have had an effect.&lt;/p&gt;
&lt;p&gt;Using alloca with 4500 bytes and with a stack size of 0x800 works correctly. However, duplicating the number of bytes for alloca (9000 bytes) and greatly increasing the stack_size to 0x8000 does not work.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/396883?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 11:59:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5b59e0a-38fc-4273-987b-36acdfddc824</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;I have tested your sample project and managed to reproduce your issue.&amp;nbsp;&lt;br /&gt;In your code, inside CheckMemory() function, you should be careful how you use array and alloca() function.&lt;br /&gt;The size of the array could potentially be as you have set it. However, there is no guarantee that this number of bytes would be available at run-time. As a result, you may not have enough stack space. Allocation on the stack with function alloca() may produce stack overflow with very large values.&amp;nbsp;&lt;a href="https://www.man7.org/linux/man-pages/man3/alloca.3.html"&gt;Alloca() man page&lt;/a&gt;&amp;nbsp;specifies &amp;quot;The alloca() function returns a pointer to the beginning of the&amp;nbsp;allocated space. If the allocation causes stack overflow,&amp;nbsp;program behavior is undefined.&amp;quot;&amp;nbsp;Therefore, you may consider using alloca() with fewer bytes.&amp;nbsp;&lt;br /&gt;I have also modified and tested your sample with char c[10] and void *c=alloca(10) and everything was fine. I would suggest that you use less bytes in your array declaration as well as in the alloca() function.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/395431?ContentTypeID=1</link><pubDate>Sun, 13 Nov 2022 10:07:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d13db6f-8d14-4a8d-b23e-bcc4569c536b</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;Here you have an updated version of the sample project, with warnings removed. There are only 2 warnings, related with unused variables. These variables are used for testing VLA and &lt;em&gt;alloca&lt;/em&gt;.&amp;nbsp;There should be no problem with these warnings.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6874.tfm_5F00_secure_5F00_partition_5F00_stacksize.zip"&gt;devzone.nordicsemi.com/.../6874.tfm_5F00_secure_5F00_partition_5F00_stacksize.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think you need to enable the &lt;em&gt;&amp;quot;Enable debug options&amp;quot;&lt;/em&gt; option for the build. This should allow you to see the TF-M log that I have shown in my last message.&lt;/p&gt;
&lt;p&gt;To reproduce the error, you must modify the size given as a parameter in the &lt;em&gt;CheckMemory&lt;/em&gt; function, which is used in &lt;em&gt;dummy_partition/dummy_partition.c&lt;/em&gt;. With a value of 9000 there is an error, but with a value of 4500 there is no error.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;printf(&amp;quot;Let&amp;#39;s check memory using malloc, VLA and alloca\r\n&amp;quot;);
for(int i = 0; i &amp;lt;= 2; i++){
	CheckMemory(i, 9000);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can also check, as I said in the previous message, that modifying the stack size in &lt;em&gt;dummy_partition/tfm_dummy_partition.yaml&lt;/em&gt; has no effect.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;quot;stack_size&amp;quot;: &amp;quot;0x8000&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/394970?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2022 16:16:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad9c69c8-bb21-45f9-accb-be98ce76680b</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;There are many warnings in your provided sample.&lt;br /&gt;&lt;br /&gt;The results of testing your current sample tfm_secure_partition_stacksize&amp;nbsp;are shown below.&lt;br /&gt;&lt;br /&gt;Application log&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/app_5F00_log_5F00_new.PNG" /&gt;&lt;br /&gt;&lt;br /&gt;TF-M log&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/tfm_5F00_log_5F00_new.PNG" /&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/394866?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2022 10:03:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bcc0035c-4e7d-4a0d-90b4-8889eb2895a8</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;Increasing stack memory didn&amp;#39;t work for me, so I used a sample project for you to check it. I don&amp;#39;t know what I am doing wrong. I&amp;#39;m using&amp;nbsp;&lt;span&gt;nRF SDK v2.0.0 and nRF5340DK.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/tfm_5F00_secure_5F00_partition_5F00_stacksize.zip"&gt;devzone.nordicsemi.com/.../tfm_5F00_secure_5F00_partition_5F00_stacksize.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;CheckMemory is a function that allocate memory using malloc, VLA or alloca. This function is executed from secure partition.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void CheckMemory(int location, int bytes){
	if(location == 0){
		// HEAP
		printf(&amp;quot;Allocating %d bytes using malloc (HEAP)...\r\n&amp;quot;, bytes);
		void * m = malloc(bytes);
		printf(&amp;quot; -&amp;gt; HEAP: OK\r\n&amp;quot;);
		free(m);
	}else if(location == 1){
		printf(&amp;quot;Allocating %d bytes using VLA (STACK)...\r\n&amp;quot;, bytes);
		// STACK 1
		char c[bytes];
		printf(&amp;quot; -&amp;gt; STACK 1: OK\r\n&amp;quot;);
	}else if(location == 2){
		printf(&amp;quot;Allocating %d bytes using alloca (STACK)...\r\n&amp;quot;, bytes);
		// STACK 2
		void * c = alloca(bytes);
		printf(&amp;quot; -&amp;gt; STACK 2: OK\r\n&amp;quot;);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Using CheckMemorySIze with bytes = 4500:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/stacksize_5F00_0x800_5F00_bytes_5F00_4500.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Using CheckMemorySize with bytes = 9000:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/stacksize_5F00_0x800_5F00_bytes_5F00_9000.png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, VLA success if bytes = 4500, but it fails if bytes = 9000. Alloca fails too.&amp;nbsp;VLA and alloca uses stack, so increasing stack size should be enough. Following your recommendation, I increased stacksize from 0x800 to 0x8000 (&lt;em&gt;tfm_dummy_partition.yaml&lt;/em&gt;), but it didn&amp;#39;t worked for me. It fails again:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/imagen_5F00_2022_2D00_11_2D00_09_5F00_104539261.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;P.S&lt;/strong&gt;&lt;/span&gt;: By default, stack size is 0x800 (2048 bytes), but I can use VLA and alloca with 4500. Does it make sense?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/393191?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2022 10:12:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f43d9031-ab19-4850-8f54-20c78b748bff</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;There is this&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/5daa9cf885abcec92ebb669c61707a0cdc4d7247/samples/tfm/tfm_secure_peripheral/secure_peripheral_partition/tfm_secure_peripheral_partition.yaml#L14"&gt;line&lt;/a&gt;&amp;nbsp;in the tfm_secure_peripheral_partition.yml which specifies the size of the stack.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/393127?ContentTypeID=1</link><pubDate>Sun, 30 Oct 2022 10:27:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16f67283-bad7-440c-9268-0c80ce5c42d9</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;/p&gt;
&lt;p&gt;As you can see in the following TF-M log, I also get an UsageFault error. The value of UFSR is 0x10.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1667120654709v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I have looked at the meaning of the UFSR fields in the &lt;a href="https://developer.arm.com/documentation/100235/0004/the-cortex-m33-peripherals/system-control-block/configurable-fault-status-register"&gt;ARM documentation&lt;/a&gt;.&amp;nbsp;The hexadecimal value 0x10 is equivalent to bit 2 with value 1. According to the ARM documentation, this is an error with name STKOF: &lt;em&gt;&amp;quot;Stack overflow flag. Sticky flag indicating whether a stack overflow error has occurred&amp;quot;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;As I guessed, it seems that there is not enough size in the safe partition stack to run this function.&amp;nbsp;The following&amp;nbsp;&lt;a href="https://github.com/supranational/blst/issues/82"&gt;issue&lt;/a&gt; from the blst repo reports a failure with the same function. In the end, it concludes that it was a stack size problem. It worked for him by allocating more than 20 kB. Do I have a way to see the available stack size or increase it, for the execution of the functions in the secure partition?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/393063?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 14:09:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91670728-05bd-4393-a70f-c70317cdc6ea</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;From my TF-M log, UsageFault Status Register (UFSR) has the value 0x10. You can check various fields of UFSR in the&amp;nbsp;&lt;a href="https://developer.arm.com/documentation/100235/0004/the-cortex-m33-peripherals/system-control-block/configurable-fault-status-register"&gt;ARM documentation&lt;/a&gt;. &amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/392057?ContentTypeID=1</link><pubDate>Mon, 24 Oct 2022 08:46:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b954e80-aa12-467d-bff1-9520e9448755</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;I have reproduced your board resetting issue. Using the same approach as have been suggested to you in your other&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/92866/using-a-failed-malloc-inside-my-secure-partition-tf-m-reboots-the-board-instead-of-returning-an-error"&gt;case&lt;/a&gt;, I have got FATAL ERROR: UsageFault. It seems that the problem occurs when jumping to non-secure code with jump_to_ns_code(). I have reported the issue internally.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/390236?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2022 10:49:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a8485c2-1d7c-409b-962f-8c435db541d4</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;/p&gt;
&lt;p&gt;I have updated the repo. Can you clone the repo again, do the build and launch the application please? I just tried cloning it and I can reproduce the problem, as you can see below (it restarts the application).&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1665485276780v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/390226?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2022 10:24:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e409c42-e53a-47a9-8650-47dc0f244e44</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;I have tested again with the same setup using your main branch (with 2 lines that you mentioned uncommented) and got the same result as before. I could not observe board resets.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/390104?ContentTypeID=1</link><pubDate>Mon, 10 Oct 2022 20:13:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:348b7389-d158-4444-b118-caf1c17bbc78</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Hi again, Dejans,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;As you can see in the repo, I have put back the function that causes the reboot, so you can reproduce the error again.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Also, I&amp;#39;ve added a function to give me an idea of how much space is available in memory.&amp;nbsp;It is not the most accurate method to obtain the available memory, but it is useful to get an estimate. &lt;/span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint32_t GetFreeMemorySize()
{
  uint32_t  i;
  uint32_t  len;
  uint8_t*  ptr;
 
  for(i=1;;i++)
  {
    len = i * 1024;
    ptr = (uint8_t*)malloc(len);
    if(!ptr){
      break;
    }
    free(ptr);
  }
 
  return i;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;I execute this function just before the signature, the function that causes the reboot.&amp;nbsp;This is what I get at the output, doing a debug with the &amp;quot;Enable debug options&amp;quot; option enabled:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;img style="max-height:180px;max-width:424px;" height="180" src="https://devzone.nordicsemi.com/resized-image/__size/848x360/__key/communityserver-discussions-components-files/4/pastedimage1665431890929v1.png" width="424" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;I thought it would be a good idea to compare it with the result of the original project, &lt;a href="https://github.com/decentralizedsecurity/bls-hsm"&gt;bls-hsm&lt;/a&gt;, which uses SPM for secure-partition and NCS 1.8.0. This is what I get at the output, doing a debug with the &amp;quot;Enable debug options&amp;quot; option enabled:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;img style="max-height:530px;max-width:419px;" height="530" src="https://devzone.nordicsemi.com/resized-image/__size/838x1060/__key/communityserver-discussions-components-files/4/pastedimage1665432367862v2.png" width="419" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;The difference in available space is significant: it is approximately 5.6 times larger for the original version, using SPM (NCS 1.8.0), compared to the new version, using TF-M (NCS 2.0.0).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;I don&amp;#39;t know if the error might be related to that, but I thought this might be of interest.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:inherit;"&gt;Pablo&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/390091?ContentTypeID=1</link><pubDate>Mon, 10 Oct 2022 16:07:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:191c1e06-bc02-4830-a211-eedcb8af0f6b</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Hi Dejans,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;It is normal that you could not reproduce the error. In one of the last commits, by mistake, I commented the program line that caused the board to reboot.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;In order to reproduce the error, lines 53 and 54 (shown below), must not be commented. This allows you to reproduce the error, which you were able to test at the time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;char msg[] = &amp;quot;5656565656565656565656565656565656565656565656565656565656565656&amp;quot;;
signature(pk, msg, buffer);	&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;This change must be made in the mycli/src/main.c file. You can try to remove the comment to those two lines and launch the application. As soon as I can, I will put it back in the repository, so you can reproduce the error directly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;I also use my computer with Windows 10. The use of the virtual machine was for the purpose of obtaining the TF-M logs.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:inherit;"&gt;Pablo&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/390000?ContentTypeID=1</link><pubDate>Mon, 10 Oct 2022 11:50:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:184355d7-a7c7-4580-8989-cec225764cea</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;Thank you for the logs. I have tested your sample (from main) using NCS v2.0.0, nRF5340-DK and Windows 10, but I could not reproduce your issue. I didn&amp;#39;t get any board resets. You could try using system without virtual machine.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/389542?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2022 08:11:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b1039e6-fbba-4aeb-97df-4a30a2cdb744</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;/p&gt;
&lt;p&gt;I have connected pins P0.25 and P0.26 to a USB-to-serial converter and managed to get the TF-M log. Here are the logs obtained from TF-M and the application output:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Without &amp;quot;enable debug options&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;Application output&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:192px;max-width:472px;" height="192" src="https://devzone.nordicsemi.com/resized-image/__size/944x384/__key/communityserver-discussions-components-files/4/pastedimage1665042345464v1.png" width="472" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;TF-M log&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:95px;max-width:475px;" height="95" src="https://devzone.nordicsemi.com/resized-image/__size/950x190/__key/communityserver-discussions-components-files/4/pastedimage1665042379074v2.png" width="475" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;With &amp;quot;enable debug options&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;Application output&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:187px;max-width:471px;" height="187" src="https://devzone.nordicsemi.com/resized-image/__size/942x374/__key/communityserver-discussions-components-files/4/pastedimage1665042563851v4.png" width="471" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;TF-M log&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:94px;max-width:470px;" height="94" src="https://devzone.nordicsemi.com/resized-image/__size/940x188/__key/communityserver-discussions-components-files/4/pastedimage1665042506581v3.png" width="470" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;It seems to be no difference whether the &amp;quot;enable debug configuration&amp;quot; option is enabled or not. I would like to remind you that the board restarts automatically when the error occurs. This is the reason why you see the same thing 3 times in each log image.&lt;/p&gt;
&lt;p&gt;I have not been able to observe any log of the application, from the non-secure partition. My understanding was that I should see it in VCOM1 in VS Code. I have also tried using PuTTY, and got nothing. I also tried with VCOM0, but nothing happened. VCOM2 is the application output.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:125px;max-width:194px;" height="125" src="https://devzone.nordicsemi.com/resized-image/__size/388x250/__key/communityserver-discussions-components-files/4/pastedimage1665043699015v5.png" width="194" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I thought that, maybe, there was nothing to show this log. Therefore, I tried adding the following configuration:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_LOG_PRINTK=y&lt;/pre&gt;&lt;br /&gt;This should dump the printk messages from my code to the log. However, I still couldn&amp;#39;t manage to see those messages in the log.&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Note&lt;/span&gt;: I get the TF-M log output from a linux virtual machine, as I was having problems with my USB-to-serial converter drivers. So I tried to look at the application&amp;#39;s log from there, but I didn&amp;#39;t get any result either.&lt;/p&gt;
&lt;p&gt;I will keep trying to get the application log. If I succeed, I will post it on the forum. Meanwhile, this is all I have.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/388978?ContentTypeID=1</link><pubDate>Mon, 03 Oct 2022 11:52:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:258fa279-45ba-4f73-947b-e28ec54b74f1</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Pablo,&lt;br /&gt;&lt;br /&gt;The first log is ordinary UART application log. If&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_logging.html#uart"&gt;UART logging&lt;/a&gt; is enabled in your application, you could use any terminal emulation program to see the log as shown in&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_testing.html"&gt;testing and debugging application&lt;/a&gt;. To see application log, you would need to connect to COM port corresponding to the application (VCOM1 in VS Code).&lt;br /&gt;&lt;br /&gt;As mentioned before, documentation explains&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/ug_tfm.html#logging"&gt;TF-M logging&lt;/a&gt;. I&amp;#39;ll provide more details here. If you want to see TF-M log, you would need to take log from UART1. If you have 2 nRF5340-DKs (v2.0.0), you could connect them together to get required logs. First, flash the project to the first DK (DK-A) and recover the second board (DK-B). Connect pins P0.25 and P0.26 on DK-A to pins P1.00 (RXD) and P1.01 (TXD) on DK-B.&amp;nbsp;Using terminal emulation program, connect to the COM ports on both devices. One of the COM ports (VCOM1 in VS Code) on the DK-A will show the application log and one of the COM ports (VCOM0 in VS Code) on DK-B will show the TF-M log. &lt;br /&gt;&lt;br /&gt;In case that you have only one nRF5340-DK board, you could connect USB to serial converter cable directly to the DK-A using pins P0.25 and P0.26. You would then have 2 COM ports and 1 USB port open. You could then connect to the second VCOM port (VCOM1) shown in VS Code to see application log and to the COM port which corresponds to UART Serial port to see TF-M log.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/388873?ContentTypeID=1</link><pubDate>Sun, 02 Oct 2022 10:43:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9bdbd2c-e81e-4ee3-8eec-7507b2b5dc51</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have removed the warnings that appeared when making the build.&amp;nbsp;The problem has not been solved.&lt;/p&gt;
&lt;p&gt;I have made a build&amp;nbsp;with and without the &amp;quot;Enable debug option&amp;quot; and another one with it enabled.&amp;nbsp;In order to enable the &amp;quot;Enable debug options&amp;quot; option, I had to increase the TF-M size. It is 0x50000 without enabling the option and 0x60000 by enabling the option. This can be checked in the prj.conf file.&lt;/p&gt;
&lt;p&gt;Again, I show what you get when you run the following command&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;west build -t partition_manager_report&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Build &lt;span style="text-decoration:underline;"&gt;without&amp;nbsp;debug options enabled&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1664706269804v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Build &lt;span style="text-decoration:underline;"&gt;with debug options enabled&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1664706503792v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;It is not clear to me which logs you need, so I would be grateful if you could specify which ones you need if they are not the ones I have given you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/388489?ContentTypeID=1</link><pubDate>Thu, 29 Sep 2022 08:37:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dedcd3d6-9629-404f-b74d-11fe804fa68d</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I have tested your sample from non_secure branch and it was successful. I also tested your sample from the main branch and it still gives many warnings during the build process. Could you please remove the warnings from main branch?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;TF-M uses 2 UART interfaces for logging, one for secure part (TF-M and MCUboot) and one for the application. Documentation provides more information about&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_logging.html#uart"&gt;logging&lt;/a&gt;. With regard to&amp;nbsp;secure logging, you can refer to the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_tfm.html#logging"&gt;TF-M logging section&lt;/a&gt;.&lt;br /&gt;&lt;span&gt;Could you send both application and TF-M output logs with and without &amp;quot;Enable debug options&amp;quot;?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Dejan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/388424?ContentTypeID=1</link><pubDate>Wed, 28 Sep 2022 17:39:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cfbfb43-1032-427b-beb4-011ecbe3eeec</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I build for nrf5340dk_nrf5340_cpuapp_ns.&amp;nbsp;My build configuration doesn&amp;#39;t include &amp;#39;Enable debug options&amp;#39;. Should I enable that?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/388418?ContentTypeID=1</link><pubDate>Wed, 28 Sep 2022 17:05:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e93a9c49-e073-4fff-ac81-c524de389580</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;For which board did you build your sample?&lt;br /&gt;&lt;br /&gt;Did your build configuration include &amp;quot;Enable debug options&amp;quot;?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/388120?ContentTypeID=1</link><pubDate>Tue, 27 Sep 2022 11:45:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23ca030f-5995-4cea-8a81-c159526cfc95</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have a couple of updates about the project.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First of all, I have fixed some warnings that appear when doing the build. As I expected,&amp;nbsp;this&amp;nbsp;didn&amp;#39;t solve the problem, but it&amp;#39;s good to get rid of them.&lt;/p&gt;
&lt;p&gt;Secondly, I have added to the repository a branch called &amp;quot;non_secure&amp;quot;, in which I have imported the static library and run the functions in the non-secure partition. The function that gives me problems in tf-m works correctly in non secure partition. To make it work, I have added the following configuration to prj.conf, to allocate spare memory to the main stack:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_MAIN_STACK_SIZE=104080&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Although I am not using the tf-m functions in this branch, I have not removed it from the configuration.&lt;/p&gt;
&lt;p&gt;When building, the following memory usage data is displayed:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1664279000467v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;In case it is useful, this is the log obtained when executing the command:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;west build -t partition_manager_report&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1664278878632v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/387882?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2022 11:25:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41f28c30-94b0-4fcf-a4a7-6a2f610bff70</guid><dc:creator>Pablosanserr</dc:creator><description>&lt;p&gt;I narrowed down the problem by doing a step-by-step debug. I found that it is in that line of code that the board reboot occurs.&lt;/p&gt;
&lt;p&gt;As for the warnings I get when doing the build, they don&amp;#39;t seem to be related to the problem. I will still try to fix them&lt;/p&gt;
&lt;p&gt;Executing the following command inside bls-hsm-2/mycli, i get this log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;west build -t partition_manager_report&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1664190866227v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The reboot of the board made me think that it might be a RAM problem. To do so, I set the value of the RAM assigned to the safe partition to an extremely high value, by writing the following in prj.conf:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PM_PARTITION_SIZE_TFM_SRAM=0x63000&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This did not solve the problem.&amp;nbsp;&lt;/span&gt;Running the same command, having added this configuration inside prj.conf to the build gives the following log:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1664191327991v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Are them the logs you need?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pablo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Board reboots when a function is executed in TF-M</title><link>https://devzone.nordicsemi.com/thread/387722?ContentTypeID=1</link><pubDate>Fri, 23 Sep 2022 15:05:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e2163f8-2d52-4559-ab45-6798b07a7402</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I have looked into your project. I noticed that there are many warnings during build process. I would suggest you to go through these warnings and try to fix them. &lt;span&gt;There seems to be a problem with your project that would need to be investigated further.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Could you provide more information on how you narrowed down the problem to the&amp;nbsp;&lt;span&gt;blst_sign_pk_in_g1 function from&amp;nbsp;lib/bls_hsm.h?&lt;br /&gt;&lt;br /&gt;It would be beneficial if you could provide some logs. Could you show application log and secure partition log?&lt;br /&gt;&lt;br /&gt;Have you seen any hard fault errors?&lt;br /&gt;&lt;br /&gt;Bes regards,&lt;br /&gt;Dejan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>