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 2021/08/09 02:04:38 UTC

[GitHub] [mynewt-newtmgr] LockeKK commented on issue #185: Flash alignment mismatch leads to large overhead with Zephyr mcumgr

LockeKK commented on issue #185:
URL: https://github.com/apache/mynewt-newtmgr/issues/185#issuecomment-894907940


   I found the exact issue. My solution is like this. It squeezed the time from minutes to 17 sec for 340KB binary.
   
   diff --git a/nmxact/nmserial/serial_xport.go b/nmxact/nmserial/serial_xport.go
   index 1c97fc0..164d496 100644
   --- a/nmxact/nmserial/serial_xport.go
   +++ b/nmxact/nmserial/serial_xport.go
   @@ -287,7 +287,7 @@ func (sx *SerialXport) Tx(bytes []byte) error {
                    * carriage return (and possibly LF 2 bytes), */
    
                   /* all totaled, 124 bytes should work */
   -               writeLen := util.Min(124, totlen-written)
   +               writeLen := util.Min(1024, totlen-written)
    
                   writeBytes := base64Data[written : written+writeLen]
                   sx.txRaw(writeBytes)
   diff --git a/nmxact/xact/image.go b/nmxact/xact/image.go
   index b3b332c..95ee2d7 100644
   --- a/nmxact/xact/image.go
   +++ b/nmxact/xact/image.go
   @@ -46,6 +46,7 @@ const IMAGE_UPLOAD_START_WS = 1
    const IMAGE_UPLOAD_DEF_MAX_WS = 5
    const IMAGE_UPLOAD_STATUS_EXPECTED = 0
    const IMAGE_UPLOAD_STATUS_RQ = 1
   +const IMAGE_UPLOAD_CHUNK_ALIGNMENT = 4
    
    type ImageUploadProgressFn func(c *ImageUploadCmd, r *nmp.ImageUploadRsp)
    type ImageUploadCmd struct {
   @@ -150,6 +151,14 @@ func findChunkLen(s sesn.Sesn, hash []byte, upgrade bool, data []byte,
                   chunklen -= overflow
           }
    
   +       //Ensure the chunk length is always aligned as bootloader expected
   +       if chunklen > IMAGE_UPLOAD_CHUNK_ALIGNMENT {
   +               remain_bytes := chunklen % IMAGE_UPLOAD_CHUNK_ALIGNMENT
   +               if remain_bytes != 0 {
   +                       chunklen -= remain_bytes
   +               }
   +       }
   +
           return chunklen, nil
    }
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

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