<?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>Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79130/fault-when-reading-magic-from-image-header</link><description>Hi, 
 I am trying to send some information from the application image (e.g. header, TLVs, etc.) through a SPI channel. 
 The problem is that whenever I try to copy the header information of the application from Flash to a buffer in RAM I always get a</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Sep 2021 13:21:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79130/fault-when-reading-magic-from-image-header" /><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327988?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 13:21:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7237c24-c0c3-4815-9ae5-28272bbf28ca</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;Thanks for confirming that it worked for you as well! I forgot to add that the memory layout is controlled by &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html"&gt;Partition Manager&lt;/a&gt; when its enabled (always enabeld for multi-image builds), and not by the paritions defined in DTS.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327984?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 13:10:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1da92a16-e6d7-49d6-bbf9-1177f8061993</guid><dc:creator>uhrm</dc:creator><description>&lt;p&gt;Hey Vidar,&lt;/p&gt;
&lt;p&gt;That did the trick, I confirm that I can now read the header of the image when I have both the mcuboot and spm enabled.&lt;/p&gt;
&lt;p&gt;Thanks for the help!&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327976?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 12:44:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a9aec16-14e5-4562-8d28-537e5fc0ac9f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve discussed this case with a colleague now. Turns out you need to use the SPMs &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/secure_services.html#secure-services"&gt;secure services&lt;/a&gt; to get read access to the MCUBoot pad area when SPM is enabled. I quickly verified that it worked here with this code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;secure_services.h&amp;quot;

