<?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>DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation</link><description>My project has a nrf5340+external flash, and an external USB-C connector. The device exposes a USB file system (FAT) which is hosted on the external flash partition, and appears as an external disk when connected to a host. This all works well and is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Mar 2025 15:26:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation" /><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/527230?ContentTypeID=1</link><pubDate>Thu, 13 Mar 2025 15:26:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19608bb9-6577-4212-ac31-42547b27d7ce</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Thanks Brian. I have forwarded the request to the team. Will keep you updated.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/527052?ContentTypeID=1</link><pubDate>Wed, 12 Mar 2025 21:43:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:814b140f-50b8-4491-b0a5-35e95b427520</guid><dc:creator>BrianW</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/526963"]Your request is to have multiple image confirm in mcuboot.c and the implementation of the same functionality in dfu_target , correct?&amp;nbsp;[/quote]
&lt;p&gt;Yes, thats right. It would be much more coherent to have the confirmation function the dfu_target module (given dfu_target always does the DFU as &amp;#39;test&amp;#39;, it is required to do the confirmation post DFU)&lt;/p&gt;
&lt;p&gt;Currenrly I can do the multi-image confirm using the mcuboot.c exposed function, but there is NO&amp;nbsp;&lt;em&gt;boot_is_img_confirmed_multi()&lt;/em&gt; function available which&amp;nbsp; would mean it has to be confirmed every boot by the app.. I have dealt with the issue just now by using the existing boot_is_img_confirmed() for&amp;nbsp;image 0 , and the mcuboot_swap_type_multi() function to detect if the other images are confirmed:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;/** check if a specific image is confirmed ok&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp;* This should be a function in mcuboot.c/bootutil_public.c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;static bool _boot_is_img_confirmed_multi(int image_index) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; // Only got a &amp;#39;proper&amp;#39; fn to check for confirmed for image 0, otherwise we use a hack&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; if (image_index==0) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return boot_is_img_confirmed();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; // Check what mcuboot says it would do on next boot - if any action other than NONE then the image is not confirmed&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; return (mcuboot_swap_type_multi(image_index)==BOOT_SWAP_TYPE_NONE);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;But this should be in mcuboot.c and check the swap image ok status properly...&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/526963?ContentTypeID=1</link><pubDate>Wed, 12 Mar 2025 14:00:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0af4b8de-ef20-4e58-ba30-43eefec440d4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;br /&gt;Sorry for the late reply.&amp;nbsp;&lt;br /&gt;Your finding is correct. The slot partition has to be aligned to the page size.&amp;nbsp;I don&amp;#39;t have much insight on MCUBoot (it&amp;#39;s not made by us) but for our bootloader in nRF5 SDK the main reason is for block/page erasing. If it&amp;#39;s not page aligned, it&amp;#39;s&amp;nbsp;more complex to prepare the area for receiving, swapping image.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I agree that the MCUBoot documentation should be improved. It&amp;#39;s sufficient for simple application when user just follow the default setting. But if they want to modify something or optimize the configuration they will have to study the code to find more info.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regarding your request on&amp;nbsp;&lt;em&gt;dfu_target_mcuboot_is_img_confirmed_multi,&lt;span&gt;dfu_target_mcuboot_img_confirm_multi . &lt;/span&gt;&lt;/em&gt;My understanding is that in the current implementation of the dfu_target we don&amp;#39;t handle the confirmation of the image at all. And you have to do image confirmation by usuing mcuboot.c . Your request is to have multiple image confirm in mcuboot.c and the implementation of the same functionality in dfu_target , correct?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/526809?ContentTypeID=1</link><pubDate>Tue, 11 Mar 2025 16:49:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae0f6367-ce6b-4274-9613-9eef47db7469</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;So.... a CRITICAL thing I have discovered, which is not IMHO well documented, is that it is essential that your slot partitions for mcuboot (primary, secondary) are both aligned at their start address on a flash erase sector boundry &lt;strong&gt;AND that their size is ALSO aligned on a erase boundry&lt;/strong&gt; (0x1000=4Kb for my flash device for example).&lt;/p&gt;
&lt;p&gt;The &amp;#39;mcuboot_pad&amp;#39; partition (for the 1st image ie the app) is the one to align on the boundry, not the following &amp;#39;app&amp;#39; partition (so that the &amp;#39;mcuboot_primary&amp;#39; partition ends up on the boundary).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Its the &amp;#39;mcuboot_primary&amp;#39; size that must be aligned, and the &amp;#39;mcuboot_secondary&amp;#39; must be this size, not the app size....&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t align the start&amp;nbsp;of the particion : after a mcuboot swap, the resulting primary image is unreadable for booting (presumably because it couldn&amp;#39;t erase the start sector properly?)&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t align the size of the primary/secondary : the swap procedure fails to clear the mcuboot trailer (because its size is not aligned for erase?), and your 2 slots will flip-flop on reboot....&lt;/p&gt;
&lt;p&gt;When you are trying to use every last byte of the internal flash for your app (eg because the wifi stack is taking up 3/4 of the flash....) then the temptation is to avoid any wasted space... but the alignment needs to be there as the mcuboot code doesn&amp;#39;t cope otherwise....&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s my new pm_static.yml : note the &amp;#39;app&amp;#39; is not an aligned size, but both mcuboot_primary and mcuboot_secondary are...&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcuboot:
    address: 0x0
    end_address: 0x11000
    region: flash_primary
    affiliation: 
        - mcuboot
    size: 0x11000

mcuboot_pad:
    # should be aligned on CONFIG_FPROTECT_BLOCK_SIZE (0x4000 on nrf5340) boundry to allow FPROTECT to be enabled
    # and AT minimum on 0x1000 sector size for erase needs (otherwise DFU (move algo) will NOT WORK)
    address: 0x11000
    end_address: 0x11200
    region: flash_primary
    affiliation: 
        - mcuboot
    size: 0x200

app:
    address: 0x11200
    end_address: 0x100000
    region: flash_primary
    size: 0xeee00

mcuboot_primary_app:
    address: 0x11200
    end_address: 0x100000
    region: flash_primary
    affiliation: 
        - mcuboot
    size: 0xeee00
    span: [app]

mcuboot_primary:
    address: 0x11000
    end_address: 0x100000
    region: flash_primary
    affiliation: 
        - mcuboot
    size: 0xef000
    span: [mcuboot_pad, app]

# define partition for fatfs disk, on the external flash storage (probably the device defined by nordic,pm-ext-flash in the DTS)
fatfs_storage:
    region: external_flash
    affiliation: 
        - disk
    extra_params: {
        disk_name: &amp;quot;NAND&amp;quot;,
        disk_cache_size: 4096,
        disk_sector_size: 512,
        disk_read_only: 0
    }
    # 6Mb size, external flash is 8Mb total
    address: 0x0
    size: 0x600000

nvs_storage:
    region: external_flash
    affiliation: 
        - nvs
    # 64kB size, its just for small stuff
    address: 0x600000
    size: 0x10000

mcuboot_secondary_1:
    region: external_flash
    affiliation: 
        - mcuboot
    # 256kb size, its for netcore flash image
    address: 0x610000
    size: 0x40000

mcuboot_secondary:
    region: external_flash
    affiliation: 
        - mcuboot
    address: 0x650000
    # MUST be same size as the &amp;#39;mcuboot_primary&amp;#39; slot size, and share_size does not appear to work
    size: 0xef000
    #share_size: [mcuboot_primary]

# get next slot to be aligned on 0x4000
PAD1_END:
    region: external_flash
    address: 0x73f000
    size: 0x1000

# allow wifi patches to be updated by mcuboot
nrf70_wifi_fw_mcuboot_pad:
    region: external_flash
    address: 0x740000
    size: 0x200
    #device: MX25R64

nrf70_wifi_fw:
    region: external_flash
    # 128kB size for the wifi fw (-0x200 bytes, the mcuboot pad so that total is aligned on 0x1000 - and 0x4000 - to keep mcuboot happy), 
    address: 0x740200
    size: 0x1fe00

mcuboot_primary_2:
    region: external_flash
    orig_span: &amp;amp;id003
    - nrf70_wifi_fw_mcuboot_pad
    - nrf70_wifi_fw
    span: *id003
    address: 0x740000
    affiliation: 
        - mcuboot
    size: 0x20000
    #device: MX25R64

mcuboot_secondary_2:
    region: external_flash
    address: 0x760000
    affiliation: 
        - mcuboot
    size: 0x20000
    #device: MX25R64

# remaining external flash space starts at 0x78000

# need fake flash ram flash partition to do cpunet DFU...
mcuboot_primary_1:
    region: ram_flash
    address: 0x0
    affiliation: 
        - mcuboot
    size: 0x40000
    device: flash_ctrl
    #  end_address: 0x40000
    #  device: nordic_ram_flash_controller

ram_flash:
  address: 0x40000
  end_address: 0x40000
  region: ram_flash
  size: 0x0

# internal cuisine
#otp:
#    address: 0xff8100
#    end_address: 0xff83fc
#    region: otp
#    size: 0x2fc
#pcd_sram:
#    address: 0x20000000
#    end_address: 0x20002000
#    region: sram_primary
#    size: 0x2000
#rpmsg_nrf53_sram:
#    address: 0x20070000
#    end_address: 0x20080000
#    region: sram_primary
#    size: 0x10000
#sram_primary:
#    address: 0x20002000
#    end_address: 0x20070000
#    region: sram_primary
#    size: 0x6e000

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And with this layout that critically &lt;strong&gt;aligned the size of the mcuboot_secondary on a flash erase boundary&lt;/strong&gt;, the mcuboot &amp;#39;swap-using-move&amp;#39; procedure plus the call to&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;boot_write_img_confirmed_multi&lt;/span&gt;() mean that the image no longer flip flops on each boot!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This should really be in the mcuboot/bootloader doc as its a critical point and not obvious....&lt;/p&gt;
&lt;p&gt;by the way, it would be nice if in the dfu_target subsystem &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;dfu_target_mcuboot.c&lt;/span&gt; provided the required multi-image confirmation functions&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;dfu_target_mcuboot_is_img_confirmed_multi(int img_num)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;dfu_target_mcuboot_img_confirm_multi(int img_num)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/526691?ContentTypeID=1</link><pubDate>Tue, 11 Mar 2025 08:43:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd200071-d4ab-4643-81f1-b353a0c30b00</guid><dc:creator>BrianW</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/507937"]&lt;div&gt;&lt;div&gt;&lt;span&gt;If I confirm the image instead, next boot is like this:&amp;nbsp;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;cursor:zoom-in;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1729858246038v4.png" alt=" " /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span&gt;So it&amp;#39;s very important that the secondary image&amp;#39;s magic should be unset and the primary image_ok is set.&amp;nbsp;&lt;br /&gt;What I noticed in my case is that at the beginning before the first test swap, the primary image&amp;#39;s magic is unset. This is very important. The primary image magic will be come the secondary image magic after the swap (it follows the image). So if at the beginning you already set the primary image magic to set, it may result in what you observed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Having read thru the mcuboot bootutil_public.c&amp;nbsp;boot_swap_type_multi() code, which uses the boot swap tables arrayu to decide what should happen at boot time, I agree that if the secondary magic is GOOD, then it WILL be used to swap (either as test or perm). So, as after the DFU the secondary is the ex-primary, this implies the PRIMARY must have magic=UNSET (means all 0xff for empty flash) before we start DFU.&lt;/p&gt;
&lt;p&gt;If I look at you &amp;#39;post successful DFU&amp;#39; screenshot, I note the primary has magic=GOOD -&amp;gt; so if you do the DFU step again in future, the secondary will end up with good magic, and the DFU will rollback!&lt;/p&gt;
&lt;p&gt;So.... who/where/how should the magic of the current primary be cleared? I would think this could be done when the code confirms that the new DFU target is in place in the secondary slot?&lt;/p&gt;
&lt;p&gt;This is the call that does that&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;dfu_target_mcuboot.c : dfu_target_mcuboot_schedule_update(img_num);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;-&amp;gt; calls&amp;nbsp;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;dfu_target_mcuboot.c : dfu_target_mcuboot_schedule_one_img(img);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;-&amp;gt; calls&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;mcuboot.c : boot_request_upgrade_multi(img_num, BOOT_UPGRADE_TEST);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;-&amp;gt; calls (as BOOT_UPGRADE_TEST=0)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;bootutil_public. : boot_set_pending_multi(img, 0);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;-&amp;gt; calls&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;bootutil_public. :&lt;span&gt;&amp;nbsp;&lt;/span&gt;boot_set_next(&amp;lt;flash area of secondary slot for img&amp;gt;, false, false); -&amp;gt; this is not the active image, and we don&amp;#39;t confirm it&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;In here, if your secondary slot magic is already GOOD, it does... nothing.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;As we have just updated the secondary slot with the new firmware using dfu_target, the magic should be UNSET.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;In this case, it writes the good magic, and leaves image ok as unset (because its not a confirmed ie permanent move). It also writes the &amp;#39;swap_type&amp;#39; in the trailer to TEST based on this flag.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;It does NOT do anything to the primary&amp;#39;s magic slot....&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Do you agree therefore that this will work for a DFU once, but the 2nd time we have the magic=good on the primary and this will cause the flip flop for subsequent cases? Or do I miss something I should do?&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/526633?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 17:59:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50aa68d5-942b-4ccb-a808-19a45b2cd51a</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;So... I come back to this dfu issue after several weeks (months) of having fun migrating to NCS2.9, dealing with sysbuild etc....&lt;/p&gt;
&lt;p&gt;Now, I have 3 image slots, for the app, CPU-NET (its a nrf5340) and the wifi firmware (because the wifi code is so big I needed to push the wifi fw (78kb!) out to my external flash).&lt;/p&gt;
&lt;p&gt;First moan :&amp;nbsp; the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;dfu_target_xx&lt;/span&gt; subsystem (supposed to hide the bootloader from me) lacks both a &amp;#39;check if image is confirmed&amp;#39; and a &amp;#39;confirm the primary slot of an image is good&amp;#39; method. So I have to go directly to the mcuboot methods to do this anyway (but we already noted the failing of the dfu_target API in the thread above...)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Second moan : the mcuboot api (exposed in include/zephyr/dfu/mcuboot.h) contains a multi-image compatible call to confirm an image (&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;boot_write_img_confirmed_multi(image_number)&lt;/span&gt;), but not a function to check if the image is already confirmed (to avoid writing to the mcuboot header at every boot...): there is&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;boot_is_img_confirmed()&lt;/span&gt; but not&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;boot_is_img_confirmed_multi(imgage_number)&lt;/span&gt;. WHY OH WHY? and there isn&amp;#39;t even the function in bootutil.c (which mcuboot.c delegates all the multi-image stuff to...)&lt;/p&gt;
&lt;p&gt;So I have to add my own function&amp;nbsp; to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;bootloader/mcuboot/boot/bootutil/src/bootutil_public.c&lt;/span&gt; (as this is the code that has the mapping table for the image number-&amp;gt;flash area id....). Not great for future NCS updates....&lt;/p&gt;
&lt;p&gt;Now, with sysbuild when I flash the merged.hex, the initial state of the slots is&lt;/p&gt;
&lt;p&gt;*** Booting MCUboot v2.1.0-dev-12e5ee106034 ***&lt;br /&gt;*** Using nRF Connect SDK v2.9.0-7787b2649840 ***&lt;br /&gt;*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***&lt;br /&gt;Starting bootloader&lt;/p&gt;
&lt;p&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;br /&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;br /&gt;Boot source: none&lt;br /&gt;Image index: 0, Swap type: none&lt;/p&gt;
&lt;p&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;br /&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;br /&gt;Boot source: none&lt;br /&gt;Image index: 1, Swap type: none&lt;/p&gt;
&lt;p&gt;Primary image: magic=good, swap_type=0x0, copy_done=0x1, image_ok=0x1&lt;br /&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;br /&gt;Boot source: none&lt;br /&gt;Image index: 2, Swap type: none&lt;/p&gt;
&lt;p&gt;Bootloader chainload address offset: 0x11000&lt;/p&gt;
&lt;p&gt;Only the primary slots for images 0 and 2 are relevant, as they have been written from the merged.hex.&lt;/p&gt;
&lt;p&gt;Immediately we can see that the build sets the magic of the application image (0) primary slot to be UNSET, while the nrf70 wifi fw (2) primary slot has magic=good!&lt;/p&gt;
&lt;p&gt;But lets see if updating the NCS2.9 has fixed the mcuboot &amp;#39;confirmation&amp;#39; issue. I remove my &amp;#39;break the secondary image code&amp;#39;, and make it confirm att 3 slots as &amp;#39;ok&amp;#39; after 30s of execution....&lt;/p&gt;
&lt;p&gt;When I DFU the wifi fw in image 2, it all works&amp;nbsp;ok :&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting MCUboot v2.1.0-dev-12e5ee106034 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using nRF Connect SDK v2.9.0-7787b2649840 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting bootloader&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 0, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 1, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=good, swap_type=0x0, copy_done=0x1, image_ok=0x1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 2, Swap type: test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting swap using move algorithm.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;applicaiton then runs, my code then confirms all images as ok using the mcuboot function aftre 30s.&lt;/p&gt;
&lt;p&gt;on next reboot:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting bootloader&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 0, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 1, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=good, swap_type=0x0, copy_done=0x1, image_ok=0x1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 2, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The image 2 secondary slot has had its magic &amp;#39;unset&amp;#39; and the swap_type set to NONE (1). So, no reverting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BUT: when I do exactly the same operation for the application, the &amp;#39;confirmation&amp;#39; does not work:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting MCUboot v2.1.0-dev-12e5ee106034 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using nRF Connect SDK v2.9.0-7787b2649840 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting bootloader&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 0, Swap type: test&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 1, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=good, swap_type=0x0, copy_done=0x1, image_ok=0x1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 2, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting swap using move algorithm.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Bootloader chainload address offset: 0x11000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;-&amp;gt; update done ok&lt;br /&gt;after 30s my code confirms the images, exactly as it did for the wifi fw.&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:30.417,694] &amp;lt;inf&amp;gt; app: Boot : confirmed image 0 ok to mcuboot&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:30.417,816] &amp;lt;wrn&amp;gt; app: Boot : failed to confirm mcuboot image 1 as ok (-5)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:30.418,182] &amp;lt;inf&amp;gt; app: Boot : image 2 is already flagged as ok to mcuboot&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;reboot:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting MCUboot v2.1.0-dev-12e5ee106034 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using nRF Connect SDK v2.9.0-7787b2649840 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting bootloader&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 0, Swap type: test&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 1, Swap type: none&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Primary image: magic=good, swap_type=0x0, copy_done=0x1, image_ok=0x1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Image index: 2, Swap type: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Starting swap using move algorithm.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;And we&amp;#39;re back to flip-flop between the 2 slots at each reboot.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;In the wifi case, I don&amp;#39;t&amp;nbsp;&amp;nbsp;see what code has set the secondary slot&amp;#39;s magic to unset, which is the differnce between the wifi and the app cases... I&amp;#39;m wondering if its actually the wifi setup firmware loader code?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Any ideas?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/508289?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2024 07:57:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d93ac56-2643-47fe-aec8-a73be50c3faf</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;I don&amp;#39;t think I explicitly set the magic to good anywhere... the code only does the call to say &amp;#39;image ok&amp;#39; once it runs...&lt;/p&gt;
&lt;p&gt;And if we have done a successful update (secondary-&amp;gt;primary), the primary will then have a good magic (because it was a good secondary), so for the next update both primary and secondary have magic=good...&lt;/p&gt;
&lt;p&gt;I thought the magic was just to let mcuboot know that the image is a legitimate mcuboot image, and its set by the build process?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/507937?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2024 12:35:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9102e2e9-8003-4971-a08c-67b3d3635f12</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry for the late response.&amp;nbsp;&lt;br /&gt;I took a look at your result again. It seems that what you have:&amp;nbsp;&lt;br /&gt;&lt;span&gt;I:&amp;nbsp;&lt;strong&gt;Primary&lt;/strong&gt;&amp;nbsp;image:&amp;nbsp;&lt;strong&gt;magic=good&lt;/strong&gt;, swap_type=0x2, copy_done=0x1,&amp;nbsp;&lt;strong&gt;image_ok=0x1&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Matched with this scenario:&amp;nbsp;&lt;br /&gt; {&lt;br /&gt; .magic_primary_slot = BOOT_MAGIC_ANY,&lt;br /&gt; .magic_secondary_slot = BOOT_MAGIC_GOOD,&lt;br /&gt; .image_ok_primary_slot = BOOT_FLAG_ANY,&lt;br /&gt; .image_ok_secondary_slot = BOOT_FLAG_UNSET,&lt;br /&gt; .copy_done_primary_slot = BOOT_FLAG_ANY,&lt;br /&gt; .swap_type = BOOT_SWAP_TYPE_TEST,&lt;br /&gt; },&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You have&amp;nbsp;&lt;span&gt;magic_secondary_slot&amp;nbsp;= good,&amp;nbsp;&amp;nbsp;image_ok_secondary =0x3 (UNSET)&amp;nbsp; the rest is just any so it match and it explains why the swap type is test instead of non and it will be swapped.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is what I have in my test, first when I send the test image:&amp;nbsp;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1729858005655v1.png" alt=" " /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It matched with the scenario above =&amp;gt; swap test.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then if I don&amp;#39;t do anything, it will revert:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1729858165803v3.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;span&gt;magic_primary_slot&lt;/span&gt;&lt;span&gt; = &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;BOOT_MAGIC_GOOD&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;span&gt;magic_secondary_slot&lt;/span&gt;&lt;span&gt; = &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;BOOT_MAGIC_UNSET&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;span&gt;image_ok_primary_slot&lt;/span&gt;&lt;span&gt; = &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;BOOT_FLAG_UNSET&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;span&gt;image_ok_secondary_slot&lt;/span&gt;&lt;span&gt; = &amp;nbsp;&lt;/span&gt;&lt;span&gt;BOOT_FLAG_ANY&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;span&gt;copy_done_primary_slot&lt;/span&gt;&lt;span&gt; = &amp;nbsp; &lt;/span&gt;&lt;span&gt;BOOT_FLAG_SET&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/span&gt;&lt;span&gt;swap_type&lt;/span&gt;&lt;span&gt; = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;BOOT_SWAP_TYPE_REVERT&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; },&lt;br /&gt;&lt;br /&gt;If I confirm the image instead, next boot is like this:&amp;nbsp;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1729858246038v4.png" alt=" " /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span&gt;So it&amp;#39;s very important that the secondary image&amp;#39;s magic should be unset and the primary image_ok is set.&amp;nbsp;&lt;br /&gt;What I noticed in my case is that at the beginning before the first test swap, the primary image&amp;#39;s magic is unset. This is very important. The primary image magic will be come the secondary image magic after the swap (it follows the image). So if at the beginning you already set the primary image magic to set, it may result in what you observed.&amp;nbsp;&lt;br /&gt;The only difference in my no swap booting is the secondary magic is unset (and swaptype =0x01 but&amp;nbsp; that&amp;#39;s not important in my opinion).&amp;nbsp;&lt;br /&gt;Please take a look and check why you have both image magic = good.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/506420?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2024 07:38:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a8c03b2-70ef-4cdd-9ebc-d8798a89af41</guid><dc:creator>BrianW</dc:creator><description>[quote userid="134465" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505941"]Hopefully fresh eyes will let you see what the corner case is that stops it doing what is expected..[/quote]
&lt;p&gt;Anything on why mcuboot feels the need to revert?&lt;/p&gt;
[quote userid="134465" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505976"]Did you have any idea about why the FPROTECT doesnt like my flash layout above??[/quote]
&lt;p&gt;Or why FPROTECT complains now that the partition sizes are (normally) aligned as required?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505976?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2024 09:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c559bc41-d3e0-437c-8933-46fbf2b34229</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;Did you have any idea about why the FPROTECT doesnt like my flash layout above??&amp;nbsp;&lt;/p&gt;
&lt;p&gt;thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505941?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 15:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d2a10e3-3dae-457a-a38b-d211395b0949</guid><dc:creator>BrianW</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505935"]But having to erase 2nd slot doesn&amp;#39;t sound like a best option.&amp;nbsp;[/quote]
&lt;p&gt;Totally agree.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505935"]I would suggest to check the code where the logic for deciding reverting in MCUBoot to see why it revert. [/quote]
&lt;p&gt;Well, I was hoping to avoid debugging mcuboot... especially as I am using the standard high level api calls to do the DFU (dfu_target) and mark the image as ok...&lt;/p&gt;
&lt;p&gt;MCUBoot&amp;nbsp;&amp;nbsp;logic is convoluted, to say the least. I have gone through it at least twice, and my understand is that is image_ok is SET and the magic is GOOD, then it should NOT revert....&lt;/p&gt;
&lt;p&gt;Hopefully fresh eyes will let you see what the corner case is that stops it doing what is expected...&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505935?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 15:13:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a78c9521-1be3-4c3e-8eab-277b60643659</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;br /&gt;I haven&amp;#39;t got the time to look into this yet.&amp;nbsp;&lt;br /&gt;But having to erase 2nd slot doesn&amp;#39;t sound like a best option.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would suggest to check the code where the logic for deciding reverting in MCUBoot to see why it revert. Also try to do a normal DFU with BLE or UART for example, and see how the image _magic and image _ok are written on first boot and on the second boot.&amp;nbsp;&lt;br /&gt;Will try to find time to look into this next week.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505679?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2024 08:59:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8091e2b0-1b42-4762-978f-0cdbe33a7420</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, thats what confuses me. At boot mcuboot tells me what its found:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting nRF Connect SDK 3758bcbfa5cd ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Starting bootloader&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: &lt;strong&gt;Primary&lt;/strong&gt; image: &lt;strong&gt;magic=good&lt;/strong&gt;, swap_type=0x2, copy_done=0x1, &lt;strong&gt;image_ok=0x1&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Image index: 0, Swap type: test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Starting swap using move algorithm.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Bootloader chainload address offset: 0xe000&lt;/span&gt;&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505634"]In your case if magic_primary_slot=BOOT_MAGIC_GOOD and&amp;nbsp;image_ok_primary_slot=&amp;nbsp;BOOT_FLAG_SET then I don&amp;#39;t see why it would do a revert.&amp;nbsp;[/quote]
&lt;p&gt;And as you can see it has that, so it SHOULD NOT REVERT : and yet it does.&lt;/p&gt;
&lt;p&gt;Work around (but not a good long term solution) : I destroy the secondary slot by running a fake dfu_target process on it with just 1 buffer of 0&amp;#39;s (which essentially makes the image invalid) -&amp;gt; mcuboot is forced to stay with my new primary).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Not very satisfactory, as it means I have no rollback later....but at least it stops it flip flopping at every boot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505634?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 19:42:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82d7f1a4-b332-487e-957d-a52a58e7aefb</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;br /&gt;I was looking at this line&amp;nbsp;&lt;a href="https://github.com/mcu-tools/mcuboot/blob/main/boot/bootutil/src/bootutil_public.c#L534"&gt;https://github.com/mcu-tools/mcuboot/blob/main/boot/bootutil/src/bootutil_public.c#L534&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But the magic of the slot was not&amp;nbsp;BOOT_MAGIC_UNSET ? I assume it&amp;#39;s BOOT_MAGIC_GOOD?&lt;br /&gt;&lt;br /&gt;As far as I know at the first boot, the new image should already be in the primary slot and the old image should be in the secondary (test swap).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;There are 3 scenarios where action (new swap) need to be taken as in &lt;a href="https://github.com/mcu-tools/mcuboot/blob/main/boot/bootutil/src/bootutil_public.c#L102"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;In your case if magic_primary_slot=BOOT_MAGIC_GOOD and&amp;nbsp;image_ok_primary_slot=&amp;nbsp;BOOT_FLAG_SET then I don&amp;#39;t see why it would do a revert.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505575?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 12:57:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bf13b16-a8dd-42b5-845b-339fb3bd30be</guid><dc:creator>BrianW</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505522"]Please make sure you give the application enough time to write to flash before reset.&amp;nbsp;[/quote]
&lt;p&gt;yes, I give it at least 10s and this appears ot be ok as mcuboot sees image_ok as 0x1 after the reboot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505563?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 12:32:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d74e45b-b3d3-4f2d-9b7c-b30d45e11d7f</guid><dc:creator>BrianW</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505522"]As far as I know you only need to call&amp;nbsp;boot_write_img_confirmed() in the application at its first boot after the swap then it should be permanent.&amp;nbsp;[/quote]
&lt;p&gt;Yes, that was my understanding. My code calls&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;ret = boot_write_img_confirmed&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;exactly as per the sample. However the swap_type remains as BOOT_SWAP_TYPE_TEST - as far as I can see the bootutil code for boot_set_next() just updates the image_ok flag to SET...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;(inspecting the bootutil code on the mcu github)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Where do you see the swap_type being updated?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&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: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505522?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 10:48:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6be7e64-fb8e-4ef8-a84c-0810e3ee800e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brian,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As far as I know you only need to call&amp;nbsp;boot_write_img_confirmed() in the application at its first boot after the swap then it should be permanent.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can find the call in the&amp;nbsp;\nrf\samples\bluetooth\mesh\dfu\target sample. Where we call&amp;nbsp;dfu_target_image_confirm() after bluetooth initialized.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From what I can see in the code swap type should be set to&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;swap_type&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;BOOT_SWAP_TYPE_PERM&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;in&amp;nbsp;&lt;/span&gt;&lt;/span&gt;boot_write_img_confirmed-&amp;gt;&amp;nbsp;boot_set_next()&lt;br /&gt;&lt;br /&gt;Could you confirm you call&amp;nbsp;&lt;span&gt;dfu_target_image_confirm() in the application after the first boot after swapping ?&amp;nbsp;&lt;br /&gt;Please make sure you give the application enough time to write to flash before reset.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505500?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 09:45:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c04e1166-ea8d-4bbd-b507-5b54bf64b11d</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;After a look at the mcuboot bootutil code, I understand that the value 0x1 means &amp;quot;SET&amp;quot; and 0x3 means &amp;quot;UNSET&amp;quot;. So at boot, copy_done=SET, image_ok=SET for primary slot.&lt;/p&gt;
&lt;p&gt;And as I understand the algorithm of mcuboot, ths should mean that even though the swap_type=0x2 (TEST), it should NOT swap to the secondary slot (unless my code expliclty asked for this as part of DFU - which it didn&amp;#39;t).&lt;/p&gt;
&lt;p&gt;So, why did mcuboot swap in this case?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505491?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 09:04:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad2d63aa-39c1-44f7-ba08-e7ab6b4c1f3c</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;Post update : once mcuboot has sucessfully swapped the slots, it runs the new image - great.&lt;/p&gt;
&lt;p&gt;But at the next boot, it swaps back, as it had done the swap in &amp;#39;test&amp;#39; mode... and then next boot it swaps again...&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Normally, to stop this &amp;#39;revert&amp;#39;, I understand from the mcuboot doc that the new image must make itself as &amp;#39;good&amp;#39;. No thanks to the mcuboot doc page (which says nothing about how to do this), it seems this should be as simple as a call to&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;boot_write_img_confirmed();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;(definition in zephyr/dfu/mcuboot.h)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;So, I set a timer, and&amp;nbsp; 60s after boot it pops and I call this method. return is 0, so success.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And on the next reset, mcuboot does indeed see the image_ok flag as 0x1 which (according to the doc) is OK.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;But... it swaps anyway&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting nRF Connect SDK 3758bcbfa5cd ***&lt;br /&gt;I: Starting bootloader&lt;br /&gt;I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1&lt;br /&gt;I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;br /&gt;I: Boot source: none&lt;br /&gt;I: Image index: 0, Swap type: test&lt;br /&gt;I: Starting swap using move algorithm.&lt;br /&gt;I: Bootloader chainload address offset: 0xe000&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I guess this is because although primary image slot is OK, the secondard slot is also still OK, and it didn&amp;#39;t set its flag to know ifs the old version or that the &amp;#39;test&amp;#39; swap was really OK? ALso, image_ok=0x3 - can&amp;#39;t find the doc that says what this value is : 0x1 or 0xFF are the only values noted....&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The mcuboot doc (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.2/page/mcuboot/design.html#image_swapping"&gt;https://docs.nordicsemi.com/bundle/ncs-2.6.2/page/mcuboot/design.html#image_swapping&lt;/a&gt;) implies that mcuboot itself should set the magic of the secondary slot to None, to disable it... I would have thought this would be when I call the confirmed() function.... but clearly this has not happend.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Do I need to overwrite the secondary slot image header myself to remove the revert?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505120?ContentTypeID=1</link><pubDate>Mon, 07 Oct 2024 08:36:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:621b6309-56ba-408d-ac23-1241a2b4ad89</guid><dc:creator>BrianW</dc:creator><description>[quote userid="134465" url="~/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/505001"]&lt;div&gt;&lt;span&gt;but it doesn&amp;#39;t mention having to set a buffer for mcuboot before the call to dfu_target_init()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And nowhere in dfu_target.c does it do this?!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;What is the point of having a &amp;#39;standard&amp;#39; api dfu_target to mask the different &amp;#39;targets&amp;#39;, if app has to explicitly call a target specific function to get it to work? And not described in the doc either?&lt;/span&gt;&lt;/div&gt;[/quote]
&lt;p&gt;So... I changed my code to just use the dfu_target_mscuboot_XXX API directly. This all seems to work just fine, except that after dfu_target completes (with no errors), mcuboot still refuses to update from the secondary slot : the relevant logs:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:00.544,769] &amp;lt;inf&amp;gt; base: dfu: opened app_update.bin, image type identified as mcuboot&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:00.555,236] &amp;lt;inf&amp;gt; base: dfu: starting update of image for app_update.bin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Copying to secondard slot.................................................................................................................................................................................................................................. DONE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.828,277] &amp;lt;inf&amp;gt; dfu_target_mcuboot: MCUBoot image-0 upgrade scheduled. Reset device to apply&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.838,562] &amp;lt;inf&amp;gt; base: dfu: no image file for net_core_app_update.bin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.846,130] &amp;lt;wrn&amp;gt; base: dfu : found new images, rebooting in 5s to update....see you on the other side...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Rebooting...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting nRF Connect SDK 3758bcbfa5cd ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Starting bootloader&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;W: Cannot upgrade: not a compatible amount of sectors&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Bootloader chainload address offset: 0xe000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;After a search on this forum, I found this:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/94313/mcuboot-runtime-error-cannot-upgrade-not-a-compatible-amount-of-sectors-with-external-flash-on-nrf9160"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/94313/mcuboot-runtime-error-cannot-upgrade-not-a-compatible-amount-of-sectors-with-external-flash-on-nrf9160&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Turns out that the size of the secondard slot MUST be exactly equal to the primary (not just bigger), and that a) this is not enforced at build time and b) the share_size directive does not work in your pm_static.yml.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;[as an aside, I note that post was over 2 years ago, and the information about these 2 points was supposed to being fed back to developers.... but still no fix or even any documentation....]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Making my mcuboot_secondary partition be the same size as the mcuboot_primary_app one fixed the mcuboot log and now I get:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;............................................................................................................................................................................................................................ DONE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.582,580] &amp;lt;inf&amp;gt; dfu_target_mcuboot: MCUBoot image-0 upgrade scheduled. Reset device to apply&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.592,864] &amp;lt;inf&amp;gt; base: dfu: no image file for net_core_app_update.bin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.600,402] &amp;lt;inf&amp;gt; base: dfu :System write boot ok flag to NVM&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:27.607,360] &amp;lt;wrn&amp;gt; base: dfu : found new images, rebooting in 5s to update....&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;[00:00:30.319,671] &amp;lt;inf&amp;gt; base: System running ok, write boot ok flag to NVM&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Rebooting...see you on the other side...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting nRF Connect SDK 3758bcbfa5cd ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Starting bootloader&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Boot source: none&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Image index: 0, Swap type: test&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Starting swap using move algorithm.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Bootloader chainload address offset: 0xe000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;And miracle : a working DFU from USB filesystem!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;For those also looking to do this: &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;the &amp;#39;dfu from local file&amp;#39; fn (call it with the name of the file on the FS, and reboot if it returns true). You will need to implement the usb_fs_XX functions, but these are just wrappers round the FAT FS fs_XX api.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
// DFU related code
static void _dfu_cb(enum dfu_target_evt_id evt_id) {
	log_info(&amp;quot;dfu: callback says event %d&amp;quot;, evt_id);
}

// read blocks of 4K from fle and pass to DFU updater
// Returns false if couldn&amp;#39;t access or dfu the given file 
#define DFU_BUF_SZ	(4096)
static bool _do_dfu(char* filename, int img_num) {
	int32_t fsize = usb_fs_get_file_size(filename);
	if (fsize&amp;lt;0) {
		log_info(&amp;quot;dfu: no image file for %s&amp;quot;,filename);
		return false;
	}
	file_handle_t fh = usb_fs_open_file(filename, true);	// open in read only
	if (fh==NULL) {
		log_warn(&amp;quot;dfu : failed to open file %s&amp;quot;, filename);
		return false;
	}
	uint8_t* buf = Util_amalloc(DFU_BUF_SZ);
	if (buf==NULL) {
		usb_fs_close_file(fh);
		log_warn(&amp;quot;dfu : failed to alloc buffer to read %s&amp;quot;, filename);
		return false;
	}
	uint32_t buf_sz = 0;
	// Read first block to let dfu analyse file type
	buf_sz = usb_fs_read_file(fh, buf, DFU_BUF_SZ);
	if (buf_sz!=DFU_BUF_SZ) {
		// image file must be &amp;gt; 4K so if fail to read then give up
		usb_fs_close_file(fh);
		Util_afree(buf);
		log_warn(&amp;quot;dfu : failed to read 4K from file %s, %d&amp;quot;, filename, buf_sz);
		return false;
	}
	if (!dfu_target_mcuboot_identify(buf)) {
		usb_fs_close_file(fh);
		Util_afree(buf);
		log_warn(&amp;quot;dfu : file %s is not an mcuboot image, cannot DFU&amp;quot;, filename);
		return false;
	}
	log_info(&amp;quot;dfu: opened %s, image type identified as mcuboot&amp;quot;, filename);
	dfu_target_mcuboot_reset();	// always start from beginning as not downloading

	// Give it a scratch buffer for flash writing
	uint8_t* mcuboot_buf = Util_amalloc(DFU_BUF_SZ);
	dfu_target_mcuboot_set_buf(mcuboot_buf, DFU_BUF_SZ);

	int ret = dfu_target_mcuboot_init(fsize, img_num, _dfu_cb);
	if (ret&amp;lt;0) {
		usb_fs_close_file(fh);
		Util_afree(buf);
		Util_afree(mcuboot_buf);
		log_warn(&amp;quot;dfu : init for %s image identified as type mcuboot failed code %d&amp;quot;, filename, ret);
		return false;
	}
	log_info(&amp;quot;dfu: starting update of image for %s&amp;quot;, filename);
	printk(&amp;quot;Copying to secondard slot.&amp;quot;);
	while(buf_sz==DFU_BUF_SZ) {
		// write the block
		int wret = dfu_target_mcuboot_write(buf, buf_sz);
		if (wret==0) {
			// read the next
			buf_sz = usb_fs_read_file(fh, buf, DFU_BUF_SZ);
			printk(&amp;quot;.&amp;quot;);
		} else {
			buf_sz = wret;
			printk(&amp;quot;[WRITE FAIL %d]\n&amp;quot;, wret);
		}
	}
	if (buf_sz&amp;gt;0) {
		// Write the final block
		buf_sz = dfu_target_mcuboot_write(buf, buf_sz);
		printk(&amp;quot;. DONE\n&amp;quot;);
	}
	usb_fs_close_file(fh);
	Util_afree(buf);
	Util_afree(mcuboot_buf);
	if (buf_sz&amp;lt;0) {
		log_warn(&amp;quot;dfu : failed during install of file %s, %d&amp;quot;, filename, buf_sz);
		dfu_target_mcuboot_done(false);
		// TBD : should we delete the &amp;#39;bad&amp;#39; bin file? or try again next boot?
		return false;
	}
	// Success! Delete the file (we don&amp;#39;t want it hanging about and triggering dfu again next boot time!)
	usb_fs_delete_file(filename);
	int dret = dfu_target_mcuboot_done(true);
	if (dret==0) {
		dret = dfu_target_mcuboot_schedule_update(img_num);
		if (dret==0) {
			return true;
		} else {
			log_warn(&amp;quot;dfu : schedule_update() returns error %d, dfu filed for %s&amp;quot;, dret, filename);
		}
	} else {
		log_warn(&amp;quot;dfu : done() returns error %d, dfu filed for %s&amp;quot;, dret, filename);
	}
	return false;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;And my pm_static.yml also, as this is also a pain in the neck to get right...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcuboot:
    address: 0x0
    end_address: 0xe000
    region: flash_primary
    size: 0xe000

mcuboot_pad:
    address: 0xe000
    end_address: 0xe200
    region: flash_primary
    size: 0x200

app:
    address: 0xe200
    end_address: 0x100000
    region: flash_primary
    size: 0xf1e00

mcuboot_primary_app:
    address: 0xe200
    end_address: 0x100000
    region: flash_primary
    size: 0xf1e00
    span: [app]

mcuboot_primary:
    address: 0xe000
    end_address: 0x100000
    region: flash_primary
    size: 0xf2000
    span: [mcuboot_pad, mcuboot_primary_app]

# define partition for fatfs disk, on the external flash storage (probably the device defined by nordic,pm-ext-flash in the DTS)
fatfs_storage:
    region: external_flash
    affiliation: 
        - disk
    extra_params: {
        disk_name: &amp;quot;NAND&amp;quot;,
        disk_cache_size: 4096,
        disk_sector_size: 512,
        disk_read_only: 0
    }
    # 6Mb size, external flash is 8Mb total
    address: 0x0
    size: 0x600000

nvs_storage:
    region: external_flash
    affiliation: 
        - nvs
    # 64kB size, its just for small stuff
    address: 0x600000
    size: 0x10000

mcuboot_secondary_1:
    region: external_flash
    affiliation: 
        - mcuboot
    # 256kb size, its for netcore flash image
    address: 0x610000
    size: 0x40000

mcuboot_secondary:
    region: external_flash
    affiliation: 
        - mcuboot
    address: 0x650000
    # MUST be same size as the primary application slot size, and share_size does not appear to work
    size: 0xf1e00
    #share_size: [mcuboot_primary_app]

# internal cuisine
otp:
    address: 0xff8100
    end_address: 0xff83fc
    region: otp
    size: 0x2fc
pcd_sram:
    address: 0x20000000
    end_address: 0x20002000
    #placement:
    #    after:
    #    - start
    region: sram_primary
    size: 0x2000
rpmsg_nrf53_sram:
    address: 0x20070000
    end_address: 0x20080000
    #placement:
    #    before:
    #    - end
    region: sram_primary
    size: 0x10000
sram_primary:
    address: 0x20002000
    end_address: 0x20070000
    region: sram_primary
    size: 0x6e000

# TODO need fake flash ram flash partition to do cpunet DFU...
#mcuboot_primary_1:
#  address: 0x0
#  device: nordic_ram_flash_controller
#  end_address: 0x40000
#  region: ram_flash
#  size: 0x40000
#
#ram_flash:
#  address: 0x40000
#  end_address: 0x40000
#  region: ram_flash
#  size: 0x0
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;(you&amp;#39;re welcome)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Note app_update.bin is the file generated by the build, and has the mcuboot magic number at the start...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;I haven&amp;#39;t yet tried the CPUNET update (as you can see the ram flash simulator is still commented out).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505042?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 16:15:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7af8d9be-d560-4d01-9cde-692a569073a5</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;Still complains:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** Booting nRF Connect SDK 3758bcbfa5cd ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Starting bootloader&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;W: Cannot upgrade: not a compatible amount of sectors&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Bootloader chainload address offset: 0xe000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;I: Jumping to the first image slot&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;E: Protect mcuboot flash failed, cancel startup.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;partitions.yml :&amp;nbsp;insert-&amp;gt;file &amp;quot;type yml still not allowed.&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;app:
  address: 0xe200
  end_address: 0x100000
  region: flash_primary
  size: 0xf1e00
external_flash:
  address: 0x750000
  end_address: 0x800000
  region: external_flash
  size: 0xb0000
fatfs_storage:
  address: 0x0
  affiliation:
  - disk
  end_address: 0x600000
  extra_params:
    disk_cache_size: 0x1000
    disk_name: NAND
    disk_read_only: 0x0
    disk_sector_size: 0x200
  region: external_flash
  size: 0x600000
mcuboot:
  address: 0x0
  end_address: 0xe000
  region: flash_primary
  size: 0xe000
mcuboot_pad:
  address: 0xe000
  end_address: 0xe200
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0xe000
  end_address: 0x100000
  region: flash_primary
  size: 0xf2000
  span:
  - mcuboot_pad
  - mcuboot_primary_app
mcuboot_primary_app:
  address: 0xe200
  end_address: 0x100000
  region: flash_primary
  size: 0xf1e00
  span:
  - app
mcuboot_secondary:
  address: 0x650000
  affiliation:
  - mcuboot
  end_address: 0x750000
  region: external_flash
  size: 0x100000
mcuboot_secondary_1:
  address: 0x610000
  affiliation:
  - mcuboot
  end_address: 0x650000
  region: external_flash
  size: 0x40000
nvs_storage:
  address: 0x600000
  affiliation:
  - nvs
  end_address: 0x610000
  region: external_flash
  size: 0x10000
otp:
  address: 0xff8100
  end_address: 0xff83fc
  region: otp
  size: 0x2fc
pcd_sram:
  address: 0x20000000
  end_address: 0x20002000
  region: sram_primary
  size: 0x2000
rpmsg_nrf53_sram:
  address: 0x20070000
  end_address: 0x20080000
  region: sram_primary
  size: 0x10000
sram_primary:
  address: 0x20002000
  end_address: 0x20070000
  region: sram_primary
  size: 0x6e000
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;pm_static.yml&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcuboot:
    address: 0x0
    end_address: 0xe000
    region: flash_primary
    size: 0xe000

mcuboot_pad:
    address: 0xe000
    end_address: 0xe200
    region: flash_primary
    size: 0x200

app:
    address: 0xe200
    end_address: 0x100000
    region: flash_primary
    size: 0xf1e00

mcuboot_primary_app:
    address: 0xe200
    end_address: 0x100000
    region: flash_primary
    size: 0xf1e00
    span: [app]

mcuboot_primary:
    address: 0xe000
    end_address: 0x100000
    region: flash_primary
    size: 0xf2000
    span: [mcuboot_pad, mcuboot_primary_app]

# define partition for fatfs disk, on the external flash storage (probably the device defined by nordic,pm-ext-flash in the DTS)
fatfs_storage:
    region: external_flash
    affiliation: 
        - disk
    extra_params: {
        disk_name: &amp;quot;NAND&amp;quot;,
        disk_cache_size: 4096,
        disk_sector_size: 512,
        disk_read_only: 0
    }
    # 6Mb size, external flash is 8Mb total
    address: 0x0
    size: 0x600000

nvs_storage:
    region: external_flash
    affiliation: 
        - nvs
    # 64kB size, its just for small stuff
    address: 0x600000
    size: 0x10000

mcuboot_secondary_1:
    region: external_flash
    affiliation: 
        - mcuboot
    # 256kb size, its for netcore flash image
    address: 0x610000
    size: 0x40000

mcuboot_secondary:
    region: external_flash
    affiliation: 
        - mcuboot
    # 1Mb size, its for an application flash image
    address: 0x650000
    size: 0x100000
    #share_size: [mcuboot_primary_app]

# internal cuisine
otp:
    address: 0xff8100
    end_address: 0xff83fc
    region: otp
    size: 0x2fc
pcd_sram:
    address: 0x20000000
    end_address: 0x20002000
    #placement:
    #    after:
    #    - start
    region: sram_primary
    size: 0x2000
rpmsg_nrf53_sram:
    address: 0x20070000
    end_address: 0x20080000
    #placement:
    #    before:
    #    - end
    region: sram_primary
    size: 0x10000
sram_primary:
    address: 0x20002000
    end_address: 0x20070000
    region: sram_primary
    size: 0x6e000

# TODO need fake flash ram flash partition to do cpunet DFU...
#mcuboot_primary_1:
#  address: 0x0
#  device: nordic_ram_flash_controller
#  end_address: 0x40000
#  region: ram_flash
#  size: 0x40000
#
#ram_flash:
#  address: 0x40000
#  end_address: 0x40000
#  region: ram_flash
#  size: 0x0
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;ie partition table for internal flash:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;flash_primary (0x100000 - 1024kB):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+-------------------------------------------------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0x0: mcuboot (0xe000 - 56kB) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+---0xe000: mcuboot_primary (0xf2000 - 968kB)-----+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0xe000: mcuboot_pad (0x200 - 512B) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+---0xe200: mcuboot_primary_app (0xf1e00 - 967kB)-+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0xe200: app (0xf1e00 - 967kB) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+-------------------------------------------------+&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505038?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 15:09:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5d23078-b313-499b-bbe8-6a1ae50d4154</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;I chose 0xfe00 because the original problem was that mcuboot was too big for the flash size selected by PM (0xc000 = 48kB, mcuboot image is around 53kB...), so I aligned the app start partition nicely on 0x10000 -&amp;gt; which when you take off the 0x200 pad gives 0xfe00.&lt;/p&gt;
&lt;p&gt;Sadly the build process and the PM didn&amp;#39;t flag up this alignment requirement for FPROTECT...&lt;/p&gt;
&lt;p&gt;I will change it to 0xe000 size for mcuboot and see if that lets FPROTECT be happy... with the primary partition therefore at 0xe200.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505002?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 12:44:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77efac93-8cea-49b0-8105-f6a93dac62cb</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;again,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can attach file by clicking Insert -&amp;gt; Image/Video/file&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Or you can add code by Insert -&amp;gt; Code&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regarding the mcuboot partition, can you tell why you choose 0xfe00 ( mcuboot end address) and 0x10000 (mcuboot pad end address) ?&amp;nbsp;&lt;br /&gt;The problem of this address is that it doesn&amp;#39;t allign with&amp;nbsp;FPROTECT_BLOCK_SIZE ( =NRF_SPU_FLASH_REGION_SIZE = 0x4000).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Could you try again with 0xc000 and 0xc200 respectively or try 0x10000 and 0x10200 respectively.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/505001?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 12:33:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:287c7aa4-4555-4dcc-9e0d-b8f3ec7902bc</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;So, now that mcuboot is actually bootingmy code (FPROTECT disabled) I have added&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_STREAM_FLASH&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_STREAM_FLASH_ERASE&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_DFU_TARGET_STREAM&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_IMG_MANAGER&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_DFU_TARGET_MCUBOOT&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;and using the dfu_target library to copy the contents of app_update.bin to the mcuboot_secondary partition.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;However, it failed with this log&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;quot;Missing stream_buf, call &amp;#39;..set_buf&amp;#39; before &amp;#39;..init&amp;quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;as found in dfu_target_mcuboot.c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I use the dfu_target api as described in the doc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.2.0/page/nrf/libraries/dfu/dfu_target.html#c.dfu_target_init"&gt;https://docs.nordicsemi.com/bundle/ncs-2.2.0/page/nrf/libraries/dfu/dfu_target.html#c.dfu_target_init&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;but it doesn&amp;#39;t mention having to set a buffer for mcuboot before the call to dfu_target_init()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And nowhere in dfu_target.c does it do this?!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;What is the point of having a &amp;#39;standard&amp;#39; api dfu_target to mask the different &amp;#39;targets&amp;#39;, if app has to explicitly call a target specific function to get it to work? And not described in the doc either?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&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: DFU using USB file system (not serial emulation)?</title><link>https://devzone.nordicsemi.com/thread/504966?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 10:31:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff6a6852-b61d-470d-a0d0-aec0a81c97ba</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;From pm.config in the build directory:&lt;/p&gt;
&lt;p&gt;PM_MCUBOOT_OFFSET=0x0&lt;/p&gt;
&lt;p&gt;PM_MCUBOOT_PRIMARY_OFFSET=0xfe00&lt;/p&gt;
&lt;p&gt;This is exactly what I expect given my pm_static.yml which starts like:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;mcuboot:
&amp;#160; &amp;#160; address: 0x0
&amp;#160; &amp;#160; end_address: 0xfe00
&amp;#160; &amp;#160; #placement:
&amp;#160; &amp;#160; # &amp;#160;before:
&amp;#160; &amp;#160; # &amp;#160;- mcuboot_primary
&amp;#160; &amp;#160; region: flash_primary
&amp;#160; &amp;#160; size: 0xfe00

mcuboot_pad:
&amp;#160; &amp;#160; address: 0xfe00
&amp;#160; &amp;#160; end_address: 0x10000
&amp;#160; &amp;#160; #placement:
&amp;#160; &amp;#160; # &amp;#160;align:
&amp;#160; &amp;#160; # &amp;#160; &amp;#160;start: 0xfe00
&amp;#160; &amp;#160; # &amp;#160;before:
&amp;#160; &amp;#160; # &amp;#160;- mcuboot_primary
&amp;#160; &amp;#160; region: flash_primary
&amp;#160; &amp;#160; size: 0x200

app:
&amp;#160; &amp;#160; address: 0x10000
&amp;#160; &amp;#160; end_address: 0x100000
&amp;#160; &amp;#160; region: flash_primary
&amp;#160; &amp;#160; size: 0xf0000

mcuboot_primary_app:
&amp;#160; &amp;#160; address: 0x10000
&amp;#160; &amp;#160; end_address: 0x100000
&amp;#160; &amp;#160; region: flash_primary
&amp;#160; &amp;#160; size: 0xf0000
&amp;#160; &amp;#160; # &amp;#160;span: *id002
&amp;#160; &amp;#160; span: [app]

mcuboot_primary:
&amp;#160; &amp;#160; address: 0xfe00
&amp;#160; &amp;#160; end_address: 0x100000
&amp;#160; &amp;#160; region: flash_primary
&amp;#160; &amp;#160; size: 0xf0200
&amp;#160; &amp;#160; # &amp;#160;span: *id001
&amp;#160; &amp;#160; span: [mcuboot_pad, mcuboot_primary_app]&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;I don&amp;#39;t see how to attach files to a ticket? Simple drag-n-drop tells me the file type yml is not allowed...&lt;/p&gt;
&lt;p&gt;partition_manager_report target gives me:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;external_flash (0x800000 - 8192kB):
+-------------------------------------------------+
| 0x0: fatfs_storage (0x600000 - 6144kB) |
| 0x600000: nvs_storage (0x10000 - 64kB) |
| 0x610000: mcuboot_secondary_1 (0x40000 - 256kB) |
| 0x650000: mcuboot_secondary (0xfc000 - 1008kB) |
| 0x74c000: external_flash (0xb4000 - 720kB) |
+-------------------------------------------------+

flash_primary (0x100000 - 1024kB):
+--------------------------------------------------+
| 0x0: mcuboot (0xfe00 - 63kB) |
+---0xfe00: mcuboot_primary (0xf0200 - 960kB)------+
| 0xfe00: mcuboot_pad (0x200 - 512B) |
+---0x10000: mcuboot_primary_app (0xf0000 - 960kB)-+
| 0x10000: app (0xf0000 - 960kB) |
+--------------------------------------------------+

otp (0x2fc - 764B):
+------------------------------+
| 0xff8100: otp (0x2fc - 764B) |
+------------------------------+

sram_primary (0x80000 - 512kB):
+-----------------------------------------------+
| 0x20000000: pcd_sram (0x2000 - 8kB) |
| 0x20002000: sram_primary (0x6e000 - 440kB) |
| 0x20070000: rpmsg_nrf53_sram (0x10000 - 64kB) |
+-----------------------------------------------+

CPUNET flash_primary (0x40000 - 256kB):
+--------------------------------------------+
+---0x1000000: b0n_container (0x8800 - 34kB)-+
| 0x1000000: b0n (0x8580 - 33kB) |
| 0x1008580: provision (0x280 - 640B) |
+---0x1008800: app (0x37800 - 222kB)---------+
| 0x1008800: hci_ipc (0x37800 - 222kB) |
+--------------------------------------------+

CPUNET sram_primary (0x10000 - 64kB):
+-------------------------------------------+
| 0x21000000: sram_primary (0x10000 - 64kB) |
+-------------------------------------------+&lt;/pre&gt;&lt;br /&gt;which is prettier anyway...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>