[mynewt-imgmod] branch master updated: go.mod: Update to mynewt-artifact 0.0.19

2020-10-27 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git


The following commit(s) were added to refs/heads/master by this push:
 new 076b983  go.mod: Update to mynewt-artifact 0.0.19
076b983 is described below

commit 076b9838b924e131221865eb4bfd592095835d8d
Author: Christopher Collins 
AuthorDate: Wed Aug 12 16:56:09 2020 -0700

go.mod: Update to mynewt-artifact 0.0.19

This adds some missing fields to the `imgmod image show` output.
---
 go.mod | 2 +-
 go.sum | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/go.mod b/go.mod
index a463cca..66114d1 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
 module mynewt.apache.org/imgmod
 
 require (
-   github.com/apache/mynewt-artifact v0.0.18
+   github.com/apache/mynewt-artifact v0.0.19
github.com/otiai10/copy v1.0.1
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2
diff --git a/go.sum b/go.sum
index 7d5fabe..a46f797 100644
--- a/go.sum
+++ b/go.sum
@@ -13,6 +13,8 @@ github.com/apache/mynewt-artifact v0.0.17 
h1:O1lqIEygow3vFHHF9PllPoBWIK51aV0RsXP
 github.com/apache/mynewt-artifact v0.0.17/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/apache/mynewt-artifact v0.0.18 
h1:E5em2q/hbkDU0/xSGJozWdKSo42XJcZVmSLj20G1KXQ=
 github.com/apache/mynewt-artifact v0.0.18/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
+github.com/apache/mynewt-artifact v0.0.19 
h1:g/LjJvl0amG38INCEf1Gl/i0Z8wJl0dgN2elCcL0hIg=
+github.com/apache/mynewt-artifact v0.0.19/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod 
h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod 
h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod 
h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=



[mynewt-newt] branch master updated (d80e771 -> b57111d)

2020-10-27 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from d80e771  build.sh: Invoke sh as a login shell
 add b57111d  upgrade: Don't abort if repo references bad commit

No new revisions were added by this update.

Summary of changes:
 newt/install/install.go | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)



[mynewt-newt] branch master updated (d80e771 -> b57111d)

2020-10-27 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from d80e771  build.sh: Invoke sh as a login shell
 add b57111d  upgrade: Don't abort if repo references bad commit

No new revisions were added by this update.

Summary of changes:
 newt/install/install.go | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)



[mynewt-newt] branch master updated (d254d7c -> d80e771)

2020-10-27 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from d254d7c  builder: Add build profile to the environment variables
 add d80e771  build.sh: Invoke sh as a login shell

No new revisions were added by this update.

Summary of changes:
 build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[mynewt-newt] branch master updated: builder: Add build profile to the environment variables

2020-10-25 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new d254d7c  builder: Add build profile to the environment variables
d254d7c is described below

commit d254d7cc5019b42c0c773a06cfe0ec4a6f7ee44d
Author: Casper Meijn 
AuthorDate: Fri Oct 23 09:57:23 2020 +0200

builder: Add build profile to the environment variables
---
 newt/builder/buildutil.go | 17 ++---
 newt/builder/extcmd.go| 15 ---
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/newt/builder/buildutil.go b/newt/builder/buildutil.go
index 9fe2ecb..7bc83f6 100644
--- a/newt/builder/buildutil.go
+++ b/newt/builder/buildutil.go
@@ -247,13 +247,14 @@ func SlotEnvVars(bspPkg *pkg.BspPackage,
 }
 
 type UserEnvParams struct {
-   Lpkg   *pkg.LocalPackage
-   TargetName string // Short name
-   AppNamestring
-   BuildName  string // "app" or "loader"
-   UserSrcDir string // "" if none
-   UserIncDir string // "" if none
-   WorkDirstring
+   Lpkg *pkg.LocalPackage
+   TargetName   string // Short name
+   BuildProfile string
+   AppName  string
+   BuildNamestring // "app" or "loader"
+   UserSrcDir   string // "" if none
+   UserIncDir   string // "" if none
+   WorkDir  string
 }
 
 // UserEnvVars calculates the set of environment variables required by external
@@ -279,6 +280,8 @@ func UserEnvVars(params UserEnvParams) map[string]string {
m["MYNEWT_USER_INCLUDE_DIR"] = params.UserIncDir
}
 
+   m["MYNEWT_BUILD_PROFILE"] = params.BuildProfile
+
return m
 }
 
diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go
index 4819dfe..3424cc0 100644
--- a/newt/builder/extcmd.go
+++ b/newt/builder/extcmd.go
@@ -112,13 +112,14 @@ func (t *TargetBuilder) envVarsForCmd(sf stage.StageFunc, 
userSrcDir string,
}
 
