<?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>Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90585/writing-image-to-slot1-partition-causes-a-hard-fault-for-firmware-update</link><description>I&amp;#39;m using VS Code on a Windows 10 machine to develop a product that will use an over the air device firmware update. I have my system setup with static memory partitions. I can get the data to the device, but as soon as I go to write the data to the partition</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Aug 2022 07:21:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90585/writing-image-to-slot1-partition-causes-a-hard-fault-for-firmware-update" /><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/380040?ContentTypeID=1</link><pubDate>Thu, 04 Aug 2022 07:21:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f82dd5d-e2eb-4902-bce9-e16dc7c4f5c5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I&amp;#39;m glad to hear that it works now, thanks for the update. If you encounter a similar problem in the future, I would suggest you try the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/services/debugging/thread-analyzer.html#thread-analyzer"&gt;Thread analyzer&lt;/a&gt;. It will periodically print the stack usage for all threads.&lt;/p&gt;
&lt;p&gt;Config settings to enable thread analyzer:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_AUTO=y
CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
CONFIG_THREAD_NAME=y&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379968?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2022 15:12:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6f376e4-5c3e-4f11-adbe-e3391c1256eb</guid><dc:creator>Ryjan</dc:creator><description>&lt;p&gt;Ok, that is making sense to me. I do think that it&amp;#39;s fixed now. I increased the same thread that I had before a little more, by about 40 bytes and the log message finally spit out a message about a stack overflow. I doubled the stack size and now the function call to &amp;quot;&lt;span style="color:#dcdcaa;" data-darkreader-inline-color=""&gt;flash_img_buffered_write&lt;/span&gt;&amp;quot; long longer fails. &lt;span style="color:#dcdcaa;" data-darkreader-inline-color=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Since this was a project I was handed with no familiarity with Zephyr, but was tasked with getting some DFU running the main task (always_run, in this case) was not large enough to handle the receive buffer I made for the DFU data. So this makes sense, it was just difficult to find the cause since the thread was so undersized that it would not spit out a log message. It would skip the log message running Ozone or the RTT viewer just the same.&lt;/p&gt;
&lt;p&gt;Thank you, Vidar!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379966?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2022 14:59:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9112da2b-88b5-4a1f-af9a-d9e4edc26aa1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I suspect it&amp;#39;s a stack overflow because the MSTKERR bit is set and that MMFAR contains a RAM address.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Don&amp;#39;t you get a crash log at all? Is it also the same if you run the program without Ozone (looks like ozone is halting the cpu when the exception is raised which may prevent the crash log from being printed)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379965?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2022 14:50:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d65ee2fd-1e35-4e99-be39-c5d4a3bb0292</guid><dc:creator>Ryjan</dc:creator><description>&lt;p&gt;When you say that this looks more like a stack overflow, what do you see that makes you think that? Is is because of the RAM address? I had a stack overflow last week and the log message spit our some good information so I was able to fix the thread size. With this I see no data. I turned the suggested option on, but I saw no difference in the terminal output. Right now I&amp;#39;m reading through the link you included about MPU-assisted stack overflow protection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379963?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2022 14:30:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c286a985-af26-4a28-8e0c-2ddf76f0fc24</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming. This looks more a stack overflow (&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/arch/arm_cortex_m.html#mpu-assisted-stack-overflow-detection"&gt;MPU-assisted stack overflow detection&lt;/a&gt;). Do you have logging enabled so you can get the crash log from error handler? With &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_THREAD_NAME"&gt;CONFIG_THREAD_NAME=y&lt;/a&gt; it should tell you in which thread the stack overflow occurred.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379945?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2022 13:49:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6629e879-60d8-4cf9-b93e-ac316e2c2a9b</guid><dc:creator>Ryjan</dc:creator><description>&lt;p&gt;First, I will confirm that I am not using mcumgr protocol for BLE. I was not aware of that system, so that will prove valuable for some future projects. This project, however needs to be compatible with our old system. It is using our own proprietary protocol to be legacy compatible with older products.&lt;/p&gt;
&lt;p&gt;I checked the MMFAR register and it shows 0x20007538 as the stored value. That looks like a location in ram rather than a location in flash. It&amp;#39;s not that same address as the one I see calculated in code for the write. In the steam structure in the flash_ctx structure I get the correct offset of 0x00044000, but that&amp;#39;s not the same as the MMFAR register. I has assumed that the address in the MMFAR was the location of the instruction that was causing the crash.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve included a screenshot of the crash in Ozone:&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/hf_5F00_dfu_5D00_.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379885?ContentTypeID=1</link><pubDate>Wed, 03 Aug 2022 11:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7705f34-eed5-4e72-a28e-da84ae359949</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Could you check the MMFAR address as well to see if it is indeed in the slot 1 memory range? Also, can you please confirm whether you are using the mcumgr protocol to transfer the image over BLE or not (i.e if you are using the same approach as covered in this tutorial &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu"&gt;Add DFU support to your applicationn&lt;/a&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379756?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 14:57:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c537e701-ffae-44c1-88d3-9ec86466e662</guid><dc:creator>Ryjan</dc:creator><description>&lt;p&gt;Ok, I spoke too soon. I had to also add CONFIG_MCUMGR=y since CONFIG_MCUMGR_CMD_IMG_MGMT=y requires it. After that the compile system seems happy. Before VSCode was just underlining it and saying it would be changed to &amp;quot;=n&amp;quot;. I added &lt;pre class="ui-code" data-mode="c_cpp"&gt;CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to the prj.conf and it compiles fine. I checked the build folder .config file and &amp;quot;&lt;span style="color:#9cdcfe;" data-darkreader-inline-color=""&gt;CONFIG_MPU_ALLOW_FLASH_WRITE&lt;/span&gt;&lt;span style="color:#d4d4d4;" data-darkreader-inline-color=""&gt;=y&lt;/span&gt;&amp;quot; still appears, but I still get the same MPU hard-fault.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379747?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 14:12:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e181b49e-8ce0-4c62-b049-7bea27d28876</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Could you please post your build log which shows the error when CONFIG_MCUMGR_CMD_IMG_MGMT is enabled? Also, are you doing DFU over a proprietary protocol since you have work directly with the mcumgr flash functions?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379744?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 14:05:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:227c47c0-d922-4cda-b6d7-e09bec490251</guid><dc:creator>Ryjan</dc:creator><description>&lt;p&gt;I checked and found &amp;quot;CONFIG_MPU_ALLOW_FLASH_WRITE=y&amp;quot; in the build config, but I then checked for &amp;quot;CONFIG_MCUMGR_CMD_IMG_MGMT &amp;quot; in my prj.config and found that I had commented it out. When I try to add it, VSCode claims that the in the build it&amp;#39;s set to &amp;quot;n&amp;quot;. It is very hard to trace and find out why, but I assume it is a Kconfig rule set somewhere else that is in conflict with another. Still &amp;quot;CONFIG_MPU_ALLOW_FLASH_WRITE&amp;quot; is set in the build file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing image to Slot1 partition causes a hard-fault for firmware update</title><link>https://devzone.nordicsemi.com/thread/379727?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 13:18:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e56f5789-3c2f-44a3-84ce-866093fff98f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Please confirm if your build includes &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/kconfig/index.html#CONFIG_MPU_ALLOW_FLASH_WRITE"&gt;CONFIG_MPU_ALLOW_FLASH_WRITE&lt;/a&gt;=y (you can check this in the .config file located in &amp;lt;build folder&amp;gt;/zephyr/). If this is not enabled, then you will get a fault exception you like you described. Although, this setting should have been selected already if you have enabled the flash APIs through the CONFIG_MCUMGR_CMD_IMG_MGMT config setting.&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></channel></rss>