@@ -58,6 +58,11 @@ LOG_MODULE_DECLARE(mcumgr_img_grp, CONFIG_MCUMGR_GRP_IMG_LOG_LEVEL);
58
58
#define DIRECT_XIP_BOOT_FOREVER 3
59
59
#endif
60
60
61
+ #if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER ) && \
62
+ CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER > 1
63
+ #warning "MCUmgr img mgmt only supports 1 image"
64
+ #endif
65
+
61
66
/**
62
67
* Collects information about the specified image slot.
63
68
*/
@@ -196,7 +201,6 @@ int img_mgmt_get_next_boot_slot(int image, enum img_mgmt_next_boot_type *type)
196
201
#else
197
202
198
203
#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT )
199
-
200
204
static int read_directxip_state (int slot )
201
205
{
202
206
struct boot_swap_state bss ;
@@ -229,6 +233,8 @@ static int read_directxip_state(int slot)
229
233
}
230
234
#endif /* defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT) */
231
235
236
+ #if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP ) || \
237
+ defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT )
232
238
int img_mgmt_get_next_boot_slot (int image , enum img_mgmt_next_boot_type * type )
233
239
{
234
240
struct image_version aver ;
@@ -301,12 +307,14 @@ int img_mgmt_get_next_boot_slot(int image, enum img_mgmt_next_boot_type *type)
301
307
302
308
return return_slot ;
303
309
}
310
+ #endif /* defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP) || \
311
+ * defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT)
312
+ */
304
313
#endif /* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP) && \
305
314
* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT) && \
306
315
* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER)
307
316
*/
308
317
309
-
310
318
/**
311
319
* Indicates whether any image slot is pending (i.e., whether a test swap will
312
320
* happen on the next reboot.
@@ -494,6 +502,7 @@ static bool img_mgmt_state_encode_slot(struct smp_streamer *ctxt, uint32_t slot,
494
502
/**
495
503
* Command handler: image state read
496
504
*/
505
+ #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER )
497
506
int
498
507
img_mgmt_state_read (struct smp_streamer * ctxt )
499
508
{
@@ -551,6 +560,43 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
551
560
552
561
return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE ;
553
562
}
563
+ #else
564
+ int
565
+ img_mgmt_state_read (struct smp_streamer * ctxt )
566
+ {
567
+ zcbor_state_t * zse = ctxt -> writer -> zs ;
568
+ uint32_t i ;
569
+ bool ok ;
570
+
571
+ ok = zcbor_tstr_put_lit (zse , "images" ) &&
572
+ zcbor_list_start_encode (zse , 2 );
573
+
574
+ img_mgmt_take_lock ();
575
+
576
+ for (i = 0 ; ok && i < CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER ; i ++ ) {
577
+ /* _a is active slot, _o is opposite slot */
578
+ int slot_a = img_mgmt_active_slot (i );
579
+ int slot_o = img_mgmt_get_opposite_slot (slot_a );
580
+ int flags_a = REPORT_SLOT_ACTIVE ;
581
+ int flags_o = REPORT_SLOT_CONFIRMED ;
582
+
583
+ ok = img_mgmt_state_encode_slot (ctxt , slot_o , flags_o ) &&
584
+ img_mgmt_state_encode_slot (ctxt , slot_a , flags_a );
585
+ }
586
+
587
+ /* Ending list encoding for two slots per image */
588
+ ok = ok && zcbor_list_end_encode (zse , 2 );
589
+ /* splitStatus is always 0 so in frugal list it is not present at all */
590
+ if (!IS_ENABLED (CONFIG_MCUMGR_GRP_IMG_FRUGAL_LIST ) && ok ) {
591
+ ok = zcbor_tstr_put_lit (zse , "splitStatus" ) &&
592
+ zcbor_int32_put (zse , 0 );
593
+ }
594
+
595
+ img_mgmt_release_lock ();
596
+
597
+ return ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE ;
598
+ }
599
+ #endif /* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) */
554
600
555
601
static int img_mgmt_set_next_boot_slot_common (int slot , int active_slot , bool confirm )
556
602
{
0 commit comments