You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/08/31 18:44:07 UTC

incubator-mynewt-newt git commit: newtmgr image; retire old versions of 'image list' and 'image boot'.

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop faee1f4c6 -> 319e51082


newtmgr image; retire old versions of 'image list' and 'image boot'.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/319e5108
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/319e5108
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/319e5108

Branch: refs/heads/develop
Commit: 319e51082e77f7d48ef09cc57d0c22b07087ca2a
Parents: faee1f4
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Aug 31 11:42:53 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Aug 31 11:42:53 2016 -0700

----------------------------------------------------------------------
 newtmgr/cli/image.go          | 110 +------------------------------------
 newtmgr/protocol/imageboot.go |  90 ------------------------------
 newtmgr/protocol/imagelist.go |  37 -------------
 3 files changed, 2 insertions(+), 235 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/319e5108/newtmgr/cli/image.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 6ddd304..32f3c2d 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -45,58 +45,6 @@ var (
 )
 
 func imageListCmd(cmd *cobra.Command, args []string) {
-	cpm, err := config.NewConnProfileMgr()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	profile, err := cpm.GetConnProfile(ConnProfileName)
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	conn, err := transport.NewConnWithTimeout(profile, time.Second*3)
-	if err != nil {
-		nmUsage(nil, err)
-	}
-	defer conn.Close()
-
-	runner, err := protocol.NewCmdRunner(conn)
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	imageList, err := protocol.NewImageList()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	nmr, err := imageList.EncodeWriteRequest()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	if err := runner.WriteReq(nmr); err != nil {
-		nmUsage(cmd, err)
-	}
-
-	rsp, err := runner.ReadResp()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	iRsp, err := protocol.DecodeImageListResponse(rsp.Data)
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-	fmt.Println("Images:")
-	for i := 0; i < len(iRsp.Images); i++ {
-		fmt.Println("   ", i, ": "+iRsp.Images[i])
-	}
-
-}
-
-func imageListCmd2(cmd *cobra.Command, args []string) {
 	runner, err := getTargetCmdRunner()
 	if err != nil {
 		nmUsage(cmd, err)
@@ -276,45 +224,6 @@ func imageBootCmd(cmd *cobra.Command, args []string) {
 		nmUsage(cmd, err)
 	}
 
-	imageBoot, err := protocol.NewImageBoot()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	if len(args) >= 1 {
-		imageBoot.BootTarget = args[0]
-	}
-	nmr, err := imageBoot.EncodeWriteRequest()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	if err := runner.WriteReq(nmr); err != nil {
-		nmUsage(cmd, err)
-	}
-
-	rsp, err := runner.ReadResp()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
-	iRsp, err := protocol.DecodeImageBootResponse(rsp.Data)
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-	if len(args) == 0 {
-		fmt.Println("    Test image:", iRsp.Test)
-		fmt.Println("    Main image:", iRsp.Main)
-		fmt.Println("    Active img:", iRsp.Active)
-	}
-}
-
-func imageBoot2Cmd(cmd *cobra.Command, args []string) {
-	runner, err := getTargetCmdRunner()
-	if err != nil {
-		nmUsage(cmd, err)
-	}
-
 	imageBoot, err := protocol.NewImageBoot2()
 	if err != nil {
 		nmUsage(cmd, err)
@@ -653,18 +562,11 @@ func imageCmd() *cobra.Command {
 	}
 
 	listCmd := &cobra.Command{
-		Use:   "list2",
-		Short: "Show target images",
-		Run:   imageListCmd2,
-	}
-	imageCmd.AddCommand(listCmd)
-
-	listOldCmd := &cobra.Command{
 		Use:   "list",
 		Short: "Show target images",
 		Run:   imageListCmd,
 	}
-	imageCmd.AddCommand(listOldCmd)
+	imageCmd.AddCommand(listCmd)
 
 	uploadEx := "  newtmgr -c olimex image upload <image_file\n"
 	uploadEx += "  newtmgr -c olimex image upload bin/slinky_zero/apps/slinky.img\n"
@@ -677,9 +579,8 @@ func imageCmd() *cobra.Command {
 	}
 	imageCmd.AddCommand(uploadCmd)
 
-	bootEx := "  newtmgr -c olimex image boot [<version>]\n"
+	bootEx := "  newtmgr -c olimex image boot [<image hash>]\n"
 	bootEx += "  newtmgr -c olimex image boot\n"
-	bootEx += "  newtmgr -c olimex image boot 1.2.3\n"
 
 	bootCmd := &cobra.Command{
 		Use:     "boot",
@@ -689,13 +590,6 @@ func imageCmd() *cobra.Command {
 	}
 	imageCmd.AddCommand(bootCmd)
 
-	boot2Cmd := &cobra.Command{
-		Use:   "boot2",
-		Short: "Which image to boot",
-		Run:   imageBoot2Cmd,
-	}
-	imageCmd.AddCommand(boot2Cmd)
-
 	fileUploadEx := "  newtmgr -c olimex image fileupload <filename> <tgt_file>\n"
 	fileUploadEx += "  newtmgr -c olimex image fileupload sample.lua /sample.lua\n"
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/319e5108/newtmgr/protocol/imageboot.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/imageboot.go b/newtmgr/protocol/imageboot.go
deleted file mode 100644
index b949928..0000000
--- a/newtmgr/protocol/imageboot.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package protocol
-
-import (
-	"encoding/json"
-
-	"fmt"
-	"mynewt.apache.org/newt/util"
-)
-
-type ImageBoot struct {
-	BootTarget string
-	Test       string
-	Main       string
-	Active     string
-	ReturnCode int `json:"rc"`
-}
-
-func NewImageBoot() (*ImageBoot, error) {
-	s := &ImageBoot{}
-	s.BootTarget = ""
-	s.Test = ""
-	s.Main = ""
-	s.Active = ""
-	return s, nil
-}
-
-func (i *ImageBoot) EncodeWriteRequest() (*NmgrReq, error) {
-	nmr, err := NewNmgrReq()
-	if err != nil {
-		return nil, err
-	}
-
-	nmr.Op = NMGR_OP_READ
-	nmr.Flags = 0
-	nmr.Group = NMGR_GROUP_ID_IMAGE
-	nmr.Id = IMGMGR_NMGR_OP_BOOT
-	nmr.Len = 0
-
-	if i.BootTarget != "" {
-		type BootReq struct {
-			Test string `json:"test"`
-		}
-
-		bReq := &BootReq{
-			Test: i.BootTarget,
-		}
-		data, _ := json.Marshal(bReq)
-		nmr.Data = data
-		nmr.Len = uint16(len(data))
-		nmr.Op = NMGR_OP_WRITE
-	}
-	return nmr, nil
-}
-
-func DecodeImageBootResponse(data []byte) (*ImageBoot, error) {
-	i := &ImageBoot{}
-
-	if len(data) == 0 {
-		return i, nil
-	}
-	err := json.Unmarshal(data, &i)
-	if err != nil {
-		return nil, util.NewNewtError(fmt.Sprintf("Invalid incoming json: %s",
-			err.Error()))
-	}
-	if i.ReturnCode != 0 {
-		return nil, util.NewNewtError(fmt.Sprintf("Target error: %d",
-			i.ReturnCode))
-	}
-	return i, nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/319e5108/newtmgr/protocol/imagelist.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/imagelist.go b/newtmgr/protocol/imagelist.go
index 8f4fe8b..47e8514 100644
--- a/newtmgr/protocol/imagelist.go
+++ b/newtmgr/protocol/imagelist.go
@@ -22,16 +22,11 @@ package protocol
 import (
 	"encoding/base64"
 	"encoding/hex"
-	"encoding/json"
 	"fmt"
 
 	"mynewt.apache.org/newt/util"
 )
 
-type ImageList struct {
-	Images []string
-}
-
 const (
 	IMGMGR_NMGR_OP_LIST     = 0
 	IMGMGR_NMGR_OP_UPLOAD   = 1
@@ -60,35 +55,3 @@ func HashEncode(src string) (string, error) {
 	}
 	return base64.StdEncoding.EncodeToString(imgHex), nil
 }
-
-func NewImageList() (*ImageList, error) {
-	s := &ImageList{}
-	s.Images = []string{}
-	return s, nil
-}
-
-func (i *ImageList) EncodeWriteRequest() (*NmgrReq, error) {
-	nmr, err := NewNmgrReq()
-	if err != nil {
-		return nil, err
-	}
-
-	nmr.Op = NMGR_OP_READ
-	nmr.Flags = 0
-	nmr.Group = NMGR_GROUP_ID_IMAGE
-	nmr.Id = IMGMGR_NMGR_OP_LIST
-	nmr.Len = 0
-
-	return nmr, nil
-}
-
-func DecodeImageListResponse(data []byte) (*ImageList, error) {
-	list := &ImageList{}
-
-	err := json.Unmarshal(data, &list)
-	if err != nil {
-		return nil, util.NewNewtError(fmt.Sprintf("Invalid incoming json: %s",
-			err.Error()))
-	}
-	return list, nil
-}


Fwd: incubator-mynewt-newt git commit: newtmgr image; retire old versions of 'image list' and 'image boot'.

Posted by marko kiiskila <ma...@runtime.io>.
Hi,

heads-up in develop; I finally retired the old versions of ‘image list’/‘image boot’ commands from
newtmgr. Now images can only be referenced using hash of the image.
I also removed the matching portion from firmware side to reduce code size.

If you’ve been using the new versions of these commands in the protocol, nothing should change.
Command line of newtmgr has changed such that ‘newtmgr list2’ is now ‘newtmgr list’ and
‘newtmgr boot2’ is now ‘newtmgr boot’. I’m sorry for this inconvenience.

Let me know if you run into trouble.

> Begin forwarded message:
> 
> From: marko@apache.org
> Subject: incubator-mynewt-newt git commit: newtmgr image; retire old versions of 'image list' and 'image boot'.
> Date: August 31, 2016 at 11:44:07 AM PDT
> To: commits@mynewt.incubator.apache.org
> Reply-To: dev@mynewt.incubator.apache.org
> 
> Repository: incubator-mynewt-newt
> Updated Branches:
>  refs/heads/develop faee1f4c6 -> 319e51082
> 
> 
> newtmgr image; retire old versions of 'image list' and 'image boot'.
> 
>