Skip to content

Commit c854c85

Browse files
de-nordiccarlescufi
authored andcommitted
snapshot: Update mcumgr to commit 12b496e3 from the upstream
The commit applies changes that have appeared between the last snapshot update from the upstream: apache/mynewt-mcumgr 47fdde0c9a2bac821d2a814541e31d734dd78866 and the current top of the upstream: apache/mynewt-mcumgr 12b496e37caf20a45ab5aee4209b06c5d79ef9b1 Signed-off-by: Dominik Ermel <[email protected]>
1 parent a730114 commit c854c85

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

cborattr/src/cborattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ cbor_internal_read_object(CborValue *root_value,
306306
err |= CborErrorIllegalType;
307307
}
308308
}
309-
cbor_value_advance(&cur_value);
309+
err = cbor_value_advance(&cur_value);
310310
}
311311
if (!err) {
312312
/* that should be it for this container */

cmd/img_mgmt/include/img_mgmt/img_mgmt_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
/* Number of updatable images */
2424
#define IMG_MGMT_UPDATABLE_IMAGE_NUMBER 1
25+
/* Image status list will only contain image attributes that are true/non-zero */
26+
#define IMG_MGMT_FRUGAL_LIST 0
2527

2628
#if defined MYNEWT
2729

@@ -45,6 +47,10 @@
4547
#undef IMG_MGMT_UPDATABLE_IMAGE_NUMBER
4648
#define IMG_MGMT_UPDATABLE_IMAGE_NUMBER CONFIG_IMG_MGMT_UPDATABLE_IMAGE_NUMBER
4749
#endif
50+
#ifdef CONFIG_IMG_MGMT_FRUGAL_LIST
51+
#undef IMG_MGMT_FRUGAL_LIST
52+
#define IMG_MGMT_FRUGAL_LIST CONFIG_IMG_MGMT_FRUGAL_LIST
53+
#endif
4854

4955
#else
5056

cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ img_mgmt_get_unused_slot_area_id(int slot)
181181
for (slot = 0; slot < 2; slot++) {
182182
if (img_mgmt_slot_in_use(slot) == 0) {
183183
int area_id = zephyr_img_mgmt_flash_area_id(slot);
184-
if (area_id != -1) {
184+
if (area_id >= 0) {
185185
return area_id;
186186
}
187187
}
@@ -319,8 +319,13 @@ img_mgmt_impl_read(int slot, unsigned int offset, void *dst,
319319
{
320320
const struct flash_area *fa;
321321
int rc;
322+
int area_id = zephyr_img_mgmt_flash_area_id(slot);
322323

323-
rc = flash_area_open(zephyr_img_mgmt_flash_area_id(slot), &fa);
324+
if (area_id < 0) {
325+
return MGMT_ERR_EUNKNOWN;
326+
}
327+
328+
rc = flash_area_open(area_id, &fa);
324329
if (rc != 0) {
325330
return MGMT_ERR_EUNKNOWN;
326331
}
@@ -682,8 +687,13 @@ img_mgmt_impl_erased_val(int slot, uint8_t *erased_val)
682687
{
683688
const struct flash_area *fa;
684689
int rc;
690+
int area_id = zephyr_img_mgmt_flash_area_id(slot);
691+
692+
if (area_id < 0) {
693+
return MGMT_ERR_EUNKNOWN;
694+
}
685695

686-
rc = flash_area_open(zephyr_img_mgmt_flash_area_id(slot), &fa);
696+
rc = flash_area_open(area_id, &fa);
687697
if (rc != 0) {
688698
return MGMT_ERR_EUNKNOWN;
689699
}

cmd/img_mgmt/src/img_mgmt_state.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,32 +229,47 @@ img_mgmt_state_read(struct mgmt_ctxt *ctxt)
229229
err |= cbor_encode_text_stringz(&image, "hash");
230230
err |= cbor_encode_byte_string(&image, hash, IMAGE_HASH_LEN);
231231

232-
err |= cbor_encode_text_stringz(&image, "bootable");
233-
err |= cbor_encode_boolean(&image, !(flags & IMAGE_F_NON_BOOTABLE));
232+
if (!IMG_MGMT_FRUGAL_LIST || !(flags & IMAGE_F_NON_BOOTABLE)) {
233+
err |= cbor_encode_text_stringz(&image, "bootable");
234+
err |= cbor_encode_boolean(&image, !(flags & IMAGE_F_NON_BOOTABLE));
235+
}
234236

235-
err |= cbor_encode_text_stringz(&image, "pending");
236-
err |= cbor_encode_boolean(&image,
237-
state_flags & IMG_MGMT_STATE_F_PENDING);
237+
if (!IMG_MGMT_FRUGAL_LIST || (state_flags & IMG_MGMT_STATE_F_PENDING)) {
238+
err |= cbor_encode_text_stringz(&image, "pending");
239+
err |= cbor_encode_boolean(&image,
240+
state_flags & IMG_MGMT_STATE_F_PENDING);
241+
}
238242

239-
err |= cbor_encode_text_stringz(&image, "confirmed");
240-
err |= cbor_encode_boolean(&image,
241-
state_flags & IMG_MGMT_STATE_F_CONFIRMED);
243+
if (!IMG_MGMT_FRUGAL_LIST ||
244+
(state_flags & IMG_MGMT_STATE_F_CONFIRMED)) {
245+
err |= cbor_encode_text_stringz(&image, "confirmed");
246+
err |= cbor_encode_boolean(&image,
247+
state_flags & IMG_MGMT_STATE_F_CONFIRMED);
248+
}
242249

243-
err |= cbor_encode_text_stringz(&image, "active");
244-
err |= cbor_encode_boolean(&image,
245-
state_flags & IMG_MGMT_STATE_F_ACTIVE);
250+
if (!IMG_MGMT_FRUGAL_LIST || (state_flags & IMG_MGMT_STATE_F_ACTIVE)) {
251+
err |= cbor_encode_text_stringz(&image, "active");
252+
err |= cbor_encode_boolean(&image,
253+
state_flags & IMG_MGMT_STATE_F_ACTIVE);
254+
}
246255

247-
err |= cbor_encode_text_stringz(&image, "permanent");
248-
err |= cbor_encode_boolean(&image,
249-
state_flags & IMG_MGMT_STATE_F_PERMANENT);
256+
if (!IMG_MGMT_FRUGAL_LIST ||
257+
(state_flags & IMG_MGMT_STATE_F_PERMANENT)) {
258+
err |= cbor_encode_text_stringz(&image, "permanent");
259+
err |= cbor_encode_boolean(&image,
260+
state_flags & IMG_MGMT_STATE_F_PERMANENT);
261+
}
250262

251263
err |= cbor_encoder_close_container(&images, &image);
252264
}
253265

254266
err |= cbor_encoder_close_container(&ctxt->encoder, &images);
255267

256-
err |= cbor_encode_text_stringz(&ctxt->encoder, "splitStatus");
257-
err |= cbor_encode_int(&ctxt->encoder, 0);
268+
/* splitStatus is always 0 so in frugal list it is not present at all */
269+
if (!IMG_MGMT_FRUGAL_LIST) {
270+
err |= cbor_encode_text_stringz(&ctxt->encoder, "splitStatus");
271+
err |= cbor_encode_int(&ctxt->encoder, 0);
272+
}
258273

259274
if (err != 0) {
260275
return MGMT_ERR_ENOMEM;

0 commit comments

Comments
 (0)