Skip to content

Commit 3fc94b3

Browse files
committed
boot: boot_serial: Fix slot info response on error
Fixes the CBOR response when a flash area is not listed due to an error Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent e2c97da commit 3fc94b3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,13 @@ bs_slot_info(uint8_t op, char *buf, int len)
746746

747747
if (rc) {
748748
ok = zcbor_tstr_put_lit(cbor_state, "rc") &&
749-
zcbor_int32_put(cbor_state, rc);
749+
zcbor_int32_put(cbor_state, rc) &&
750+
zcbor_map_end_encode(cbor_state, CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP);
751+
752+
if (ok && slot == (BOOT_NUM_SLOTS - 1)) {
753+
ok = zcbor_list_end_encode(cbor_state, BOOT_NUM_SLOTS) &&
754+
zcbor_map_end_encode(cbor_state, CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP);
755+
}
750756
} else {
751757
if (sizeof(fap->fa_size) == sizeof(uint64_t)) {
752758
ok = zcbor_tstr_put_lit(cbor_state, "size") &&
@@ -808,7 +814,6 @@ bs_slot_info(uint8_t op, char *buf, int len)
808814
}
809815

810816
ok = zcbor_map_end_encode(cbor_state, CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP);
811-
812817
}
813818
}
814819

0 commit comments

Comments
 (0)