<?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>MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80844/mcuboot-s-secondary-image-on-external-flash-down-into-the-rabbit-hole-and-back</link><description>I struggled to host MCUBoot&amp;#39;s secondary image on the external Flash of the nRF5340DK. I hit so many obstacles along the way that I&amp;#39;m pretty sure I went off track early on and didn&amp;#39;t do this properly. First I followed these guidelines and added a device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Nov 2022 12:41:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80844/mcuboot-s-secondary-image-on-external-flash-down-into-the-rabbit-hole-and-back" /><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/394909?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2022 12:41:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4ed8225-a088-4348-a644-fccb609e592c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will continue in the new thread that you created.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/394809?ContentTypeID=1</link><pubDate>Tue, 08 Nov 2022 20:58:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebed887d-764d-4721-916d-dd32df3ebcbc</guid><dc:creator>ayuzva</dc:creator><description>&lt;p&gt;After merging my device tree (custom board) and the overlay file. I am no longer getting the abovementioned restarts. So it seems I was not passing the device tree overlay to the mcuboot correctly. However, now I am getting &amp;quot;Remote error: No Entry (5)&amp;quot; when I try to upload an image in the nRF Connect Device Manager. This cooresponds to &amp;quot;&lt;span&gt;MGMT_ERR_ENOENT&amp;quot; of mcumgr.&lt;/span&gt;&amp;nbsp;This code is returned from img_mgmt_read_info().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;have opened a thread on this issue:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/93696/dfu-over-ble-mcuboot-external-flash-qspi-mgmt_err_enoent"&gt;devzone.nordicsemi.com/.../dfu-over-ble-mcuboot-external-flash-qspi-mgmt_err_enoent&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/394782?ContentTypeID=1</link><pubDate>Tue, 08 Nov 2022 16:30:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc0eb041-87d3-4906-9f9b-8a6ce2db6ae7</guid><dc:creator>ayuzva</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/hkn"&gt;Håkon Alseth&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am having a similar use case (but over BLE) and similar issues. Whenever I start a transfer from nRF Connect Device Manager the target microcontroller immediately restarts. I can confirm that the restart is getting triggered from os_mgmt by SMP. I can also confirm that OTA works just with internal flash.&lt;/p&gt;
&lt;p&gt;Unlike the original poster, I am not getting to the point of writing the boot magic number. I am working with nRF52840 SoC and&amp;nbsp;AT25QL641 QSPI Flash chip. I am on v2.1.0 of nRF Connect SDK.&lt;/p&gt;
&lt;p&gt;I have already fixed the &amp;quot;partition_manager.cmake&amp;quot; per your comment here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/91180/nrf9160dk-fota-using-external-flash-ncs-2-0-2/394765"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/91180/nrf9160dk-fota-using-external-flash-ncs-2-0-2/394765&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the&amp;nbsp;device tree I have:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
    chosen {
            nordic,pm-ext-flash = &amp;amp;at25ql641;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In child_image/mcuboot.conf I have:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=n
CONFIG_FLASH=y
CONFIG_NRFX_QSPI=y
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In my partitions.yml I made sure that primary and secondary partitions have the same size:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcuboot_primary:
  address: 0xc000
  end_address: 0x100000
  orig_span: &amp;amp;id001
  - app
  - mcuboot_pad
  region: flash_primary
  size: 0xf4000
  span: *id001
mcuboot_primary_app:
  address: 0xc200
  end_address: 0x100000
  orig_span: &amp;amp;id002
  - app
  region: flash_primary
  size: 0xf3e00
  span: *id002
mcuboot_secondary:
  address: 0x0
  device: /soc/qspi@40029000/at25ql641@0
  end_address: 0xf4000
  placement:
    align:
      start: 0x4
  region: external_flash
  share_size:
  - mcuboot_primary
  size: 0xf4000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I also noticed that providing &amp;quot;size-in-bytes&amp;quot; parameter to the QSPI driver causes Partition Manager to fail at compilation, but providing &amp;quot;size&amp;quot; parameter works.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will try to provide more information as I continue to test. Thank you.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/335215?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 08:05:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a0c08ce-512c-4817-9b7d-9329c0ed0803</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="lodup29"]&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;I confirm that :&amp;nbsp;&lt;/p&gt;[/quote][quote user="lodup29"]does the trick.[/quote]