void main(void)	
{
	uint32_t mcuboot_magic;

	int err = spm_request_read(&amp;amp;mcuboot_magic, 0x10000, sizeof(mcuboot_magic));
	if (err) {
		printk(&amp;quot;Failed to read from MCUBoot pad area at 0x10000 (err %d)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;MCUBoot magic word %x\n&amp;quot;, mcuboot_magic);
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327800?ContentTypeID=1</link><pubDate>Thu, 02 Sep 2021 12:41:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dcbe5189-03db-4a57-a51e-a79b5f12db60</guid><dc:creator>uhrm</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;As a test I disabled mcuboot, and the resulting layout is below.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1630585700715v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Everything got shifted to lower memory addresses due not having the mcuboot, but the application is still located in the secure partition starting at 0x10000 even though (as mentioned in an earlier post) it is specified to go to the non secure partition.&lt;/p&gt;
&lt;p&gt;I am able to read the flash at 0x10000 without getting the fault, but now I don&amp;#39;t have the mcuboot to handle the firmware updates.&lt;/p&gt;
&lt;p&gt;So my question is, what is the dependency between having the mcuboot enabled and reading out of flash from the secure area? In both cases the SPM is enabled.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327664?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 15:31:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a8e1d6b-665d-49d5-9b93-7f096963e740</guid><dc:creator>uhrm</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Per your question, looking at the MAP files and memory of the device, here is what I have:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp;Image&amp;nbsp;header @ 0x10000 (512 bytes total: 32 header bytes + padding bytes)&lt;/p&gt;
&lt;p&gt;2. SPM code @ 0x10200&lt;/p&gt;
&lt;p&gt;3. Application &amp;#39;code @ 0x20200&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thoughts?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327659?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 14:57:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:378d8ed7-3783-4384-9f9e-d2c0f8af053f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;Sorry, I didn&amp;#39;t notice the discrepancy between DTS and what was printed by the partition manager, I just assumed they would be the same. Could you check if you have anything at 0x20000? Based on the partition manager and *.map output, the NS app is starting 0x20200.&lt;/p&gt;
&lt;p&gt;I will find out why the DTS and Partition manager don&amp;#39;t operate with the same addresses in the meantime.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327656?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 14:30:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a9eacf3-f03f-449e-a1a3-02e936580e4a</guid><dc:creator>uhrm</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;See the layout in my project below, which looks similar&amp;nbsp;to the one you sent:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1630505272744v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding the secure and non-secure partitions, in the DTS they are currently as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;partitions {
						compatible = &amp;quot;fixed-partitions&amp;quot;;
						#address-cells = &amp;lt; 0x1 &amp;gt;;
						#size-cells = &amp;lt; 0x1 &amp;gt;;
						boot_partition: partition@0 {
							label = &amp;quot;mcuboot&amp;quot;;
							reg = &amp;lt; 0x0 0x10000 &amp;gt;;
						};
						slot0_partition: partition@10000 {
							label = &amp;quot;image-0&amp;quot;;
							reg = &amp;lt; 0x10000 0x40000 &amp;gt;;
						};
						slot0_ns_partition: partition@50000 {
							label = &amp;quot;image-0-nonsecure&amp;quot;;
							reg = &amp;lt; 0x50000 0x30000 &amp;gt;;
						};
						slot1_partition: partition@80000 {
							label = &amp;quot;image-1&amp;quot;;
							reg = &amp;lt; 0x80000 0x40000 &amp;gt;;
						};
						slot1_ns_partition: partition@c0000 {
							label = &amp;quot;image-1-nonsecure&amp;quot;;
							reg = &amp;lt; 0xc0000 0x30000 &amp;gt;;
						};
						scratch_partition: partition@f0000 {
							label = &amp;quot;image-scratch&amp;quot;;
							reg = &amp;lt; 0xf0000 0xa000 &amp;gt;;
						};
						storage_partition: partition@fa000 {
							label = &amp;quot;storage&amp;quot;;
							reg = &amp;lt; 0xfa000 0x6000 &amp;gt;;
						};
					};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From looking into memory, I don&amp;#39;t have anything in the non secure&amp;nbsp;partition at 0x50000,&amp;nbsp;but I do in the secure one at 0x10000. Not sure why this is happening because the board file I use specifies the code to be in the non-secure partition:&lt;/p&gt;
&lt;p&gt;&lt;span&gt; &lt;/span&gt;zephyr,code-partition = &amp;amp;slot0_ns_partition;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thoughts?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327639?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 13:31:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1d85235-0d63-44a2-a904-93e29a4f2978</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Peter, &lt;/p&gt;
&lt;p&gt;Yes I was wondering if you built the app as non-secure. I think you may be attempting to read from the mcu pad area for the &lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.6.1/nrf/samples/spm/README.html"&gt;SPM&lt;/a&gt; which runs in the Trust Zone secure domain.&lt;/p&gt;
&lt;p&gt;Here is a screenshot I took from VS code with the new &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/nrf-connect-for-visual-studio-code-preview"&gt;nRF connect plug-in&lt;/a&gt; to illustrate what the typical memory layout may look like:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1630502982997v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Notice that the main non-secure application starts after the SPM at 0x50000.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327632?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 13:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06621a2c-920e-4a6b-b380-ccc26fa399ed</guid><dc:creator>uhrm</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;I am using a non-secure board for the 9160, but we do have the mcuboot enabled and the application is signed. Is this what you refer about the secure domain?&lt;/p&gt;
&lt;p&gt;All I want to do is to read the header and some of the TLV information from the application, so I can send it to a master SPI peripheral which will compare it to a locally stored 9160 image and determine if an update is needed.&lt;/p&gt;
&lt;p&gt;If I can&amp;#39;t read the header and TLV information from the 9160, what options do I have to accomplish this?&lt;/p&gt;
&lt;p&gt;In the meantime I will check about the debug log as well.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327619?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 12:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7579b39-c0c1-4b12-9ad2-53cbee9500b3</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Is there a chance that the source pointer may be pointing to the secure domain? Do you have any debug logs from the device? I think the crashlog might provide some more clues. Just make sure you have &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/CONFIG_RESET_ON_FATAL_ERROR.html"&gt;CONFIG_RESET_ON_FATAL_ERROR &lt;/a&gt;set to &amp;#39;n&amp;#39; in your prj.conf file for both SPM and your app to prevent it from entering a boot loop.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fault When Reading Magic From Image Header</title><link>https://devzone.nordicsemi.com/thread/327445?ContentTypeID=1</link><pubDate>Tue, 31 Aug 2021 13:45:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8fa44f1-2f20-4380-b8b7-a78d41ebca32</guid><dc:creator>uhrm</dc:creator><description>&lt;p&gt;Forgot to add, this is happening in an nRF9160. I have tried the same in an nRF5340 and I don&amp;#39;t see the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>