<?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>Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently</link><description>Dear Nordic Team 
 When I run the command `west build -t partition_manager_report` from inside our build folder I get : 
 flash_primary (0x100000 - 1024kB): 
 +--------------------------------------------------+ 
 | 0x0: mcuboot (0xc000 - 48kB) | 
 |</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Feb 2023 13:23:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently" /><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/408875?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 13:23:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e43837a-b96e-48a5-9755-6aa7bdf868ab</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Cla"]tfm:&lt;br /&gt; address: 0x8200&lt;br /&gt; end_address: 0x14200[/quote]
&lt;p&gt;That looks 0x4000 = 16KiB aligned, which is odd.&lt;/p&gt;
[quote user="Cla"]I understand it like that too. My guess was, that it will configure the region that contains both (tfm and app) as secure with a non-secure subregion[/quote]
&lt;p&gt;That could be. It would be a bit confusing if actual secure and non-secure regions were mixed in such a way.&lt;/p&gt;
&lt;p&gt;Can you share the project or the pm_static.yml to achieve your partitioning so I can try it myself?&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/408334?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2023 15:06:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca4e8054-53a9-470b-bae5-7ea2b582e28a</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;In your example yes, but in my example it is way off:&lt;br /&gt;&lt;br /&gt;tfm:&lt;br /&gt; address: 0x8200&lt;br /&gt; end_address: 0x14200&lt;/p&gt;
&lt;p&gt;That lead me to think, that it need not be aligned.&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/407772"]The way I understand this, the secure region still has the same boundaries limited to 32KiB. &lt;br /&gt;And the NSC regions are just a sub-region of the secure region.[/quote]
&lt;p&gt;&lt;br /&gt;I understand it like that too. My guess was, that it will configure the region that contains both (tfm and app) as secure with a non-secure subregion. Lets say like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;32 KiB | secure&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | tfm part 1 (start: 0x8000, end: 0xf000)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;32 KiB | secure&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | tfm part 2 (start: 0x0f000, end: 0x14200)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | app part 1 (non-secure subregion, start: 0x14200, end: 0x18000)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;32 KiB | non-secure | app part 2 (start: 0x18000, end: 0x1f000)&lt;/span&gt;&lt;br /&gt;...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/407772?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2023 12:48:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eda57eee-97ed-4381-a652-c1776dcee7c1</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Cla"]I was wondering, why the end of the `tfm` partition, bordering the `app` did not have to be aligned to `0x8000`.[/quote]
&lt;p&gt;If you take the end -0x200, I think you will get it aligned to 0x8000, right?&lt;br /&gt;If yes, then it is the bug I talked about.&lt;br /&gt;Let me know if you see other numbers.&lt;/p&gt;
[quote user="Cla"]My guess would be, that &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2774%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C291.023%2Cnull%5D"&gt;FLASHNSC[n].REGION&lt;/a&gt; and &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2774%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C98.123%2Cnull%5D"&gt;FLASHNSC[n].SIZE&lt;/a&gt; are use to define the secure-callable and non-secure-callable sub-regions within a region?[/quote]
&lt;p&gt;The Non-Secure callable regions are part of the secure flash.&lt;br /&gt;From &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_1_0#flash_nsc"&gt;Non-secure callable (NSC) region definition in flash&lt;/a&gt;: &lt;br /&gt;A non-secure callable sub-region can only exist within an existing secure region&lt;/p&gt;
&lt;p&gt;The way I understand this, the secure region still has the same boundaries limited to 32KiB. &lt;br /&gt;And the NSC regions are just a sub-region of the secure region.&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/407754?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2023 12:18:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e69ef930-7783-4c99-a58c-8aa9eac1b1fc</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;It is good to hear, that this discussion helped in finding a bug.&lt;br /&gt;&lt;br /&gt;Unfortunately I do not really understand it to 100% yet.&lt;/p&gt;
[quote userid="121943" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/405064"]I was wondering, why the end of the `tfm` partition, bordering the `app` did not have to be aligned to `0x8000`. My guess would be, that &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2774%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C291.023%2Cnull%5D"&gt;FLASHNSC[n].REGION&lt;/a&gt; and &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2774%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C98.123%2Cnull%5D"&gt;FLASHNSC[n].SIZE&lt;/a&gt; are use to define the secure-callable and non-secure-callable sub-regions within a region?[/quote]
&lt;p&gt;My focus is on the internal workings here, just for better understanding. Did I understand this correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/407035?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2023 09:31:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99d9314c-4706-4d41-a656-e50078d61dad</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Our developers agree that the part of the tfm partition that exceeds the secure flash is there because we have forgot to take the padding into account.&lt;/p&gt;
&lt;p&gt;This means it is a bug, and we have created an internal ticket for it.&lt;/p&gt;
&lt;p&gt;Thanks for pointing this out!&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/406696?ContentTypeID=1</link><pubDate>Thu, 26 Jan 2023 14:28:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c88d26e-1ae7-4f7b-918b-f563b1885b12</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;First I was spending a bit of time to understand that you were talking about the last 0x200 part of the tfm partition.&lt;/p&gt;
&lt;p&gt;And now that I understand it, I it looks odd to me, and I think it could even be a bug in the partitioning.&lt;/p&gt;
&lt;p&gt;I think that TF-M does not really care that much about the partitions of zephyr, as it does not really build in the &amp;quot;zephyr way&amp;quot;.&lt;/p&gt;
&lt;p&gt;Either way, I have asked our developers about this.&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/405428?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2023 10:19:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dec6c191-4a86-49d0-90d7-09628d4dcc8c</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Cla"]This is more an understanding question out of interest. The original question can be considered answered.[/quote]
&lt;p&gt;This also helps me get more understanding into this complicated topic, so I am glad to continue answering.&lt;/p&gt;
&lt;p&gt;I might take a bit longer to answer than usual, since the important part of the case is solved, but I will figure this out eventually.&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/405064?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2023 13:51:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7761e3ba-9edd-416c-a1a3-e7972ab7e6b4</guid><dc:creator>Cla</dc:creator><description>[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/405057"]Is this what you were looking for?[/quote]
&lt;p&gt;Not quite. I am sorry, that I did not express myself well.&lt;br /&gt;&lt;br /&gt;I was wondering, why the end of the `tfm` partition, bordering the `app` did not have to be aligned to `0x8000`. My guess would be, that &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2774%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C291.023%2Cnull%5D"&gt;FLASHNSC[n].REGION&lt;/a&gt; and &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2774%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C98.123%2Cnull%5D"&gt;FLASHNSC[n].SIZE&lt;/a&gt; are use to define the secure-callable and non-secure-callable sub-regions within a region?&lt;br /&gt;&lt;br /&gt;This is more an understanding question out of interest. The original question can be considered answered.&lt;br /&gt;Thanks for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/405057?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2023 13:41:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed149f08-58c2-4d8c-a0d5-a78602d89b44</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Cla"]So, just for my understanding, the tfm partition does not have to be aligned to the flash-regions (and can therefore share a region with the `app`), because it makes use of non-secure-callable sub-regions[/quote]
&lt;p&gt;Since we have 2 different regions we talk about here, I am a bit unsure what you ask about.&lt;br /&gt;But I asked our experts the following question:&lt;/p&gt;
&lt;p&gt;&amp;quot;Does the TF-M partition need to be aligned to fit with The SPUs 32 KiB regions?&amp;quot;&lt;/p&gt;
&lt;p&gt;And they answer:&lt;/p&gt;
&lt;p&gt;&amp;quot;The answer is yes.&lt;br /&gt;Or to be more precise. The application needs to start on an SPU aligned 32 / 16 KB region.&lt;br /&gt;So that means if you have bootloaders, that affects it also. As the sum of bootloaders + TF-M sizes is what you need to look at.&amp;quot;&lt;/p&gt;
&lt;p&gt;and&lt;br /&gt;&amp;quot;Correct it needs to be aligned within the locking granularity of &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_1#register.FLASHREGION.PERM"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_1#register.FLASHREGION.PERM &lt;/a&gt;&lt;br /&gt;So that you are ensured that the flash can be set to secure.&lt;br /&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;Is this what you were looking for?&lt;/p&gt;
&lt;p&gt;My example might have misled you some.&lt;br /&gt;When testing it, I had to increase the size of MCUboot by exactly 16KiB as you see.&lt;br /&gt;If I remember correctly, it did not build for smaller increases.&lt;br /&gt;I should have realized this when testing, but oh well. &lt;br /&gt;Good job asking questions about this, it increases both our understanding on the matter.&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404970?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2023 09:26:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7143534e-8c0c-4f63-a339-90f95052937e</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Very good, thanks.&lt;br /&gt;So, just for my understanding, the tfm partition does not have to be aligned to the flash-regions (and can therefore share a region with the `app`), because it makes use of non-secure-callable sub-regions (&lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2810%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C465.123%2Cnull%5D"&gt;https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2810%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C465.123%2Cnull%5D&lt;/a&gt;)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404809?ContentTypeID=1</link><pubDate>Fri, 13 Jan 2023 13:19:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:460382c2-4d7c-48cd-94c6-c3e80d7c77f3</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;To test the placement of the tfm partition, I did the following:&lt;/p&gt;
&lt;p&gt;Use nrf/samples/crypto/aes_cbc, with CONFIG_BOOTLOADER_MCUBOOT=y.&lt;/p&gt;
&lt;p&gt;Now the partition manager report is as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;+-------------------------------------------------+
| 0x0: mcuboot (0xc000 - 48kB)                    |
+---0xc000: mcuboot_primary (0x74000 - 464kB)-----+
+---0xc000: tfm_secure (0x40200 - 256kB)----------+
| 0xc000: mcuboot_pad (0x200 - 512B)              |
+---0xc200: mcuboot_primary_app (0x73e00 - 463kB)-+
| 0xc200: tfm (0x40000 - 256kB)                   |
+---0x4c200: tfm_nonsecure (0x33e00 - 207kB)------+
| 0x4c200: app (0x33e00 - 207kB)                  |
+-------------------------------------------------+
| 0x80000: mcuboot_secondary (0x74000 - 464kB)    |
| 0xf4000: EMPTY_0 (0x4000 - 16kB)                |
+---0xf8000: tfm_storage (0x8000 - 32kB)----------+
| 0xf8000: tfm_its (0x2000 - 8kB)                 |
| 0xfa000: tfm_otp_nv_counters (0x2000 - 8kB)     |
| 0xfc000: tfm_ps (0x4000 - 16kB)                 |
+-------------------------------------------------+

  otp (0x2fc - 764B): 
+------------------------------+
| 0xff8100: otp (0x2fc - 764B) |
+------------------------------+

  sram_primary (0x80000 - 512kB): 
+------------------------------------------------+
+---0x20000000: sram_secure (0x40000 - 256kB)----+
| 0x20000000: tfm_sram (0x40000 - 256kB)         |
+---0x20040000: sram_nonsecure (0x40000 - 256kB)-+
| 0x20040000: sram_primary (0x40000 - 256kB)     |
+------------------------------------------------+

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To move the tfm partition, I increased the size of mcuboot. &lt;br /&gt;Then the tfm partition would have to move to make space.&lt;/p&gt;
&lt;p&gt;I used the following pm_static.yml:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcuboot:
  address: 0x0
  end_address: 0x10000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x10000
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And get the following partition manager report:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;+--------------------------------------------------+
| 0x0: mcuboot (0x10000 - 64kB)                    |
+---0x10000: mcuboot_primary (0x74000 - 464kB)-----+
+---0x10000: tfm_secure (0x40200 - 256kB)----------+
| 0x10000: mcuboot_pad (0x200 - 512B)              |
+---0x10200: mcuboot_primary_app (0x73e00 - 463kB)-+
| 0x10200: tfm (0x40000 - 256kB)                   |
+---0x50200: tfm_nonsecure (0x33e00 - 207kB)-------+
| 0x50200: app (0x33e00 - 207kB)                   |
+--------------------------------------------------+
| 0x84000: mcuboot_secondary (0x74000 - 464kB)     |
+---0xf8000: tfm_storage (0x8000 - 32kB)-----------+
| 0xf8000: tfm_its (0x2000 - 8kB)                  |
| 0xfa000: tfm_otp_nv_counters (0x2000 - 8kB)      |
| 0xfc000: tfm_ps (0x4000 - 16kB)                  |
+--------------------------------------------------+

  otp (0x2fc - 764B): 
+------------------------------+
| 0xff8100: otp (0x2fc - 764B) |
+------------------------------+

  sram_primary (0x80000 - 512kB): 
+------------------------------------------------+
+---0x20000000: sram_secure (0x40000 - 256kB)----+
| 0x20000000: tfm_sram (0x40000 - 256kB)         |
+---0x20040000: sram_nonsecure (0x40000 - 256kB)-+
| 0x20040000: sram_primary (0x40000 - 256kB)     |
+------------------------------------------------+&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Observe that in the first build, tfm starts at 0xc200.&lt;br /&gt;At the second build, tfm starts at 0x10200&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404720?ContentTypeID=1</link><pubDate>Fri, 13 Jan 2023 08:06:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b6681ed-8eb2-4aeb-b2c5-f9ae97958245</guid><dc:creator>Cla</dc:creator><description>[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/404599"]I will try to create a sample to move TF-M partitions to test this tomorrow or Monday.[/quote]
&lt;p&gt;Could it be, that tfm is using sub-regions?&lt;br /&gt;&lt;br /&gt; &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2810%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C465.123%2Cnull%5D"&gt;https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf#%5B%7B%22num%22%3A2810%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C85.039%2C465.123%2Cnull%5D&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;6.15.2.1 Non-secure callable (NSC) region definition in flash&amp;quot;&lt;br /&gt;&lt;br /&gt;I interpret this section to mean, that in each region there can be a &amp;quot;non-secure&amp;quot; and a &amp;quot;secure&amp;quot;-callable sub-region. This might explain, why the tfm-partition does not need to be aligned to the region border?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404601?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 14:56:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bcf5bd2e-6e64-423b-a32a-c4bf4143e180</guid><dc:creator>Cla</dc:creator><description>[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/404599"]I will try to create a sample to move TF-M partitions to test this tomorrow or Monday.[/quote]
&lt;p&gt;Thanks&lt;br /&gt;&lt;br /&gt;And thanks for the quick and detailed answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404599?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 14:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13daa256-6b1a-4b25-8929-f9439d265b60</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Cla"]These are unfortunately not accessible to me. I get a &amp;quot;503 Service unavailable&amp;quot;.[/quote]
&lt;p&gt;Infocenter is now up and running again.&lt;/p&gt;
[quote user="Cla"]Do you know, what the alignment requirements are for the tfm_secure partition? [/quote]
&lt;p&gt;I do not know.&lt;br /&gt;I will try to create a sample to move TF-M partitions to test this tomorrow or Monday.&lt;/p&gt;
[quote user="Cla"]as far as I could see this was closed.[/quote]
&lt;p&gt;I reached out to the guy who closed it and it seems like it was closed due to it being 1 year since it was created.&lt;br /&gt;If you comment the issue it will show that users are interested in this feature, which may speed up its progress.&lt;/p&gt;
[quote user="Cla"]Alternatively, we considered reserving the required amount in the `pm_static`, but I was unsure about what that amount should be (hence my question here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/95633/mcuboot-swap-using-move-how-to-calculate-size"&gt;MCUBoot Swap using move, how to calculate size?&lt;/a&gt;). Now I start to understand, that the block size is 4kB and to be used in that calculation whereas the sectors/partitions are 32KiB to be used for partitioning. Is this correct?[/quote]
&lt;p&gt;I agree yes.&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404595?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 14:30:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6b2ae52-b87e-481a-85aa-1f36e3c3a448</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Thanks for the detailed explanation.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/404585"]The general block size of the flash is 4kB(0x1000), see &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/ficr.html?cp=2_0_0_3_4_0_6#register.INFO.CODEPAGESIZE"&gt;INFO.CODEPAGESIZE in the FICR&lt;/a&gt;.&lt;br /&gt;However, the SPU splits the flash for partitions, and have a size of 32kB(0x8000). See &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_1#flash_access_control"&gt;SPU Flash access control&lt;/a&gt;.[/quote]
&lt;p&gt;These are unfortunately not accessible to me. I get a &amp;quot;503 Service unavailable&amp;quot;.&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/404585"]I do not know of any certain address requirements of tfm. Can you explain a bit further?[/quote]
&lt;p&gt;When I hand edited the `pm_static` I ran into a linker issue with tfm. Even when I did not modify the size of the partition. This was unexpected. Now that I learned more, I guess that it was an alignment issue. Nevertheless: Do you know, what the alignment requirements are for the tfm_secure partition? I would have guessed, that it will need its own 32KiB sector also, but that does not seem to be, what the partition manager puts out.&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/404585"]Yes, and there seems to be a pull request for this as well: &lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/6245"&gt;https://github.com/nrfconnect/sdk-nrf/pull/6245&lt;/a&gt;[/quote]
&lt;p&gt;as far as I could see this was closed.&lt;br /&gt;Alternatively, we considered reserving the required amount in the `pm_static`, but I was unsure about what that amount should be (hence my question here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/95633/mcuboot-swap-using-move-how-to-calculate-size"&gt;MCUBoot Swap using move, how to calculate size?&lt;/a&gt;). Now I start to understand, that the block size is 4kB and to be used in that calculation whereas the sectors/partitions are 32KiB to be used for partitioning. Is this correct?&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/95599/partition-manager-not-using-flash-efficiently/404585"]Good job with searching and finding relevant DevZone cases yourself by the way.[/quote]
&lt;p&gt;Thanks. Maybe I should have searched a bit more &lt;em&gt;before&lt;/em&gt; asking though ;) &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404585?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 14:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49789542-1ccf-418d-801d-76b4dbb5bd25</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;span style="color:rgba(0, 0, 255, 1);"&gt;My main question is, how can the flash layout be optimized (by Hand)? If it cannot, how can partition manager be disable, so that the partitions from the device-tree are used instead?&lt;/span&gt;[/quote]
&lt;p&gt;Yes, static partitioning (pm_static.yml) is the way to optimize partitions &amp;quot;by hand&amp;quot;.&lt;/p&gt;
&lt;p&gt;If you use child images, Partition Manager is included by default, so I think it will be hard to disable it if you want to use MCUboot.&lt;/p&gt;
[quote user=""]&lt;span style="color:rgba(0, 0, 255, 1);"&gt;1. Is this approach to optimize the flash-layout correct?&lt;/span&gt;[/quote]
&lt;p&gt;You have two different ways to configure mcuboot flash usage:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;CONFIG_PM_PARTITION_SIZE_MCUBOOT and CONFIG_PM_PARTITION_SIZE_MCUBOOT_PAD. Ref &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/92406/west-build-generates-large-empty-partitions/389795"&gt;RE: west build generates large EMPTY partitions&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;pm_static.yml&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;MCUboot operates with static partitioning.&lt;br /&gt;Meaning that you can not change partitioning in an DFU update to MCUboot.&lt;/p&gt;
&lt;p&gt;Because of this, I think it is just as well to use pm_static.yml, as you might want static partitions either way.&lt;/p&gt;
[quote user=""]&lt;span style="color:rgba(0, 0, 255, 1);"&gt;2. Is there a reason, that the tfm partition is expected to be located at a certain address?&lt;/span&gt;[/quote]
&lt;p&gt;I do not know of any certain address requirements of tfm. Can you explain a bit further?&lt;/p&gt;
&lt;p&gt;If we imagine an application without a bootloader for a moment: The tfm partition is placed at the beginning of flash to make sure it is the first thing that is executed.&lt;/p&gt;
[quote user="Cla"]On 3. It seems it is for the image header answer found here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64013/partition-manager-primary-and-secondary-slot-sizes"&gt;Partition manager primary and secondary slot sizes&lt;/a&gt; &lt;br /&gt;[/quote]
&lt;p&gt;Yes&lt;/p&gt;
[quote user="Cla"]On 4. I found some helpful infos here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/82781/interpretation-of-the-partition-manager-report"&gt;Interpretation of the partition manager report&lt;/a&gt;&lt;br /&gt;Is the &lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.8.0/lib/fprotect/Kconfig#L46"&gt;CONFIG_NRF_SPU_FLASH_REGION_SIZE&lt;/a&gt;&lt;/span&gt; = 0x8000 in the nRF9160 ?[/quote]
&lt;p&gt;The general block size of the flash is 4kB(0x1000), see &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/ficr.html?cp=2_0_0_3_4_0_6#register.INFO.CODEPAGESIZE"&gt;INFO.CODEPAGESIZE in the FICR&lt;/a&gt;.&lt;br /&gt;However, the SPU splits the flash for partitions, and have a size of 32kB(0x8000). See &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spu.html?cp=2_0_0_5_14_1#flash_access_control"&gt;SPU Flash access control&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Use Kcofig(in VS Code) search to verify what this configuration is set to for your build specifically.&lt;br /&gt;Or &amp;quot;west build -t menuconfig&amp;quot; in the Terminal.&lt;/p&gt;
[quote user="Cla"]&lt;p&gt;On 5. It seems others have also observed:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64013/partition-manager-primary-and-secondary-slot-sizes"&gt;Partition manager primary and secondary slot sizes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/78984/big-primary-image-prevents-fota"&gt;Big primary image prevents FOTA&lt;/a&gt;&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;Yes, and there seems to be a pull request for this as well: &lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/6245"&gt;https://github.com/nrfconnect/sdk-nrf/pull/6245&lt;/a&gt;&lt;/p&gt;
[quote user="Cla"]After investigating a bit, I think I have to update my assumptions. Maybe someone could confirm?&lt;br /&gt;- On the nRF9160 the flash sector size is 0x8000=32KiB. It has a total of 1MiB/32KiB=32 sectors.&lt;br /&gt;- The sectors occupied by mcuboot can not hold anything else. Since the build &amp;gt; 32KiB it takes 2 sectors&lt;br /&gt;- The storages (nvs and tfm) currently takes 1 sector, exactly 32kiB size.&lt;br /&gt;- that leaves 32 - 3 = 29 sectors for the mcuboot primary and secondary partition. They need to be equal size (leaving out the caveat about the move algorithm for now). They also need to be aligned to the flash sectors (if so, why?). That means the sector count has to be even 29-1=28. Each partition needs half of the space 28/2=14. Which is what we see in the above report (14*32KiB = 448KiB).[/quote]
&lt;p&gt;Yes, both I and one of my colleagues agree with your assumptions.&lt;/p&gt;
&lt;p&gt;I hope I answered your questions.&lt;br /&gt;Let me know if I missed some or if you have more.&lt;br /&gt;Good job with searching and finding relevant DevZone cases yourself by the way.&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><item><title>RE: Partition Manager not using flash efficiently</title><link>https://devzone.nordicsemi.com/thread/404498?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 09:23:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:073da5f4-7ccc-499a-b7d2-b327e2f97b96</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Update:&lt;br /&gt;On 4. I found some helpful infos here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/82781/interpretation-of-the-partition-manager-report"&gt;Interpretation of the partition manager report&lt;/a&gt;&lt;br /&gt;Is the &lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.8.0/lib/fprotect/Kconfig#L46"&gt;CONFIG_NRF_SPU_FLASH_REGION_SIZE&lt;/a&gt;&lt;/span&gt; = 0x8000 in the nRF9160 ?&lt;br /&gt;&lt;br /&gt;On 3. It seems it is for the image header answer found here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64013/partition-manager-primary-and-secondary-slot-sizes"&gt;Partition manager primary and secondary slot sizes&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;On 5. It seems others have also observed:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/64013/partition-manager-primary-and-secondary-slot-sizes"&gt;Partition manager primary and secondary slot sizes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/78984/big-primary-image-prevents-fota"&gt;Big primary image prevents FOTA&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regarding the empty partitions also see:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/92406/west-build-generates-large-empty-partitions/389795"&gt;RE: west build generates large EMPTY partitions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After investigating a bit, I think I have to update my assumptions. Maybe someone could confirm?&lt;br /&gt;- On the nRF9160 the flash sector size is 0x8000=32KiB. It has a total of 1MiB/32KiB=32 sectors.&lt;br /&gt;- The sectors occupied by mcuboot can not hold anything else. Since the build &amp;gt; 32KiB it takes 2 sectors&lt;br /&gt;- The storages (nvs and tfm) currently takes 1 sector, exactly 32kiB size.&lt;br /&gt;- that leaves 32 - 3 = 29 sectors for the mcuboot primary and secondary partition. They need to be equal size (leaving out the caveat about the move algorithm for now). They also need to be aligned to the flash sectors (if so, why?). That means the sector count has to be even 29-1=28. Each partition needs half of the space 28/2=14. Which is what we see in the above report (14*32KiB = 448KiB).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>