&lt;p&gt;Thank you for coming back to us, that is great to hear! I will still follow up internally on improving documentation and configuration around these settings.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hope you have a wonderful day!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/335139?ContentTypeID=1</link><pubDate>Wed, 20 Oct 2021 15:11:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5761906-1fd6-4681-ba00-2aab2116103b</guid><dc:creator>Louis</dc:creator><description>&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;I confirm that :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;does the trick.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/335135?ContentTypeID=1</link><pubDate>Wed, 20 Oct 2021 14:59:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e82614bf-75e9-446d-8b7e-bf3e770b0ec8</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;My deepest apologies for my mixup, I seemed to have copied the wrong config.&lt;/p&gt;
&lt;p&gt;The one I copied is for when using SPIM, not QSPI. The correct one shall then be:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/335106?ContentTypeID=1</link><pubDate>Wed, 20 Oct 2021 12:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1d57c19-3e64-4d14-a740-415cbb0875cd</guid><dc:creator>Louis</dc:creator><description>&lt;p&gt;Indeed. It didn&amp;#39;t work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/335103?ContentTypeID=1</link><pubDate>Wed, 20 Oct 2021 12:45:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab223965-70de-454a-84f4-19db7e5cde20</guid><dc:creator>Louis</dc:creator><description>&lt;p&gt;I&amp;#39;ll give that a try but I&amp;#39;m pretty sure it won&amp;#39;t work. The decision to call&amp;nbsp;write_from_nvmc is made at the level of the Flash driver. Unless&amp;nbsp;&lt;span&gt;write_from_nvmc actually succeeded thanks to that.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot’s secondary image on external Flash : Down into the rabbit hole and back</title><link>https://devzone.nordicsemi.com/thread/335099?ContentTypeID=1</link><pubDate>Wed, 20 Oct 2021 12:35:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c8d57a4-6c65-4c49-9e44-85c8e28d9319</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry to hear that the process was this demanding! I will surely report this internally.&lt;/p&gt;
[quote user=""]For there, things went smoothly up until the point where &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/13efbe937b52e75fdb8a66e088a0f2c71f127054/subsys/dfu/dfu_target/src/dfu_target_mcuboot.c#L178"&gt;boot_request_upgrade&lt;/a&gt; is called (either directly or from DFU API). I dug a little deeper and found that it fails attempting to &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/master/boot/bootutil/src/bootutil_public.c#L316"&gt;write the boot magic number&lt;/a&gt;. Unlike the chunks of firmware updates, the magic number is not hosted in RAM, but in the internal Flash program memory (variable defined as const) and &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/flash/nrf_qspi_nor.c#L1049"&gt;write_from_nvmc&lt;/a&gt; instead of &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/flash/nrf_qspi_nor.c#L1051"&gt;nrfx_qspi_write&lt;/a&gt; is called. Quite frankly I didn&amp;#39;t bother to check why, but &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/flash/nrf_qspi_nor.c#L977"&gt;write_from_nvmc&lt;/a&gt; returns an error that translates to EINVAL (Invalid argument). I just went ahead and changed &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/master/boot/bootutil/src/bootutil_public.c#L316"&gt;MCUBoot&lt;/a&gt; to :[/quote]
&lt;p&gt;Looking at the sequence, and your description of the problem, it seems that it is unable to write the external flash (secondary slot) magic tags.&lt;/p&gt;
&lt;p&gt;As a alternative test, could you try setting this in mcuboot.conf and see if it works w/o changing boot_write_magic() then?&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the setting for child_image/mcuboot.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SPI_NRFX_RAM_BUFFER_SIZE=16&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>