p := UserEnvParams{
-   Lpkg:   sf.Pkg,
-   TargetName: t.target.FullName(),
-   AppName:t.appPkg.FullName(),
-   BuildName:  buildName,
-   UserSrcDir: userSrcDir,
-   UserIncDir: userIncDir,
-   WorkDir:workDir,
+   Lpkg: sf.Pkg,
+   TargetName:   t.target.FullName(),
+   BuildProfile: t.target.BuildProfile,
+   AppName:  t.appPkg.FullName(),
+   BuildName:buildName,
+   UserSrcDir:   userSrcDir,
+   UserIncDir:   userIncDir,
+   WorkDir:  workDir,
}
uenv := UserEnvVars(p)
for k, v := range uenv {



[mynewt-core] branch master updated: apps: Fix cbmem sizes

2020-10-14 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 868cea2  apps: Fix cbmem sizes
868cea2 is described below

commit 868cea2d8841cb94f78704b58bc4d2aea911efb3
Author: Casper Meijn 
AuthorDate: Tue Oct 13 21:17:35 2020 +0200

apps: Fix cbmem sizes

The size passed to cbmem_init is in bytes. Therefore the datatype of
cbmem_buf needs to be one byte long.
---
 apps/sensors_test/src/main.c  | 1 -
 apps/slinky/src/main.c| 2 +-
 apps/slinky_oic/src/main.c| 2 +-
 apps/splitty/src/main.c   | 2 +-
 docs/os/modules/logs/logs.rst | 3 ++-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 363a3fe..e2447ea 100644
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -106,7 +106,6 @@ static int sensor_oic_gap_event(struct ble_gap_event 
*event, void *arg);
 /* Task 1 */
 #define TASK1_PRIO (8)
 #define TASK1_STACK_SIZEOS_STACK_ALIGN(192)
-#define MAX_CBMEM_BUF 600
 static struct os_task task1;
 static volatile int g_task1_loops;
 
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index b1c8f3e..e352303 100644
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -79,7 +79,7 @@ static struct conf_handler test_conf_handler = {
 static uint8_t test8;
 static uint8_t test8_shadow;
 static char test_str[32];
-static uint32_t cbmem_buf[MAX_CBMEM_BUF];
+static uint8_t cbmem_buf[MAX_CBMEM_BUF];
 static struct cbmem cbmem;
 
 static char *
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index 35d5e9b..5d38f6b 100644
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -89,7 +89,7 @@ static struct conf_handler test_conf_handler = {
 static uint8_t test8;
 static uint8_t test8_shadow;
 static char test_str[32];
-static uint32_t cbmem_buf[MAX_CBMEM_BUF];
+static uint8_t cbmem_buf[MAX_CBMEM_BUF];
 static struct cbmem cbmem;
 
 static char *
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index e3800fd..8ef8820 100644
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -73,7 +73,7 @@ STATS_NAME_START(gpio_stats)
 STATS_NAME(gpio_stats, toggles)
 STATS_NAME_END(gpio_stats)
 
-static uint32_t cbmem_buf[MAX_CBMEM_BUF];
+static uint8_t cbmem_buf[MAX_CBMEM_BUF];
 static struct cbmem cbmem;
 
 static void
diff --git a/docs/os/modules/logs/logs.rst b/docs/os/modules/logs/logs.rst
index 2be7c79..de28a7b 100644
--- a/docs/os/modules/logs/logs.rst
+++ b/docs/os/modules/logs/logs.rst
@@ -157,7 +157,8 @@ circular buffer.
 
 #include 
 
-static uint32_t cbmem_buf[MAX_CBMEM_BUF];
+#define MAX_CBMEM_BUF 300
+static uint8_t cbmem_buf[MAX_CBMEM_BUF];
 static struct cbmem cbmem;
 
 



[mynewt-core] branch master updated: sys/log/cbmem: Fix return code for early break in log_cbmem_walk

2020-10-10 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new bf32947  sys/log/cbmem: Fix return code for early break in 
log_cbmem_walk
bf32947 is described below

commit bf329478be3e737f33abf7a00c9ea15f6b38bd32
Author: Casper Meijn 
AuthorDate: Tue Oct 6 19:59:18 2020 +0200

sys/log/cbmem: Fix return code for early break in log_cbmem_walk

The return code of succesfull log_cbmem_walk was 0, even when the loop
ended early. In case of an early loop break, we want to return the rc of
the walked function.
This is needed to make `newtmgr log show --all` work, as the rc is
passed to the client to indicate more data available.
---
 sys/log/full/src/log_cbmem.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sys/log/full/src/log_cbmem.c b/sys/log/full/src/log_cbmem.c
index 31f163e..e7194e7 100644
--- a/sys/log/full/src/log_cbmem.c
+++ b/sys/log/full/src/log_cbmem.c
@@ -176,6 +176,7 @@ log_cbmem_walk(struct log *log, log_walk_func_t walk_func,
 struct cbmem_entry_hdr *hdr;
 struct cbmem_iter iter;
 int rc;
+int walk_rc = 0;
 
 cbmem = (struct cbmem *) log->l_arg;
 
@@ -190,7 +191,7 @@ log_cbmem_walk(struct log *log, log_walk_func_t walk_func,
 if (log_offset->lo_ts < 0) {
 hdr = cbmem->c_entry_end;
 if (hdr != NULL) {
-rc = walk_func(log, log_offset, (void *)hdr, hdr->ceh_len);
+walk_rc = walk_func(log, log_offset, (void *)hdr, hdr->ceh_len);
 }
 } else {
 cbmem_iter_start(cbmem, );
@@ -200,8 +201,8 @@ log_cbmem_walk(struct log *log, log_walk_func_t walk_func,
 break;
 }
 
-rc = walk_func(log, log_offset, (void *)hdr, hdr->ceh_len);
-if (rc == 1) {
+walk_rc = walk_func(log, log_offset, (void *)hdr, hdr->ceh_len);
+if (walk_rc != 0) {
 break;
 }
 }
@@ -212,7 +213,7 @@ log_cbmem_walk(struct log *log, log_walk_func_t walk_func,
 goto err;
 }
 
-return (0);
+return (walk_rc);
 err:
 return (rc);
 }



[mynewt-artifact] branch master updated: sec: Fix infinite loop

2020-08-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
 new aa99c4c  sec: Fix infinite loop
aa99c4c is described below

commit aa99c4ccd95b2da7d2ccc916b287faf509146e99
Author: Christopher Collins 
AuthorDate: Thu Aug 20 14:07:48 2020 -0700

sec: Fix infinite loop

If the caller of EncryptAES() supplied a nonce shorter than 16 bytes,
the function would enter an endless loop.
---
 sec/encrypt.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sec/encrypt.go b/sec/encrypt.go
index 8d142e3..97aaaec 100644
--- a/sec/encrypt.go
+++ b/sec/encrypt.go
@@ -263,7 +263,7 @@ func EncryptAES(plain []byte, secret []byte, nonce []byte) 
([]byte, error) {
 
iv := nonce
for len(iv) < 16 {
-   iv = append(nonce, 0)
+   iv = append(iv, 0)
}
 
stream := cipher.NewCTR(blk, iv)



[mynewt-newt] branch master updated: mfg/README.md: Section describing MMR structure

2020-08-13 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new 10a946c  mfg/README.md: Section describing MMR structure
10a946c is described below

commit 10a946ce5b83dc0020bd4c638c5298227b091dc8
Author: Christopher Collins 
AuthorDate: Wed Aug 12 16:47:53 2020 -0700

mfg/README.md: Section describing MMR structure
---
 newt/mfg/README.md | 55 ++
 1 file changed, 55 insertions(+)

diff --git a/newt/mfg/README.md b/newt/mfg/README.md
index 8c29a27..ceb4340 100644
--- a/newt/mfg/README.md
+++ b/newt/mfg/README.md
@@ -105,6 +105,61 @@ The `meta` manifest object describes the contents of an 
mfgimage's MMR.  It cons
 | `flash_map_present`   | `true` if the MMR contains a set of flash area TLVs; 
`false` otherwise. |
 | `mmrs`| An array of references to external MMRs. |
 
+### MMR Structure
+
+Every mfgimage contains an MMR (manufacturing meta region).  The MMR is always 
located at the end of a flash area (that is, the last byte in the MMR occupies 
the last byte in the flash area).
+
+In a boot mfgimage, the MMR must go in the first flash area, i.e., the area 
containing the boot loader.  A non-boot mfgimage can place its MMR in any flash 
area.
+
+The reason a boot mfgimage's MMR must go in the boot loader area is to solve a 
boot strapping problem. The flash map that bsp.yml defines is not necessarily 
the flash map that every device uses; it is just the flash map that gets 
embedded in newly built mfg images.  This is so becauase the flash map itself 
is embedded in the boot mfgimage's MMR. If we change the contents of bsp.yml 
and then start manufacturing devices with a new mfgimage, we now have two 
different flash maps being used i [...]
+
+An MMR has three basic components: header, TLVs, and footer.
+
+
+```
+ 0   1   2   3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -,
+|Version (0x01) |  0xff padding |   >-- 
Header
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -'
+|   TLV type|   TLV size| TLV data ("TLV size" bytes)   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   ~
+~   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|   TLV type|   TLV size| TLV data ("TLV size" bytes)   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   ~
+~   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -,
+|   Region size | 0xff padding  |   \
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+>- 
Footer
+|   Magic (0x3bb2a269)  |   /
++-+-+-+-+-+--+-+-+-+-end of boot loader area+-+-+-+-+-+-+-+-+-+-+ -'
+```
+
+All numeric fields are in host byte order (typically little endian).
+
+The number of TLVs is variable; two are shown above for illustrative purposes.
+
+*Header*
+
+| Field | Description |
+| - | --- |
+| Version | Manufacturing meta version number; always 0x01. |
+
+*TLVs*
+
+| Field | Description |
+| - | --- |
+| TLV type | Indicates the type of data to follow. |
+| TLV size | The number of bytes of data to follow. |
+| TLV data | TLV-size bytes of data. |
+
+*Footer*
+
+| Field | Description |
+| - | --- |
+| Region size | The size, in bytes, of the entire manufacturing meta region; 
includes header, TLVs, and footer. |
+| Magic | indicates the presence of the manufacturing meta region. |
 
 ### Design
 



[mynewt-artifact] annotated tag v0.0.19 updated (7b5e1d8 -> 8029298)

2020-08-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.19
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.19 was modified! ***

from 7b5e1d8  (commit)
  to 8029298  (tag)
 tagging 7b5e1d873e28c52aa9142f0ee5194b3069a9457d (commit)
 replaces v0.0.18
  by Christopher Collins
  on Wed Aug 12 16:55:28 2020 -0700

- Log -
image: Add some missing fields to json conversion
---


No new revisions were added by this update.

Summary of changes:



[mynewt-artifact] 01/03: image: Add some missing fields to json conversion

2020-08-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git

commit 8fe37e2c13ca5e9f308a1ce52fa41df72626b676
Author: Christopher Collins 
AuthorDate: Wed Aug 12 14:32:47 2020 -0700

image: Add some missing fields to json conversion
---
 image/map.go | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/image/map.go b/image/map.go
index 947cb88..7e95aa0 100644
--- a/image/map.go
+++ b/image/map.go
@@ -31,6 +31,7 @@ func (h *ImageHdr) Map(offset int) map[string]interface{} {
"_offset": offset,
"flags":   h.Flags,
"hdr_sz":  h.HdrSz,
+   "prot_sz": h.ProtSz,
"img_sz":  h.ImgSz,
"magic":   h.Magic,
"vers":h.Vers.String(),
@@ -72,6 +73,12 @@ func (img *Image) Map() (map[string]interface{}, error) {
m := map[string]interface{}{}
m["header"] = img.Header.Map(offs.Header)
m["body"] = rawBodyMap(offs.Body)
+
+   if img.Header.ProtSz > 0 {
+   protTrailer := img.ProtTrailer()
+   m["prot_trailer"] = protTrailer.Map(offs.ProtTrailer)
+   }
+
trailer := img.Trailer()
m["trailer"] = trailer.Map(offs.Trailer)
 



[mynewt-artifact] 02/03: Add some comments

2020-08-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git

commit 30b07ba324c12550223389445e375866cf544ec7
Author: Christopher Collins 
AuthorDate: Wed Aug 12 14:33:07 2020 -0700

Add some comments
---
 image/create.go | 16 
 1 file changed, 16 insertions(+)

diff --git a/image/create.go b/image/create.go
index 225a386..ff5d400 100644
--- a/image/create.go
+++ b/image/create.go
@@ -100,6 +100,7 @@ func sigTlvType(key sec.PrivSignKey) uint8 {
}
 }
 
+// GenerateHWKeyIndexTLV creates a hardware key index TLV.
 func GenerateHWKeyIndexTLV(secretIndex uint32) (ImageTlv, error) {
id := make([]byte, 4)
binary.LittleEndian.PutUint32(id, secretIndex)
@@ -113,6 +114,7 @@ func GenerateHWKeyIndexTLV(secretIndex uint32) (ImageTlv, 
error) {
}, nil
 }
 
+// GenerateNonceTLV creates a nonce TLV given a nonce.
 func GenerateNonceTLV(nonce []byte) (ImageTlv, error) {
return ImageTlv{
Header: ImageTlvHdr{
@@ -124,6 +126,7 @@ func GenerateNonceTLV(nonce []byte) (ImageTlv, error) {
}, nil
 }
 
+// GenerateEncTlv creates an encryption-secret TLV given a secret.
 func GenerateEncTlv(cipherSecret []byte) (ImageTlv, error) {
var encType uint8
 
@@ -147,6 +150,7 @@ func GenerateEncTlv(cipherSecret []byte) (ImageTlv, error) {
}, nil
 }
 
+// GenerateSig signs an image using an rsa key.
 func GenerateSigRsa(key sec.PrivSignKey, hash []byte) ([]byte, error) {
opts := rsa.PSSOptions{
SaltLength: rsa.PSSSaltLengthEqualsHash,
@@ -160,6 +164,7 @@ func GenerateSigRsa(key sec.PrivSignKey, hash []byte) 
([]byte, error) {
return signature, nil
 }
 
+// GenerateSig signs an image using an ec key.
 func GenerateSigEc(key sec.PrivSignKey, hash []byte) ([]byte, error) {
r, s, err := ecdsa.Sign(rand.Reader, key.Ec, hash)
if err != nil {
@@ -187,6 +192,7 @@ func GenerateSigEc(key sec.PrivSignKey, hash []byte) 
([]byte, error) {
return signature, nil
 }
 
+// GenerateSig signs an image using an ed25519 key.
 func GenerateSigEd25519(key sec.PrivSignKey, hash []byte) ([]byte, error) {
sig := ed25519.Sign(*key.Ed25519, hash)
 
@@ -199,6 +205,7 @@ func GenerateSigEd25519(key sec.PrivSignKey, hash []byte) 
([]byte, error) {
return sig, nil
 }
 
+// GenerateSig signs an image.
 func GenerateSig(key sec.PrivSignKey, hash []byte) (sec.Sig, error) {
pub := key.PubKey()
typ, err := pub.SigType()
@@ -238,6 +245,8 @@ func GenerateSig(key sec.PrivSignKey, hash []byte) 
(sec.Sig, error) {
}, nil
 }
 
+// BuildKeyHash produces a key-hash TLV given a public verification key.  Users
+// do not normally need to call this.  Call BuildSigTlvs instead.
 func BuildKeyHashTlv(keyBytes []byte) ImageTlv {
data := sec.RawKeyHash(keyBytes)
return ImageTlv{
@@ -250,6 +259,8 @@ func BuildKeyHashTlv(keyBytes []byte) ImageTlv {
}
 }
 
+// BuildSigTlvs signs an image and creates a pair of TLVs representing the
+// signature.
 func BuildSigTlvs(keys []sec.PrivSignKey, hash []byte) ([]ImageTlv, error) {
var tlvs []ImageTlv
 
@@ -282,6 +293,7 @@ func BuildSigTlvs(keys []sec.PrivSignKey, hash []byte) 
([]ImageTlv, error) {
return tlvs, nil
 }
 
+// GeneratePlainSecret randomly generates a 16-byte image-encrypting secret.
 func GeneratePlainSecret() ([]byte, error) {
plainSecret := make([]byte, 16)
if _, err := rand.Read(plainSecret); err != nil {
@@ -291,6 +303,7 @@ func GeneratePlainSecret() ([]byte, error) {
return plainSecret, nil
 }
 
+// GenerateImage produces an Image object from a set of image creation options.
 func GenerateImage(opts ImageCreateOpts) (Image, error) {
ic := NewImageCreator()
 
@@ -365,6 +378,7 @@ func GenerateImage(opts ImageCreateOpts) (Image, error) {
return ri, nil
 }
 
+// calcHash calculates the sha256 for an image with the given components.
 func calcHash(initialHash []byte, hdr ImageHdr, pad []byte,
plainBody []byte, protTlvs []ImageTlv) ([]byte, error) {
 
@@ -422,6 +436,7 @@ func calcHash(initialHash []byte, hdr ImageHdr, pad []byte,
return hash.Sum(nil), nil
 }
 
+// calcProtSize calculates the size, in bytes, of a set of protected TLVs.
 func calcProtSize(protTlvs []ImageTlv) uint16 {
var size = uint16(0)
for _, tlv := range protTlvs {
@@ -434,6 +449,7 @@ func calcProtSize(protTlvs []ImageTlv) uint16 {
return size
 }
 
+// Create produces an Image object.
 func (ic *ImageCreator) Create() (Image, error) {
img := Image{}
 



[mynewt-artifact] branch master updated (252824c -> 7b5e1d8)

2020-08-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


from 252824c  Encrypt AES: Don't assume nonce is 8 bytes
 new 8fe37e2  image: Add some missing fields to json conversion
 new 30b07ba  Add some comments
 new 7b5e1d8  image/README.md: Document of Mynewt image anatomy

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 image/README.md | 168 
 image/create.go |  16 ++
 image/map.go|   7 +++
 3 files changed, 191 insertions(+)
 create mode 100644 image/README.md



[mynewt-artifact] 03/03: image/README.md: Document of Mynewt image anatomy

2020-08-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git

commit 7b5e1d873e28c52aa9142f0ee5194b3069a9457d
Author: Christopher Collins 
AuthorDate: Wed Aug 12 14:33:12 2020 -0700

image/README.md: Document of Mynewt image anatomy
---
 image/README.md | 168 
 1 file changed, 168 insertions(+)

diff --git a/image/README.md b/image/README.md
new file mode 100644
index 000..b839e05
--- /dev/null
+++ b/image/README.md
@@ -0,0 +1,168 @@
+# Mynewt Images
+
+## Anatomy
+
+```
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|Header |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+~  Padding (optional)   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+~   ~
+~   ~
+~ Body  ~
+~   ~
+~   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Protected Trailer (optional)  |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+~   ~
+~   Protected TLVs (optional)   ~
+~   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|Trailer|
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+~   ~
+~ TLVs  ~
+~   ~
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+```
+
+All fields are in host-byte order (typically little endian).
+
+### Header
+
+```
+ 0   1   2   3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|  Magic (0x96f3b83d)   |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Reserved1 (0x)|
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|  Header size  |Protected size |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|   Body size   |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Flags |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Major version | Minor version |   Revision|
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Build number  |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Reserved2 (0x)|
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+```
+
+| Field | Description | Notes |
+| - | --- | - |
+| Magic | Identifies the start of an image | |
+| Header size | 32 + the amount of padding that follows the header | |
+| Protected size | Size, in bytes, of the protected trailer PLUS the protected 
TLVs | 0 if no protected TLVs |
+| Body size | Size, in bytes, of the image body | |
+| Flags | One bit per flag | See below |
+| Major version | The first element of the version number | 
major.minor.revision.build |
+| Minor version | The second element of the version number | 
major.minor.revision.build |
+| Revision  | The third element of the version number | 
major.minor.revision.build |
+| Build number  | The fourth element of the version number | No meaning in 
semver |
+
+### Body
+
+The executable itself.  In encrypted images, this is the encrypted portion.
+
+### Protected trailer
+
+Describes the set of protected TLVs that follow.  This trailer is NOT present 
if there are no protected TLVs.
+
+```
+ 0   1   2   3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|Magic (0x6908) |Protected size

[mynewt-artifact] branch master updated: Encrypt AES: Don't assume nonce is 8 bytes

2020-08-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
 new 252824c  Encrypt AES: Don't assume nonce is 8 bytes
252824c is described below

commit 252824cdbca1dc71e5bf1cd59af36552628c049a
Author: Christopher Collins 
AuthorDate: Thu Jul 30 11:09:02 2020 -0700

Encrypt AES: Don't assume nonce is 8 bytes

For AES encryption, the client can optionally pass a nonce to use as the
beginning of the IV.  The code assumed the nonce was exactly eight
bytes, so it would always append eight zeros to form the 16-byte nonce.

The fix is to only append as many zeros are necessary for a 16-byte IV.
---
 sec/encrypt.go | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sec/encrypt.go b/sec/encrypt.go
index 85d4571..8d142e3 100644
--- a/sec/encrypt.go
+++ b/sec/encrypt.go
@@ -31,9 +31,10 @@ import (
"crypto/sha256"
"crypto/x509"
"encoding/base64"
-   "golang.org/x/crypto/hkdf"
"io"
 
+   "golang.org/x/crypto/hkdf"
+
keywrap "github.com/NickBall/go-aes-key-wrap"
"github.com/apache/mynewt-artifact/errors"
 )
@@ -251,17 +252,18 @@ func (k *PrivEncKey) Decrypt(ciph []byte) ([]byte, error) 
{
 }
 
 func EncryptAES(plain []byte, secret []byte, nonce []byte) ([]byte, error) {
+   if len(nonce) > 16 {
+   return nil, errors.Errorf("AES nonce has invalid length: 
have=%d want<=16", len(nonce))
+   }
+
blk, err := aes.NewCipher(secret)
if err != nil {
return nil, errors.Errorf("Failed to create block cipher")
}
 
-   var iv []byte
-   if nonce == nil {
-   iv = make([]byte, 16)
-   } else {
-   zeros := make([]byte, 8)
-   iv = append(nonce, zeros...)
+   iv := nonce
+   for len(iv) < 16 {
+   iv = append(nonce, 0)
}
 
stream := cipher.NewCTR(blk, iv)



[mynewt-core] branch master updated: docs: Add page for build-time hooks

2020-08-10 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new faeadf3  docs: Add page for build-time hooks
faeadf3 is described below

commit faeadf339e04281ec26f72fcb95a9e5fa9c82a11
Author: Christopher Collins 
AuthorDate: Fri Aug 7 12:44:09 2020 -0700

docs: Add page for build-time hooks
---
 docs/os/modules/extcmd/extcmd.rst | 139 ++
 docs/os/os_user_guide.rst |   1 +
 2 files changed, 140 insertions(+)

diff --git a/docs/os/modules/extcmd/extcmd.rst 
b/docs/os/modules/extcmd/extcmd.rst
new file mode 100644
index 000..3ee98bf
--- /dev/null
+++ b/docs/os/modules/extcmd/extcmd.rst
@@ -0,0 +1,139 @@
+Build-Time Hooks
+
+
+A package specifies custom commands in its ``pkg.yml`` file.  There are
+three types of commands:
+
+1. pre_build_cmds (run before the build)
+2. pre_link_cmds (run after compilation, before linking)
+3. post_build_cmds (run after the build)
+
+Example
+~~~
+
+Example (apps/blinky/pkg.yml):
+
+.. code-block:: yaml
+
+pkg.pre_build_cmds:
+scripts/pre_build1.sh: 100
+scripts/pre_build2.sh: 200
+
+pkg.pre_link_cmds:
+scripts/pre_link.sh: 500
+
+pkg.post_build_cmds:
+scripts/post_build.sh: 100
+
+
+For each command, the string on the left specifies the command to run.
+The number on the right indicates the command's relative ordering.  All
+paths are relative to the project root.
+
+When newt builds this example, it performs the following sequence:
+
+- scripts/pre_build1.sh
+- scripts/pre_build2.sh
+- [compile]
+- scripts/pre_link.sh
+- [link]
+- scripts/post_build.sh
+
+If other packages specify custom commands, those commands would also be
+executed during the above sequence.  For example, if another package
+specifies a pre build command with an ordering of 150, that command
+would run immediately after ``pre_build1.sh``.  In the case of a tie,
+the commands are run in lexicographic order (by path).
+
+All commands are run from the project's base directory.  In the above
+example, the ``scripts`` directory is a sibling of ``targets``.
+
+Custom Build Inputs
+~~~
+
+A custom pre-build or pre-link command can produce files that get fed
+into the current build.
+
+*Pre-build* commands can generate any of the following:
+
+1. ``.c`` files for newt to compile.
+2. ``.a`` files for newt to link.
+3. ``.h`` files that any package can include.
+
+*Pre-link* commands can only generate .a files.
+
+``.c`` and ``.a`` files should be written to the
+``$MYNEWT_USER_SRC_DIR`` environment variable (defined by newt), or any
+subdirectory within.
+
+``.h`` files should be written to ``$MYNEWT_USER_INCLUDE_DIR``.  The
+directory structure used here is directly reflected by the includer.
+E.g., if a script writes to ``$MYNEWT_USER_INCLUDE_DIR/foo/bar.h``,
+then a source file can include this header with:
+
+.. code-block:: cpp
+
+#include "foo/bar.h"
+
+Details
+~~~
+
+Environment Variables
+^
+
+In addition to the usual environment variables defined for debug and
+download scripts, newt defines the following env vars for custom
+commands:
+
+== 
=
 ===
+  Environment variable  Description
   Notes
+-- 
-
 ---
+  MYNEWT_APP_BIN_DIRThe directory where the current target's binary 
gets written.
+  MYNEWT_PKG_BIN_ARCHIVEThe path to the current package's ``.a`` file.
+  MYNEWT_PKG_BIN_DIRThe directory where the current package's ``.o`` 
and ``.a`` files get written.
+  MYNEWT_PKG_NAME   The full name of the current package.
+  MYNEWT_USER_INCLUDE_DIR   Path where globally-accessible headers get 
written.   Pre-build only.
+  MYNEWT_USER_SRC_DIR   Path where build inputs get written.   
   Pre-build and pre-link only.
+  MYNEWT_USER_WORK_DIR  Shared temp directory; used for communication 
between commands.
+== 
=
 ===
+
+These environment variables are defined for each process that a custom
+command runs in.  They are *not* defined in the newt process itself.
+So, the following snippet will not produce the expected output:
+
+BAD Example (apps/blinky/pkg.yml):
+
+.. code-block:: yaml
+
+pkg.pre_cmds:
+'echo $MYNEWT_USER_SRC_DIR': 100
+
+You can execute ``sh`` here instead i

[mynewt-core] branch master updated: docs: sysinit and sysdown

2020-08-07 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 585bc6c  docs: sysinit and sysdown
585bc6c is described below

commit 585bc6cc44f82978fbde7946576033bc9b59f09f
Author: Christopher Collins 
AuthorDate: Fri Aug 7 10:21:20 2020 -0700

docs: sysinit and sysdown

This commit removes sysinit from the syscfg+sysinit page and moves it to
its own page.  It also adds a section for sysdown to the new page.
---
 docs/os/core_os/mynewt_os.rst   |   2 +-
 docs/os/modules/sysinitconfig/sysinitconfig.rst | 183 +--
 docs/os/modules/sysinitdown/sysinitdown.rst | 282 
 docs/os/os_user_guide.rst   |   1 +
 4 files changed, 289 insertions(+), 179 deletions(-)

diff --git a/docs/os/core_os/mynewt_os.rst b/docs/os/core_os/mynewt_os.rst
index 9338723..2807d43 100644
--- a/docs/os/core_os/mynewt_os.rst
+++ b/docs/os/core_os/mynewt_os.rst
@@ -80,7 +80,7 @@ task. The main steps are:
 3. In your application ``main()`` function, call the ``sysinit()``
function to initialize the system and packages, perform application
specific initialization, then wait and dispatch events from the OS
-   default event queue in an infinite loop. (See 
:doc:`../modules/sysinitconfig/sysinitconfig`
+   default event queue in an infinite loop. (See 
:doc:`../modules/sysinitdown/sysinitdown`
for more details.)
 
 Initializing application modules and tasks can get somewhat complicated
diff --git a/docs/os/modules/sysinitconfig/sysinitconfig.rst 
b/docs/os/modules/sysinitconfig/sysinitconfig.rst
index bda1fb0..cd52e93 100644
--- a/docs/os/modules/sysinitconfig/sysinitconfig.rst
+++ b/docs/os/modules/sysinitconfig/sysinitconfig.rst
@@ -1,4 +1,4 @@
-Compile-Time Configuration and Initialization
+Compile-Time Configuration
 ---
 
 .. toctree::
@@ -6,10 +6,10 @@ Compile-Time Configuration and Initialization
 
sysconfig_error
 
-This guide describes how Mynewt manages system configuration and
-initialization. It shows you how to tell Mynewt to use default or
-customized values to initialize packages that you develop or use to
-build a target. This guide:
+This guide describes how Mynewt manages system configuration.  It shows
+you how to tell Mynewt to use default or customized values to
+configure packages that you develop or use to build a target. This
+guide:
 
 -  Assumes you have read the
:ref:`concepts` section that describes
@@ -17,9 +17,6 @@ build a target. This guide:
``syscfg.yml`` files.
 -  Assumes you have read the Mynewt :doc:`../../../newt/newt_operation` and 
are familiar with how newt
determines package dependencies for your target build.
--  Covers only the system initialization for hardware independent
-   packages. It does not cover the Board Support Package (BSP) and other
-   hardware dependent system initialization.
 
 .. contents::
:local:
@@ -28,8 +25,6 @@ build a target. This guide:
 Mynewt defines several configuration parameters in the ``pkg.yml`` and
 ``syscfg.yml`` files. The newt tool uses this information to:
 
--  Generate a system initialization function that calls all the
-   package-specific system initialization functions.
 -  Generate a system configuration header file that contains all the
package configuration settings and values.
 -  Display the system configuration settings and values in the
@@ -512,171 +507,3 @@ when the setting value is non-zero.
 SYSINIT_PANIC_ASSERT(rc == 0);
 #endif
 }
-
-System Initialization
-~
-
-During system startup, Mynewt creates a default event queue and a main
-task to process events from this queue. You can override the
-``OS_MAIN_TASK_PRIO`` and ``OS_MAIN_TASK_STACK_SIZE`` setting values
-defined by the ``kernel/os`` package to specify different task priority
-and stack size values.
-
-Your application's ``main()`` function executes in the context of the
-main task and must perform the following:
-
--  At the start of ``main()``, call the Mynewt ``sysinit()`` function to
-   initialize the packages before performing any other processing.
--  At the end of ``main()``, wait for and dispatch events from the
-   default event queue in an infinite loop.
-
-**Note:** You must include the ``sysinit/sysinit.h`` header file to
-access the ``sysinit()`` function.
-
-Here is an example of a ``main()`` function:
-
-.. code-block:: cpp
-
-int
-main(int argc, char **argv)
-{
-/* First, call sysinit() to perform the system and package 
initialization */
-sysinit();
-
-/* ... other application initialization processing ... */
-
-/*  Last, process events from the default event queue.  */
-while (1) {
-   os_eventq_run(os_eventq_dflt_get

[mynewt-core] branch master updated: docs: Add section about conditional settings

2020-08-07 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 1cdfed8  docs: Add section about conditional settings
1cdfed8 is described below

commit 1cdfed87fc44cb3296be74e006e67f77247612f3
Author: Christopher Collins 
AuthorDate: Thu Aug 6 11:51:42 2020 -0700

docs: Add section about conditional settings
---
 docs/os/modules/sysinitconfig/sysinitconfig.rst | 74 ++---
 1 file changed, 41 insertions(+), 33 deletions(-)

diff --git a/docs/os/modules/sysinitconfig/sysinitconfig.rst 
b/docs/os/modules/sysinitconfig/sysinitconfig.rst
index ae70886..bda1fb0 100644
--- a/docs/os/modules/sysinitconfig/sysinitconfig.rst
+++ b/docs/os/modules/sysinitconfig/sysinitconfig.rst
@@ -352,6 +352,47 @@ use the flash area named ``FLASH_AREA_NFFS`` in the 
``syscfg.yml`` file.
 syscfg.vals:
 NFFS_FLASH_AREA: FLASH_AREA_NFFS
 
+Conditional Settings
+
+
+Setings in most Mynewt YAML files can be made conditional on syscfg
+settings.  For example, a package might depend on a second package
+*only if a syscfg setting has a particular value*.  The condition can
+be the value of a single syscfg setting or an arbitrary expression
+involving many settings.
+
+Examples of Conditional Settings
+
+
+Example 6
+`
+
+In this example, a package depends on ``lib/pkg2`` only if
+``MY_SETTING`` has a true value.
+
+
+.. code-block:: yaml
+
+pkg.deps.MY_SETTING:
+# Only depend on pkg2 if MY_SETTING is true.
+- lib/pkg2
+
+A setting is "true" if it has a value other than 0 or the empty string.
+Undefined settings are not true.
+
+Example 7
+`
+
+In this example, a package overrides the setting ``FOO`` only if
+``BAR`` is greater than 5 and ``BAZ`` is not true.
+
+
+.. code-block:: yaml
+
+syscfg.vals.'(BAR > 5 && !BAZ):
+# Only override FOO if BAR is greater than 5 and BAZ is untrue.
+FOO: 35
+
 Generated syscfg.h and Referencing System Configuration Settings
 
 
@@ -639,36 +680,3 @@ function:
 nmgr_shell_pkg_init();
 }
 #endif
-
-Conditional Configurations
-~~
-
-You can use the system configuration setting values to conditionally
-specify parameter values in ``pkg.yml`` and ``syscfg.yml`` files. The
-syntax is:
-
-.. code-block:: yaml
-
-parameter_name.PKGA_SYSCFG_NAME:
- parameter_value
-
-This specifies that ``parameter_value`` is only set for
-``parameter_name`` if the ``PKGA_SYSCFG_NAME`` configuration setting
-value is non-zero. Here is an example from the ``libs/os`` package
-``pkg.yml`` file:
-
-.. code-block:: yaml
-
-pkg.deps:
-- "@apache-mynewt-core/sys/sysinit"
-- "@apache-mynewt-core/util/mem"
-
-pkg.deps.OS_CLI
-- "@apache-mynewt-core/sys/shell"
-
-This example specifies that the ``os`` package depends on the
-``sysinit`` and ``mem`` packages, and also depends on the ``shell``
-package when ``OS_CLI`` is enabled.
-
-The newt tool aborts the build when it detects circular conditional
-dependencies.



[mynewt-newt] branch master updated: Execute .sh scripts with bash on windows

2020-06-22 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new 8330e7f  Execute .sh scripts with bash on windows
8330e7f is described below

commit 8330e7f8bd6570e2bccb73377b115ab78541933d
Author: J. Ipanienko 
AuthorDate: Wed Feb 19 13:19:16 2020 -0800

Execute .sh scripts with bash on windows
---
 util/util.go | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/util/util.go b/util/util.go
index 91e8aed..d693f1a 100644
--- a/util/util.go
+++ b/util/util.go
@@ -369,8 +369,17 @@ func ShellCommandLimitDbgOutput(
name = "/bin/sh"
args = []string{"-c", strings.Replace(cmd, "\"", "\\\"", -1)}
} else {
-   name = cmdStrs[0]
-   args = cmdStrs[1:]
+   if strings.HasSuffix(cmdStrs[0], ".sh") {
+   var newt_sh = os.Getenv("NEWT_SH")
+   if newt_sh == "" {
+   newt_sh = "bash"
+   }
+   name = newt_sh
+   args = cmdStrs
+   } else {
+   name = cmdStrs[0]
+   args = cmdStrs[1:]
+   }
}
cmd := exec.Command(name, args...)
 
@@ -428,6 +437,18 @@ func ShellInteractiveCommand(cmdStr []string, env 
map[string]string,
// Escape special characters for Windows.
fixupCmdArgs(cmdStr)
 
+   var newt_sh string
+   if runtime.GOOS == "windows" && strings.HasSuffix(cmdStr[0], ".sh") {
+   newt_sh = os.Getenv("NEWT_SH")
+   if newt_sh == "" {
+   bash, err := exec.LookPath("bash")
+   if err != nil {
+   return err
+   }
+   newt_sh = bash
+   }
+   cmdStr = append([]string{newt_sh}, cmdStr...)
+   }
log.Print("[VERBOSE] " + cmdStr[0])
 
c := make(chan os.Signal, 1)



[mynewt-core] branch master updated: net/oic: Fail init if any interface fails

2020-06-16 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 9d57b34  net/oic: Fail init if any interface fails
9d57b34 is described below

commit 9d57b349ddca9832e1ecf80c47af96f456f8faf1
Author: Christopher Collins 
AuthorDate: Mon Jun 15 15:45:36 2020 -0700

net/oic: Fail init if any interface fails

oc_connectivity_init() would succeed if at least one interface was
successfully initialized.  This allowed interfaces to silently fail.

This commit changes oc_connectivity_init() so that it fails unless *all*
interfaces successfully initialize.
---
 net/oic/src/port/mynewt/adaptor.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/oic/src/port/mynewt/adaptor.c 
b/net/oic/src/port/mynewt/adaptor.c
index 23e0e70..24b29b7 100644
--- a/net/oic/src/port/mynewt/adaptor.c
+++ b/net/oic/src/port/mynewt/adaptor.c
@@ -172,21 +172,25 @@ oc_connectivity_shutdown(void)
 int
 oc_connectivity_init(void)
 {
-int rc = -1;
+int rc;
 int i;
 const struct oc_transport *ot;
 
 oc_conn_init();
+
 for (i = 0; i < OC_TRANSPORT_MAX; i++) {
 if (!oc_transports[i]) {
 continue;
 }
+
 ot = oc_transports[i];
-if (ot->ot_init() == 0) {
-rc = 0;
+rc = ot->ot_init();
+if (rc != 0) {
+return -1;
 }
 }
-return rc;
+
+return 0;
 }
 
 void



[mynewt-core] branch master updated: util/scfg: Support for unsigned integer types

2020-06-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 92ca78c  util/scfg: Support for unsigned integer types
92ca78c is described below

commit 92ca78ca89ff80d2c4831192d0ffce5f467e0dab
Author: Christopher Collins 
AuthorDate: Fri Jun 12 13:57:08 2020 -0700

util/scfg: Support for unsigned integer types

When scfg was implemented, sys/config did not support unsigned integer
types.  Support has since been added to sys/config, but scfg still
rejects them.

This commit makes scfg not reject settings with unsigned integer types.
---
 util/scfg/src/scfg.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/util/scfg/src/scfg.c b/util/scfg/src/scfg.c
index 347d5d7..3b3c76b 100644
--- a/util/scfg/src/scfg.c
+++ b/util/scfg/src/scfg.c
@@ -229,6 +229,10 @@ scfg_register(struct scfg_group *group, char *name)
 case CONF_INT16:
 case CONF_INT32:
 case CONF_INT64:
+case CONF_UINT8:
+case CONF_UINT16:
+case CONF_UINT32:
+case CONF_UINT64:
 case CONF_STRING:
 case CONF_BOOL:
 break;



[mynewt-core] 03/04: base64: Fail on incomplete input

2020-06-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fa773361fd420e6437e387a13f6ac58151e02bed
Author: Christopher Collins 
AuthorDate: Sat Jun 13 10:47:08 2020 -0700

base64: Fail on incomplete input

The code was relying on strchr to detect a misplaced null terminator.
However, from `man strchr`:

The terminating null byte is considered part of the string, so that
if c is specified as '\0', these functions return a pointer to the
terminator.

The fix is to check for a null character separately.
---
 encoding/base64/src/base64.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/encoding/base64/src/base64.c b/encoding/base64/src/base64.c
index 30fb079..d36d4f0 100644
--- a/encoding/base64/src/base64.c
+++ b/encoding/base64/src/base64.c
@@ -231,6 +231,10 @@ base64_decoder_go(struct base64_decoder *dec)
 /* Detect invalid input. */
 for (i = 0; i < read_len; i++) {
 sval = dec->src[src_off + i];
+if (sval == '\0') {
+/* Incomplete input. */
+return -1;
+}
 if (sval != '=' && strchr(base64_chars, sval) == NULL) {
 /* Invalid base64 character. */
 return -1;



[mynewt-core] branch master updated (e6249ac -> 97d7fbe)

2020-06-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from e6249ac  Merge pull request #2305 from nkaje/fix_typo_oicmgr_syscfg
 new 93a850c  shell_nlip: trim trailing '\n' on input lines
 new f1ce7cb  base64: fix buffer overrun
 new fa77336  base64: Fail on incomplete input
 new 97d7fbe  base64: style fixes

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 encoding/base64/src/base64.c | 25 ++---
 sys/shell/src/shell_nlip.c   |  6 ++
 2 files changed, 24 insertions(+), 7 deletions(-)



[mynewt-core] 02/04: base64: fix buffer overrun

2020-06-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit f1ce7cb5f55dfd78d91e850193e548b3d271eb13
Author: Christopher Collins 
AuthorDate: Fri Jun 12 23:10:59 2020 -0700

base64: fix buffer overrun

The `token_decode()` function accepts a string, but the caller was only
passing it a byte array without a null terminator.

The fix is to change `token_decode()` so that it accepts a second `len`
argument.  The first argument is now considered a byte array, not a
string.
---
 encoding/base64/src/base64.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/encoding/base64/src/base64.c b/encoding/base64/src/base64.c
index 60a90cb..30fb079 100644
--- a/encoding/base64/src/base64.c
+++ b/encoding/base64/src/base64.c
@@ -126,12 +126,12 @@ base64_pad(char *buf, int len)
 #define DECODE_ERROR -1
 
 static unsigned int
-token_decode(const char *token)
+token_decode(const char *token, int len)
 {
 int i;
 unsigned int val = 0;
 int marker = 0;
-if (strlen(token) < 4)
+if (len < 4)
 return DECODE_ERROR;
 for (i = 0; i < 4; i++) {
 val *= 64;
@@ -248,7 +248,7 @@ base64_decoder_go(struct base64_decoder *dec)
 
 /* Copy full token into buf and decode it. */
 memcpy(>buf[dec->buf_len], >src[src_off], read_len);
-val = token_decode(dec->buf);
+val = token_decode(dec->buf, read_len);
 if (val == DECODE_ERROR) {
 return -1;
 }



[mynewt-core] 04/04: base64: style fixes

2020-06-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 97d7fbe8471674573897a32bfcbfd6a8f4fb9b2d
Author: Christopher Collins 
AuthorDate: Sat Jun 13 11:06:05 2020 -0700

base64: style fixes
---
 encoding/base64/src/base64.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/encoding/base64/src/base64.c b/encoding/base64/src/base64.c
index d36d4f0..5177121 100644
--- a/encoding/base64/src/base64.c
+++ b/encoding/base64/src/base64.c
@@ -131,19 +131,26 @@ token_decode(const char *token, int len)
 int i;
 unsigned int val = 0;
 int marker = 0;
-if (len < 4)
+
+if (len < 4) {
 return DECODE_ERROR;
+}
+
 for (i = 0; i < 4; i++) {
 val *= 64;
-if (token[i] == '=')
+if (token[i] == '=') {
 marker++;
-else if (marker > 0)
+} else if (marker > 0) {
 return DECODE_ERROR;
-else
+} else {
 val += pos(token[i]);
+}
 }
-if (marker > 2)
+
+if (marker > 2) {
 return DECODE_ERROR;
+}
+
 return (marker << 24) | val;
 }
 



[mynewt-core] 01/04: shell_nlip: trim trailing '\n' on input lines

2020-06-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 93a850c8c979c27bd2f512a6ff840664e10c6883
Author: Christopher Collins 
AuthorDate: Fri Jun 12 23:09:04 2020 -0700

shell_nlip: trim trailing '\n' on input lines

The base64 decode code was recently changed to reject invalid input.
This broke nlip receive.

The fix is to trim the trailing newline character before passing input
to base64_decode().
---
 sys/shell/src/shell_nlip.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/sys/shell/src/shell_nlip.c b/sys/shell/src/shell_nlip.c
index 21f5ff3..82b38f4 100644
--- a/sys/shell/src/shell_nlip.c
+++ b/sys/shell/src/shell_nlip.c
@@ -58,6 +58,12 @@ shell_nlip_process(char *data, int len)
 struct os_mbuf *m;
 uint16_t crc;
 
+/* Trim trailing newline. */
+if (len >= 1 && data[len - 1] == '\n') {
+data[len - 1] = '\0';
+len--;
+}
+
 rc = base64_decode(data, data);
 if (rc < 0) {
 goto err;



[mynewt-newt] branch master updated: Fix --imgfile option for the `load` command

2020-06-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new d7efc36  Fix --imgfile option for the `load` command
d7efc36 is described below

commit d7efc36caf7314782c7a21053b7cfa9c46a10fd8
Author: Christopher Collins 
AuthorDate: Fri Jun 12 13:29:09 2020 -0700

Fix --imgfile option for the `load` command

`--imgfile` lets the user specify the image file to load rather than
letting newt derive it from the target name.

This option wasn't working properly.  For the download scripts to load
the specified file, the `BIN_BASENAME` environment variable needs to be
set to the file's *base* (i.e., strip the `.img` extension).

Prior to this commit, this environment variable wasn't being overridden
at all.  The effect was that the `--imgfile` option was ignored
completely.
---
 newt/builder/load.go | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/newt/builder/load.go b/newt/builder/load.go
index d09ce48..f437e8d 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -81,18 +81,28 @@ func (t *TargetBuilder) Load(extraJtagCmd string, 
imgFileOverride string) error
"cannot specify image file override for split images")
}
 
-   appImg := imgFileOverride
-   if appImg == "" {
-   appImg = t.AppBuilder.AppBinBasePath()
+   var imgBase string
+   if imgFileOverride == "" {
+   imgBase = t.AppBuilder.AppBinBasePath()
+   } else {
+   // The download script appends ".img" to the basename.  Make 
sure we
+   // can strip the extension here and the script will reconstruct 
the
+   // original filename.
+   imgBase = strings.TrimSuffix(imgFileOverride, ".img")
+   if imgBase == imgFileOverride {
+   return util.FmtNewtError(
+   "invalid img filename: must end in \".img\": 
filename=%s",
+   imgFileOverride)
+   }
}
 
if t.LoaderBuilder != nil {
-   err = t.loadApp(1, extraJtagCmd, appImg)
+   err = t.loadApp(1, extraJtagCmd, imgBase)
if err == nil {
err = t.loadLoader(0, extraJtagCmd, 
t.LoaderBuilder.AppBinBasePath())
}
} else {
-   err = t.loadApp(0, extraJtagCmd, appImg)
+   err = t.loadApp(0, extraJtagCmd, imgBase)
}
 
return err
@@ -194,6 +204,9 @@ func (b *Builder) Load(imageSlot int, extraJtagCmd string, 
imgFilename string) e
// compatibility with unix-in-windows environemnts (e.g., cygwin).
binPath := util.TryRelPath(imgFilename)
 
+   // Make sure the img override (if any) gets used.
+   env["BIN_BASENAME"] = binPath
+
if err := Load(binPath, b.targetBuilder.bspPkg, env); err != nil {
return err
}



[mynewt-newtmgr] branch master updated: Remove illegal space

2020-06-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git


The following commit(s) were added to refs/heads/master by this push:
 new 61395d2  Remove illegal space
61395d2 is described below

commit 61395d2a705611c376226fa5114ea81392ded671
Author: Andrew Stevenson 
AuthorDate: Sat May 16 18:39:12 2020 +0200

Remove illegal space

newtmgr (1.9.0-dev at least) doesn't allow the space between the command 
and baud.
---
 docs/command_list/newtmgr_conn.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/command_list/newtmgr_conn.rst 
b/docs/command_list/newtmgr_conn.rst
index 23c1ab9..b75cab1 100644
--- a/docs/command_list/newtmgr_conn.rst
+++ b/docs/command_list/newtmgr_conn.rst
@@ -67,7 +67,7 @@ The var-names are: ``type``, and ``connstring``. The valid 
values for each var-n
 * ``baud``: (Optional) A number that specifies the buad rate for the 
connection. Defaults to **115200** if the
   attribute is not specified.
 
-Example: ``connstring="dev=/dev/ttyUSB0, baud=9600"``
+Example: ``connstring="dev=/dev/ttyUSB0,baud=9600"``
 **Note:** The 1.0 format, which only requires a serial port name, is still 
supported. For example, ``connstring=/dev/ttyUSB0``.
 
   - **udp** and **oic_udp**: The peer ip address and port number that the 
newtmgr or oicmgr on the remote device is



[mynewt-core] branch master updated: oic tcp4_adaptor: Don't loop if nothing to rx

2020-05-29 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new b8a9ddd  oic tcp4_adaptor: Don't loop if nothing to rx
b8a9ddd is described below

commit b8a9ddd8a07fda008c2083de026fe0549f16046a
Author: Christopher Collins 
AuthorDate: Wed May 27 17:35:10 2020 -0700

oic tcp4_adaptor: Don't loop if nothing to rx

Prior to commit:

When a managed TCP connection had no pending receives, the code would
enqueue another "rx" event.  As a result, the "rx" event would always be
executing or enqueued!

Fix:

If a connection has no pending receives, move on to the next connection.
Do not enqueue an "rx" event.
---
 net/oic/src/port/mynewt/tcp4_adaptor.c | 52 +-
 1 file changed, 38 insertions(+), 14 deletions(-)

diff --git a/net/oic/src/port/mynewt/tcp4_adaptor.c 
b/net/oic/src/port/mynewt/tcp4_adaptor.c
index 9d132a6..deea866 100644
--- a/net/oic/src/port/mynewt/tcp4_adaptor.c
+++ b/net/oic/src/port/mynewt/tcp4_adaptor.c
@@ -294,27 +294,51 @@ oc_connectivity_shutdown_tcp4(void)
 }
 }
 
-static void
-oc_event_tcp4(struct os_event *ev)
+/**
+ * Receives all buffered packets sent over the given connection.
+ */
+static int
+oc_tcp4_recv_conn(struct oc_tcp4_conn *conn)
 {
 struct mn_sockaddr_in from;
-struct oc_tcp4_conn *conn;
 struct os_mbuf *frag;
 int rc;
 
-SLIST_FOREACH(conn, _tcp4_conn_list, next) {
-while (1) {
-rc = mn_recvfrom(conn->sock, , (struct mn_sockaddr *) );
-if (rc != 0) {
-if (rc != MN_EAGAIN) {
-oc_tcp4_err(conn->sock, rc);
-}
-os_eventq_put(oc_evq_get(), _tcp4_read_event);
-return;
-}
-
+/* Keep receiving until there are no more pending packets. */
+while (1) {
+rc = mn_recvfrom(conn->sock, , (struct mn_sockaddr *) );
+switch (rc) {
+case 0:
 assert(OS_MBUF_IS_PKTHDR(frag));
 oc_tcp_rx_frag(conn->sock, frag, );
+break;
+
+case MN_EAGAIN:
+// No more packets to receive.
+return 0;
+
+default:
+return rc;
+}
+}
+}
+
+static void
+oc_event_tcp4(struct os_event *ev)
+{
+struct oc_tcp4_conn *conn;
+int rc;
+
+SLIST_FOREACH(conn, _tcp4_conn_list, next) {
+rc = oc_tcp4_recv_conn(conn);
+if (rc != 0) {
+/* The connection is in a bad state and needs to be removed from
+ * the list.  We can't continue looping after modifying the list,
+ * so enqueue "receive" event and return.
+ */
+oc_tcp4_err(conn->sock, rc);
+os_eventq_put(oc_evq_get(), _tcp4_read_event);
+return;
 }
 }
 }



[mynewt-core] branch master updated (a24dcf2 -> 077e669)

2020-05-29 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from a24dcf2  Merge pull request #2299 from ccollins476ad/native_sock_fixes
 new 4b607cb  net/oic: make OC_MBUF_ENDPOINT use OS_MBUF_USRHDR
 new 635b97a  oc_ri: Don't over-copy on cb init
 new c327aa4  net/oic: Allow init/send of generic CoAP requests
 new fdf2974  net/oic: Separate "stream" code from BLE transport
 new 1b3a84d  TCP/IPv4 adaptor for CoAP
 new 077e669  Merge pull request #2300 from ccollins476ad/tcp3

The 9647 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 net/oic/include/oic/oc_api.h   |  12 +
 net/oic/include/oic/port/mynewt/ip.h   |   2 +
 net/oic/include/oic/port/mynewt/stream.h   |  95 +++
 net/oic/include/oic/port/mynewt/tcp4.h |  71 +
 net/oic/include/oic/port/oc_connectivity.h |   6 +-
 net/oic/pkg.yml|   1 +
 net/oic/src/api/oc_client_api.c|  93 +++
 net/oic/src/api/oc_ri.c|   3 +-
 net/oic/src/messaging/coap/engine.c|  20 +-
 net/oic/src/port/mynewt/ble_adaptor.c  | 156 +--
 net/oic/src/port/mynewt/ip4_adaptor.c  |   2 +
 net/oic/src/port/mynewt/stream.c   | 112 
 net/oic/src/port/mynewt/tcp4_adaptor.c | 425 +
 net/oic/syscfg.yml |  15 +
 14 files changed, 861 insertions(+), 152 deletions(-)
 create mode 100644 net/oic/include/oic/port/mynewt/stream.h
 create mode 100644 net/oic/include/oic/port/mynewt/tcp4.h
 create mode 100644 net/oic/src/port/mynewt/stream.c
 create mode 100644 net/oic/src/port/mynewt/tcp4_adaptor.c



[mynewt-core] branch master updated (869c322 -> a24dcf2)

2020-05-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from 869c322  missing syscfg for SPI2/SPI3 for stm32
 new 24e3d10  native_sock: Make accept()ed sockets nonblocking
 new 88c7f3d  native_sock: Don't SIGPIPE on tx-over-closed conn
 new 7dada0b  native_sock: Don't call mn_readable during receive
 new a24dcf2  Merge pull request #2299 from ccollins476ad/native_sock_fixes

The 9641 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 net/ip/native_sockets/src/native_sock.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)



[mynewt-newtmgr] branch master updated: Fix for BLE in macOS catalina

2020-05-17 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git


The following commit(s) were added to refs/heads/master by this push:
 new 35ba93a  Fix for BLE in macOS catalina
35ba93a is described below

commit 35ba93ae741c94e5d4852c884f07d58cb1e2
Author: Christopher Collins 
AuthorDate: Sat May 16 22:44:30 2020 -0700

Fix for BLE in macOS catalina

Pull in latest `ble` library to fix hang in catalina.
---
 go.mod | 4 ++--
 go.sum | 4 
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/go.mod b/go.mod
index 19f667b..c9eea6f 100644
--- a/go.mod
+++ b/go.mod
@@ -3,8 +3,8 @@ module mynewt.apache.org/newtmgr
 go 1.12
 
 require (
-   github.com/JuulLabs-OSS/ble v0.0.0-20200421174404-4a6a93a950fe
-   github.com/JuulLabs-OSS/cbgo v0.0.0-20200421065905-1762a9c3147c
+   github.com/JuulLabs-OSS/ble v0.0.0-20200517053828-ca7534402217
+   github.com/JuulLabs-OSS/cbgo v0.0.1
github.com/abiosoft/ishell v2.0.0+incompatible // indirect
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // 
indirect
github.com/cheggaaa/pb v2.0.7+incompatible // indirect
diff --git a/go.sum b/go.sum
index 00c1281..14bd273 100644
--- a/go.sum
+++ b/go.sum
@@ -3,8 +3,12 @@ github.com/JuulLabs-OSS/ble v0.0.0-20200415235928-df3a9e6783a9 
h1:2VXy9m1Bl4unkc
 github.com/JuulLabs-OSS/ble v0.0.0-20200415235928-df3a9e6783a9/go.mod 
h1:qMsm/vRFvBk32uWdeFzvSZ8xsw0DUopgJFRgxaYpzt4=
 github.com/JuulLabs-OSS/ble v0.0.0-20200421174404-4a6a93a950fe 
h1:YnTwo0OKGlHaI9LgmuJRdecE08aZ5q/xBKkKx6NGWlQ=
 github.com/JuulLabs-OSS/ble v0.0.0-20200421174404-4a6a93a950fe/go.mod 
h1:pfS28CC0m6k3HdEWztSfIpvKpn3Zsxu1jzuNJ3pnFNo=
+github.com/JuulLabs-OSS/ble v0.0.0-20200517053828-ca7534402217 
h1:THtxHOyxAZdHhhHkRFGXxev58uYyKDkACzP3XDdc0mM=
+github.com/JuulLabs-OSS/ble v0.0.0-20200517053828-ca7534402217/go.mod 
h1:6deIuswYSv6W1l3sM/nonw0OKWtIZCn7ZOWvIREoq2A=
 github.com/JuulLabs-OSS/cbgo v0.0.0-20200421065905-1762a9c3147c 
h1:CwwgT8zV4/uvoPQuRtGBt+aQwLL7zCV/ezGz0UdXp14=
 github.com/JuulLabs-OSS/cbgo v0.0.0-20200421065905-1762a9c3147c/go.mod 
h1:L4YtGP+gnyD84w7+jN66ncspFRfOYB5aj9QSXaFHmBA=
+github.com/JuulLabs-OSS/cbgo v0.0.1 
h1:A5JdglvFot1J9qYR0POZ4qInttpsVPN9lqatjaPp2ro=
+github.com/JuulLabs-OSS/cbgo v0.0.1/go.mod 
h1:L4YtGP+gnyD84w7+jN66ncspFRfOYB5aj9QSXaFHmBA=
 github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5/go.mod 
h1:w5D10RxC0NmPYxmQ438CC1S07zaC1zpvuNW7s5sUk2Q=
 github.com/abiosoft/ishell v2.0.0+incompatible 
h1:zpwIuEHc37EzrsIYah3cpevrIc8Oma7oZPxr03tlmmw=
 github.com/abiosoft/ishell v2.0.0+incompatible/go.mod 
h1:HQR9AqF2R3P4XXpMpI0NAzgHf/aS6+zVXRj14cVk9qg=



[mynewt-core] branch master updated (2eb0948 -> ca5acee)

2020-05-11 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from 2eb0948  Merge pull request #2280 from mlaz/nrf52_adc_fixes
 new d7ba5ff  encoding/base64: Support decode in chunks
 new cbbfccd  encoding/base64: unit tests
 new ca5acee  Merge pull request #2287 from ccollins476ad/base64

The 9618 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 encoding/base64/include/base64/base64.h|  21 +++
 .../base64/selftest/src/base64_test.c  |  13 +-
 .../{encoding_test_priv.h => base64_test_priv.h}   |  16 ++-
 encoding/base64/selftest/src/encoding_test.c   |  39 --
 .../base64/selftest/src/testcases/decode_basic.c   |  54 
 .../base64/selftest/src/testcases/decode_chunks.c  |  79 +++
 .../base64/selftest/src/testcases/decode_maxlen.c  |  27 ++--
 encoding/base64/src/base64.c   | 151 +++--
 8 files changed, 262 insertions(+), 138 deletions(-)
 copy net/oic/selftest/src/test_oic.c => 
encoding/base64/selftest/src/base64_test.c (83%)
 copy encoding/base64/selftest/src/{encoding_test_priv.h => base64_test_priv.h} 
(80%)
 delete mode 100644 encoding/base64/selftest/src/encoding_test.c
 copy sys/sysinit/src/sysinit.c => 
encoding/base64/selftest/src/testcases/decode_basic.c (52%)
 create mode 100644 encoding/base64/selftest/src/testcases/decode_chunks.c
 copy hw/mcu/nxp/MK64F12/src/hal_system.c => 
encoding/base64/selftest/src/testcases/decode_maxlen.c (62%)



[mynewt-documentation] branch master updated: ble bare bones tutorial: Add missing #include

2020-05-11 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-documentation.git


The following commit(s) were added to refs/heads/master by this push:
 new d66fed8  ble bare bones tutorial: Add missing #include
d66fed8 is described below

commit d66fed8fea271c03cc2b6f3cb12be74fcc124cc1
Author: Christopher Collins 
AuthorDate: Sat May 9 20:54:28 2020 -0700

ble bare bones tutorial: Add missing #include
---
 docs/tutorials/ble/ble_bare_bones.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/docs/tutorials/ble/ble_bare_bones.rst 
b/docs/tutorials/ble/ble_bare_bones.rst
index f789411..b679a37 100644
--- a/docs/tutorials/ble/ble_bare_bones.rst
+++ b/docs/tutorials/ble/ble_bare_bones.rst
@@ -158,6 +158,12 @@ NimBLE controller into build. For this update 
``apps/ble_app/syscfg.yml``
 syscfg.vals:
 BLE_HCI_TRANSPORT: builtin
 
+Your `main.c` will also need to include the nimble host header:
+
+.. code-block:: console
+:emphasize-lines: 1
+
+#include "host/ble_hs.h"
 
 **Important note:** The controller package affects system configuration,
 see :doc:`this page <../../network/ble_setup/ble_lp_clock>` for



[mynewt-newt] branch master updated (ec8c217 -> f0a1342)

2020-04-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from ec8c217  Log exported environnment variables with `-ldebug`
 new 71d8423  load: add --imgfile option
 new f0a1342  debug: add --elffile option

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 newt/builder/load.go   | 92 ++
 newt/cli/build_cmds.go | 10 --
 newt/cli/run_cmds.go   |  4 +--
 3 files changed, 73 insertions(+), 33 deletions(-)



[mynewt-newt] 02/02: debug: add --elffile option

2020-04-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit f0a1342e44fbc85ff1d5cb2b9f6b46e70885eb87
Author: Christopher Collins 
AuthorDate: Mon Apr 27 17:43:46 2020 -0700

debug: add --elffile option

This option allows the user to specify the .elf file to load into gdb.
If the option is unspecified, newt uses the .elf file from the target's
bin directory as before.
---
 newt/builder/load.go   | 54 ++
 newt/cli/build_cmds.go |  5 -
 newt/cli/run_cmds.go   |  2 +-
 3 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/newt/builder/load.go b/newt/builder/load.go
index ce72591..d09ce48 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -48,23 +48,23 @@ func (t *TargetBuilder) loadApp(slot int, extraJtagCmd 
string, imgFilename strin
 }
 
 func (t *TargetBuilder) debugLoader(extraJtagCmd string, reset bool,
-   noGDB bool) error {
+   noGDB bool, elfBase string) error {
 
if err := t.bspPkg.Reload(t.LoaderBuilder.cfg.SettingValues()); err != 
nil {
return err
}
 
-   return t.LoaderBuilder.Debug(extraJtagCmd, reset, noGDB)
+   return t.LoaderBuilder.Debug(extraJtagCmd, reset, noGDB, elfBase)
 }
 
 func (t *TargetBuilder) debugApp(extraJtagCmd string, reset bool,
-   noGDB bool) error {
+   noGDB bool, elfBase string) error {
 
if err := t.bspPkg.Reload(t.AppBuilder.cfg.SettingValues()); err != nil 
{
return err
}
 
-   return t.AppBuilder.Debug(extraJtagCmd, reset, noGDB)
+   return t.AppBuilder.Debug(extraJtagCmd, reset, noGDB, elfBase)
 }
 
 // Load loads a .img file onto a device.  If imgFileOverride is not empty, it
@@ -201,15 +201,40 @@ func (b *Builder) Load(imageSlot int, extraJtagCmd 
string, imgFilename string) e
return nil
 }
 
-func (t *TargetBuilder) Debug(extraJtagCmd string, reset bool, noGDB bool) 
error {
+// Debug runs gdb on the .elf file corresponding to what is running on a
+// device.  If elfFileOverride is not empty, it specifies the path of the .elf
+// file to debug.  If it is empty, the .elf file in the target's `bin`
+// directory is loaded.
+func (t *TargetBuilder) Debug(extraJtagCmd string, reset bool, noGDB bool, 
elfFileOverride string) error {
if err := t.PrepBuild(); err != nil {
return err
}
 
+   var elfBase string // Everything except ".elf"
+
+   if elfFileOverride != "" {
+   // The debug script appends ".elf" to the basename.  Make sure 
we can strip
+   // the extension here and the script will reconstruct the 
original
+   // filename.
+   elfBase = strings.TrimSuffix(elfFileOverride, ".elf")
+   if elfBase == elfFileOverride {
+   return util.FmtNewtError(
+   "invalid elf filename: must end in \".elf\": 
filename=%s",
+   elfFileOverride)
+   }
+   }
+
if t.LoaderBuilder == nil {
-   return t.debugApp(extraJtagCmd, reset, noGDB)
+   if elfBase == "" {
+   elfBase = t.AppBuilder.AppBinBasePath()
+   }
+   return t.debugApp(extraJtagCmd, reset, noGDB, elfBase)
+   } else {
+   if elfBase == "" {
+   elfBase = t.LoaderBuilder.AppBinBasePath()
+   }
+   return t.debugLoader(extraJtagCmd, reset, noGDB, elfBase)
}
-   return t.debugLoader(extraJtagCmd, reset, noGDB)
 }
 
 func (b *Builder) debugBin(binPath string, extraJtagCmd string, reset bool,
@@ -231,6 +256,9 @@ func (b *Builder) debugBin(binPath string, extraJtagCmd 
string, reset bool,
return err
}
 
+   // Make sure the elf override (if any) gets used.
+   env["BIN_BASENAME"] = binPath
+
if extraJtagCmd != "" {
env["EXTRA_JTAG_CMD"] = extraJtagCmd
}
@@ -241,9 +269,6 @@ func (b *Builder) debugBin(binPath string, extraJtagCmd 
string, reset bool,
env["NO_GDB"] = "1"
}
 
-   // The debug script appends ".elf" to the basename.
-   env["BIN_BASENAME"] = strings.TrimSuffix(env["BIN_BASENAME"], ".elf")
-
os.Chdir(project.GetProject().Path())
 
RunOptionalCheck(bspPkg.OptChkScript, env)
@@ -257,11 +282,6 @@ func (b *Builder) debugBin(binPath string, extraJtagCmd 
string, reset bool,
return util.ShellInteractiveCommand(cmdLine, env, false)
 }
 
-func (b *Builder) Debug(extraJtagCmd string, reset bool, noGDB bool) error {
-   binPath, err := b.binBasePath()
-   if err != nil {

[mynewt-newt] 01/02: load: add --imgfile option

2020-04-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 71d8423722a554c00bd8ff5734878252d4f42919
Author: Christopher Collins 
AuthorDate: Mon Apr 27 17:12:44 2020 -0700

load: add --imgfile option

This option allows the user to specify the .img file to load onto the
device.  If the option is unspecified, newt loads the image file from
the target's bin directory as before.
---
 newt/builder/load.go   | 38 ++
 newt/cli/build_cmds.go |  5 -
 newt/cli/run_cmds.go   |  2 +-
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/newt/builder/load.go b/newt/builder/load.go
index ec8f4df..ce72591 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -31,20 +31,20 @@ import (
"mynewt.apache.org/newt/util"
 )
 
-func (t *TargetBuilder) loadLoader(slot int, extraJtagCmd string) error {
+func (t *TargetBuilder) loadLoader(slot int, extraJtagCmd string, imgFilename 
string) error {
if err := t.bspPkg.Reload(t.LoaderBuilder.cfg.SettingValues()); err != 
nil {
return err
}
 
-   return t.LoaderBuilder.Load(slot, extraJtagCmd)
+   return t.LoaderBuilder.Load(slot, extraJtagCmd, imgFilename)
 }
 
-func (t *TargetBuilder) loadApp(slot int, extraJtagCmd string) error {
+func (t *TargetBuilder) loadApp(slot int, extraJtagCmd string, imgFilename 
string) error {
if err := t.bspPkg.Reload(t.AppBuilder.cfg.SettingValues()); err != nil 
{
return err
}
 
-   return t.AppBuilder.Load(slot, extraJtagCmd)
+   return t.AppBuilder.Load(slot, extraJtagCmd, imgFilename)
 }
 
 func (t *TargetBuilder) debugLoader(extraJtagCmd string, reset bool,
@@ -67,19 +67,32 @@ func (t *TargetBuilder) debugApp(extraJtagCmd string, reset 
bool,
return t.AppBuilder.Debug(extraJtagCmd, reset, noGDB)
 }
 
-func (t *TargetBuilder) Load(extraJtagCmd string) error {
+// Load loads a .img file onto a device.  If imgFileOverride is not empty, it
+// specifies the path of the image file to load.  If it is empty, the image in
+// the target's `bin` directory is loaded.
+func (t *TargetBuilder) Load(extraJtagCmd string, imgFileOverride string) 
error {
err := t.PrepBuild()
if err != nil {
return err
}
 
+   if t.LoaderBuilder != nil && imgFileOverride != "" {
+   return util.FmtNewtError(
+   "cannot specify image file override for split images")
+   }
+
+   appImg := imgFileOverride
+   if appImg == "" {
+   appImg = t.AppBuilder.AppBinBasePath()
+   }
+
if t.LoaderBuilder != nil {
-   err = t.loadApp(1, extraJtagCmd)
+   err = t.loadApp(1, extraJtagCmd, appImg)
if err == nil {
-   err = t.loadLoader(0, extraJtagCmd)
+   err = t.loadLoader(0, extraJtagCmd, 
t.LoaderBuilder.AppBinBasePath())
}
} else {
-   err = t.loadApp(0, extraJtagCmd)
+   err = t.loadApp(0, extraJtagCmd, appImg)
}
 
return err
@@ -149,7 +162,7 @@ func Load(binBasePath string, bspPkg *pkg.BspPackage,
return nil
 }
 
-func (b *Builder) Load(imageSlot int, extraJtagCmd string) error {
+func (b *Builder) Load(imageSlot int, extraJtagCmd string, imgFilename string) 
error {
if b.appPkg == nil {
return util.NewNewtError("app package not specified")
}
@@ -171,15 +184,16 @@ func (b *Builder) Load(imageSlot int, extraJtagCmd 
string) error {
 
if _, ok := env["BOOT_LOADER"]; ok {
util.StatusMessage(util.VERBOSITY_DEFAULT,
-   "Loading bootloader\n")
+   "Loading bootloader (%s)\n", imgFilename)
} else {
util.StatusMessage(util.VERBOSITY_DEFAULT,
-   "Loading %s image into slot %d\n", b.buildName, 
imageSlot+1)
+   "Loading %s image into slot %d (%s)\n", b.buildName, 
imageSlot+1, imgFilename)
}
 
// Convert the binary path from absolute to relative.  This is required 
for
// compatibility with unix-in-windows environemnts (e.g., cygwin).
-   binPath := util.TryRelPath(b.AppBinBasePath())
+   binPath := util.TryRelPath(imgFilename)
+
if err := Load(binPath, b.targetBuilder.bspPkg, env); err != nil {
return err
}
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 6901e4a..ff11231 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -104,6 +104,7 @@ func pkgToUnitTests(pack *pkg.LocalPackage) 
[]*pkg.LocalPackage {
 var extraJtagCmd string
 var noGDB_flag bool
 var diffFriendly_flag

[mynewt-newt] branch master updated: Log exported environnment variables with `-ldebug`

2020-04-27 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new ec8c217  Log exported environnment variables with `-ldebug`
ec8c217 is described below

commit ec8c217bac1985f34c9a6f62902a3e5ee7abfa45
Author: Christopher Collins 
AuthorDate: Wed Apr 22 10:39:23 2020 -0700

Log exported environnment variables with `-ldebug`
---
 newt/builder/targetbuild.go | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index bbc35ff..57e4952 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -25,6 +25,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+   "sort"
"strings"
 
log "github.com/sirupsen/logrus"
@@ -227,8 +228,19 @@ func (t *TargetBuilder) ensureResolved() error {
 
// Configure the basic set of environment variables in the current 
process.
env := BasicEnvVars("", t.bspPkg)
-   for k, v := range env {
-   if err := os.Setenv(k, v); err != nil {
+   keys := make([]string, 0, len(env))
+   for k, _ := range env {
+   keys = append(keys, k)
+   }
+   sort.Strings(keys)
+
+   log.Debugf("exporting environment variables:")
+   for _, k := range keys {
+   v := env[k]
+   log.Debugf("%s=%s", k, env[k])
+
+   err := os.Setenv(k, v)
+   if err != nil {
return util.FmtNewtError(
"failed to set env var %s=%s: %s", k, v, 
err.Error())
}



[mynewt-core] branch master updated: sys/config: read/write access config for mgmt cmd

2020-04-22 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 3118782  sys/config: read/write access config for mgmt cmd
 new e437573  Merge pull request #2277 from ccollins476ad/config-mgmt-rw
3118782 is described below

commit 3118782f981ee96bec464527792126fec0696b07
Author: Christopher Collins 
AuthorDate: Tue Apr 21 13:52:43 2020 -0700

sys/config: read/write access config for mgmt cmd

Before commit: the `CONFIG_MGMT` syscfg setting disabled or enabled the
config newtmgr command in its entirety.  There was no way to enable only
the read half of the command (for example).

After commit: there is a second syscfg setting: `CONFIG_MGMT_RW`.  The
semantics mirror the `CONFIG_CLI_RW` setting.  That is:

* If `CONFIG_MGMT` is 0, the entire command is disabled.

Otherwise:

* If `CONFIG_MGMT_RW` is 1, only read commands are allowed.
* If `CONFIG_MGMT_RW` is 2, only write commands are allowed.
* If `CONFIG_MGMT_RW` is 3, both reads and writes are allowed.
---
 sys/config/src/config_mgmt.c | 24 +++-
 sys/config/syscfg.yml|  7 +++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/sys/config/src/config_mgmt.c b/sys/config/src/config_mgmt.c
index f74bae7..9a8fe7d 100644
--- a/sys/config/src/config_mgmt.c
+++ b/sys/config/src/config_mgmt.c
@@ -28,11 +28,29 @@
 #include "config/config.h"
 #include "config_priv.h"
 
+#define CONFIG_MGMT_READ(MYNEWT_VAL(CONFIG_MGMT_RW) & 1)
+#define CONFIG_MGMT_WRITE   (MYNEWT_VAL(CONFIG_MGMT_RW) & 2)
+
+#if CONFIG_MGMT_READ
 static int conf_mgmt_read(struct mgmt_ctxt *);
+#endif
+#if CONFIG_MGMT_WRITE
 static int conf_mgmt_write(struct mgmt_ctxt *);
+#endif
 
 static const struct mgmt_handler conf_mgmt_handlers[] = {
-[CONF_NMGR_OP] = { conf_mgmt_read, conf_mgmt_write}
+[CONF_NMGR_OP] = {
+#if CONFIG_MGMT_READ
+conf_mgmt_read,
+#else
+NULL,
+#endif
+#if CONFIG_MGMT_WRITE
+conf_mgmt_write,
+#else
+NULL,
+#endif
+}
 };
 
 static struct mgmt_group conf_mgmt_group = {
@@ -41,6 +59,7 @@ static struct mgmt_group conf_mgmt_group = {
 .mg_group_id = MGMT_GROUP_ID_CONFIG
 };
 
+#if CONFIG_MGMT_READ
 static int
 conf_mgmt_read(struct mgmt_ctxt *cb)
 {
@@ -80,7 +99,9 @@ conf_mgmt_read(struct mgmt_ctxt *cb)
 }
 return 0;
 }
+#endif
 
+#if CONFIG_MGMT_WRITE
 static int
 conf_mgmt_write(struct mgmt_ctxt *cb)
 {
@@ -141,6 +162,7 @@ conf_mgmt_write(struct mgmt_ctxt *cb)
 }
 return 0;
 }
+#endif
 
 int
 conf_mgmt_register(void)
diff --git a/sys/config/syscfg.yml b/sys/config/syscfg.yml
index d8e5dbd..e615a59 100644
--- a/sys/config/syscfg.yml
+++ b/sys/config/syscfg.yml
@@ -41,6 +41,13 @@ syscfg.defs:
 description: 'SMP access to config'
 value: 0
 
+CONFIG_MGMT_RW:
+description: >
+Config management access: 1=read-only, 2=write-only, 3=read/write
+No effect if `CONFIG_MGMT` is 0.
+value: 3
+range: 1,2,3
+
 CONFIG_CLI:
 description: 'CLI commands for accessing config'
 value: 0



[mynewt-newt] branch master updated: INSTALLING.md fix

2020-04-22 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new c2f8b25  INSTALLING.md fix
c2f8b25 is described below

commit c2f8b25c301bf60b45857f412dcc82f04395850b
Author: Krzysztof Kopyściński 
AuthorDate: Thu Mar 26 09:57:10 2020 +0100

INSTALLING.md fix

- corrected requiered version of Go
- second method of installation made easier
---
 INSTALLING.md | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/INSTALLING.md b/INSTALLING.md
index 5b01c5a..2d97f74 100644
--- a/INSTALLING.md
+++ b/INSTALLING.md
@@ -11,7 +11,7 @@ when available.  To find these, please go to 
https://mynewt.apache.org/.
 # Installing From Source
 
 The newt tool is written in Go (https://golang.org/).  In order to build Apache
-Mynewt, you must have Go 1.10 or later installed on your system.  Please visit
+Mynewt, you must have Go 1.12 or later installed on your system.  Please visit
 the Golang website for more information on installing Go (https://golang.org/).
 
 Once you have Go installed, you can build newt by running the contained
@@ -25,12 +25,14 @@ following path, relative to the source directory:
 If you do not wish to run the included script, you can build newt manually 
with Go as follows (executed from the source directory):
 
 ```no-highlight
-$ mkdir "$GOPATH"/src/mynewt.apache.org
-$ cp -r * "$GOPATH"/src/mynewt.apache.org # Or untar to this path
-$ go install mynewt.apache.org/newt/newt
+$ cd "$GOPATH"/src/
+$ git clone https://github.com/apache/mynewt-newt
+$ cd mynewt-newt/newt
+$ go get
+$ go build
 ```
 
-This puts the newt binary in $GOPATH/bin
+This downloads the dependencies and builds newt executable.
 
 You can test the installation by running newt:
 



[mynewt-newtmgr] branch master updated: mojave / catalina support

2020-04-15 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git


The following commit(s) were added to refs/heads/master by this push:
 new 1c5d2dc  mojave / catalina support
1c5d2dc is described below

commit 1c5d2dcf5101274a3c94895455442440fe9c711a
Author: Christopher Collins 
AuthorDate: Mon Apr 13 13:58:35 2020 -0700

mojave / catalina support

This commit switches newtmgr from the official go-ble library to the
runtimeco fork.

The runtimeco fork implements central functionality using the
CoreBluetooth API rather than XPC messages.  This makes it compatible
across all versions of macOS.

The runtimeco fork does not implement any peripheral functionality.
That is why the changes are not being merged upstream.  This is fine for
our use case since newtmgr doesn't need any peripheral functionality.
---
 go.mod| 16 +++-
 go.sum| 32 
 newtmgr/bll/bll_common.go |  2 +-
 newtmgr/bll/bll_sesn.go   |  2 +-
 newtmgr/bll/bll_sesn_cfg.go   |  2 +-
 newtmgr/bll/bll_util.go   |  2 +-
 newtmgr/bll/bll_xport.go  | 11 ++-
 newtmgr/bll/bll_xport_linux.go|  6 +++---
 newtmgr/bll/bll_xport_nonlinux.go |  2 +-
 newtmgr/config/bll_config.go  |  2 +-
 10 files changed, 54 insertions(+), 23 deletions(-)

diff --git a/go.mod b/go.mod
index 2706735..6112ac2 100644
--- a/go.mod
+++ b/go.mod
@@ -3,8 +3,10 @@ module mynewt.apache.org/newtmgr
 go 1.12
 
 require (
+   github.com/JuulLabs-OSS/ble v0.0.0-20200415235928-df3a9e6783a9
+   github.com/abiosoft/ishell v2.0.0+incompatible // indirect
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // 
indirect
-   github.com/cheggaaa/pb v2.0.7+incompatible
+   github.com/cheggaaa/pb v2.0.7+incompatible // indirect
github.com/chzyer/logex v1.1.10 // indirect
github.com/chzyer/readline v0.0.0-20171208011716-f6d7a1f6fbf3 // 
indirect
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
@@ -12,31 +14,27 @@ require (
github.com/fatih/color v1.7.0 // indirect
github.com/fatih/structs v1.1.0
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 // 
indirect
-   github.com/go-ble/ble v0.0.0-20190521171521-147700f13610
-   github.com/go-delve/delve v1.3.1 // indirect
github.com/joaojeronimo/go-crc16 v0.0.0-20140729130949-59bd0194935e
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
-   github.com/mattn/go-colorable v0.1.4 // indirect
-   github.com/mattn/go-isatty v0.0.10 // indirect
+   github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-runewidth v0.0.6 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/peterh/liner v1.1.0 // indirect
github.com/pkg/errors v0.8.1
-   github.com/raff/goble v0.0.0-20190909174656-72afc67d6a99 // indirect
+   github.com/raff/goble v0.0.0-20200327175727-d63360dcfd80 // indirect
github.com/runtimeco/go-coap v0.0.0-20190911184520-8e5532820fc0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cast v1.3.0
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
-   github.com/ugorji/go v1.1.7
+   github.com/ugorji/go v1.1.7 // indirect
github.com/ugorji/go/codec v1.1.7
go.starlark.net v0.0.0-20190919145610-979af19b165c // indirect
golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 // indirect
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914
-   golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e // indirect
gopkg.in/VividCortex/ewma.v1 v1.1.1 // indirect
gopkg.in/abiosoft/ishell.v2 v2.0.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
@@ -46,5 +44,5 @@ require (
gopkg.in/mattn/go-isatty.v0 v0.0.4 // indirect
gopkg.in/mattn/go-runewidth.v0 v0.0.4 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
-   mynewt.apache.org/newt v0.0.0-20191121024904-fffae9bf8db8
+   mynewt.apache.org/newt v0.0.0-20200409145402-c5d1e422bfa3
 )
diff --git a/go.sum b/go.sum
index 494a900..ddf1498 100644
--- a/go.sum
+++ b/go.sum
@@ -1,17 +1,23 @@
 github.com/BurntSushi/toml v0.3.1/go.mod 
h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/JuulLabs-OSS/ble v0.0.0-20200415235928-df3a9e6783a9 
h1:2VXy9m1Bl4unkc3ZcWUrwn/sv1uCoimg99wmFv4xoNE=
+github.com/JuulLabs-OSS/ble v0.0.0-20200415235928-df3a9e6783a9/go.mod 
h1:qMsm/vRFvBk32uWdeFzvSZ8xsw0DUopgJFRgxaYpzt4=
 github.com/NickBall

[mynewt-core] branch master updated: Adding a version into newt compatilibilty map, for version: 0.0.1

2020-04-03 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new f57b528  Adding a version into newt compatilibilty map, for version: 
0.0.1
f57b528 is described below

commit f57b528b578ddd1187e032b4c61567fab37145d1
Author: Robertino Benis 
AuthorDate: Fri Apr 3 15:29:02 2020 -0700

Adding a version into newt compatilibilty map, for version: 0.0.1

- this removes newt warning when building JDP, since newt picks 0.0.1 for 
commit from master
- and warns that 0.0.1 is not listed in compatibility map.
---
 repository.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/repository.yml b/repository.yml
index eef1e38..f6b4609 100644
--- a/repository.yml
+++ b/repository.yml
@@ -60,6 +60,8 @@ repo.newt_compatibility:
 # present.
 0.0.0:
 0.0.0: good
+0.0.1:
+0.0.1: good
 
 # Core 1.1.0+ requires newt 1.1.0+ (feature: self-overrides).
 # Core 1.4.0+ requires newt 1.4.0+ (feature: sync repo deps).



[mynewt-core] branch master updated: const correctness log name

2020-04-03 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 98cb076  const correctness log name
98cb076 is described below

commit 98cb07656920a360f141a38dc32c97f9f2d042e9
Author: Simon Frank <521620+5fr...@users.noreply.github.com>
AuthorDate: Fri Apr 3 16:01:41 2020 +0200

const correctness log name

const recently added to struct os_dev name (which is great) but using
that name with the log module currently gives compile error.
---
 sys/log/full/include/log/log.h | 4 ++--
 sys/log/full/src/log.c | 2 +-
 sys/log/stub/include/log/log.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/log/full/include/log/log.h b/sys/log/full/include/log/log.h
index 7a1f98f..7ca34c1 100644
--- a/sys/log/full/include/log/log.h
+++ b/sys/log/full/include/log/log.h
@@ -202,7 +202,7 @@ STATS_SECT_END
 #endif
 
 struct log {
-char *l_name;
+const char *l_name;
 const struct log_handler *l_log;
 void *l_arg;
 STAILQ_ENTRY(log) l_next;
@@ -248,7 +248,7 @@ uint8_t log_module_register(uint8_t id, const char *name);
 const char *log_module_get_name(uint8_t id);
 
 /* Log functions, manipulate a single log */
-int log_register(char *name, struct log *log, const struct log_handler *,
+int log_register(const char *name, struct log *log, const struct log_handler *,
  void *arg, uint8_t level);
 
 /**
diff --git a/sys/log/full/src/log.c b/sys/log/full/src/log.c
index 13e4a3d..473618e 100644
--- a/sys/log/full/src/log.c
+++ b/sys/log/full/src/log.c
@@ -371,7 +371,7 @@ log_read_last_hdr(struct log *log, struct log_entry_hdr 
*out_hdr)
  * Associate an instantiation of a log with the logging infrastructure
  */
 int
-log_register(char *name, struct log *log, const struct log_handler *lh,
+log_register(const char *name, struct log *log, const struct log_handler *lh,
  void *arg, uint8_t level)
 {
 struct log_entry_hdr hdr;
diff --git a/sys/log/stub/include/log/log.h b/sys/log/stub/include/log/log.h
index 2b1a17f..0729c1d 100644
--- a/sys/log/stub/include/log/log.h
+++ b/sys/log/stub/include/log/log.h
@@ -40,7 +40,7 @@ struct log_handler {
 };
 
 static inline int
-log_register(char *name, struct log *log, const struct log_handler *h,
+log_register(const char *name, struct log *log, const struct log_handler *h,
  void *arg, uint8_t level)
 {
 return 0;



[mynewt-newt] branch master updated (b8147e0 -> 316ca1d)

2020-04-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from b8147e0  Use rc-tag-inference in inter-repo dependencies
 new c5a8844  Update documentation for mfg create
 new 627d4d3  Removed create-image for bootloader, added link to file 
structure
 new 316ca1d  Removed unnecessary newt build

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/command_list/newt_mfg.rst | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)



[mynewt-newt] 02/03: Removed create-image for bootloader, added link to file structure

2020-04-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 627d4d3e6db26c58eed6406de645463d630d5c35
Author: Stefan Diewald 
AuthorDate: Thu Apr 2 09:13:36 2020 +0200

Removed create-image for bootloader, added link to file structure

Removed create-image for the bootloader as commented by @ccollins476ad.
Added a link to the file structure overview in the mfg README.md
---
 docs/command_list/newt_mfg.rst | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/docs/command_list/newt_mfg.rst b/docs/command_list/newt_mfg.rst
index ee89005..8df2a68 100644
--- a/docs/command_list/newt_mfg.rst
+++ b/docs/command_list/newt_mfg.rst
@@ -104,7 +104,7 @@ Build the bootloader and app images.
 
 .. code-block:: console
 
-$ newt build rb_boot && newt create-image rb_boot 0.0.1
+$ newt build rb_boot
 $ newt build rb_blink && newt create-image rb_blinky 0.0.1
 
 Run the ``newt mfg create`` command to collect all the manufacturing snapshot 
files.
@@ -116,3 +116,5 @@ Run the ``newt mfg create`` command to collect all the 
manufacturing snapshot fi
 
 Generated the following files:
 
+
+A description of the generated files is available in the implementation's 
`readme 
<https://github.com/apache/mynewt-newt/blob/master/newt/mfg/README.md#file-structure>`_



[mynewt-newt] 01/03: Update documentation for mfg create

2020-04-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit c5a8844fe2c59486768c5bf55384a64c47851e07
Author: Stefan Diewald 
AuthorDate: Wed Apr 1 15:40:57 2020 +0200

Update documentation for mfg create

Update for the documentation of mfg create command
to match the current implementation.

Signed-off-by: Stefan Diewald 
---
 docs/command_list/newt_mfg.rst | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/docs/command_list/newt_mfg.rst b/docs/command_list/newt_mfg.rst
index e614788..ee89005 100644
--- a/docs/command_list/newt_mfg.rst
+++ b/docs/command_list/newt_mfg.rst
@@ -73,7 +73,7 @@ Create the directory to hold the mfg packages.
 
 $ mkdir -p mfgs/rb_blinky_rsa
 
-The ``rb_blinky_rsa`` package needs a pkg.yml file. In addition it is needs a 
mfg.yml file to specify the two constituent targets. An example of each file is 
shown below.
+The ``rb_blinky_rsa`` package needs a pkg.yml file. In addition, it needs a 
mfg.yml file to specify the two constituent targets. An example of each file is 
shown below.
 
 .. code-block:: console
 
@@ -87,16 +87,25 @@ The ``rb_blinky_rsa`` package needs a pkg.yml file. In 
addition it is needs a mf
 .. code-block:: console
 
 $  more mfgs/rb_blinky_rsa/mfg.yml
-mfg.bootloader: 'targets/rb_boot'
-mfg.images:
-- 'targets/rb_blinky'
+mfg.bsp: "@apache-mynewt-core/hw/bsp/rb-nano2"
+mfg.targets:
+- rb_boot:
+  name: "targets/rb_boot"
+  area: FLASH_AREA_BOOTLOADER
+  offset: 0x0
+- rb_blinky:
+  name: "targets/rb_blinky"
+  area: FLASH_AREA_IMAGE_0
+  offset: 0x0
+mfg.meta:
+area: FLASH_AREA_BOOTLOADER
 
 Build the bootloader and app images.
 
 .. code-block:: console
 
-$ newt build rb_boot
-$ newt create-image rb_blinky 0.0.1
+$ newt build rb_boot && newt create-image rb_boot 0.0.1
+$ newt build rb_blink && newt create-image rb_blinky 0.0.1
 
 Run the ``newt mfg create`` command to collect all the manufacturing snapshot 
files.
 



[mynewt-newt] 03/03: Removed unnecessary newt build

2020-04-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 316ca1d40001450ed56cc1f1321a2cef54c0e6f1
Author: Stefan Diewald 
AuthorDate: Thu Apr 2 18:26:41 2020 +0200

Removed unnecessary newt build

Removed unnecessary newt build

Signed-off-by: Stefan Diewald 
---
 docs/command_list/newt_mfg.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/command_list/newt_mfg.rst b/docs/command_list/newt_mfg.rst
index 8df2a68..819a27e 100644
--- a/docs/command_list/newt_mfg.rst
+++ b/docs/command_list/newt_mfg.rst
@@ -105,7 +105,7 @@ Build the bootloader and app images.
 .. code-block:: console
 
 $ newt build rb_boot
-$ newt build rb_blink && newt create-image rb_blinky 0.0.1
+$ newt create-image rb_blinky 0.0.1
 
 Run the ``newt mfg create`` command to collect all the manufacturing snapshot 
files.
 



[mynewt-newt] 01/02: downloader: Return base commit if no rc tag

2020-03-25 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 2faa8ca9b2670b724d396d7affd3b88d71d2b089
Author: Christopher Collins 
AuthorDate: Tue Mar 24 16:54:46 2020 -0700

downloader: Return base commit if no rc tag

downloader.LatestRc() infers the latest "rc" tag given a base string
(e.g., "mynewt_1_8_0_tag" might resolve to "mynewt_1_8_0_rc3_tag").

If there are no rc tags for the given base, this function used to return
"".  This is error prone and it requires the caller to stash the base
string until he has inspected the return value.

This commit changes this function so that it returns the base string
unmodified if there are no rc tags.
---
 newt/downloader/downloader.go | 11 ++-
 newt/repo/repo.go |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go
index 506b798..2230db1 100644
--- a/newt/downloader/downloader.go
+++ b/newt/downloader/downloader.go
@@ -728,14 +728,11 @@ func (gd *GenericDownloader) LatestRc(path string,
 
notag := strings.TrimSuffix(base, "_tag")
if notag == base {
-   return "", nil
+   return base, nil
}
 
restr := fmt.Sprintf("^%s_rc(\\d+)_tag$", regexp.QuoteMeta(notag))
-   re, err := regexp.Compile(restr)
-   if err != nil {
-   return "", util.FmtNewtError("internal error: %s", err.Error())
-   }
+   re := regexp.MustCompile(restr)
 
bestNum := -1
bestStr := ""
@@ -750,6 +747,10 @@ func (gd *GenericDownloader) LatestRc(path string,
}
}
 
+   if bestStr == "" {
+   bestStr = base
+   }
+
return bestStr, nil
 }
 
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 0770c90..5f1ccce 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -291,7 +291,7 @@ func (r *Repo) updateRepo(commit string) error {
"Error updating \"%s\": %s", r.Name(), 
err.Error())
}
 
-   if newCommit != "" {
+   if newCommit != commit {
util.StatusMessage(util.VERBOSITY_DEFAULT,
"in repo \"%s\": commit \"%s\" does not exist; 
"+
"using \"%s\" instead\n",



[mynewt-newt] 02/02: Use rc-tag-inference in inter-repo dependencies

2020-03-25 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit b8147e0284cf75765799a79f6ec0f57a49542a50
Author: Christopher Collins 
AuthorDate: Tue Mar 24 16:54:37 2020 -0700

Use rc-tag-inference in inter-repo dependencies

A repo can specify dependencies in its `repository.yml` file, e.g.,

repo.deps:
apache-mynewt-nimble:
type: github
user: apache
repo: mynewt-nimble
vers:
mynewt_1_4_0_tag: 1.0.0

The `mynewt_1_4_0_tag` tag of *this repo* depends on nimble 1.0.0.  If
`mynewt_1_4_0_tag` does not exist, then `newt upgrade` would fail.

The tag-validity check that newt was doing here was too strict.  If the
specified tag doesn't exist, newt should attempt rc-tag-inference.  For
example, if `mynewt_1_4_0_tag` does not exist, newt should check for the
latest corresponding rc tag (e.g., `mynewt_1_4_0_rc1_tag`).  If one is
found, then the dependency list is valid after all.

Newt already applies this rc-tag-inference procedure when it actually
performs the upgrade.  However, the check that happens before the
upgrade was not using rc-tag-inference.  This commit adds
rc-tag-inference to this check.
---
 newt/install/install.go | 5 +
 1 file changed, 5 insertions(+)

diff --git a/newt/install/install.go b/newt/install/install.go
index 5bc5f0c..c26e956 100644
--- a/newt/install/install.go
+++ b/newt/install/install.go
@@ -423,6 +423,11 @@ func (inst *Installer) calcVersionMap(candidates 
[]*repo.Repo) (
 
for _, r := range repoList {
for commit, _ := range r.CommitDepMap() {
+   commit, err := r.Downloader().LatestRc(r.Path(), commit)
+   if err != nil {
+   return nil, err
+   }
+
equiv, err := r.Downloader().CommitsFor(r.Path(), 
commit)
if err != nil {
return nil, err



[mynewt-newt] branch master updated (e73b109 -> b8147e0)

2020-03-25 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from e73b109  newt new: Infer latest "rc" tag for blinky
 new 2faa8ca  downloader: Return base commit if no rc tag
 new b8147e0  Use rc-tag-inference in inter-repo dependencies

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 newt/downloader/downloader.go | 11 ++-
 newt/install/install.go   |  5 +
 newt/repo/repo.go |  2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)



[mynewt-core] branch master updated: Revert "Prepare for Apache Mynewt 1.8.0 release"

2020-03-18 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 455a6d2  Revert "Prepare for Apache Mynewt 1.8.0 release"
455a6d2 is described below

commit 455a6d2feba7a13677634483db1261630f29363a
Author: Christopher Collins 
AuthorDate: Wed Mar 18 11:33:57 2020 -0700

Revert "Prepare for Apache Mynewt 1.8.0 release"

This reverts commit 03b8d33d6fb03b696f9ff2ebad2e6982894045d4.

Fix `newt upgrade` until we resolve the newt rc-infer issues.
---
 repository.yml | 8 
 1 file changed, 8 deletions(-)

diff --git a/repository.yml b/repository.yml
index eef1e38..1e80771 100644
--- a/repository.yml
+++ b/repository.yml
@@ -36,7 +36,6 @@ repo.versions:
 "1.5.0": "mynewt_1_5_0_tag"
 "1.6.0": "mynewt_1_6_0_tag"
 "1.7.0": "mynewt_1_7_0_tag"
-"1.8.0": "mynewt_1_8_0_tag"
 
 "0-latest": "1.7.0"
 "1-latest": "1.7.0"
@@ -52,7 +51,6 @@ repo.versions:
 "1.5-latest": "1.5.0"
 "1.6-latest": "1.6.0"
 "1.7-latest": "1.7.0"
-"1.8-latest": "1.8.0"
 
 repo.newt_compatibility:
 # Allow all versions for 0.0.0.  This is a workaround to prevent a warning
@@ -66,9 +64,6 @@ repo.newt_compatibility:
 # Core 1.5.0+ requires newt 1.5.0+ (feature: transient packages)
 # Core 1.6.0+ requires newt 1.6.0+ (feature: choice)
 # Core 1.7.0+ requires newt 1.7.0+ (feature: range)
-# Core 1.8.0+ requires newt 1.8.0+ (feature: version.yml not needed)
-1.8.0:
-1.8.0: good
 1.7.0:
 1.7.0: good
 1.6.0:
@@ -98,7 +93,6 @@ repo.deps:
 mynewt_1_5_0_tag: 1.0.0
 mynewt_1_6_0_tag: 1.1.0
 mynewt_1_7_0_tag: 1.2.0
-mynewt_1_8_0_tag: 1.3.0
 
 mcuboot:
 type: github
@@ -107,7 +101,6 @@ repo.deps:
 vers:
 master: 0-dev
 mynewt_1_7_0_tag: 1.3.1
-mynewt_1_8_0_tag: 1.5.0
 
 apache-mynewt-mcumgr:
 type: github
@@ -115,4 +108,3 @@ repo.deps:
 repo: mynewt-mcumgr
 vers:
 master: 0-dev
-mynewt_1_8_0_tag: 0.1.0



[mynewt-newt] branch master updated: newt new: Infer latest "rc" tag for blinky

2020-03-18 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new e73b109  newt new: Infer latest "rc" tag for blinky
e73b109 is described below

commit e73b109c22f057ea8ac0db4cdafaf12531ae66d5
Author: Christopher Collins 
AuthorDate: Wed Mar 18 09:38:43 2020 -0700

newt new: Infer latest "rc" tag for blinky

To prevent code churn during the release process, newt infers the latest
"rc" tag when updating a Mynewt repo (rather than forcing the maintainer
to update the non-rc tag each time a new release candidate is created).

This tag inference feature was applied to repos during `newt upgrade`.
It was not applied to the blinky repo during `newt new`.'

This commit adds tag inference to `newt new`.
---
 newt/cli/project_cmds.go | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index 68bfbef..290a04c 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -60,12 +60,22 @@ func newRunCmd(cmd *cobra.Command, args []string) {
}
defer os.RemoveAll(tmpdir)
 
-   if err := dl.Clone(newtutil.NewtBlinkyTag, tmpdir); err != nil {
+   if err := dl.Clone("master", tmpdir); err != nil {
+   NewtUsage(nil, err)
+   }
+
+   commit, err := dl.LatestRc(tmpdir, newtutil.NewtBlinkyTag)
+   if err != nil {
+   NewtUsage(nil, err)
+   }
+
+   err = dl.Checkout(tmpdir, commit)
+   if err != nil {
NewtUsage(nil, err)
}
 
util.StatusMessage(util.VERBOSITY_DEFAULT, "Installing "+
-   "skeleton in %s...\n", newDir)
+   "skeleton in %s (commit: %s)\n", newDir, commit)
 
if err := util.CopyDir(tmpdir, newDir); err != nil {
NewtUsage(cmd, err)



[mynewt-newt] branch master updated: upgrade: Don't warn on fixup to an equivalent URL

2020-03-09 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new 45add9e  upgrade: Don't warn on fixup to an equivalent URL
45add9e is described below

commit 45add9ee283c1bfd1a5a80fce694451e1cdffcd8
Author: Christopher Collins 
AuthorDate: Thu Mar 5 17:00:31 2020 -0800

upgrade: Don't warn on fixup to an equivalent URL

If `project.yml` specifies a repo with a different URL than the current
`origin`, newt fixes the `origin` URL and produces a warning like this:

WARNING: Repo's "origin" remote points to unexpected URL:
g...@github.com:apache/mynewt-nimble.git; correcting it to
https://github.com/apache/mynewt-nimble.git.  Repo contents may be
incorrect.

This commit suppresses the warning if the two URLs are "equivalent".
URLs are considered equivalent if:

1. The strings are identical after the optional ".git" suffixes are
   stripped,

   OR

2. One is a "git@" URL and the other is an "https://; URL for the same
   repo.  For example:
   g...@github.com:apache/mynewt-core.git
   https://github.com/apache/mynewt-core
---
 newt/downloader/downloader.go | 55 +--
 1 file changed, 53 insertions(+), 2 deletions(-)

diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go
index 474309d..506b798 100644
--- a/newt/downloader/downloader.go
+++ b/newt/downloader/downloader.go
@@ -314,6 +314,57 @@ func getCommits(path string) (map[string]Commit, error) {
return m, nil
 }
 
+// urlsEquivalent determines if two URLs point to the same repo.  URLs are
+// equivalent if:
+// 1. The strings are identical after the optional ".git" suffixes are
+//stripped,
+//  OR
+// 2. One is a "git@" URL and the other is an "https://; URL for the same
+//repo.  For example:
+//g...@github.com:apache/mynewt-core.git
+//https://github.com/apache/mynewt-core
+func urlsEquivalent(a string, b string) bool {
+   // Strip optional `.git` suffix.
+   a = strings.TrimSuffix(a, ".git")
+   b = strings.TrimSuffix(b, ".git")
+
+   if a == b {
+   return true
+   }
+
+   gitRE := regexp.MustCompile(`git@([^:]+):(.*)`)
+
+   parseGit := func(s string) string {
+   groups := gitRE.FindStringSubmatch(s)
+   if len(groups) != 3 {
+   return ""
+   }
+
+   return groups[1] + "/" + groups[2]
+   }
+
+   parseHttps := func(s string) string {
+   if !strings.HasPrefix(s, "https://;) {
+   return ""
+   }
+
+   return strings.TrimPrefix(s, "https://;)
+   }
+
+   var git string
+   var https string
+
+   git = parseGit(a)
+   if git == "" {
+   git = parseGit(b)
+   https = parseHttps(a)
+   } else {
+   https = parseHttps(b)
+   }
+
+   return git != "" && git == https
+}
+
 // init populates a generic downloader with branch and tag information.
 func (gd *GenericDownloader) init(path string) error {
cmap, err := getCommits(path)
@@ -848,7 +899,7 @@ func (gd *GithubDownloader) FixupOrigin(path string) error {
 
// Use the public URL, i.e., hide the login and password.
_, publicUrl := gd.remoteUrls()
-   if curUrl == publicUrl {
+   if urlsEquivalent(curUrl, publicUrl) {
return nil
}
 
@@ -925,7 +976,7 @@ func (gd *GitDownloader) FixupOrigin(path string) error {
return err
}
 
-   if curUrl == gd.Url {
+   if urlsEquivalent(curUrl, gd.Url) {
return nil
}
 



[mynewt-imgmod] branch master updated: Don't print warning if `-q` specified

2020-03-05 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git


The following commit(s) were added to refs/heads/master by this push:
 new 973568a  Don't print warning if `-q` specified
973568a is described below

commit 973568a80eacc8e36220a22b892bedceea1317ed
Author: Christopher Collins 
AuthorDate: Thu Mar 5 09:26:48 2020 -0800

Don't print warning if `-q` specified
---
 cli/image_cmds.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 13f2564..12262b0 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -313,8 +313,7 @@ func runHashableCmd(cmd *cobra.Command, args []string) {
}
 
if (img.Header.Flags & image.IMAGE_F_ENCRYPTED) != 0 {
-   fmt.Fprintf(os.Stderr,
-   "* Warning: extracting hashable content from an 
encrypted image\n")
+   iutil.Printf("warning: extracting hashable content from an 
encrypted image\n")
}
 
f, err := os.Create(outFilename)



[mynewt-artifact] annotated tag v0.0.17 updated (46c91b0 -> 16a54d2)

2020-03-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.17
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.17 was modified! ***

from 46c91b0  (commit)
  to 16a54d2  (tag)
 tagging 46c91b0331838f159570616e8c2320b0e9fb5cc9 (commit)
 replaces v0.0.16
  by Christopher Collins
  on Wed Mar 4 18:08:06 2020 -0800

- Log -
hardware-encrypted images
---


No new revisions were added by this update.

Summary of changes:



[mynewt-artifact] annotated tag v0.0.18 updated (56b9e16 -> 77a8c67)

2020-03-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.18
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.18 was modified! ***

from 56b9e16  (commit)
  to 77a8c67  (tag)
 tagging 56b9e1661ceb3dd059b145cc47b4302c2456ee68 (commit)
 replaces v0.0.17
  by Christopher Collins
  on Wed Mar 4 18:08:26 2020 -0800

- Log -
FindWithinFlashAreaDevOff: Fix bad compare
---


No new revisions were added by this update.

Summary of changes:



[mynewt-imgmod] branch master updated: Pull in mynewt-artifact 0.0.18

2020-03-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git


The following commit(s) were added to refs/heads/master by this push:
 new 885cb67  Pull in mynewt-artifact 0.0.18
885cb67 is described below

commit 885cb67fa869f142d732c57fb08033e422020d42
Author: Christopher Collins 
AuthorDate: Wed Mar 4 18:04:38 2020 -0800

Pull in mynewt-artifact 0.0.18

This fixes the `imgmod mfg split` command.
---
 go.mod | 2 +-
 go.sum | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/go.mod b/go.mod
index ef1091a..a463cca 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
 module mynewt.apache.org/imgmod
 
 require (
-   github.com/apache/mynewt-artifact v0.0.17
+   github.com/apache/mynewt-artifact v0.0.18
github.com/otiai10/copy v1.0.1
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2
diff --git a/go.sum b/go.sum
index 88014b7..7d5fabe 100644
--- a/go.sum
+++ b/go.sum
@@ -11,6 +11,8 @@ github.com/apache/mynewt-artifact v0.0.15 
h1:NOAdYAMjVBGVm/4iOs70+oQnb4StlD2tavk
 github.com/apache/mynewt-artifact v0.0.15/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/apache/mynewt-artifact v0.0.17 
h1:O1lqIEygow3vFHHF9PllPoBWIK51aV0RsXPxNVFgPXY=
 github.com/apache/mynewt-artifact v0.0.17/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
+github.com/apache/mynewt-artifact v0.0.18 
h1:E5em2q/hbkDU0/xSGJozWdKSo42XJcZVmSLj20G1KXQ=
+github.com/apache/mynewt-artifact v0.0.18/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod 
h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod 
h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod 
h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=



[mynewt-artifact] branch master updated: FindWithinFlashAreaDevOff: Fix bad compare

2020-03-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
 new 56b9e16  FindWithinFlashAreaDevOff: Fix bad compare
56b9e16 is described below

commit 56b9e1661ceb3dd059b145cc47b4302c2456ee68
Author: Christopher Collins 
AuthorDate: Wed Mar 4 17:59:41 2020 -0800

FindWithinFlashAreaDevOff: Fix bad compare

This function was broken due to a typo in a comparison.
---
 manifest/mfg_manifest.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/manifest/mfg_manifest.go b/manifest/mfg_manifest.go
index 4ac6b74..95fd7d7 100644
--- a/manifest/mfg_manifest.go
+++ b/manifest/mfg_manifest.go
@@ -155,7 +155,7 @@ func (m *MfgManifest) FindWithinFlashAreaDevOff(device int, 
offset int) *flash.F
fa := [i]
if fa.Device == device {
end := fa.Offset + fa.Size
-   if offset >= offset && offset < end {
+   if offset >= fa.Offset && offset < end {
return fa
}
}



[mynewt-artifact] annotated tag v0.0.18 updated (6475442 -> 9a0face)

2020-03-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.18
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.18 was modified! ***

from 6475442  (commit)
  to 9a0face  (tag)
 tagging 64754426e73ea5b2902db6698f2451619f55df53 (commit)
 replaces v0.0.17
  by Christopher Collins
  on Wed Mar 4 18:03:35 2020 -0800

- Log -
FindWithinFlashAreaDevOff: Fix bad compare
---


No new revisions were added by this update.

Summary of changes:



[mynewt-newt] branch master updated: Remove "final-atom" target specifier type

2020-03-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new db229b2  Remove "final-atom" target specifier type
db229b2 is described below

commit db229b26d5f81779d3bf9e78a2d776fc247cb9df
Author: Christopher Collins 
AuthorDate: Mon Mar 2 15:12:28 2020 -0800

Remove "final-atom" target specifier type

Prior to this commit, newt allowed a target to be specified in any of
three ways:

1. Fully qualified name:
`@myrepo/targets/blinky`

2. Implicit `targets` directory in local repo:
`blinky` (resolves to `targets/blinky`)

3. Final atom in target package name:
`slinky_sim` (could resolve to `extra/my_stuff/slinky_sim`)

This commit removes support for the third type of specifier.

This third type of specifies is actually just a buggy attempt to support
something else.  The intent was to allow the name of a target in a
different repo without requiring the `@repo-name` prefix.  The
implementation is buggy because it allows the user to omit more than
just the repo name.  It also applies to the top-level project when it is
only intended for targets in other repos.

Allowing this type of specifier is bad because it can lead to
ambiguities.  For example, if a project contains two targets:

targets/arch1/blinky
targets/arch2/blinky

then the command `newt build blinky` is ambiguous.  Currently, newt just
selects the target whose name comes first in a lexicographic sort
(arch1).

Rather than detect ambiguities, this commit just removes support for
this type of target specifier entirely.
---
 newt/cli/util.go | 12 
 1 file changed, 12 deletions(-)

diff --git a/newt/cli/util.go b/newt/cli/util.go
index 4346659..75f6028 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -24,7 +24,6 @@ import (
"bytes"
"fmt"
"os"
-   "path/filepath"
"regexp"
"strings"
 
@@ -101,17 +100,6 @@ func ResolveTarget(name string) *target.Target {
return t
}
 
-   // Check each repo alphabetically.
-   fullNames := []string{}
-   for fullName, _ := range targetMap {
-   fullNames = append(fullNames, fullName)
-   }
-   for _, fullName := range util.SortFields(fullNames...) {
-   if name == filepath.Base(fullName) {
-   return targetMap[fullName]
-   }
-   }
-
return nil
 }
 



[mynewt-core] branch master updated: Fix json decoding of empty array

2020-03-03 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new f98ee55  Fix json decoding of empty array
f98ee55 is described below

commit f98ee5574f02df26745ffb38397defc39370f5c6
Author: Stefan Diewald 
AuthorDate: Fri Feb 28 09:33:41 2020 +0100

Fix json decoding of empty array

Without the fix, decoding an empty array leads to JSON_ERR_BADTRAIL.
When peek is "positive", the read cursor needs to be forwarded to
discard the closing "]".

Signed-off-by: Stefan Diewald 
---
 encoding/json/src/json_decode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/encoding/json/src/json_decode.c b/encoding/json/src/json_decode.c
index 8d39d24..81df9de 100644
--- a/encoding/json/src/json_decode.c
+++ b/encoding/json/src/json_decode.c
@@ -526,6 +526,7 @@ json_read_array(struct json_buffer *jb, const struct 
json_array_t *arr)
 json_skip_ws(jb);
 
 if (json_peek(jb) == ']') {
+jb->jb_read_next(jb);
 goto breakout;
 }
 



[mynewt-newt] branch master updated: mfg: Make external paths relative to project base

2020-03-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new 7861c32  mfg: Make external paths relative to project base
7861c32 is described below

commit 7861c323c778cf6c29905dd8f7d2696deb0a1de9
Author: Christopher Collins 
AuthorDate: Mon Mar 2 13:56:59 2020 -0800

mfg: Make external paths relative to project base

An mfgimage's "raw" section specifies files to embed in the generated
binary.  Prior to this commit, paths were interpreted as relative to the
mfgimage package directory.  Now, paths are considered relative to the
project base.
---
 newt/mfg/build.go | 43 ---
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index 86e1199..e13b93c 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -25,10 +25,8 @@ import (
"fmt"
"io/ioutil"
"os"
-   "path"
"path/filepath"
"sort"
-   "strings"
 
"github.com/apache/mynewt-artifact/errors"
"github.com/apache/mynewt-artifact/flash"
@@ -249,22 +247,35 @@ func newMfgBuildTarget(dt DecodedTarget,
}, nil
 }
 
-func newMfgBuildRaw(dr DecodedRaw,
-   fm flashmap.FlashMap, basePath string) (MfgBuildRaw, error) {
+func newMfgBuildRaw(dr DecodedRaw, fm flashmap.FlashMap) (MfgBuildRaw, error) {
+   checkFile := func(filename string) (string, int, error) {
+   abs, err := filepath.Abs(filename)
+   if err != nil {
+   return "", 0, util.FmtNewtError(
+   "failed to determine absolute path of file: 
path=%s", filename)
+   }
 
-   pathToBase := func(s string) string {
-   if !strings.HasPrefix(s, "/") {
-   s = basePath + "/" + s
+   st, err := os.Stat(abs)
+   if err != nil {
+   return "", 0, errors.Wrapf(err,
+   "failed to determine size of file \"%s\"", abs)
}
 
-   return filepath.Clean(s)
+   return abs, int(st.Size()), nil
}
 
-   filename := pathToBase(dr.Filename)
+   filename, filesize, err := checkFile(dr.Filename)
+   if err != nil {
+   return MfgBuildRaw{}, err
+   }
 
var extraFiles []string
for _, ef := range dr.ExtraFiles {
-   extraFiles = append(extraFiles, pathToBase(ef))
+   ename, _, err := checkFile(ef)
+   if err != nil {
+   return MfgBuildRaw{}, err
+   }
+   extraFiles = append(extraFiles, ename)
}
 
area, err := lookUpArea(fm, dr.Area)
@@ -272,16 +283,10 @@ func newMfgBuildRaw(dr DecodedRaw,
return MfgBuildRaw{}, err
}
 
-   st, err := os.Stat(filename)
-   if err != nil {
-   return MfgBuildRaw{}, errors.Wrapf(err,
-   "failed to determine size of file \"%s\"", filename)
-   }
-
return MfgBuildRaw{
-   Filename:  path.Clean(filename),
+   Filename:  filename,
Offset:dr.Offset,
-   Size:  int(st.Size()),
+   Size:  filesize,
Area:  area,
ExtraFiles:extraFiles,
ExtraManifest: dr.ExtraManifest,
@@ -439,7 +444,7 @@ func newMfgBuilder(basePkg *pkg.LocalPackage, dm DecodedMfg,
}
 
for _, dr := range dm.Raws {
-   mbr, err := newMfgBuildRaw(dr, bsp.FlashMap, basePkg.BasePath())
+   mbr, err := newMfgBuildRaw(dr, bsp.FlashMap)
if err != nil {
return mb, err
}



[mynewt-imgmod] branch master updated: mfg split: Don't discard trailing 0xff bytes

2020-03-02 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git


The following commit(s) were added to refs/heads/master by this push:
 new 66c90bf  mfg split: Don't discard trailing 0xff bytes
66c90bf is described below

commit 66c90bfda43352f045a4212e189fcccbe66bbc2c
Author: Christopher Collins 
AuthorDate: Wed Feb 12 14:52:12 2020 -0800

mfg split: Don't discard trailing 0xff bytes

The `mfg split` command separates an mfgimg binary into several files,
one for each flash area.

Prior to this commit, imgmod would strip all trailing erase-val bytes
(0xff) from each file.  Usually this was the correct behavior, but if
the contents of a flash area legitimately ended with an erase-val byte,
then the file would be corrupted during this step.

The problem is that `newt` was throwing away information when it created
mfgimages.  It embedded the specified binaries into a single mfgimage
and filled in the gaps with erase-val bytes, and it did this without
leaving any indication of the sizes of the binaries used as input.

Newt was recently changed to include the sizes of these binaries in the
`manifest.json` file that accompanies an mfgimage.  This commit changes
imgmod to read these sizes from the manifest file so that it knows how
many erase-val bytes it can safely strip.

If the manifest does not contain size information (backwards
compatibility), imgmod falls back to the old behavior or stripping all
trailing erase-val bytes.
---
 cli/mfg_cmds.go |  2 +-
 imfg/imfg.go| 74 +
 2 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/cli/mfg_cmds.go b/cli/mfg_cmds.go
index d8cfb18..80afb19 100644
--- a/cli/mfg_cmds.go
+++ b/cli/mfg_cmds.go
@@ -184,7 +184,7 @@ func runSplitCmd(cmd *cobra.Command, args []string) {
ImgmodUsage(nil, err)
}
 
-   nbmap, err := imfg.Split(bin, man.Device, areas, man.EraseVal)
+   nbmap, err := imfg.Split(bin, man, areas)
if err != nil {
ImgmodUsage(nil, err)
}
diff --git a/imfg/imfg.go b/imfg/imfg.go
index 93a0187..a8caddc 100644
--- a/imfg/imfg.go
+++ b/imfg/imfg.go
@@ -28,6 +28,7 @@ import (
 
"github.com/apache/mynewt-artifact/errors"
"github.com/apache/mynewt-artifact/flash"
+   "github.com/apache/mynewt-artifact/manifest"
"github.com/apache/mynewt-artifact/mfg"
"mynewt.apache.org/imgmod/iutil"
 )
@@ -78,8 +79,63 @@ func VerifyAreas(areas []flash.FlashArea) error {
return nil
 }
 
-func Split(mfgBin []byte, deviceNum int,
-   areas []flash.FlashArea, eraseVal byte) (NameBlobMap, error) {
+// areaDataEnd calculates the end offset of valid data in a flash area.  "Valid
+// data" includes all target binaries and raw sections.  If it cannot determine
+// the end of any constituent part, it returns an error.
+func areaDataEnd(area flash.FlashArea, man manifest.MfgManifest) (int, error) {
+   end := 0
+
+   // Updates `end` if the specified region extends beyond our current 
concept
+   // of "the end".
+   checkOne := func(offset int, size int) error {
+   a := man.FindWithinFlashAreaDevOff(man.Device, offset)
+   if a.Id != area.Id {
+   // Data belongs to a different area.
+   return nil
+   }
+
+   // Older manifests do not contain target size information.
+   if size <= 0 {
+   return errors.Errorf(
+   "failed to calculate end offset of data at %d: 
"+
+   "manifest lacks size",
+   offset)
+   }
+
+   subEnd := offset - a.Offset + size
+   if subEnd > end {
+   end = subEnd
+   }
+
+   return nil
+   }
+
+   for _, t := range man.Targets {
+   err := checkOne(t.Offset, t.Size)
+   if err != nil {
+   return 0, err
+   }
+   }
+
+   for _, r := range man.Raws {
+   err := checkOne(r.Offset, r.Size)
+   if err != nil {
+   return 0, err
+   }
+   }
+
+   if man.Meta != nil {
+   err := checkOne(man.Meta.EndOffset-1, 1)
+   if err != nil {
+   return 0, err
+   }
+   }
+
+   return end, nil
+}
+
+func Split(mfgBin []byte, man manifest.MfgManifest,
+   areas []flash.FlashArea) (NameBlobMap, error) {
 
mm := NameBlobMap{}
 
@@ -89,7 +145,7 @@ func Split(mfgBin []byte, deviceNum i

[mynewt-imgmod] 05/08: New command: image decrypthw

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit ec8fdbbd990773f05b5f619eeb046310c7c2da20
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:26:10 2020 -0800

New command: image decrypthw
---
 cli/image_cmds.go | 48 
 iimg/iimg.go  | 11 +++
 2 files changed, 59 insertions(+)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index a4ea984..882277b 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -492,6 +492,39 @@ func runDecryptFullCmd(cmd *cobra.Command, args []string) {
}
 }
 
+func runDecryptHwCmd(cmd *cobra.Command, args []string) {
+   if len(args) < 2 {
+   ImgmodUsage(cmd, nil)
+   }
+
+   imgFilename := args[0]
+   secretFilename := args[1]
+
+   outFilename, err := CalcOutFilename(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   img, err := readImage(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   secretBytes, err := ioutil.ReadFile(secretFilename)
+   if err != nil {
+   ImgmodUsage(cmd, errors.Wrapf(err, "error reading secret file"))
+   }
+
+   img, err = iimg.DecryptImageHw(img, secretBytes)
+   if err != nil {
+   ImgmodUsage(nil, err)
+   }
+
+   if err := writeImage(img, outFilename); err != nil {
+   ImgmodUsage(nil, err)
+   }
+}
+
 func runEncryptCmd(cmd *cobra.Command, args []string) {
if len(args) < 2 {
ImgmodUsage(cmd, nil)
@@ -733,6 +766,21 @@ func AddImageCommands(cmd *cobra.Command) {
Run: runDecryptFullCmd,
}
 
+   decryptHwCmd := {
+   Use:   "decrypthw  ",
+   Short: "Decrypts an hardware-encrypted Mynewt image file",
+   Long: "Decrypts the body of a hardware-encrypted Mynewt image 
file and " +
+   "removes the encryption TLVs.  The aes-secret can be 
64-encoded " +
+   "or raw.",
+   Run: runDecryptHwCmd,
+   }
+
+   decryptHwCmd.PersistentFlags().StringVarP(, "outfile", 
"o",
+   "", "File to write to")
+   decryptHwCmd.PersistentFlags().BoolVarP(, "inplace", "i", 
false,
+   "Replace input file")
+   imageCmd.AddCommand(decryptHwCmd)
+
decryptFullCmd.PersistentFlags().StringVarP(, "outfile", 
"o",
"", "File to write to")
decryptFullCmd.PersistentFlags().BoolVarP(, "inplace", "i", 
false,
diff --git a/iimg/iimg.go b/iimg/iimg.go
index d4e7c9a..9fc53fd 100644
--- a/iimg/iimg.go
+++ b/iimg/iimg.go
@@ -20,6 +20,7 @@
 package iimg
 
 import (
+   "encoding/base64"
"encoding/hex"
"fmt"
"strings"
@@ -181,6 +182,16 @@ func DecryptImageFull(img image.Image,
return img, nil
 }
 
+func DecryptImageHw(img image.Image, secretBytes []byte) (image.Image, error) {
+   secret, err := base64.StdEncoding.DecodeString(string(secretBytes))
+   if err != nil {
+   // Not base64 encoded.  Assume this is a raw AES secret.
+   secret = secretBytes
+   }
+
+   return image.DecryptHw(img, secret)
+}
+
 func EncryptImage(img image.Image, pubKeBytes []byte) (image.Image, error) {
key, err := sec.ParsePubEncKey(pubKeBytes)
if err != nil {



[mynewt-imgmod] 01/08: Pull in latest mynewt-artifact

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit fbb10f8f0c2b76060bbfacff64f415d825ee073b
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:49:12 2020 -0800

Pull in latest mynewt-artifact
---
 go.mod | 2 +-
 go.sum | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/go.mod b/go.mod
index 4b623b9..ef1091a 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
 module mynewt.apache.org/imgmod
 
 require (
-   github.com/apache/mynewt-artifact v0.0.15
+   github.com/apache/mynewt-artifact v0.0.17
github.com/otiai10/copy v1.0.1
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2
diff --git a/go.sum b/go.sum
index 03e1893..88014b7 100644
--- a/go.sum
+++ b/go.sum
@@ -9,6 +9,8 @@ github.com/apache/mynewt-artifact v0.0.3/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29O
 github.com/apache/mynewt-artifact v0.0.9/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/apache/mynewt-artifact v0.0.15 
h1:NOAdYAMjVBGVm/4iOs70+oQnb4StlD2tavkvwJiTbhI=
 github.com/apache/mynewt-artifact v0.0.15/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
+github.com/apache/mynewt-artifact v0.0.17 
h1:O1lqIEygow3vFHHF9PllPoBWIK51aV0RsXPxNVFgPXY=
+github.com/apache/mynewt-artifact v0.0.17/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod 
h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod 
h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod 
h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=



[mynewt-imgmod] 04/08: image addsig: Allow sig type to be in hexadecimal

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit 296fca75b9a0504469dd79b2749b1465dc88dd2d
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:24:28 2020 -0800

image addsig: Allow sig type to be in hexadecimal
---
 cli/image_cmds.go | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 9dcb171..a4ea984 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -372,9 +372,8 @@ func runAddsigCmd(cmd *cobra.Command, args []string) {
keyFilename := args[1]
sigFilename := args[2]
 
-   sigType, err := strconv.Atoi(args[3])
-   if err != nil || sigType < 0 || sigType > 255 ||
-   !image.ImageTlvTypeIsSig(uint8(sigType)) {
+   sigType, err := strconv.ParseUint(args[3], 0, 8)
+   if err != nil || !image.ImageTlvTypeIsSig(uint8(sigType)) {
 
ImgmodUsage(cmd, errors.Errorf("invalid signature type: %s", 
args[3]))
}



[mynewt-imgmod] 08/08: New command: image rehash

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit fa5c27974afdf16ae53453446de0449439a11b2f
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:27:56 2020 -0800

New command: image rehash
---
 cli/image_cmds.go | 40 
 iimg/iimg.go  |  8 
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 6ef308e..13f2564 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -693,6 +693,33 @@ func runExtractBodyCmd(cmd *cobra.Command, args []string) {
}
 }
 
+func runRehashImgCmd(cmd *cobra.Command, args []string) {
+   if len(args) < 1 {
+   ImgmodUsage(cmd, nil)
+   }
+
+   imgFilename := args[0]
+
+   outFilename, err := CalcOutFilename(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   img, err := readImage(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   img, err = iimg.RecalcHash(img)
+   if err != nil {
+   ImgmodUsage(nil, err)
+   }
+
+   if err := writeImage(img, outFilename); err != nil {
+   ImgmodUsage(nil, err)
+   }
+}
+
 func AddImageCommands(cmd *cobra.Command) {
imageCmd := {
Use:   "image",
@@ -910,4 +937,17 @@ func AddImageCommands(cmd *cobra.Command) {
}
 
imageCmd.AddCommand(extractBodyCmd)
+
+   rehashImgCmd := {
+   Use:   "rehash ",
+   Short: "Calculates an image's hash and replaces its SHA256 TLV",
+   Run:   runRehashImgCmd,
+   }
+
+   rehashImgCmd.PersistentFlags().StringVarP(, "outfile", 
"o",
+   "", "File to write to")
+   rehashImgCmd.PersistentFlags().BoolVarP(, "inplace", "i", 
false,
+   "Replace input file")
+
+   imageCmd.AddCommand(rehashImgCmd)
 }
diff --git a/iimg/iimg.go b/iimg/iimg.go
index 72e86b3..ea9d436 100644
--- a/iimg/iimg.go
+++ b/iimg/iimg.go
@@ -129,8 +129,8 @@ func ExtractSecret(img *image.Image) ([]byte, error) {
return tlvs[0].Data, nil
 }
 
-func recalcHash(img image.Image) (image.Image, error) {
-   hash, err := img.CalcHash()
+func RecalcHash(img image.Image) (image.Image, error) {
+   hash, err := img.CalcHash(nil)
if err != nil {
return img, err
}
@@ -174,7 +174,7 @@ func DecryptImageFull(img image.Image,
img.Header.Flags &^= image.IMAGE_F_ENCRYPTED
 
// The hash needs to be recalculated now that the header has changed.
-   img, err = recalcHash(img)
+   img, err = RecalcHash(img)
if err != nil {
return img, err
}
@@ -208,7 +208,7 @@ func EncryptImageFull(img image.Image,
 
// The hash needs to be recalculated now that the header has changed.
var err error
-   img, err = recalcHash(img)
+   img, err = RecalcHash(img)
if err != nil {
return img, err
}



[mynewt-imgmod] 03/08: image hashable: Include padding and protected TLVs

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit 9e6ead5589ee76080c961ab86c0f24a0bafd1056
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:23:30 2020 -0800

image hashable: Include padding and protected TLVs

Header padding and protected TLVs are inputs during hash calculation.
Update the `image hashable` command to account for this.
---
 cli/image_cmds.go | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 2b75b59..9dcb171 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -323,14 +323,43 @@ func runHashableCmd(cmd *cobra.Command, args []string) {
}
defer f.Close()
 
-   if err := binary.Write(f, binary.LittleEndian, ); err != nil 
{
+   err = binary.Write(f, binary.LittleEndian, )
+   if err != nil {
ImgmodUsage(nil, errors.Wrapf(err, "error writing image 
header"))
}
+
+   _, err = f.Write(img.Pad)
+   if err != nil {
+   ImgmodUsage(nil, errors.Wrapf(err, "error writing image 
padding"))
+   }
+
_, err = f.Write(img.Body)
if err != nil {
ImgmodUsage(nil, errors.Wrapf(err, "error writing image body"))
}
 
+   if len(img.ProtTlvs) > 0 {
+   trailer := image.ImageTrailer{
+   Magic: image.IMAGE_PROT_TRAILER_MAGIC,
+   TlvTotLen: img.Header.ProtSz,
+   }
+   err = binary.Write(f, binary.LittleEndian, trailer)
+   if err != nil {
+   ImgmodUsage(nil, errors.Wrapf(err, "error writing image 
protected TLV trailer"))
+   }
+
+   for _, t := range img.ProtTlvs {
+   err = binary.Write(f, binary.LittleEndian, t.Header)
+   if err != nil {
+   ImgmodUsage(nil, errors.Wrapf(err, "error 
writing image protected TLVs"))
+   }
+   _, err = f.Write(t.Data)
+   if err != nil {
+   ImgmodUsage(nil, errors.Wrapf(err, "error 
writing image protected TLVs"))
+   }
+   }
+   }
+
iutil.Printf("Wrote hashable content to %s\n", outFilename)
 }
 



[mynewt-imgmod] 06/08: New command: image setbody

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit 14683ca04c0778be383806534ef46d6f8f65e977
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:26:41 2020 -0800

New command: image setbody
---
 cli/image_cmds.go | 49 +
 iimg/iimg.go  |  7 +++
 2 files changed, 56 insertions(+)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 882277b..5aa1315 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -591,6 +591,42 @@ func runEncryptFullCmd(cmd *cobra.Command, args []string) {
}
 }
 
+func runSetBodyCmd(cmd *cobra.Command, args []string) {
+   if len(args) < 2 {
+   ImgmodUsage(cmd, nil)
+   }
+
+   imgFilename := args[0]
+   bodyFilename := args[1]
+
+   if bodyFilename == "" {
+   ImgmodUsage(cmd, errors.Errorf("image body required"))
+   }
+   bodyBytes, err := ioutil.ReadFile(bodyFilename)
+   if err != nil {
+   ImgmodUsage(cmd, errors.Wrapf(err, "error reading image body 
file"))
+   }
+
+   outFilename, err := CalcOutFilename(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   img, err := readImage(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   img, err = iimg.ReplaceBody(img, bodyBytes)
+   if err != nil {
+   ImgmodUsage(nil, err)
+   }
+
+   if err := writeImage(img, outFilename); err != nil {
+   ImgmodUsage(nil, err)
+   }
+}
+
 func runVerifyCmd(cmd *cobra.Command, args []string) {
if len(args) < 1 {
ImgmodUsage(cmd, nil)
@@ -820,6 +856,19 @@ func AddImageCommands(cmd *cobra.Command) {
 
imageCmd.AddCommand(encryptFullCmd)
 
+   setBodyCmd := {
+   Use:   "setbody  ",
+   Short: "Replaces an image's body with a file's contents",
+   Run:   runSetBodyCmd,
+   }
+
+   setBodyCmd.PersistentFlags().StringVarP(, "outfile", "o",
+   "", "File to write to")
+   setBodyCmd.PersistentFlags().BoolVarP(, "inplace", "i", 
false,
+   "Replace input file")
+
+   imageCmd.AddCommand(setBodyCmd)
+
verifyCmd := {
Use:   "verify ",
Short: "Verifies an Mynewt image's integrity",
diff --git a/iimg/iimg.go b/iimg/iimg.go
index 9fc53fd..72e86b3 100644
--- a/iimg/iimg.go
+++ b/iimg/iimg.go
@@ -220,3 +220,10 @@ func EncryptImageFull(img image.Image,
 
return img, nil
 }
+
+func ReplaceBody(img image.Image, body []byte) (image.Image, error) {
+   delta := len(body) - len(img.Body)
+   img.Body = body
+   img.Header.ImgSz += uint32(delta)
+   return img, nil
+}



[mynewt-imgmod] branch master updated (408e217 -> fa5c279)

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git.


from 408e217  .gitignore: Ignore `imgmod` binary
 new fbb10f8  Pull in latest mynewt-artifact
 new c8887e4  Fix bad copy+paste in help text
 new 9e6ead5  image hashable: Include padding and protected TLVs
 new 296fca7  image addsig: Allow sig type to be in hexadecimal
 new ec8fdbb  New command: image decrypthw
 new 14683ca  New command: image setbody
 new 0f5f9ea  New command: image extractbody
 new fa5c279  New command: image rehash

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 cli/image_cmds.go | 202 --
 go.mod|   2 +-
 go.sum|   2 +
 iimg/iimg.go  |  26 +--
 4 files changed, 222 insertions(+), 10 deletions(-)



[mynewt-imgmod] 07/08: New command: image extractbody

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit 0f5f9eaead163a6fa61fb4ed75613260b60a964b
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:27:31 2020 -0800

New command: image extractbody
---
 cli/image_cmds.go | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 5aa1315..6ef308e 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -674,6 +674,25 @@ func runVerifyCmd(cmd *cobra.Command, args []string) {
}
 }
 
+func runExtractBodyCmd(cmd *cobra.Command, args []string) {
+   if len(args) < 1 {
+   ImgmodUsage(cmd, nil)
+   }
+
+   imgFilename := args[0]
+   outFilename := args[1]
+
+   img, err := readImage(imgFilename)
+   if err != nil {
+   ImgmodUsage(cmd, err)
+   }
+
+   err = WriteFile(img.Body, outFilename)
+   if err != nil {
+   ImgmodUsage(nil, err)
+   }
+}
+
 func AddImageCommands(cmd *cobra.Command) {
imageCmd := {
Use:   "image",
@@ -883,4 +902,12 @@ func AddImageCommands(cmd *cobra.Command) {
"", "Manifest file")
 
imageCmd.AddCommand(verifyCmd)
+
+   extractBodyCmd := {
+   Use:   "extractbody  ",
+   Short: "Extracts a Mynewt image's body",
+   Run:   runExtractBodyCmd,
+   }
+
+   imageCmd.AddCommand(extractBodyCmd)
 }



[mynewt-imgmod] 02/08: Fix bad copy+paste in help text

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit c8887e4ee5ef34ca7e4554429783d12348e10705
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:28:10 2020 -0800

Fix bad copy+paste in help text
---
 cli/image_cmds.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 4decd4c..2b75b59 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -656,7 +656,7 @@ func AddImageCommands(cmd *cobra.Command) {
 
hashableCmd := {
Use:   "hashable ",
-   Short: "Removes all signatures from a Mynewt image file",
+   Short: "Extracts an image's hashable content",
Run:   runHashableCmd,
}
 



[mynewt-artifact] annotated tag v0.0.17 updated (46c91b0 -> ee34a2c)

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.17
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.17 was modified! ***

from 46c91b0  (commit)
  to ee34a2c  (tag)
 tagging 46c91b0331838f159570616e8c2320b0e9fb5cc9 (commit)
 replaces v0.0.16
  by Christopher Collins
  on Fri Feb 28 16:48:27 2020 -0800

- Log -
hardware-encrypted images
---


No new revisions were added by this update.

Summary of changes:



[mynewt-artifact] 03/03: manifest: Add flash helper function

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git

commit 46c91b0331838f159570616e8c2320b0e9fb5cc9
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:06:15 2020 -0800

manifest: Add flash helper function

// FindWithinFlashAreaDevOff searches an mfg manifest for a flash area
// with the specified device that contains the given offset.
func (m *MfgManifest) FindWithinFlashAreaDevOff(
device int, offset int) *flash.FlashArea {
---
 manifest/mfg_manifest.go | 16 
 1 file changed, 16 insertions(+)

diff --git a/manifest/mfg_manifest.go b/manifest/mfg_manifest.go
index 10ea6e8..4ac6b74 100644
--- a/manifest/mfg_manifest.go
+++ b/manifest/mfg_manifest.go
@@ -148,6 +148,22 @@ func (m *MfgManifest) FindFlashAreaDevOff(device int, 
offset int) *flash.FlashAr
return nil
 }
 
+// FindWithinFlashAreaDevOff searches an mfg manifest for a flash area with the
+// specified device that contains the given offset.
+func (m *MfgManifest) FindWithinFlashAreaDevOff(device int, offset int) 
*flash.FlashArea {
+   for i, _ := range m.FlashAreas {
+   fa := [i]
+   if fa.Device == device {
+   end := fa.Offset + fa.Size
+   if offset >= offset && offset < end {
+   return fa
+   }
+   }
+   }
+
+   return nil
+}
+
 // FindFlashAreaName searches an mfg manifest for a flash area with the
 // specified name.
 func (m *MfgManifest) FindFlashAreaName(name string) *flash.FlashArea {



[mynewt-artifact] 01/03: image: Allow CalcHash to accept an initial hash

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git

commit dbcedfc3469cf41e6ab5f3fa1e27fd10d911e2d2
Author: Christopher Collins 
AuthorDate: Fri Feb 28 16:01:54 2020 -0800

image: Allow CalcHash to accept an initial hash

The initial hash is only used for split images.
---
 image/create.go | 9 +
 image/image.go  | 7 ---
 image/verify.go | 2 +-
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/image/create.go b/image/create.go
index 6fc0f27..225a386 100644
--- a/image/create.go
+++ b/image/create.go
@@ -487,8 +487,6 @@ func (ic *ImageCreator) Create() (Image, error) {
 
img.Header.ProtSz = calcProtSize(img.ProtTlvs)
 
-   payload := 
-
// Followed by data.
if ic.PlainSecret != nil {
encBody, err := sec.EncryptAES(ic.Body, ic.PlainSecret, 
ic.Nonce)
@@ -496,16 +494,11 @@ func (ic *ImageCreator) Create() (Image, error) {
return img, err
}
img.Body = append(img.Body, encBody...)
-
-   if ic.HWKeyIndex >= 0 {
-   payload = 
-   }
-
} else {
img.Body = append(img.Body, ic.Body...)
}
 
-   hashBytes, err := calcHash(ic.InitialHash, img.Header, img.Pad, 
*payload, img.ProtTlvs)
+   hashBytes, err := img.CalcHash(ic.InitialHash)
if err != nil {
return img, err
}
diff --git a/image/image.go b/image/image.go
index 97bb080..c543cd3 100644
--- a/image/image.go
+++ b/image/image.go
@@ -475,9 +475,10 @@ func (i *Image) Hash() ([]byte, error) {
return tlv.Data, nil
 }
 
-// CalcHash calculates a SHA256 of the given image.
-func (i *Image) CalcHash() ([]byte, error) {
-   return calcHash(nil, i.Header, i.Pad, i.Body, i.ProtTlvs)
+// CalcHash calculates a SHA256 of the given image.  initialHash should be nil
+// for non-split-images.
+func (i *Image) CalcHash(initialHash []byte) ([]byte, error) {
+   return calcHash(initialHash, i.Header, i.Pad, i.Body, i.ProtTlvs)
 }
 
 // WritePlusOffsets writes a binary image to the given writer.  It returns
diff --git a/image/verify.go b/image/verify.go
index 7096621..ec98b67 100644
--- a/image/verify.go
+++ b/image/verify.go
@@ -35,7 +35,7 @@ func (img *Image) verifyHashDecrypted() error {
return err
}
 
-   wantHash, err := img.CalcHash()
+   wantHash, err := img.CalcHash(nil)
if err != nil {
return err
}



[mynewt-artifact] branch master updated (85abf95 -> 46c91b0)

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


from 85abf95  manifest: Add `MfgManifestTarget.Size` field
 new dbcedfc  image: Allow CalcHash to accept an initial hash
 new c1233d0  image: Functions to decrypt hw-encrypted images
 new 46c91b0  manifest: Add flash helper function

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 image/create.go  |  9 +
 image/image.go   | 52 +---
 image/verify.go  |  2 +-
 manifest/mfg_manifest.go | 16 +++
 4 files changed, 67 insertions(+), 12 deletions(-)



[mynewt-artifact] 02/03: image: Functions to decrypt hw-encrypted images

2020-02-28 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git

commit c1233d06be5faa00caff00a65ed97d6c9ac2331d
Author: Christopher Collins 
AuthorDate: Fri Feb 21 16:49:05 2020 -0800

image: Functions to decrypt hw-encrypted images

"Hardware-encrypted images" are images that run on devices capable of
on-the-fly decryption.  These images differ from regular encrypted
images in the following ways:
* Contain some extra TLVs (nonce, secret ID)
* The hash is of the *encrypted* image
---
 image/image.go | 45 +
 1 file changed, 45 insertions(+)

diff --git a/image/image.go b/image/image.go
index c543cd3..f7ef6e6 100644
--- a/image/image.go
+++ b/image/image.go
@@ -388,11 +388,17 @@ func (i *Image) RemoveProtTlvsIf(pred func(tlv ImageTlv) 
bool) []ImageTlv {
if pred(tlv) {
rmed = append(rmed, tlv)
i.ProtTlvs = append(i.ProtTlvs[:idx], 
i.ProtTlvs[idx+1:]...)
+
+   i.Header.ProtSz -= uint16(IMAGE_TLV_SIZE + 
len(tlv.Data))
} else {
idx++
}
}
 
+   if len(i.ProtTlvs) == 0 {
+   i.Header.ProtSz = 0
+   }
+
return rmed
 }
 
@@ -725,6 +731,45 @@ func Decrypt(img Image, privEncKey sec.PrivEncKey) (Image, 
error) {
return dup, nil
 }
 
+// DecryptHw decrypts a hardware-encrypted image.  It does NOT strip the
+// "nonce" or "secret ID" protected TLVs.
+func DecryptHw(img Image, secret []byte) (Image, error) {
+   dup := img.Clone()
+
+   tlvs := dup.FindProtTlvs(IMAGE_TLV_AES_NONCE)
+   if len(tlvs) != 1 {
+   return dup, errors.Errorf(
+   "failed to decrypt hw-encrypted image: "+
+   "wrong count of AES nonce TLVs; have=%d 
want=1", len(tlvs))
+   }
+   nonce := tlvs[0].Data
+
+   body, err := sec.EncryptAES(dup.Body, secret, nonce)
+   if err != nil {
+   return dup, err
+   }
+
+   dup.Body = body
+
+   return dup, nil
+}
+
+// DecryptHw decrypts a hardware-encrypted image and strips the "nonce" and
+// "secret ID" protected TLVs.
+func DecryptHwFull(img Image, secret []byte) (Image, error) {
+   var err error
+
+   img, err = DecryptHw(img, secret)
+   if err != nil {
+   return img, err
+   }
+
+   img.RemoveProtTlvsWithType(IMAGE_TLV_AES_NONCE)
+   img.RemoveProtTlvsWithType(IMAGE_TLV_SECRET_ID)
+
+   return img, nil
+}
+
 // IsEncrypted indicates whether an image's "encrypted" flag is set.
 func (img *Image) IsEncrypted() bool {
return img.Header.Flags_F_ENCRYPTED != 0



[mynewt-imgmod] 02/02: .gitignore: Ignore `imgmod` binary

2020-02-21 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit 408e217166c6b8277df0f84638de10ec1e8f39e2
Author: Christopher Collins 
AuthorDate: Thu Feb 20 10:00:23 2020 -0800

.gitignore: Ignore `imgmod` binary
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 1377554..a5f4674 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 *.swp
+imgmod



[mynewt-imgmod] 01/02: Use Makefile to embed version string

2020-02-21 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git

commit 7a8a8a53755954bceb8b38637d1d612fa2ab1795
Author: Christopher Collins 
AuthorDate: Thu Feb 20 09:59:32 2020 -0800

Use Makefile to embed version string

This allows us to include a git hash and build date in the
`imgmod version` output.
---
 Makefile   | 31 +++
 imgmod.go  |  8 
 version/version.go | 13 +
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
new file mode 100644
index 000..dd94567
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,31 @@
+PKG := mynewt.apache.org/imgmod/version
+VERSION:="0.0.3"
+DATE := $(shell date -u +%F,%R)
+COMMIT := $(shell git rev-parse --short HEAD)
+ifneq ($(shell git status --porcelain),)
+COMMIT_SUFFIX := "-dirty"
+endif
+GIT_STATE := ${COMMIT}${COMMIT_SUFFIX}
+
+GOOS?=linux
+GOARCH?=amd64
+
+GWARCH=${GOOS}-${GOARCH}
+
+all:
+   @echo "Usage:"
+   @echo "make binary GOOS=linux   # Linux"
+   @echo "make binary GOOS=darwin  # MacOS"
+   @echo "make binary GOOS=windows # Windows"
+
+.PHONY: version
+version:
+   @echo ${VERSION}
+
+.PHONY: gitstate
+gitstate:
+   @echo ${GIT_STATE}
+
+binary:
+   @GOOS=${GOOS} GOARCH=${GOARCH} GO111MODULE=on go build -ldflags \
+   "-X ${PKG}.Version=${VERSION} -X ${PKG}.BuildDate=${DATE} -X 
${PKG}.GitState=${GIT_STATE}"
diff --git a/imgmod.go b/imgmod.go
index b3e2bb0..e4b9982 100644
--- a/imgmod.go
+++ b/imgmod.go
@@ -20,16 +20,16 @@
 package main
 
 import (
-   "github.com/apache/mynewt-artifact/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
 
+   "github.com/apache/mynewt-artifact/errors"
+
"mynewt.apache.org/imgmod/cli"
"mynewt.apache.org/imgmod/iutil"
+   "mynewt.apache.org/imgmod/version"
 )
 
-var imgmodVersion = "0.0.2"
-
 func main() {
imgmodHelpText := ""
imgmodHelpEx := ""
@@ -68,7 +68,7 @@ func main() {
Long:versHelpText,
Example: versHelpEx,
Run: func(cmd *cobra.Command, args []string) {
-   iutil.Printf("%s\n", imgmodVersion)
+   iutil.Printf("imgmod %s\n", version.VersionStr())
},
}
imgmodCmd.AddCommand(versCmd)
diff --git a/version/version.go b/version/version.go
new file mode 100644
index 000..811fc84
--- /dev/null
+++ b/version/version.go
@@ -0,0 +1,13 @@
+package version
+
+import "fmt"
+
+var (
+   Version   string = "unknown_version"
+   BuildDate string = "unknown_date"
+   GitState  string = "unknown_git_state"
+)
+
+func VersionStr() string {
+   return fmt.Sprintf("%s / %s / %s", Version, GitState, BuildDate)
+}



[mynewt-newt] branch master updated: Emit `size` in mfg manifest target entries

2020-02-21 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
 new 9e6fc3d  Emit `size` in mfg manifest target entries
9e6fc3d is described below

commit 9e6fc3de427274b756cb9070b44221e9213599cb
Author: Christopher Collins 
AuthorDate: Wed Feb 12 15:50:23 2020 -0800

Emit `size` in mfg manifest target entries

MfgManifestTarget.Size was recently added to the artifact library.
---
 go.mod|  2 +-
 go.sum|  2 ++
 newt/mfg/build.go | 12 +++-
 newt/mfg/emit.go  |  3 +++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/go.mod b/go.mod
index 64e5afd..ad4b839 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.13
 
 require (
github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5
-   github.com/apache/mynewt-artifact v0.0.15
+   github.com/apache/mynewt-artifact v0.0.16
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/sirupsen/logrus v1.4.2
diff --git a/go.sum b/go.sum
index 03ac25a..c6c41f0 100644
--- a/go.sum
+++ b/go.sum
@@ -15,6 +15,8 @@ github.com/apache/mynewt-artifact v0.0.9 
h1:Pv/nAD50Zvom6YJ5gzQG7M4jsItPA3txSV/5
 github.com/apache/mynewt-artifact v0.0.9/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/apache/mynewt-artifact v0.0.15 
h1:NOAdYAMjVBGVm/4iOs70+oQnb4StlD2tavkvwJiTbhI=
 github.com/apache/mynewt-artifact v0.0.15/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
+github.com/apache/mynewt-artifact v0.0.16 
h1:MUy07kNuCgZHXqEpJRp3JbZcdT3FkWUW4oiOxf1NW/4=
+github.com/apache/mynewt-artifact v0.0.16/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod 
h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod 
h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod 
h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index bf23219..86e1199 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -48,6 +48,7 @@ type MfgBuildTarget struct {
Target*target.Target
Area  flash.FlashArea
Offsetint
+   Size  int
IsBootbool
BinPath   string
ExtraManifest map[string]interface{}
@@ -229,12 +230,21 @@ func newMfgBuildTarget(dt DecodedTarget,
 
isBoot := parse.ValueIsTrue(man.Syscfg["BOOT_LOADER"])
 
+   binPath := targetSrcBinPath(t, isBoot)
+
+   st, err := os.Stat(binPath)
+   if err != nil {
+   return MfgBuildTarget{}, errors.Wrapf(err,
+   "failed to determine size of file \"%s\"", binPath)
+   }
+
return MfgBuildTarget{
Target:t,
Area:  area,
Offset:dt.Offset,
+   Size:  int(st.Size()),
IsBoot:isBoot,
-   BinPath:   targetSrcBinPath(t, isBoot),
+   BinPath:   binPath,
ExtraManifest: dt.ExtraManifest,
}, nil
 }
diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go
index 0a86b22..7a8068f 100644
--- a/newt/mfg/emit.go
+++ b/newt/mfg/emit.go
@@ -53,6 +53,7 @@ type CpEntry struct {
 type MfgEmitTarget struct {
Name  string
Offsetint
+   Size  int
IsBootbool
BinPath   string
ElfPath   string
@@ -121,6 +122,7 @@ func newMfgEmitTarget(bt MfgBuildTarget) (MfgEmitTarget, 
error) {
return MfgEmitTarget{
Name:bt.Target.FullName(),
Offset:  bt.Area.Offset + bt.Offset,
+   Size:bt.Size,
IsBoot:  bt.IsBoot,
BinPath: targetSrcBinPath(bt.Target, bt.IsBoot),
ElfPath: targetSrcElfPath(bt.Target),
@@ -386,6 +388,7 @@ func (me *MfgEmitter) emitManifest() ([]byte, error) {
Name: t.Name,
ManifestPath: MfgTargetManifestPath(me.Name, i),
Offset:   t.Offset,
+   Size: t.Size,
Extra:t.ExtraManifest,
}
 



[mynewt-imgmod] branch master updated (9e273ae -> 408e217)

2020-02-21 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git.


from 9e273ae  Update to latest mynewt-artifact (0.0.15)
 new 7a8a8a5  Use Makefile to embed version string
 new 408e217  .gitignore: Ignore `imgmod` binary

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore |  1 +
 Makefile   | 31 +++
 imgmod.go  |  8 
 version/version.go | 13 +
 4 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 Makefile
 create mode 100644 version/version.go



[mynewt-artifact] annotated tag v0.0.16 updated (85abf95 -> 8612234)

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.16
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.16 was modified! ***

from 85abf95  (commit)
  to 8612234  (tag)
 tagging 85abf951da1d708e6b6eb45f84743b79fdd0e384 (commit)
 replaces v0.0.15
  by Christopher Collins
  on Thu Feb 20 09:22:58 2020 -0800

- Log -
manifest: Add `MfgManifestTarget.Size` field
---


No new revisions were added by this update.

Summary of changes:



[mynewt-artifact] branch master updated: manifest: Add `MfgManifestTarget.Size` field

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
 new 85abf95  manifest: Add `MfgManifestTarget.Size` field
85abf95 is described below

commit 85abf951da1d708e6b6eb45f84743b79fdd0e384
Author: Christopher Collins 
AuthorDate: Wed Feb 12 15:41:21 2020 -0800

manifest: Add `MfgManifestTarget.Size` field

This field indicates the size of the target binary (either .bin or .img
file).  This is useful for splitting an mfgimage into its constituent
parts.  Without this change, the only method of doing this is to use a
heuristic: remove all 0xff bytes from the end of each part (this is what
`imgmod mfg split` does).  However, this leads to problems if a target
or raw entry happens to contain trailing 0xff bytes.
---
 manifest/mfg_manifest.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/manifest/mfg_manifest.go b/manifest/mfg_manifest.go
index 1e7bcf9..10ea6e8 100644
--- a/manifest/mfg_manifest.go
+++ b/manifest/mfg_manifest.go
@@ -32,6 +32,7 @@ import (
 type MfgManifestTarget struct {
Name string `json:"name"`
Offset   int`json:"offset"`
+   Size int`json:"size"`
BinPath  string `json:"bin_path,omitempty"`
ImagePathstring `json:"image_path,omitempty"`
HexPath  string `json:"hex_path,omitempty"`



[mynewt-core] branch master updated: boot/split: use util/scfg for config

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new ec2f15a  boot/split: use util/scfg for config
ec2f15a is described below

commit ec2f15a934092c42e90fa5c3a03533b9d3c25e52
Author: Christopher Collins 
AuthorDate: Thu Feb 6 17:10:11 2020 -0800

boot/split: use util/scfg for config
---
 boot/split/pkg.yml|   1 +
 boot/split/src/split.c|  35 +++-
 boot/split/src/split_config.c | 126 --
 boot/split/src/split_priv.h   |  38 -
 4 files changed, 34 insertions(+), 166 deletions(-)

diff --git a/boot/split/pkg.yml b/boot/split/pkg.yml
index ddd779a..3b10457 100644
--- a/boot/split/pkg.yml
+++ b/boot/split/pkg.yml
@@ -26,6 +26,7 @@ pkg.keywords:
 
 pkg.deps:
 - "@apache-mynewt-core/sys/config"
+- "@apache-mynewt-core/util/scfg"
 
 pkg.req_apis:
 - bootloader
diff --git a/boot/split/src/split.c b/boot/split/src/split.c
index 894613e..d7b5b8d 100644
--- a/boot/split/src/split.c
+++ b/boot/split/src/split.c
@@ -22,8 +22,8 @@
 #include "bootutil/bootutil.h"
 #include "bootutil/image.h"
 #include "config/config.h"
+#include "scfg/scfg.h"
 #include "split/split.h"
-#include "split_priv.h"
 
 #define LOADER_IMAGE_SLOT   0
 #define SPLIT_IMAGE_SLOT1
@@ -32,6 +32,19 @@
 static int8_t split_mode_cur;
 static int8_t split_app_active;
 
+static struct scfg_group split_scfg = {
+.settings = (const struct scfg_setting[]) {
+{
+.name = "status",
+.val = _mode_cur,
+.type = CONF_INT8,
+},
+
+/* No more settings. */
+{ 0 },
+},
+};
+
 void
 split_app_init(void)
 {
@@ -40,7 +53,7 @@ split_app_init(void)
 /* Ensure this function only gets called by sysinit. */
 SYSINIT_ASSERT_ACTIVE();
 
-rc = split_conf_init();
+rc = scfg_register(_scfg, "split");
 assert(rc == 0);
 }
 
@@ -101,6 +114,24 @@ split_mode_set(split_mode_t split_mode)
 return 0;
 }
 
+int
+split_write_split(split_mode_t split_mode)
+{
+int rc;
+
+rc = split_mode_set(split_mode);
+if (rc != 0) {
+return rc;
+}
+
+rc = scfg_save_val(_scfg, _mode_cur);
+if (rc != 0) {
+return rc;
+}
+
+return 0;
+}
+
 /**
  * This validates and provides the loader image data
  *
diff --git a/boot/split/src/split_config.c b/boot/split/src/split_config.c
deleted file mode 100644
index 2bc7980..000
--- a/boot/split/src/split_config.c
+++ /dev/null
@@ -1,126 +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.
- */
-
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define LOADER_IMAGE_SLOT0
-#define SPLIT_IMAGE_SLOT1
-#define SPLIT_TOTAL_IMAGES  2
-
-static char *split_conf_get(int argc, char **argv, char *buf, int max_len);
-static int split_conf_set(int argc, char **argv, char *val);
-static int split_conf_commit(void);
-static int split_conf_export(void (*func)(char *name, char *val), enum 
conf_export_tgt tgt);
-
-static struct conf_handler split_conf_handler = {
-.ch_name = "split",
-.ch_get = split_conf_get,
-.ch_set = split_conf_set,
-.ch_commit = split_conf_commit,
-.ch_export = split_conf_export
-};
-
-int
-split_conf_init(void)
-{
-int rc;
-
-rc = conf_register(_conf_handler);
-
-return rc;
-}
-
-
-static char *
-split_conf_get(int argc, char **argv, char *buf, int max_len)
-{
-split_mode_t split_mode;
-
-if (argc == 1) {
-if (!strcmp(argv[0], "status")) {
-split_mode = split_mode_get();
-return conf_str_from_value(CONF_INT8, _mode, buf, max_len);
-}
-}
-return NULL;
-}
-
-static int
-split_conf_set(int argc, char **argv, char *val)
-{
-split_mode_t split_mode;
-int rc;
-
-if (argc == 1) {
-if (!strcmp(argv[0], "status")) {
-rc = CONF_VALUE_SET(val, CONF_INT8, split_

[mynewt-core] branch master updated: util/scfg: Simple config lib on top of sys/config

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 6f459fc  util/scfg: Simple config lib on top of sys/config
6f459fc is described below

commit 6f459fcb9f42d886768c6dcf81159337b5d2fcd8
Author: Christopher Collins 
AuthorDate: Fri Feb 7 11:19:51 2020 -0800

util/scfg: Simple config lib on top of sys/config
---
 util/scfg/include/scfg/scfg.h | 101 +
 util/scfg/pkg.yml |  23 
 util/scfg/src/scfg.c  | 257 ++
 util/scfg/syscfg.yml  |  24 
 4 files changed, 405 insertions(+)

diff --git a/util/scfg/include/scfg/scfg.h b/util/scfg/include/scfg/scfg.h
new file mode 100644
index 000..caa64b7
--- /dev/null
+++ b/util/scfg/include/scfg/scfg.h
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+#ifndef H_SCFG_
+#define H_SCFG_
+
+#include "config/config.h"
+
+struct scfg_setting {
+/** The name of the setting. */
+const char *name;
+
+/** Points to the RAM replica of the setting value. */
+void *val;
+
+/**
+ * Only needed for string settings.  Indicates the maximum length this
+ * setting's value can by.
+ */
+int max_len;
+
+/** This setting's data data.  One of the CONF_[...] constants. */
+uint8_t type;
+
+/**
+ * Whether this setting contains private data.  If true, the value is
+ * hidden in config dump output.
+ */
+bool private;
+};
+
+struct scfg_group {
+/*** Public */
+/** This array must be terminated with an `{ 0 }` entry. */
+const struct scfg_setting *settings;
+
+/*** Private */
+struct conf_handler handler;
+};
+
+/**
+ * Persists a single setting.
+ *
+ * @param group The group that the setting belongs to.
+ * @param setting   The setting to save.
+ *
+ * @return  0 on success; SYS_E[...] code on failure.
+ */
+int scfg_save_setting(const struct scfg_group *group,
+  const struct scfg_setting *setting);
+
+/**
+ * Persists the setting with the specified name.
+ *
+ * @param group The group that the setting belongs to.
+ * @param setting_name  The name of the setting to save.
+ *
+ * @return  0 on success; SYS_E[...] code on failure.
+ */
+int scfg_save_name(const struct scfg_group *group, const char *setting_name);
+
+/**
+ * Persists the setting whose value is stored in the specified variable.  The
+ * specified value address should be the same one that was specified in the
+ * `scfg_setting` definition.
+ *
+ * @param group The group that the setting belongs to.
+ * @param val   The address of the setting's value variable.
+ *
+ * @return  0 on success; SYS_E[...] code on failure.
+ */
+int scfg_save_val(const struct scfg_group *group, const void *val);
+
+/**
+ * Registers a group of configuration settings.  The group's public members
+ * must be populated before this function is called.
+ *
+ * @param group The group to register
+ * @param name  The name of the settings group.
+ *
+ * @return  0 on success; SYS_E[...] code on failure.
+ */
+int scfg_register(struct scfg_group *group, char *name);
+
+#endif
diff --git a/util/scfg/pkg.yml b/util/scfg/pkg.yml
new file mode 100644
index 000..b0299f7
--- /dev/null
+++ b/util/scfg/pkg.yml
@@ -0,0 +1,23 @@
+#
+# 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 i

[mynewt-core] branch master updated: sys/config: Extended callbacks

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new 34b32c4  sys/config: Extended callbacks
34b32c4 is described below

commit 34b32c4c2f68da3fe80276ded7b0e62f0c319e5d
Author: Christopher Collins 
AuthorDate: Fri Feb 7 11:19:13 2020 -0800

sys/config: Extended callbacks

The four conf_handler callbacks (get, set, commit, and export) do not
accept a `void *arg` parameter.  This means every config group must
define a dedicated set of callback functions, making it impossible wrap
the config API in a generic way.

This commit allows config groups to be defined as "extended".  An
extended config group uses slightly different callbacks.  These
callbacks do take a `void *arg` parameter.

To define an extended config group, set its `ch_ext` member to 1.
---
 sys/config/include/config/config.h | 42 +++--
 sys/config/src/config.c| 97 +-
 sys/config/src/config_cli.c|  4 +-
 sys/config/src/config_priv.h   |  6 +++
 sys/config/src/config_store.c  | 17 +++
 5 files changed, 137 insertions(+), 29 deletions(-)

diff --git a/sys/config/include/config/config.h 
b/sys/config/include/config/config.h
index 71491e4..116f629 100644
--- a/sys/config/include/config/config.h
+++ b/sys/config/include/config/config.h
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef __cplusplus
 extern "C" {
@@ -114,6 +115,7 @@ typedef enum conf_export_tgt conf_export_tgt_t;
  * @return A pointer to val or NULL if error.
  */
 typedef char *(*conf_get_handler_t)(int argc, char **argv, char *val, int 
val_len_max);
+typedef char *(*conf_get_handler_ext_t)(int argc, char **argv, char *val, int 
val_len_max, void *arg);
 
 /**
  * Set the configuration variable pointed to by argc and argv.  See
@@ -128,6 +130,7 @@ typedef char *(*conf_get_handler_t)(int argc, char **argv, 
char *val, int val_le
  * @return 0 on success, non-zero error code on failure.
  */
 typedef int (*conf_set_handler_t)(int argc, char **argv, char *val);
+typedef int (*conf_set_handler_ext_t)(int argc, char **argv, char *val, void 
*arg);
 
 /**
  * Commit shadow configuration state to the active configuration.
@@ -135,6 +138,7 @@ typedef int (*conf_set_handler_t)(int argc, char **argv, 
char *val);
  * @return 0 on success, non-zero error code on failure.
  */
 typedef int (*conf_commit_handler_t)(void);
+typedef int (*conf_commit_handler_ext_t)(void *arg);
 
 /**
  * Called per-configuration variable being exported.
@@ -154,7 +158,9 @@ typedef void (*conf_export_func_t)(char *name, char *val);
  * @return 0 on success, non-zero error code on failure.
  */
 typedef int (*conf_export_handler_t)(conf_export_func_t export_func,
-conf_export_tgt_t tgt);
+ conf_export_tgt_t tgt);
+typedef int (*conf_export_handler_ext_t)(conf_export_func_t export_func,
+ conf_export_tgt_t tgt, void *arg);
 
 /**
  * Configuration handler, used to register a config item/subtree.
@@ -165,14 +171,40 @@ struct conf_handler {
  * The name of the conifguration item/subtree
  */
 char *ch_name;
+
+/**
+ * Whether to use the extended callbacks.
+ * false: standard
+ * true:  extended
+ */
+bool ch_ext;
+
 /** Get configuration value */
-conf_get_handler_t ch_get;
+union {
+conf_get_handler_t ch_get;
+conf_get_handler_ext_t ch_get_ext;
+};
+
 /** Set configuration value */
-conf_set_handler_t ch_set;
+union {
+conf_set_handler_t ch_set;
+conf_set_handler_ext_t ch_set_ext;
+};
+
 /** Commit configuration value */
-conf_commit_handler_t ch_commit;
+union {
+conf_commit_handler_t ch_commit;
+conf_commit_handler_ext_t ch_commit_ext;
+};
+
 /** Export configuration value */
-conf_export_handler_t ch_export;
+union {
+conf_export_handler_t ch_export;
+conf_export_handler_ext_t ch_export_ext;
+};
+
+/** Custom argument that gets passed to the extended callbacks */
+void *ch_arg;
 };
 
 void conf_init(void);
diff --git a/sys/config/src/config.c b/sys/config/src/config.c
index cd0bae2..a1b08e0 100644
--- a/sys/config/src/config.c
+++ b/sys/config/src/config.c
@@ -309,6 +309,84 @@ conf_str_from_bytes(void *vp, int vp_len, char *buf, int 
buf_len)
 return buf;
 }
 
+/**
+ * Executes a conf_handler's "get" callback and returns the result.
+ */
+static char *
+conf_get_cb(struct conf_handler *ch, int argc, char **argv, char *val,
+int val_len_max)
+{
+if (ch->ch_ext) {
+if (ch->ch_get_ext != NULL) {
+return ch->ch_get_ext(argc, argv, val, val_len_m

[mynewt-newtmgr] 01/02: res: Use zero payload when no args specified

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 0d6802eb80b5277936052d5117168d7cd90c7cd8
Author: Christopher Collins 
AuthorDate: Wed Feb 19 08:53:23 2020 -0800

res: Use zero payload when no args specified

This command:

newtmgr res get /my/res

should send a CoAP GET request with *no* payload.  An optional payload
can be specified with extra arguments after the resource name.  Since
there are no extra arguments, there should be no payload.

Prior to this commit, newtmgr was including an empty map as the payload
in such requests.

The bug was caused by this quirk in Go:

https://forum.golangbridge.org/t/a-nil-a-b-b-nil-with-pointers-and-interface/10593

In short, if `nil` is assigned to a variable of type `interface{}`, the
variable will *not* compare equal to `nil`.  An interface variable
contains two pieces of information: 1) its type, and 2) its value.  The
variable is not equal to `nil` because `nil` is an *untyped* nil value.

The solution is to return the untyped `nil` rather than the nil
interface{}.
---
 newtmgr/cli/res.go | 28 ++--
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/newtmgr/cli/res.go b/newtmgr/cli/res.go
index 7f2e39e..51ff7c8 100644
--- a/newtmgr/cli/res.go
+++ b/newtmgr/cli/res.go
@@ -259,17 +259,25 @@ func parsePayload(args []string) ([]byte, error) {
if len(args) == 0 {
return nil, nil
}
-   val, err = parsePayloadJson(args[0])
+   itf, err := parsePayloadJson(args[0])
+   if err != nil {
+   return nil, err
+   }
+   // Check for zero payload.  Need to return nil explicitly; 
don't wrap
+   // in interface{}.
+   if itf == nil {
+   return nil, nil
+   }
} else {
-   val, err = parsePayloadMap(args)
-   }
-   if err != nil {
-   return nil, err
-   }
-
-   if val == nil {
-   // No payload.
-   return nil, nil
+   itf, err := parsePayloadMap(args)
+   if err != nil {
+   return nil, err
+   }
+   // Check for zero payload.  Need to return nil explicitly; 
don't wrap
+   // in interface{}.
+   if itf == nil {
+   return nil, nil
+   }
}
 
b, err := nmxutil.EncodeCbor(val)



[mynewt-newtmgr] branch master updated (42db02b -> 80e5c28)

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git.


from 42db02b  Delete unneccesary `nmxact` binary file
 new 0d6802e  res: Use zero payload when no args specified
 new 80e5c28  res: Correctly parse payload params

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 newtmgr/cli/res.go | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)



[mynewt-newtmgr] 02/02: res: Correctly parse payload params

2020-02-20 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 80e5c283e6b155177814d1e5040be7807c0d75aa
Author: Christopher Collins 
AuthorDate: Wed Feb 19 16:05:56 2020 -0800

res: Correctly parse payload params

In `newtmgr  > k1=v1 k2=v2 ...`, the tool was discarding
all the k=v pairs and encoding an empty map instead.
---
 newtmgr/cli/res.go | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/newtmgr/cli/res.go b/newtmgr/cli/res.go
index 51ff7c8..fc422f4 100644
--- a/newtmgr/cli/res.go
+++ b/newtmgr/cli/res.go
@@ -255,27 +255,28 @@ func parsePayload(args []string) ([]byte, error) {
var val interface{}
var err error
 
+   if len(args) == 0 {
+   return nil, nil
+   }
+
if resJson {
-   if len(args) == 0 {
-   return nil, nil
-   }
-   itf, err := parsePayloadJson(args[0])
+   val, err = parsePayloadJson(args[0])
if err != nil {
return nil, err
}
// Check for zero payload.  Need to return nil explicitly; 
don't wrap
// in interface{}.
-   if itf == nil {
+   if val == nil {
return nil, nil
}
} else {
-   itf, err := parsePayloadMap(args)
+   val, err = parsePayloadMap(args)
if err != nil {
return nil, err
}
// Check for zero payload.  Need to return nil explicitly; 
don't wrap
// in interface{}.
-   if itf == nil {
+   if val == nil {
return nil, nil
}
}



[mynewt-core] branch master updated (588f255 -> 117830c)

2020-02-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from 588f255  sys/config: Remove obsolete setting CONFIG_NEWTMGR
 add fa05135  sys/config: Support for unsigned integer types
 add c8cc7c6  sys/config: Simplify conf_str_from_value()
 add 117830c  sys/config: Simplify conf_value_from_str()

No new revisions were added by this update.

Summary of changes:
 sys/config/include/config/config.h |  8 +
 sys/config/src/config.c| 72 ++
 2 files changed, 65 insertions(+), 15 deletions(-)



[mynewt-core] branch master updated (797e75f -> 588f255)

2020-02-12 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from 797e75f  kernel/os: Allow to disable watchdog
 add 588f255  sys/config: Remove obsolete setting CONFIG_NEWTMGR

No new revisions were added by this update.

Summary of changes:
 sys/config/syscfg.yml | 4 
 1 file changed, 4 deletions(-)



[mynewt-newt] 01/02: Remove deprecated `install` and `sync` commands

2020-02-10 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit b43ef93e7465cd3f0e4b45b57787cc6cfcf9ee47
Author: Christopher Collins 
AuthorDate: Mon Jan 27 10:21:56 2020 -0800

Remove deprecated `install` and `sync` commands
---
 newt/cli/project_cmds.go | 63 
 1 file changed, 63 deletions(-)

diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index 087a9fc..68bfbef 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -102,18 +102,6 @@ func makeRepoPredicate(repoNames []string) func(r 
*repo.Repo) bool {
}
 }
 
-func installRunCmd(cmd *cobra.Command, args []string) {
-   proj := TryGetOrDownloadProject()
-   interfaces.SetProject(proj)
-
-   pred := makeRepoPredicate(args)
-   if err := proj.UpgradeIf(
-   newtutil.NewtForce, newtutil.NewtAsk, pred); err != nil {
-
-   NewtUsage(nil, err)
-   }
-}
-
 func upgradeRunCmd(cmd *cobra.Command, args []string) {
proj := TryGetOrDownloadProject()
interfaces.SetProject(proj)
@@ -181,39 +169,7 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
}
 }
 
-func syncRunCmd(cmd *cobra.Command, args []string) {
-   proj := TryGetOrDownloadProject()
-   pred := makeRepoPredicate(args)
-
-   if err := proj.UpgradeIf(
-   newtutil.NewtForce, newtutil.NewtAsk, pred); err != nil {
-
-   NewtUsage(nil, err)
-   }
-}
-
 func AddProjectCommands(cmd *cobra.Command) {
-   installHelpText := ""
-   installHelpEx := "  newt install\n"
-   installHelpEx += "Installs all repositories specified in 
project.yml.\n\n"
-   installHelpEx += "  newt install apache-mynewt-core\n"
-   installHelpEx += "Installs the apache-mynewt-core repository."
-   installCmd := {
-   Use:"install [repo-1] [repo-2] [...]",
-   Deprecated: "use \"upgrade\" instead",
-   Long:   installHelpText,
-   Example:installHelpEx,
-   Run:installRunCmd,
-   }
-   installCmd.PersistentFlags().BoolVarP(,
-   "force", "f", false,
-   "Force install of the repositories in project, regardless of 
what "+
-   "exists in repos directory")
-   installCmd.PersistentFlags().BoolVarP(,
-   "ask", "a", false, "Prompt user before installing any repos")
-
-   cmd.AddCommand(installCmd)
-
upgradeHelpText := ""
upgradeHelpEx := "  newt upgrade\n"
upgradeHelpEx += "Upgrades all repositories specified in 
project.yml.\n\n"
@@ -234,25 +190,6 @@ func AddProjectCommands(cmd *cobra.Command) {
 
cmd.AddCommand(upgradeCmd)
 
-   syncHelpText := ""
-   syncHelpEx := "  newt sync\n"
-   syncHelpEx += "Syncs all repositories specified in project.yml.\n\n"
-   syncHelpEx += "  newt sync apache-mynewt-core\n"
-   syncHelpEx += "Syncs the apache-mynewt-core repository."
-   syncCmd := {
-   Use:"sync [repo-1] [repo-2] [...]",
-   Deprecated: "use \"upgrade\" instead",
-   Long:   syncHelpText,
-   Example:syncHelpEx,
-   Run:syncRunCmd,
-   }
-   syncCmd.PersistentFlags().BoolVarP(,
-   "force", "f", false,
-   "Force overwrite of existing remote repositories.")
-   syncCmd.PersistentFlags().BoolVarP(,
-   "ask", "a", false, "Prompt user before syncing any repos")
-   cmd.AddCommand(syncCmd)
-
newHelpText := ""
newHelpEx := ""
newCmd := {



[mynewt-newt] branch master updated (bced1ac -> c9e2009)

2020-02-10 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from bced1ac  Add commands to build and browse man pages
 new b43ef93  Remove deprecated `install` and `sync` commands
 new c9e2009  Delete docs for `install` and `sync` commands

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/command_list/newt_install.rst | 38 ---
 docs/command_list/newt_sync.rst| 39 ---
 newt/cli/project_cmds.go   | 63 --
 3 files changed, 140 deletions(-)
 delete mode 100644 docs/command_list/newt_install.rst
 delete mode 100644 docs/command_list/newt_sync.rst



[mynewt-newt] 02/02: Delete docs for `install` and `sync` commands

2020-02-10 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit c9e20091447b7c36879c049c0b6807aafecaf531
Author: Christopher Collins 
AuthorDate: Mon Feb 10 13:33:09 2020 -0800

Delete docs for `install` and `sync` commands
---
 docs/command_list/newt_install.rst | 38 -
 docs/command_list/newt_sync.rst| 39 --
 2 files changed, 77 deletions(-)

diff --git a/docs/command_list/newt_install.rst 
b/docs/command_list/newt_install.rst
deleted file mode 100644
index 149258f..000
--- a/docs/command_list/newt_install.rst
+++ /dev/null
@@ -1,38 +0,0 @@
-newt install 
--
-
-Install project dependencies.
-
-Usage:
-^^
-
-.. code-block:: console
-
-newt install [flags]
-
-Flags:
-^^
-
-.. code-block:: console
-
--f, --force  Force install of the repositories in project, regardless 
of what exists in repos directory
-
-Global Flags:
-^
-
-.. code-block:: console
-
--h, --help  Help for newt commands
--j, --jobs int  Number of concurrent build jobs (default 8)
--l, --loglevel string   Log level (default "WARN")
--o, --outfile stringFilename to tee output to
--q, --quiet Be quiet; only display error output
--s, --silentBe silent; don't output anything
--v, --verbose   Enable verbose output when executing commands
-
-Description
-^^^
-
-This command downloads the description for all the repositories specified in 
the ``project.yml`` file for the current project, and installs the correct 
versions of all the packages specified by the project dependencies.
-
-You must run this command from within the current project directory. (Remember 
to ``cd`` into this project directory after you use ``newt new`` to create this 
project before you run ``newt install``.)
diff --git a/docs/command_list/newt_sync.rst b/docs/command_list/newt_sync.rst
deleted file mode 100644
index 685e05f..000
--- a/docs/command_list/newt_sync.rst
+++ /dev/null
@@ -1,39 +0,0 @@
-newt sync
---
-
-Synchronize and refresh the contents of the local copy of all the repositories 
used in the project with the latest
-updates maintained in the remote repositories.
-
-Usage:
-^^
-
-.. code-block:: console
-
-newt sync [flags]
-
-Flags:
-^^
-
-.. code-block:: console
-
--f, --force Force overwrite of existing remote repository
-
-Global Flags:
-^
-
-.. code-block:: console
-
--h, --help  Help for newt commands
--j, --jobs int  Number of concurrent build jobs (default 8)
--l, --loglevel string   Log level (default "WARN")
--o, --outfile stringFilename to tee output to
--q, --quiet Be quiet; only display error output
--s, --silentBe silent; don't output anything
--v, --verbose   Enable verbose output when executing commands
-
-Description
-^^^
-
-Synchronize project dependencies and repositories. Prior to 1.0.0 release, the 
command deletes and resynchronizes each
-repository. Post 1.0.0, it will abort the synchronization if there are any 
local changes to any repository. Using the -f
-to force overwrite of existing repository will stash and save the changes 
while pulling in all the latest changes from the remote repository.



[mynewt-imgmod] branch master updated: Update to latest mynewt-artifact (0.0.15)

2020-02-05 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git


The following commit(s) were added to refs/heads/master by this push:
 new 9e273ae  Update to latest mynewt-artifact (0.0.15)
9e273ae is described below

commit 9e273aeca4cb3636c4b28fa6cb77c3a56b722059
Author: Christopher Collins 
AuthorDate: Tue Feb 4 16:36:01 2020 -0800

Update to latest mynewt-artifact (0.0.15)

This pulls in a fix for verifying images with header padding.
---
 go.mod | 2 +-
 go.sum | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/go.mod b/go.mod
index cc2ca2f..4b623b9 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
 module mynewt.apache.org/imgmod
 
 require (
-   github.com/apache/mynewt-artifact v0.0.9
+   github.com/apache/mynewt-artifact v0.0.15
github.com/otiai10/copy v1.0.1
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2
diff --git a/go.sum b/go.sum
index a828f50..03e1893 100644
--- a/go.sum
+++ b/go.sum
@@ -7,6 +7,8 @@ github.com/apache/mynewt-artifact v0.0.2/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29O
 github.com/apache/mynewt-artifact v0.0.3 
h1:760wpGruGSOPjslEo0fgs9PYJ58IAvyjuJqno1t4iOc=
 github.com/apache/mynewt-artifact v0.0.3/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/apache/mynewt-artifact v0.0.9/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
+github.com/apache/mynewt-artifact v0.0.15 
h1:NOAdYAMjVBGVm/4iOs70+oQnb4StlD2tavkvwJiTbhI=
+github.com/apache/mynewt-artifact v0.0.15/go.mod 
h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod 
h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod 
h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod 
h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=



[mynewt-artifact] annotated tag v0.0.15 updated (63f9d94 -> f9ea8fe)

2020-02-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to annotated tag v0.0.15
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git.


*** WARNING: tag v0.0.15 was modified! ***

from 63f9d94  (commit)
  to f9ea8fe  (tag)
 tagging 63f9d9413e1cbc26209d56ec07e187e2375c8cb2 (commit)
 replaces v0.0.14
  by Christopher Collins
  on Tue Feb 4 16:34:43 2020 -0800

- Log -
image: calculate padding when parsing image
---


No new revisions were added by this update.

Summary of changes:



[mynewt-artifact] branch master updated: image: calculate padding when parsing image

2020-02-04 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
 new 63f9d94  image: calculate padding when parsing image
63f9d94 is described below

commit 63f9d9413e1cbc26209d56ec07e187e2375c8cb2
Author: Christopher Collins 
AuthorDate: Tue Feb 4 16:03:21 2020 -0800

image: calculate padding when parsing image

When parsing an image file, if the image indicates an extra-long header,
build a slice of bytes to hold the extra leading padding.  This is
needed to perform the image hash calculation correctly.
---
 image/parse.go | 5 +
 1 file changed, 5 insertions(+)

diff --git a/image/parse.go b/image/parse.go
index 0fa7647..85f87e9 100644
--- a/image/parse.go
+++ b/image/parse.go
@@ -239,6 +239,11 @@ func ParseImage(imgData []byte) (Image, error) {
img.Tlvs = tlvs
img.ProtTlvs = protTlvs
 
+   extra := img.Header.HdrSz - IMAGE_HEADER_SIZE
+   if extra > 0 {
+   img.Pad = make([]byte, extra)
+   }
+
return img, nil
 }
 



[mynewt-newt] 02/02: `newt info`: Include newt version at top of output

2020-02-03 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit d259c398fae3fd8f49fe24102d2ac6b18fa15ad7
Author: Christopher Collins 
AuthorDate: Mon Jan 27 10:34:49 2020 -0800

`newt info`: Include newt version at top of output

The `newt info` command displays information about each repo in the
user's project.  Including the newt version makes the output more useful
when a user reports an issue.
---
 newt/cli/project_cmds.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index 1dae11a..087a9fc 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -127,6 +127,8 @@ func upgradeRunCmd(cmd *cobra.Command, args []string) {
 }
 
 func infoRunCmd(cmd *cobra.Command, args []string) {
+   newtutil.PrintNewtVersion()
+
proj := TryGetProject()
 
// If no arguments specified, print status of all installed repos.



[mynewt-newt] 01/02: `newt version`: Print all details on one line

2020-02-03 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit b558e21a7f49b893aca1edfc7f0c2a84f686936f
Author: Christopher Collins 
AuthorDate: Mon Jan 27 10:33:36 2020 -0800

`newt version`: Print all details on one line

The `newt version` output was spread over three lines.  Putting all the
output on a single line makes it easier for users to report their
version number in slack or email.
---
 newt/newt.go  | 6 +-
 newt/newtutil/newtutil.go | 5 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/newt/newt.go b/newt/newt.go
index bffe29b..2c1fd6c 100644
--- a/newt/newt.go
+++ b/newt/newt.go
@@ -20,7 +20,6 @@
 package main
 
 import (
-   "fmt"
"os"
"runtime"
 
@@ -136,10 +135,7 @@ func newtCmd() *cobra.Command {
Long:versHelpText,
Example: versHelpEx,
Run: func(cmd *cobra.Command, args []string) {
-   fmt.Printf("Apache Newt\n")
-   fmt.Printf("   Version: %s\n", newtutil.NewtVersionStr)
-   fmt.Printf("  Git Hash: %s\n", newtutil.NewtGitHash)
-   fmt.Printf("Build Date: %s\n", newtutil.NewtDate)
+   newtutil.PrintNewtVersion()
},
}
 
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index 7037338..7dcd91c 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -185,3 +185,8 @@ func ProjRelPath(path string) string {
proj := interfaces.GetProject()
return strings.TrimPrefix(path, proj.Path()+"/")
 }
+
+func PrintNewtVersion() {
+   util.StatusMessage(util.VERBOSITY_DEFAULT, "Apache Newt %s / %s / %s\n",
+   NewtVersionStr, NewtGitHash, NewtDate)
+}



[mynewt-newt] branch master updated (9db4d91 -> d259c39)

2020-02-03 Thread ccollins
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


from 9db4d91  Fix downloading repo dependencies
 new b558e21  `newt version`: Print all details on one line
 new d259c39  `newt info`: Include newt version at top of output

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 newt/cli/project_cmds.go  | 2 ++
 newt/newt.go  | 6 +-
 newt/newtutil/newtutil.go | 5 +
 3 files changed, 8 insertions(+), 5 deletions(-)



  1   2   3   4   5   6   7   8   9   10   >