utzig closed pull request #978: Fix boot_serial to follow flash write alignment
URL: https://github.com/apache/mynewt-core/pull/978
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/boot/boot_serial/src/boot_serial.c 
b/boot/boot_serial/src/boot_serial.c
index b6574d435..7bc666893 100644
--- a/boot/boot_serial/src/boot_serial.c
+++ b/boot/boot_serial/src/boot_serial.c
@@ -190,6 +190,7 @@ bs_upload(char *buf, int len)
     uint8_t img_data[512];
     long long int off = UINT_MAX;
     size_t img_blen = 0;
+    uint8_t rem_bytes;
     long long int data_len = UINT_MAX;
     size_t slen;
     char name_str[8];
@@ -314,6 +315,12 @@ bs_upload(char *buf, int len)
         rc = 0;
         goto out;
     }
+    if (curr_off + img_blen < img_size) {
+        rem_bytes = img_blen % flash_area_align(fap);
+        if (rem_bytes) {
+            img_blen -= rem_bytes;
+        }
+    }
     rc = flash_area_write(fap, curr_off, img_data, img_blen);
     if (rc == 0) {
         curr_off += img_blen;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to