<?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 you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm</link><description>11 months ago in an answer a nordic member wrote (in regards to an error that I now also had and could solve using CONFIG_DEBUG=y): 
[quote userid=&amp;quot;81283&amp;quot; url=&amp;quot;~/f/nordic-q-a/101643/undefined-reference-to-end-with-nrf-connect-sdk-v2-4-0/435542&amp;quot;] I looked</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Jun 2024 13:37:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm" /><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489546?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2024 13:37:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac934219-dddf-4ba7-af59-9616d06a2a66</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="gdl"]It does print out the #warning &amp;quot;AAAAAAAAAAA&amp;quot; when changing the following file, so maybe thats the right [/quote]
&lt;p&gt;Then, I guess this is the file that is being defaulted to if no other file is used.&lt;/p&gt;
&lt;p&gt;As you probably see that this is a bit of new territory for us as well.&lt;br /&gt;But know that our TF-M devs are getting info from this ticket, so we will hopefully get a better way to do this stuff at a later point in time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489515?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2024 12:42:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8a50019-3cf8-4781-96ca-f240860aa504</guid><dc:creator>gdl</dc:creator><description>[quote userid="106736" url="~/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm/489406"]Yep, I think so.&lt;br /&gt;The default sram partitioning looks like this, so I guess you will have enough here that you dont need to increase that.[/quote]
&lt;p&gt;Great Many thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm/489406"]I have not used this before, but.&lt;br /&gt;When I look it up, it looks like it is passed with cmake and not Kconfig.&lt;br /&gt;For example &lt;a href="https://github.com/Z3Prover/z3/issues/990"&gt;https://github.com/Z3Prover/z3/issues/990&lt;/a&gt;: &lt;br /&gt;&amp;quot;cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ..&amp;quot;[/quote]
&lt;p&gt;I will look into it further. I seem to get an error when using it with the default size-optimized building, but the speed-optimized one probably works.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm/489406"]Can i suggest that you temporarily put #warning &amp;quot;AAAAAAAAAAA&amp;quot; inside each of the SRAM defines in those files to see which one is being used with the 9161?[/quote]
&lt;p&gt;It doesn&amp;#39;t seem to use one of the two partition_defs.h inside the common-directory as nothing seems to be displayed when pressing build&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/usern/ncs/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/nrf91/partition/region_defs.h&lt;/pre&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/usern/ncs/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It does print out the #warning &amp;quot;AAAAAAAAAAA&amp;quot; when changing the following file, so maybe thats the right &lt;pre class="ui-code" data-mode="text"&gt;one /home/usern/ncs/nrf/modules/trusted-firmware-m/tfm_boards/partition/region_defs.h&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489406?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2024 06:47:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39530fd7-3947-41f6-971f-134313c1de37</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="gdl"]How/With which command do i activate RelWithDebInfo?&lt;br /&gt;Do i need to pass it differently?[/quote]
&lt;p&gt;I have not used this before, but.&lt;br /&gt;When I look it up, it looks like it is passed with cmake and not Kconfig.&lt;br /&gt;For example &lt;a href="https://github.com/Z3Prover/z3/issues/990"&gt;https://github.com/Z3Prover/z3/issues/990&lt;/a&gt;: &lt;br /&gt;&amp;quot;cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ..&amp;quot;&lt;/p&gt;
[quote user="gdl"]And how do i increase the sram-size? Just by setting a higher number in this line in the same file you linked or is something more needed?[/quote]
&lt;p&gt;Yep, I think so.&lt;br /&gt;The default sram partitioning looks like this, so I guess you will have enough here that you dont need to increase that.&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;  sram_primary (0x40000 - 256kB): 
+--------------------------------------------------+
+---0x20000000: mcuboot_sram (0x8000 - 32kB)-------+
+---0x20000000: sram_secure (0x8000 - 32kB)--------+
| 0x20000000: tfm_sram (0x8000 - 32kB)             |
+---0x20008000: sram_nonsecure (0x38000 - 224kB)---+
+---0x20008000: nrf_modem_lib_sram (0x4568 - 17kB)-+
| 0x20008000: nrf_modem_lib_ctrl (0x4e8 - 1kB)     |
| 0x200084e8: nrf_modem_lib_tx (0x2080 - 8kB)      |
| 0x2000a568: nrf_modem_lib_rx (0x2000 - 8kB)      |
+--------------------------------------------------+
| 0x2000c568: sram_primary (0x33a98 - 206kB)       |
+--------------------------------------------------+
&lt;/pre&gt;&lt;/p&gt;
[quote user="gdl"]There is also no direct &amp;quot;equivalent&amp;quot; folder for my device (nrf9161), inside the directory &lt;br /&gt;(/home/usern/ncs/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/) only the following folders exist:&lt;br /&gt;-core&lt;br /&gt;-nrf91&lt;br /&gt;-nrf5340&lt;br /&gt;-nrf9120&lt;br /&gt;-nrf9160[/quote]
&lt;p&gt;Good point.&lt;br /&gt;Can i suggest that you temporarily put #warning &amp;quot;AAAAAAAAAAA&amp;quot; inside each of the SRAM defines in those files to see which one is being used with the 9161?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489359?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2024 15:46:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d6ea6d8-014b-4d35-8e20-618b5b28fbdc</guid><dc:creator>gdl</dc:creator><description>&lt;p&gt;Hey&lt;br /&gt;thanks for your reply&lt;br /&gt;&lt;br /&gt;Regarding RelWithDebInfo:&lt;br /&gt;I commented-out &amp;quot;CONFIG_DEBUG=y&amp;quot; and instead tried adding one of the following lines (each tested separately) to my prj.conf:&lt;br /&gt;CONFIG_relwithdebinfo =y&lt;br /&gt;relwithdebinfo =y&lt;br /&gt;CONFIG_RelWithDebInfo =y&lt;br /&gt;CONFIG_REL_WITH_DEB_INFO =y&lt;/p&gt;
&lt;p&gt;The full prj.conf then reads:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

