<?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>Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111186/cannot-confirm-image-after-swapping-from-external-secondary-mcuboot-partition</link><description>Hello, 
 I have an nrf52833 that interfaces with an external flash module. It is configured to store mcuboot&amp;#39;s secondary partition. I am able to write the secondary image and after it swaps, it does boot into this image correctly, but I am not able to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Jun 2024 07:44:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111186/cannot-confirm-image-after-swapping-from-external-secondary-mcuboot-partition" /><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/491228?ContentTypeID=1</link><pubDate>Fri, 28 Jun 2024 07:44:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08e1e2ce-7f2f-4599-b9e5-3e4c8b10fe03</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user="Joanna"]I have the exact same problem on nRF53833 with external flash. Can you explain in a little detail how you got it to work?[/quote]
&lt;p&gt;If removing the project does not resolve the issue for you, then please feel free to create a new case with some more information about the errors you&amp;#39;re seeing.&amp;nbsp;&lt;/p&gt;
[quote user="alexdr5398"]&lt;p&gt;Kind of any unsatisfying resolution, but I eventually solved it by delete my project and initializing it from the manifest file again.&lt;/p&gt;
&lt;p&gt;I must have made an unintentional change while looking through the zephyr or nrf source files that caused this issue.&lt;/p&gt;[/quote]
&lt;p&gt;I reread the solution now as I had a new look at the case and I must say I agree with your sentiment about it being an unsatisfying resolution, heh.. But anyways I&amp;#39;m glad that it worked out&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/491132?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2024 13:23:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3159e76c-aa9f-46de-95aa-6fddfb00432e</guid><dc:creator>alexdr5398</dc:creator><description>&lt;p&gt;Hi, &lt;br /&gt;&lt;br /&gt;I simply deleted the entire project and pulled everything again from the manifest repo. I must have accidentally edited some zephyr source files at some point without realizing and cloning the repo fresh again cleared those changes. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/491114?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2024 12:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3241b18-c874-4050-83bd-189bf101de55</guid><dc:creator>Joanna</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have the exact same problem on nRF53833 with external flash. Can you explain in a little detail how you got it to work?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/485502?ContentTypeID=1</link><pubDate>Wed, 22 May 2024 19:10:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68ef9a80-eae9-48e1-b335-90a8d990dcd3</guid><dc:creator>alexdr5398</dc:creator><description>&lt;p&gt;Kind of any unsatisfying resolution, but I eventually solved it by delete my project and initializing it from the manifest file again.&lt;/p&gt;
&lt;p&gt;I must have made an unintentional change while looking through the zephyr or nrf source files that caused this issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/484829?ContentTypeID=1</link><pubDate>Fri, 17 May 2024 15:10:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a32f1d95-e86a-4c72-a1f6-83af1987ad10</guid><dc:creator>alexdr5398</dc:creator><description>&lt;p&gt;There is nothing in our firmware that could be setting the flag after it boots into the new image. The only dfu target or mcuboot api calls after it boots into the new image are simply checking if the image is confirmed and reading the swap type. &lt;/p&gt;
&lt;p&gt;I have also tried using `boot_request_upgrade(BOOT_UPGRADE_PERMANENT)` rather than `boot_request_upgrade(BOOT_UPGRADE_TEST)` and the image still does not get confirmed and will revert upon the next reset.&lt;/p&gt;
&lt;p&gt;I have also noticed that after an OTA update was attempted, subsequent `west flash` will also result in an image that is not confirmed. `west flash --recover` will fix it and result in image that is confirmed with a swap time of `none`&lt;/p&gt;
&lt;p&gt;It seems to me like there are issues with our custom flash drivers? Since I know this API does work on other projects with an external flash chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/484683?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 12:20:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74086ba4-2932-4b1c-807f-b74abd3bb271</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="alexdr5398"]Which sample are you referring to that has that partition map? That might be a good reference to see how dynamic partitioning works with the external flash.[/quote]
&lt;p&gt;The sample is a generic BLE SMP sample using SPI over BLE that you can find here&amp;nbsp;&lt;a href="https://github.com/aHaugl/samples_for_NCS/tree/main/bootloader/SPI_samples/smp_ble_feat_spi"&gt;https://github.com/aHaugl/samples_for_NCS/tree/main/bootloader/SPI_samples/smp_ble_feat_spi&lt;/a&gt;&amp;nbsp;(disclaimer: this is an unofficial sample that I&amp;#39;ve made, so it is not tested similarly to the official SDK samples)&lt;/p&gt;
[quote user="alexdr5398"]The flash region for mcuboot is being overflowed because the dynamic partitioner chose 48K for the mcuboot partition, but that is too small I believe because we need to compile in our drivers for the external flash chip.[/quote]
&lt;p&gt;Ah, then I understand the reason for why the MCUboot partition size is set larger than our default 48kB selected by the dynamic partitioner.&lt;/p&gt;
[quote user=""]I am using the&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/dfu/dfu_target.html"&gt; dfu target api&lt;/a&gt; for the firmware image and the &lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__mcuboot__api.html"&gt;mcuboot image control api&lt;/a&gt; to confirm the image. The function ` boot_write_img_confirmed` returns 0 which supposedly means that it was successful, however reading the `mcuboot_swap_type` function still returns `revert` and the next time the chip is reset, it reverts to the old image.[/quote]
&lt;p&gt;From what I can see from the API documentation&amp;nbsp;you refer to I agree.&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__mcuboot__api.html#ga95ccc9e1c7460fec16b9ce9ac8ad7a72"&gt;boot_write_img_confirmed&lt;/a&gt;&amp;nbsp;returning 0 should mark the image as &amp;quot;good to go&amp;quot; after the upgrade, leading me to believe that there is something in the DFU-target that reverts the image. Are you able to track down where and when the REVERT flag gets set into mcuboot_swap_type?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/483570?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 16:59:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e577f64-2b43-425d-8ab8-23f544c6e310</guid><dc:creator>alexdr5398</dc:creator><description>&lt;p&gt;Hi Andreas,&lt;/p&gt;
&lt;p&gt;I increased the size of the mcuboot partition to 56K and it was able to create the dynamic partition and compile successfully. Unfortunately, that did not solve the issue. There are exactly the same symptoms as before. It boots into the new image, but cannot confirm it.&lt;/p&gt;
&lt;p&gt;Here is what the new partition looks like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  external_flash (0x80000 - 512kB):
+------------------------------------------+
| 0x0: mcuboot_secondary (0x72000 - 456kB) |
| 0x72000: external_flash (0xe000 - 56kB)  |
+------------------------------------------+

  flash_primary (0x80000 - 512kB):
