You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/11/30 10:10:13 UTC

[GitHub] [mynewt-mcumgr] de-nordic commented on a change in pull request #102: Add image upload support for flash erased at 0

de-nordic commented on a change in pull request #102:
URL: https://github.com/apache/mynewt-mcumgr/pull/102#discussion_r532480115



##########
File path: cmd/img_mgmt/src/img_mgmt.c
##########
@@ -137,21 +137,29 @@ img_mgmt_read_info(int image_slot, struct image_version *ver, uint8_t *hash,
     size_t data_off;
     size_t data_end;
     bool hash_found;
+    uint8_t erased_val;
+    uint32_t erased_val_32;
     int rc;
 
+    rc = img_mgmt_impl_erased_val(image_slot, &erased_val);
+    if (rc != 0) {
+        return MGMT_ERR_EUNKNOWN;
+    }
+
     rc = img_mgmt_impl_read(image_slot, 0, &hdr, sizeof hdr);
     if (rc != 0) {
         return MGMT_ERR_EUNKNOWN;
     }
 
     if (ver != NULL) {
-        memset(ver, 0xff, sizeof(*ver));
+        memset(ver, erased_val, sizeof(*ver));
     }
+    erased_val_32 = erased_val << 24 | erased_val << 16 | erased_val << 8 | erased_val;

Review comment:
       Could be done via some macro as it repeats also at zephyr_img_mgmt.c:61




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org