CONFIG_BUILD_WITH_TFM=y
CONFIG_TFM_PROFILE_TYPE_NOT_SET=y
CONFIG_TFM_CONNECTION_BASED_SERVICE_API=y
CONFIG_TFM_PARTITION_CRYPTO=n
#CONFIG_DEBUG=Y
CONFIG_relwithdebinfo=y

CONFIG_TFM_SECURE_UART=y
CONFIG_TFM_SECURE_UART1=y&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However they each led to the same undefined symbol error, so i couldn&amp;#39;t build the program (while setting CONFIG_DEBUG=y works):&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/usern/vscodeprojects/tfm_secure_partition_modified/prj.conf:12: warning: attempt to assign the value &amp;#39;y&amp;#39; to the undefined symbol relwithdebinfo

error: Aborting due to Kconfig warnings&lt;/pre&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/usern/vscodeprojects/tfm_secure_partition_modified/prj.conf:12: warning: attempt to assign the value &amp;#39;y&amp;#39; to the undefined symbol relwithdebinfo

error: Aborting due to Kconfig warnings&lt;/pre&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/usern/vscodeprojects/tfm_secure_partition_modified/prj.conf:12: warning: attempt to assign the value &amp;#39;y&amp;#39; to the undefined symbol RelWithDebInfo

error: Aborting due to Kconfig warnings&lt;/pre&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/usern/vscodeprojects/tfm_secure_partition_modified/prj.conf:12: warning: attempt to assign the value &amp;#39;y&amp;#39; to the undefined symbol REL_WITH_DEB_INFO

