You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/09/09 15:53:54 UTC
[1/2] incubator-mynewt-newt git commit: newtmgr - log hex dump of
req+rsp to debug log.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop 40c8f6811 -> 657ff8d1f
newtmgr - log hex dump of req+rsp to debug log.
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/efd6915f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/efd6915f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/efd6915f
Branch: refs/heads/develop
Commit: efd6915f166d9e2aedb87a6f1b7e6f34bb6856eb
Parents: 40c8f68
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Sep 8 18:48:18 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Sep 8 18:48:18 2016 -0700
----------------------------------------------------------------------
newtmgr/protocol/cmdrunner.go | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/efd6915f/newtmgr/protocol/cmdrunner.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/cmdrunner.go b/newtmgr/protocol/cmdrunner.go
index 5b7d31a..71372d4 100644
--- a/newtmgr/protocol/cmdrunner.go
+++ b/newtmgr/protocol/cmdrunner.go
@@ -20,6 +20,8 @@
package protocol
import (
+ "encoding/hex"
+
log "github.com/Sirupsen/logrus"
"mynewt.apache.org/newt/newtmgr/transport"
@@ -37,11 +39,9 @@ func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
}
bytes := pkt.GetBytes()
- bytes = bytes[8:]
-
- log.Debugf("before deserializing:%s", string(bytes))
+ log.Debugf("Rx packet dump:\n%s", hex.Dump(bytes))
- nmr, err := DeserializeNmgrReq(pkt.GetBytes())
+ nmr, err := DeserializeNmgrReq(bytes)
if err != nil {
return nil, err
}
@@ -61,6 +61,8 @@ func (cr *CmdRunner) WriteReq(nmr *NmgrReq) error {
return err
}
+ log.Debugf("Tx packet dump:\n%s", hex.Dump(data))
+
pkt, err := transport.NewPacket(uint16(len(data)))
if err != nil {
return err
[2/2] incubator-mynewt-newt git commit: newtmgr - Add "image
coreconvert" command.
Posted by cc...@apache.org.
newtmgr - Add "image coreconvert" command.
This command converts a raw flash dump to an elf core file.
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/657ff8d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/657ff8d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/657ff8d1
Branch: refs/heads/develop
Commit: 657ff8d1fee245a3338c8b6e61606c0027a686cc
Parents: efd6915
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Sep 8 18:48:35 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Sep 8 18:48:35 2016 -0700
----------------------------------------------------------------------
newtmgr/cli/image.go | 49 ++++++++++++++++++++++-----------------
newtmgr/core/core_convert.go | 29 +++++++++++++++++++++++
2 files changed, 57 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/657ff8d1/newtmgr/cli/image.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 32f3c2d..04ee6df 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -406,6 +406,21 @@ func fileDownloadCmd(cmd *cobra.Command, args []string) {
fmt.Println("Done")
}
+func coreConvertCmd(cmd *cobra.Command, args []string) {
+ if len(args) < 2 {
+ nmUsage(cmd, nil)
+ return
+ }
+
+ coreConvert, err := core.ConvertFilenames(args[0], args[1])
+ if err != nil {
+ nmUsage(cmd, err)
+ return
+ }
+
+ fmt.Printf("Corefile created for\n %x\n", coreConvert.ImageHash)
+}
+
func coreDownloadCmd(cmd *cobra.Command, args []string) {
if len(args) < 1 {
nmUsage(cmd, errors.New("Need to specify target filename to download"))
@@ -448,34 +463,19 @@ func coreDownloadCmd(cmd *cobra.Command, args []string) {
/*
* Download finished. Now convert to ELF corefile format.
*/
- coreConvert := core.NewCoreConvert()
-
- file, err = os.OpenFile(tmpName, os.O_RDONLY, 0)
+ coreConvert, err := core.ConvertFilenames(tmpName, args[0])
if err != nil {
- nmUsage(cmd, util.NewNewtError(fmt.Sprintf(
- "Cannot open file %s - %s", tmpName, err.Error())))
+ nmUsage(cmd, err)
+ return
}
- coreConvert.Source = file
-
- file, err = os.OpenFile(args[0], os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
if err != nil {
- nmUsage(cmd, util.NewNewtError(fmt.Sprintf(
- "Cannot open file %s - %s", args[0], err.Error())))
+ fmt.Println(err)
+ return
}
- coreConvert.Target = file
-
- err = coreConvert.Convert()
- coreConvert.Source.Close()
- coreConvert.Target.Close()
os.Remove(tmpName)
-
- if err != nil {
- fmt.Println(err)
- } else {
- fmt.Printf("Corefile created for\n %x\n", coreConvert.ImageHash)
- }
+ fmt.Printf("Corefile created for\n %x\n", coreConvert.ImageHash)
}
func coreListCmd(cmd *cobra.Command, args []string) {
@@ -637,6 +637,13 @@ func imageCmd() *cobra.Command {
coreDownloadCmd.Flags().Uint32VarP(&coreNumBytes, "bytes", "n", 0, "Number of bytes of the core to download")
imageCmd.AddCommand(coreDownloadCmd)
+ coreConvertCmd := &cobra.Command{
+ Use: "coreconvert <core-filename> <elf-filename>",
+ Short: "Convert core to elf",
+ Run: coreConvertCmd,
+ }
+ imageCmd.AddCommand(coreConvertCmd)
+
coreEraseEx := " newtmgr -c olimex image coreerase\n"
coreEraseCmd := &cobra.Command{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/657ff8d1/newtmgr/core/core_convert.go
----------------------------------------------------------------------
diff --git a/newtmgr/core/core_convert.go b/newtmgr/core/core_convert.go
index fd195b6..e07370a 100644
--- a/newtmgr/core/core_convert.go
+++ b/newtmgr/core/core_convert.go
@@ -302,3 +302,32 @@ func (cc *CoreConvert) Convert() error {
}
return nil
}
+
+func ConvertFilenames(srcFilename string,
+ dstFilename string) (*CoreConvert, error) {
+
+ coreConvert := NewCoreConvert()
+
+ var err error
+
+ coreConvert.Source, err = os.OpenFile(srcFilename, os.O_RDONLY, 0)
+ if err != nil {
+ return coreConvert, util.FmtNewtError("Cannot open file %s - %s",
+ srcFilename, err.Error())
+ }
+ defer coreConvert.Source.Close()
+
+ coreConvert.Target, err = os.OpenFile(dstFilename,
+ os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
+ if err != nil {
+ return coreConvert, util.FmtNewtError("Cannot open file %s - %s",
+ dstFilename, err.Error())
+ }
+ defer coreConvert.Target.Close()
+
+ if err := coreConvert.Convert(); err != nil {
+ return coreConvert, err
+ }
+
+ return coreConvert, nil
+}