<?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>How to disable default SPM sample and use the customized SPM firmware instead</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81337/how-to-disable-default-spm-sample-and-use-the-customized-spm-firmware-instead</link><description>Hi all, 
 
 I have successfully followed this [tutorial]( https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/using-a-custom-secure-partition-manager-wtih-your-application ) from and created our SPM firmware. However, at the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Nov 2021 13:51:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81337/how-to-disable-default-spm-sample-and-use-the-customized-spm-firmware-instead" /><item><title>RE: How to disable default SPM sample and use the customized SPM firmware instead</title><link>https://devzone.nordicsemi.com/thread/338392?ContentTypeID=1</link><pubDate>Wed, 10 Nov 2021 13:51:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bac9cc9-6ff6-4a1e-b6e0-e3ee00bf96ab</guid><dc:creator>Simon</dc:creator><description>[quote user="duyanh.y4n"]&lt;p&gt;- When I built the custom SPM app (located in /path/to/my/custom_spm_app/), the custom SPM module is loaded and executed in the final firmware.&lt;/p&gt;
&lt;p&gt;- When I built the other app or sample (for example, zephyr/samples/hello_world), the default nrf&amp;#39;s SPM sample is loaded and executed in the final firmware.&lt;/p&gt;[/quote][quote user="duyanh.y4n"]Can you confirm if this behavior is expected with the overall default configurations of NCS? (I haven&amp;#39;t had much experience with multiple image build and the partition manager module yet)[/quote]
&lt;p&gt;This should be the expected result. If you look in the CMakeLists.txt of&amp;nbsp;custom_spm_app\application, the custom SPM will be added as an extra module (which will override the default one). In the default hello world sample, there are no such instructions in the CMakeLists.txt and if you build it with a non-secure board the default SPM will be used.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to disable default SPM sample and use the customized SPM firmware instead</title><link>https://devzone.nordicsemi.com/thread/337857?ContentTypeID=1</link><pubDate>Mon, 08 Nov 2021 09:47:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:041362c2-53ec-4f13-a17d-00d79cfefd3f</guid><dc:creator>duyanh.y4n</dc:creator><description>&lt;p&gt;Thanks, Simon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the approach you suggested is ok, still, we don&amp;#39;t want to fork anything, because we don&amp;#39;t want to spend too much time managing the dependencies ourselves.&lt;/p&gt;
&lt;p&gt;So in the end, I&amp;#39;ve tried the custom SPM build as the above guide with some output printing tests. I&amp;#39;ve added, for example, &amp;quot;Hello SPM samples&amp;quot; to the nrf&amp;#39;s sample (in &amp;lt;workspace&amp;gt;/nrf/samples/spm/src/main.c) like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// nrf/samples/spm/main.c

#include &amp;lt;spm.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;


void main(void)
{
    printk(&amp;quot;Hello from SPM sample\n&amp;quot;);
	spm_config();
	spm_jump();
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On the other hand, I&amp;#39;ve modified my custom SPM source with the same code (but with a different print message) like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// /path/to/my/custom_spm_app/spm_module/zephyr/spm/src/main.c
#include &amp;lt;spm.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;

void main(void)
{
    printk(&amp;quot;Hello secure firmware\n&amp;quot;);
	spm_config();
	spm_jump();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Custom app project tree:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;workspace&amp;gt;
└── custom_spm_app
    ├── application
    │&amp;#160;&amp;#160; ├── prj.conf
    │&amp;#160;&amp;#160; └── src
    │&amp;#160;&amp;#160;     └── main.c
    └── spm_module
            ├── CMakeLists.txt
            ├── module.yml
            └── spm
                ├── boards
                │&amp;#160;&amp;#160; └── nrf9160dk_nrf9160.conf
                ├── CMakeLists.txt
                ├── nrf9160dk_nrf9160.overlay
                ├── pm.yml
                ├── prj.conf
                ├── README.rst
                ├── sample.yaml
                └── src
                    └── main.c
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So the results are as follows:&lt;/p&gt;
&lt;p&gt;- When I built the custom SPM app (located in /path/to/my/custom_spm_app/), the custom SPM module is loaded and executed in the final firmware.&lt;/p&gt;
&lt;p&gt;- When I built the other app or sample (for example, zephyr/samples/hello_world), the default nrf&amp;#39;s SPM sample is loaded and executed in the final firmware.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, in conclusion, these SPM images are not loaded together (according to my initial question above). In fact, the default SPM was overwritten with the custom SPM module, and I guess it was because that they both have the same child image name (defined in CMakeLists), and the customize SPM module is configured on the application top level.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# in path/to/custom_spm_app/spm_module/zephyr/CMakeLists.txt
if(CONFIG_SPM)
set(spm_CONFIG_SPM_SECURE_SERVICES ${CONFIG_SPM_SECURE_SERVICES})
add_child_image_from_source(
&amp;#160; NAME spm
&amp;#160; SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/spm
&amp;#160; )
endif()

# in nrf/samples/CMakeLists.txt
if(CONFIG_SPM)

# other configs...

set(spm_CONFIG_SPM_SECURE_SERVICES ${CONFIG_SPM_SECURE_SERVICES})
add_child_image_from_source(
&amp;#160; NAME spm
&amp;#160; SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/spm
&amp;#160; )
&amp;#160; 
# other configs...

endif()

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you confirm if this behavior is expected with the overall default configurations of NCS? (I haven&amp;#39;t had much experience with multiple image build and the partition manager module yet)&lt;/p&gt;
&lt;p&gt;If yes, then I think it is good for my use case and I can safely replace the default SPM sample.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to disable default SPM sample and use the customized SPM firmware instead</title><link>https://devzone.nordicsemi.com/thread/337754?ContentTypeID=1</link><pubDate>Fri, 05 Nov 2021 16:10:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0294d9a9-8344-4360-945e-dd3e0ad985a1</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I did answer a similar question some time ago, concerning the mcuboot. Check it out here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/72387/suggestions-for-customizing-ncs-immutable-and-mcuboot-boot-loaders"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/72387/suggestions-for-customizing-ncs-immutable-and-mcuboot-boot-loaders&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Does the suggested solution in that ticket work for you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>