error: Aborting due to Kconfig warnings&lt;/pre&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;        $&amp;lt;$&amp;lt;OR:$&amp;lt;CONFIG:Debug&amp;gt;,$&amp;lt;CONFIG:relwithdebinfo&amp;gt;&amp;gt;:ENABLE_HEAP&amp;gt;&lt;/pre&gt;&lt;br /&gt;How/With which command do i activate RelWithDebInfo?&lt;br /&gt;Do i need to pass it differently?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding the heap:&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/112129/can-you-use-the-heap-in-custom-secure-partitions-in-tfm/489343"]For heap size, you should be able to increase it &lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/0fa3c2a105a9c737643594bed2fef6dca11049f7/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h#L26"&gt;here&lt;/a&gt;, or equivalent for different boards.&lt;br /&gt;Just make sure to size up the partitioning of sram as well when doing that.[/quote]
&lt;p&gt;Ok thanks a lot.&lt;br /&gt;Is there still a limit on the heap size?&lt;/p&gt;
&lt;p&gt;And how do i increase the sram-size? Just by setting a higher number in this line in the same file you linked or is something more needed?&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define SPU_SRAM_REGION_SIZE    (0x00002000)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is also no direct &amp;quot;equivalent&amp;quot; folder for my device (nrf9161), inside the directory &lt;br /&gt;(/home/usern/ncs/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/) only the following folders exist:&lt;br /&gt;-core&lt;br /&gt;-nrf91&lt;br /&gt;-nrf5340&lt;br /&gt;-nrf9120&lt;br /&gt;-nrf9160&lt;br /&gt;&lt;br /&gt;Should i just edit the region_defs file within core and snrf91(/home/usern/ncs/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/nrf91/partition/region_defs.h)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489343?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2024 14:22:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c0ef2b8-623c-4acf-ad8d-dcef6614892c</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;So far this is what I got:&lt;/p&gt;
&lt;p&gt;Here is how the HEAP is enabled:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/0fa3c2a105a9c737643594bed2fef6dca11049f7/platform/CMakeLists.txt#L352"&gt;https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/0fa3c2a105a9c737643594bed2fef6dca11049f7/platform/CMakeLists.txt#L352&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;So you must use either DEBUG or relwithdebinfo (&lt;span&gt;&lt;span dir="ltr"&gt;release build with dwarf debug info enabled&lt;/span&gt;&lt;/span&gt;) to get the C heap.&lt;/p&gt;
[quote user="gdl"]And currently the programm only compiles with &amp;quot;CONFIG_DEBUG=y&amp;quot; in the prj.conf (as described in starting post). Does setting &amp;quot;CONFIG_DEBUG=y&amp;quot; impact performance or cause security issues?[/quote]
&lt;p&gt;We do not have full insight into CONFIG_DEBUG, or how it will change in the future, so unfortunally I am unable to promise anything in regards to this question now.&lt;/p&gt;
&lt;p&gt;Since debug configuration is not generally intended for releases, it could have some impacts, unfortunately.&lt;br /&gt;The one thing I know for sure will be impacted is that the program will take more space.&lt;/p&gt;
&lt;p&gt;I suggest that you try RelWithDebInfo and see if that works, as it seems to be a middle ground between release and debug builds.&lt;/p&gt;
&lt;p&gt;For heap size, you should be able to increase it &lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/0fa3c2a105a9c737643594bed2fef6dca11049f7/platform/ext/target/nordic_nrf/common/nrf5340/partition/region_defs.h#L26"&gt;here&lt;/a&gt;, or equivalent for different boards.&lt;br /&gt;Just make sure to size up the partitioning of sram as well when doing that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489210?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2024 08:13:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f98c7bf3-0b48-4411-b81b-ed9cba50b2bb</guid><dc:creator>gdl</dc:creator><description>&lt;p&gt;It&amp;#39;s a C programm running in its own secure partition that stores some data permanently on the heap (corresponding roughly to what objects and their members are in object-oriented langs) and also uses the heap to generate data and return it to the caller. The external user in the non-secure world can call roughly a dozen functions the programm offers to the outside through an interface. The individual data can be relatively large, e.g. several hundred bytes or in more rare cases &amp;gt;1000 bytes. The entire heap is ofc larger than that.&lt;br /&gt;&lt;br /&gt;Would setting the &amp;quot;heap_size&amp;quot;-attribute in the manifest change the heap-size itself?&lt;br /&gt;&lt;br /&gt;(Rewriting the application itself (instead of the secure partition configuration) would be complicated as it&amp;#39;s already finished and to be used in various different tasks (not just on a microcontroller), however would be interested in it anyway if that&amp;#39;s the suggested solution.)&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Edit: And currently the programm only compiles with &amp;quot;CONFIG_DEBUG=y&amp;quot; in the prj.conf (as described in starting post). Does setting &amp;quot;CONFIG_DEBUG=y&amp;quot; impact performance or cause security issues?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489183?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2024 06:41:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fe28c72-ca25-4636-a5db-820f599e37f3</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;The answer is that this is still a bit complicated.&lt;br /&gt;I can explain to you what you would have to do to use the heap.&lt;/p&gt;
&lt;p&gt;Could you explain a bit what you need the heap for in TF-M, so I can better guide you?&lt;/p&gt;
&lt;p&gt;Alternatively: Maybe it is easier to avoid using the heap in TF-M and solve your issue in another way instead. Worth thinking about.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489122?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 13:30:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6907931-11f9-42ef-9599-f9a5e8cbcc87</guid><dc:creator>gdl</dc:creator><description>&lt;p&gt;OK thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can you use the heap in custom secure partitions in TFM?</title><link>https://devzone.nordicsemi.com/thread/489120?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 13:21:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:875c92e6-0353-4e36-841b-c084e96a16e7</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Im will ask&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>