Hi Kevin,

On Wed, Aug 16, 2017 at 11:45:52PM +0200, Kevin Townsend wrote:
> I'm doing some tests with newtmgr over serial since this is the lowest 
> cost mechanism for many users (no J-Link required), and the update 
> process as I understand it is as follows:
> 
> - $ newtmgr -c serial1 image upload mysignedimage.img
>    ^ This will write the new image in slot=1 with no flags set
> - $ newtmgr -c serial1 image test 
> 4d0ff81e083f8cc9d428e8bb70ed86ae98f237ce8dd59bfd33f7493874addd1d
>    ^ This will set the flags to 'pending' and when you reset, the image 
> will be moved into slot 0 and the old image will be switched to slot 1
> - $ newtmgr -c serial1 reset
>    ^ Wait for the flash switch to finish ...
>      The new image is now marked as 'active' but the old image has the 
> 'confirmed' flag set so resetting again will cause the device to revert 
> to the old image if no action is taken,

All correct.

> so first we need to ...
> - $ newtmgr -c serial1 image confirm 
> 4d0ff81e083f8cc9d428e8bb70ed86ae98f237ce8dd59bfd33f7493874addd1d
>    ^ This will 'confirm' the new image (I don't think the hash is 
> necessary though), and then the old image will no longer be marked as 
> 'confirmed' and resetting will maintain the new image. Notice no more 
> 'confirmed' flag on slot 1 here, and slot 0 is now 'confirmed'
>      $ newtmgr -c serial1 image list
>      Images:
>       slot=0
>          version: 0.7.0
>          bootable: true
>          flags: active confirmed
>          hash: 
> 4d0ff81e083f8cc9d428e8bb70ed86ae98f237ce8dd59bfd33f7493874addd1d
>       slot=1
>          version: 0.6.0
>          bootable: true
>          flags:
>          hash: 
> 9a8fce478019c5e806253c307d32ddeab559ff6dc2577670ff6e0b1cb72f929b
>      Split status: N/A (0)
> 
> What confused me is that no matter if I use the has or not with 'image 
> confirm' I always get 'Error: 1' in the output, which is confusing.
> 
> $ newtmgr -c serial1 image confirm 
> 4d0ff81e083f8cc9d428e8bb70ed86ae98f237ce8dd59bfd33f7493874addd1d
> Error: 1
> 
> $ newtmgr -c serial1 image confirm
> Error: 1
> 
> Is there a logical explanation for this? I'm running the 1.1 binaries 
> installed via brew on OS X 10.11.6.

The "image confirm" command behaves differently if you specify the hash
argument:

* Confirm-without-hash: This is the "safe" version of the command.  It
confirms the currently-running image.  This can only be used when you
are "testing out" an image (i.e., slot 0 is active but not confirmed,
slot 1 is confirmed but not active).

* Confirm <hash>: This is the unsafe version.  It allows you to bypass
the "image test" step.  Say you have the following image state:

    slot 0: active confirmed, hash=xxx
    slot 1: <no flags>, hash=yyy

If you issue an "image confirm <slot-1>" command and reset the device,
the image state will look like this:

    slot 0: active confirmed, hash=yyy
    slot 1: <no flags>, hash=xxx

In other words, this version of "image confirm" permanently swaps to an
untested image.  This might be useful for upgrading lots of devices
to a known-good image.

Regarding the "Error: 1" message - I'm afraid I don't have an
explanation.  Are you sending the confirms immediately after the "image
list" commands?  That is, is the board in the (slot0: active confirmed,
slot1: <no flags>) state when you get the error?  If so, I am not able
to reproduce that behavior:

    [ccollins@ccollins-mac:~/repos/mynewt/core]$ newtmgr -c bhd-oic --name c5 
image list
    Images:
     slot=0
        version: 5.5.5.5
        bootable: true
        flags: active confirmed
        hash: ec4044b698f06f9d3128b2b900c4da0d15a500b77f0378a2bad5f87b43c1bd42
     slot=1
        version: 0.0.0
        bootable: true
        flags:
        hash: 59477eca25d3deb4edc0b1ef80f1f517f37b90d127ef33597d21ba171446d693
    Split status: N/A (0)

    [ccollins@ccollins-mac:~/repos/mynewt/core]$ newtmgr -c bhd-oic --name c5 
image confirm
    Images:
     slot=0
        version: 5.5.5.5
        bootable: true
        flags: active confirmed
        hash: ec4044b698f06f9d3128b2b900c4da0d15a500b77f0378a2bad5f87b43c1bd42
     slot=1
        version: 0.0.0
        bootable: true
        flags:
        hash: 59477eca25d3deb4edc0b1ef80f1f517f37b90d127ef33597d21ba171446d693
    Split status: N/A (0)

    [ccollins@ccollins-mac:~/repos/mynewt/core]$ newtmgr -c bhd-oic --name c5 
image confirm ec4044b698f06f9d3128b2b900c4da0d15a500b77f0378a2bad5f87b43c1bd42
    Images:
     slot=0
        version: 5.5.5.5
        bootable: true
        flags: active confirmed
        hash: ec4044b698f06f9d3128b2b900c4da0d15a500b77f0378a2bad5f87b43c1bd42
     slot=1
        version: 0.0.0
        bootable: true
        flags:
        hash: 59477eca25d3deb4edc0b1ef80f1f517f37b90d127ef33597d21ba171446d693
    Split status: N/A (0)

Chris

Reply via email to