+-------------------------------------------------+
| 0x0: mcuboot (0xe000 - 56kB)                    |
+---0xe000: mcuboot_primary (0x72000 - 456kB)-----+
| 0xe000: mcuboot_pad (0x200 - 512B)              |
+---0xe200: mcuboot_primary_app (0x71e00 - 455kB)-+
| 0xe200: app (0x71e00 - 455kB)                   |
+-------------------------------------------------+

  sram_primary (0x20000 - 128kB):
+--------------------------------------------+
| 0x20000000: sram_primary (0x20000 - 128kB) |
+--------------------------------------------+&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and the pm_static.yml:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;app:
  address: 0xe200
  end_address: 0x80000
  region: flash_primary
  size: 0x7e100
external_flash:
  address: 0x72000
  end_address: 0x80000
  region: external_flash
  size: 0xe000
mcuboot:
  address: 0x0
  end_address: 0xe000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0xe000
mcuboot_pad:
  address: 0xe000
  end_address: 0xe200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0xe000
  end_address: 0x80000
  orig_span: &amp;amp;id001
  - mcuboot_pad
  - app
  region: flash_primary
  size: 0x72000
  span: *id001
mcuboot_primary_app:
  address: 0xe200
  end_address: 0x80000
  orig_span: &amp;amp;id002
  - app
  region: flash_primary
  size: 0x71e00
  span: *id002
