zephyr: Mcuboot swap type is `test` when update fails

Describe the bug When installing an image with mcuboot swap using move, the installation can fail if the image is too big. In that case the old image is loaded again. If we ask the image for its swap type using the mcuboot_swap_type-function we expect it to say none, but we get test instead.

#include <stdbool.h>
#include <dfu/dfu_target.h>
#include <dfu/dfu_target_mcuboot.h>
#include <dfu/mcuboot.h>

void main(void)
{
    mcuboot_swap_type();
}

To Reproduce Steps to reproduce the behavior:

  1. Make mcuboot update swap using move fail by providing an image that is too big
  2. use the mcuboot_swap_type(); function somewhere in the firmware.

Expected behavior After the upgrade failed, mcuboot reverts to the previous image. It is expected to be of swap type none but instead it is of type test

Impact If someone is using the flag to check for a “healthy” boot, they get unexpected behavior. Reset cycles for example.

Logs and console output

*** Booting Zephyr OS build v3.1.99-ncs1-12-gaa84ba70d601  ***
<inf> mcuboot_util: Swap type: none

Let me know if additional context is needed.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 31 (1 by maintainers)

Most upvoted comments

As #61342 has been merged, does this not resolve the issue?

Did I see correctly, that this addresses issues related to mcumgr? The issue I report here, is reproduceable without mcumgr.

  1. Swap type is none
  2. Load in image into secondary slot and mark it for update. Swap type is test.
  3. Reboot. Swapping fails (for example image too big for slot).
  4. Expected :Swap type is none, Got: Swap type is test