|
56 | 56 | #define SEND_BOOT_REQUEST |
57 | 57 | #endif /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST && !CONFIG_MCUBOOT */ |
58 | 58 |
|
| 59 | +#ifdef CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES |
| 60 | +#include <bootutil/mcuboot_manifest.h> |
| 61 | +#endif /* CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES */ |
| 62 | + |
59 | 63 | #ifdef CONFIG_MCUBOOT |
60 | 64 | BOOT_LOG_MODULE_DECLARE(mcuboot); |
61 | 65 | #else |
@@ -398,7 +402,8 @@ boot_write_image_ok(const struct flash_area *fap) |
398 | 402 | return boot_write_trailer_flag(fap, off, BOOT_FLAG_SET); |
399 | 403 | } |
400 | 404 |
|
401 | | -#if defined(SEND_BOOT_REQUEST) || (!defined(MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP)) |
| 405 | +#if defined(SEND_BOOT_REQUEST) || (!defined(MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP)) || \ |
| 406 | + defined(CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES) |
402 | 407 | static int flash_area_to_image_slot(const struct flash_area *fa, uint32_t *slot) |
403 | 408 | { |
404 | 409 | int id = flash_area_get_id(fa); |
@@ -435,15 +440,36 @@ static int flash_area_to_image_slot(const struct flash_area *fa, uint32_t *slot) |
435 | 440 | #endif |
436 | 441 | return 0; |
437 | 442 | } |
438 | | -#endif /* SEND_BOOT_REQUEST || !MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP */ |
| 443 | +#endif /* SEND_BOOT_REQUEST || !MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP || CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES */ |
439 | 444 |
|
440 | 445 | int |
441 | 446 | boot_read_image_ok(const struct flash_area *fap, uint8_t *image_ok) |
442 | 447 | { |
443 | | -#ifdef SEND_BOOT_REQUEST |
| 448 | +#if defined(SEND_BOOT_REQUEST) || defined(CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES) |
444 | 449 | enum boot_slot slot_id = BOOT_SLOT_NONE; |
445 | 450 | int image_id = flash_area_to_image_slot(fap, &slot_id); |
446 | | - bool confirm_pending = boot_request_check_confirmed_slot(image_id, slot_id); |
| 451 | +#endif |
| 452 | +#ifdef SEND_BOOT_REQUEST |
| 453 | + bool confirm_pending; |
| 454 | +#endif |
| 455 | + |
| 456 | +#ifdef CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES |
| 457 | + /* If manifest-based updates are used, only the manifest image is considered. */ |
| 458 | + image_id = CONFIG_NCS_MCUBOOT_MANIFEST_IMAGE_NUMBER; |
| 459 | + if (slot_id == BOOT_SLOT_PRIMARY) { |
| 460 | + int rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(image_id), &fap); |
| 461 | + if (rc != 0) { |
| 462 | + return rc; |
| 463 | + } |
| 464 | + } else if (slot_id == BOOT_SLOT_SECONDARY) { |
| 465 | + int rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(image_id), &fap); |
| 466 | + if (rc != 0) { |
| 467 | + return rc; |
| 468 | + } |
| 469 | + } |
| 470 | +#endif /* CONFIG_NCS_MCUBOOT_MANIFEST_UPDATES */ |
| 471 | +#ifdef SEND_BOOT_REQUEST |
| 472 | + confirm_pending = boot_request_check_confirmed_slot(image_id, slot_id); |
447 | 473 |
|
448 | 474 | if (confirm_pending) { |
449 | 475 | BOOT_LOG_DBG("Image confirmation pending for image %d slot %d", image_id, slot_id); |
|
0 commit comments