mcuboot_secondary:
  address: 0x0
  device: DT_CHOSEN(nordic_pm_ext_flash)
  end_address: 0x72000
  placement:
    align:
      start: 0x4
  region: external_flash
  share_size:
  - mcuboot_primary
  size: 0x72000
sram_primary:
  address: 0x20000000
  end_address: 0x20020000
  region: sram_primary
  size: 0x20000
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/483543?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 14:16:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61da223b-6980-4254-9db0-1706e443b2f9</guid><dc:creator>alexdr5398</dc:creator><description>&lt;p&gt;Actually it does look like the external flash is being detected using dynamic partitioning. The flash region for mcuboot is being overflowed because the dynamic partitioner chose 48K for the mcuboot partition, but that is too small I believe because we need to compile in our drivers for the external flash chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/483518?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 13:32:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98cd1922-7165-4648-94d0-32e349ecc7ba</guid><dc:creator>alexdr5398</dc:creator><description>&lt;p&gt;Hello, Thanks for the quick reply.&lt;/p&gt;
&lt;p&gt;Using dynamic partitioning is a good suggestion. When I switch to it (by removing `pm_static.yml`) the application no longer compiles because the flash region is overrun. It looks like it&amp;#39;s no longer using the external flash chip. Unfortunately, I&amp;#39;m not the one who original set up this project, so I&amp;#39;m not totally familiar with how the external flash is set up. I know we had to write custom zephyr drivers for it though.&lt;/p&gt;
&lt;p&gt;Which sample are you referring to that has that partition map? That might be a good reference to see how dynamic partitioning works with the external flash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot confirm image after swapping from external secondary mcuboot partition</title><link>https://devzone.nordicsemi.com/thread/483488?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 11:55:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2598fd57-a0a4-4b9e-8925-65bd8a779bea</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I believe that what&amp;#39;s causing the issue is an incorrect static partitioning map. In your case both MCUboot_secondary and external flash starts at 0x0 in your case, while from the sample below it is defined differently: Do note that the sample uses dynamic partitioning and is set up for the nRF52840, but similarly you could set this up for the nRF52833 (albeit with only 512kB of flash).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  external_flash (0x800000 - 8192kB):
+---------------------------------------------+
| 0x0: mcuboot_secondary (0xf0000 - 960kB)    |
| 0xf0000: external_flash (0x710000 - 7232kB) |
+---------------------------------------------+

  flash_primary (0x100000 - 1024kB):
+--------------------------------------------------+
| 0x0: mcuboot (0x10000 - 64kB)                    |
+---0x10000: mcuboot_primary (0xf0000 - 960kB)-----+
| 0x10000: mcuboot_pad (0x200 - 512B)              |
+---0x10200: mcuboot_primary_app (0xefe00 - 959kB)-+
| 0x10200: app (0xefe00 - 959kB)                   |
+--------------------------------------------------+

  sram_primary (0x40000 - 256kB):
+--------------------------------------------+
| 0x20000000: sram_primary (0x40000 - 256kB) |
+--------------------------------------------+&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In general what I typically do (and recommend to customers) is to develop everything with a dynamic partitioning (up until where you need to do static) and, then copy the generated dynamic partition into their static partition and tweak where you need.&lt;/p&gt;
&lt;p&gt;I do also note that you MCUBoot bootloader slot is 72kB, which is quite large (default in our samples is 48kB, and you can get minimal configurations down to 21kB), so in case you wish to do other optimizations w.r.t flash I recommend you to have a look at&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/test_and_optimize/optimizing/index.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/test_and_optimize/optimizing/index.html&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/matter/end_product/bootloader.html#mcuboot_minimal_configuration"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/matter/end_product/bootloader.html#mcuboot_minimal_configuration&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let me know if resolving the static partition map fixes the issue&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>