mynewt-newt.git
22 hours agoMerge pull request #252 from utzig/fix-docs-juullabs-oss master
aditihilbert [Wed, 12 Dec 2018 21:47:08 +0000 (13:47 -0800)] 
Merge pull request #252 from utzig/fix-docs-juullabs-oss

Fix homebrew docs and add latest linux binary urls

22 hours agoFix homebrew and linux docs 252/head
Fabio Utzig [Wed, 12 Dec 2018 21:21:43 +0000 (19:21 -0200)] 
Fix homebrew and linux docs

Update docs to use JuulLabs-OSS instead of runtimeco. A few other small
fixes like using the correct spelling for macOS.

2 days agoInject target name into syscfg
Christopher Collins [Fri, 7 Dec 2018 01:16:12 +0000 (17:16 -0800)] 
Inject target name into syscfg

Newt injects the following settings into syscfg:
    TARGET_<target-name> = 1
    TARGET_NAME = "<target-name>"

2 days agoDon't automatically capitalize syscfg names
Christopher Collins [Fri, 7 Dec 2018 01:13:52 +0000 (17:13 -0800)] 
Don't automatically capitalize syscfg names

Prior to this commit, newt always capitalized all syscfg setting names.
This interferes with some injected settings (app name, BSP name, etc.).

Now, newt leaves setting name capitalization unchanged.

2 days agoInclude auto-generated macros in syscfg
Christopher Collins [Fri, 7 Dec 2018 01:09:12 +0000 (17:09 -0800)] 
Include auto-generated macros in syscfg

This fixes #144.

Among others, newt defines the following macros on the command line for
each build:
    -DAPP_NAME="<app-name>"
    -DAPP_<app-name>
    -DARCH_NAME="<arch-name>"
    -DARCH_<arch-name>
    -DBSP_NAME="<bsp-name>"
    -DBSP_<bsp-name>

This is inconsistent with all the other settings, which are accessed
through syscfg.  It also adds noise to the command line invocations,
making debugging more difficult.

Now, newt injects each of the above settings into syscfg.  These
settings can be checked using the `MYNEWT_VAL()` macro.  Newt continues
to define these macros on the command line for backwards compatibility.

2 weeks agoInclude git hash and build date in version output
Christopher Collins [Mon, 26 Nov 2018 23:16:11 +0000 (15:16 -0800)] 
Include git hash and build date in version output

The hash and build date need to be specified at build time.  This
has been added to the `build.sh` script.

2 weeks agoBump version to 1.6.0-dev
Christopher Collins [Mon, 26 Nov 2018 21:26:54 +0000 (13:26 -0800)] 
Bump version to 1.6.0-dev

2 weeks agoMerge pull request #249 from artob/bump-golang-version
mkiiskila [Tue, 27 Nov 2018 18:27:27 +0000 (20:27 +0200)] 
Merge pull request #249 from artob/bump-golang-version

Bump the Go version requirement from 1.7 to 1.10

2 weeks agoBump the Go version requirement from 1.7 to 1.10. 249/head
Arto Bendiken [Tue, 27 Nov 2018 14:49:57 +0000 (16:49 +0200)] 
Bump the Go version requirement from 1.7 to 1.10.

Attempting to build the project with an earlier Go version will result
in the following error:

    newt/builder/targetbuild.go:399: undefined: x509.MarshalPKCS1PublicKey

See: https://golang.org/doc/go1.10#crypto/x509

3 weeks agoMerge conflicting dependency conditionals
Christopher Collins [Thu, 8 Nov 2018 01:33:55 +0000 (17:33 -0800)] 
Merge conflicting dependency conditionals

This commit addresses the following example:

    pkg.deps.FOO:
        - my_pkg
    pkg.deps.BAR:
        - my_pkg

This package has two conflicting conditional dependencies.

Before this commit, newt would only process one of the dependencies, and
it did so in an inconsistent order.  So, the build would end up with one
or the other of the dependencies, but never both.

Now, newt merges such conflicting conditional dependencies into a single
dependency.  The resulting dependency is conditional on the union of all
the sub expreessions.  Newt would (internally) convert the above example
to:

    pkg.deps.'(FOO) || (BAR)'
        - my_pkg

3 weeks agoycfg: Add name string
Christopher Collins [Thu, 8 Nov 2018 01:22:10 +0000 (17:22 -0800)] 
ycfg: Add name string

This is to help users debug bad YAML files.  When a YCfg object is
created, the YAML filename is associated with the YCfg.  When an error
is encountered, the warning / error text can contain the name of the bad
file.

3 weeks agoMove `OneTimeWarning()` to util package
Christopher Collins [Thu, 8 Nov 2018 01:16:37 +0000 (17:16 -0800)] 
Move `OneTimeWarning()` to util package

This function used to be in the newtutil package.  Keeping it in
newtutil leads to circular dependency issues: ycfg needs OneTimeWarning,
but newtutil requires ycfg.

3 weeks agosysinit: Don't use unintialized result on failure
Christopher Collins [Fri, 16 Nov 2018 18:49:19 +0000 (10:49 -0800)] 
sysinit: Don't use unintialized result on failure

3 weeks agosysinit: Initialize map before use
Christopher Collins [Fri, 16 Nov 2018 18:49:07 +0000 (10:49 -0800)] 
sysinit: Initialize map before use

4 weeks agoMerge pull request #240 from mkiiskila/fix_sdkincludes_crash
mkiiskila [Thu, 15 Nov 2018 16:27:42 +0000 (18:27 +0200)] 
Merge pull request #240 from mkiiskila/fix_sdkincludes_crash

builder; fix crash when inspecting malformed SDK pkg missing src/ext

4 weeks agobuilder; fix crash when inspecting malformed SDK pkg missing src/ext 240/head
Marko Kiiskila [Thu, 15 Nov 2018 14:57:09 +0000 (16:57 +0200)] 
builder; fix crash when inspecting malformed SDK pkg missing src/ext

4 weeks agoAllow key list to be specified in `newt run`.
Christopher Collins [Mon, 12 Nov 2018 20:45:50 +0000 (12:45 -0800)] 
Allow key list to be specified in `newt run`.

4 weeks agoSupport arbitrary lists of signing keys
Christopher Collins [Mon, 12 Nov 2018 20:41:02 +0000 (12:41 -0800)] 
Support arbitrary lists of signing keys

Prior to this commit, newt allowed one RSA key and / or one ECC key per
image.

This commit allows images to be signed by an arbitrary list of keys
(e.g., 3 RSA keys and 2 ECC keys).

4 weeks agoSome cosmetic changes
Christopher Collins [Mon, 12 Nov 2018 20:54:38 +0000 (12:54 -0800)] 
Some cosmetic changes

Run gofmt, use `FmtNewtError()` instead of
`NewNewtError(fmt.Sprintf())`, etc.

4 weeks agoresolve: Prune orphan packages during dep resolutn
Christopher Collins [Wed, 7 Nov 2018 01:18:02 +0000 (17:18 -0800)] 
resolve: Prune orphan packages during dep resolutn

This fixes #233.

Detect orphan packages as follows: starting from each seed package,
recursively traverse the package's dependency list, keeping track of
which packages were visited.  After the traversal is complete, any
non-visited package in the resolver are orphans and can be removed.

4 weeks agoresolve: Maintain reverse dependency list per-pkg
Christopher Collins [Wed, 7 Nov 2018 17:46:18 +0000 (09:46 -0800)] 
resolve: Maintain reverse dependency list per-pkg

Replace `ResolvePackage`'s reference count with a reverse dependency
list (implemented as map).  This is less error prone, and it allows for
package removal to be more efficient.

5 weeks agoUpdate newt version: 1.4.9999 --> 1.5.9900
Christopher Collins [Wed, 7 Nov 2018 20:23:55 +0000 (12:23 -0800)] 
Update newt version: 1.4.9999 --> 1.5.9900

Since this is now 1.5.0-dev, the version number needs to be greater than
1.5.0.

5 weeks agoWhen pruning deps, delete dangling orphans
Christopher Collins [Fri, 2 Nov 2018 22:14:03 +0000 (15:14 -0700)] 
When pruning deps, delete dangling orphans

During dependency resolution, some newly-discovered syscfg values may
nullify existing conditional dependencies.  If the last dependency for a
particular package is removed, the package must be removed entirely from
the build, as it is not actually depended on.

Newt was already doing the above.  However, it failed to also check the
removed package's dependencies.  If the removed package was the only
dependent for a second package, the second package must also be removed.
This needs to be done recursively

Prior to this fix, some orphaned packages could be incorrectly included
in the build.

5 weeks agoUpdate newt_windows.rst
aditihilbert [Mon, 5 Nov 2018 17:47:56 +0000 (09:47 -0800)] 
Update newt_windows.rst

6 weeks agoCLI: Move some target commands to a new file
Christopher Collins [Thu, 25 Oct 2018 00:33:14 +0000 (17:33 -0700)] 
CLI: Move some target commands to a new file

Clean up `target_cmds.go` by moving the following commands to a new file:
    * target config
    * target logcfg
    * target sysinit
    * target sysdown

6 weeks agoAdd `newt target [sysinit | sysdown]` cmds
Christopher Collins [Thu, 25 Oct 2018 00:07:30 +0000 (17:07 -0700)] 
Add `newt target [sysinit | sysdown]` cmds

This commit adds four newt commands:

    newt target sysinit show <target>
    newt target sysinit brief <target>
    newt target sysdown show <target>
    newt target sysdown brief <target>

Both sysinit commands produce a report of all the sysinit entries configured
for the target.  Example output:

[SHOW]
    $ newt target sysinit show slinky-nrf52dk

    Log config for targets/slinky-nrf52dk:
    <snip>
    config_pkg_init:
        Package: @apache-mynewt-core/sys/config
        Stage:  50               [CONFIG_SYSINIT_1_STAGE]

    log_init:
        Package: @apache-mynewt-core/sys/log/full
        Stage:  100              [LOG_SYSINIT_STAGE]

    <snip>

[BRIEF]
    $ newt target sysinit brief slinky-nrf52dk

    Brief sysinit config for targets/slinky-nrf52dk:
     FUNCTION                 | PACKAGE                                                 | STAGE
    <snip>
     config_pkg_init          | @apache-mynewt-core/sys/config                          | 50               [CONFIG_SYSINIT_1_STAGE]
     log_init                 | @apache-mynewt-core/sys/log/full                        | 100              [LOG_SYSINIT_STAGE]
    <snip>

The sysdown commands are similar; they show sysdown entries rather than
sysinit entries.

6 weeks agoHigher level structures for sysinit/sysdown
Christopher Collins [Thu, 25 Oct 2018 00:03:58 +0000 (17:03 -0700)] 
Higher level structures for sysinit/sysdown

Prior to this commit, the sysinit and sysdown function lists were
created on demand, when the corresponding C code is generated.

This commit causes the sysinit and sysdown configurations to be
generated at resolution time.  This allows:
    * Better error reporting
    * CLI commands to access the sysinit / sysdown configuration

6 weeks agologcfg: use ValSetting (generic setting value)
Christopher Collins [Thu, 25 Oct 2018 00:06:34 +0000 (17:06 -0700)] 
logcfg: use ValSetting (generic setting value)

6 weeks agostage: Use ValSetting (generic setting value)
Christopher Collins [Thu, 25 Oct 2018 00:02:43 +0000 (17:02 -0700)] 
stage: Use ValSetting (generic setting value)

6 weeks agoval: Generic setting value structure
Christopher Collins [Thu, 25 Oct 2018 00:00:59 +0000 (17:00 -0700)] 
val: Generic setting value structure

6 weeks agologcfg: `target logcfg <show | brief>` commands
Christopher Collins [Tue, 16 Oct 2018 01:50:05 +0000 (18:50 -0700)] 
logcfg: `target logcfg <show | brief>` commands

Add two new newt commands:

    newt target logcfg show <target>
    newt target logcfg brief <target>

Both commands produce a report of all the logs configured for the
target.  Example output:

[SHOW]
    $ newt target logcfg show slinky-nrf52dk

    Log config for targets/slinky-nrf52dk:
    COREDUMP_LOG:
        Package: sys/coredump
        Module:  100              [COREDUMP_LOG_MODULE]
        Level:   3 (ERROR)        [COREDUMP_LOG_LEVEL]
        Flags:

    SENSORS_LOG:
        Package: sys/coredump
        Module:  99
        Level:   1 (INFO)         [COREDUMP_LOG_LEVEL]
        Flags:

[BRIEF]
    $ newt target logcfg brief slinky-nrf52dk

    Brief log config for targets/slinky-nrf52dk:
                 LOG | MODULE   | LEVEL        | FLAGS
    -----------------+----------+--------------|----------
        COREDUMP_LOG | 100      | 3 (ERROR)    |
         SENSORS_LOG | 99       | 1 (INFO)     |

6 weeks agologcfg: Allow logs to be defined in `syscfg.yml`
Christopher Collins [Tue, 16 Oct 2018 01:49:36 +0000 (18:49 -0700)] 
logcfg: Allow logs to be defined in `syscfg.yml`

A package can define logs in its `syscfg.yml` file under the heading of
`syscfg.logs`.  During the build process, newt generates a C header file
called `logcfg/logcfg.h` containing macros for using each generated log.

Each entry in the `syscfg.logs` map has the following structure:

        <log-name>:
            module: <module>
            level: <level>
            guest: <true/false> (optional)

For example:

    syscfg.logs:
        MY_LOG:
            module: MYNEWT_VAL(MY_LOG_MODULE)
            level: MYNEWT_VAL(MY_LOG_LEVEL)

It is recommended, though not required, that the module and level fields
refer to syscfg settings, as above.  This allows the target to
reconfigure a package's log without modifying the package itself.

The above log definition generates the following code in
`logcfg/logcfg.h` (assuming `MY_LOG_MODULE is set to LOG_LEVEL_ERROR (3)):

    #define MY_LOG_DEBUG(logcfg_lvl_, ...) IGNORE(__VA_ARGS__)
    #define MY_LOG_INFO(logcfg_lvl_, ...) IGNORE(__VA_ARGS__)
    #define MY_LOG_WARN(logcfg_lvl_, ...) IGNORE(__VA_ARGS__)
    #define MY_LOG_ERROR(logcfg_lvl_, ...) MODLOG_ ## logcfg_lvl_(MYNEWT_VAL(MY_LOG_MODULE), __VA_ARGS__)
    #define MY_LOG_CRITICAL(logcfg_lvl_, ...) MODLOG_ ## logcfg_lvl_(MYNEWT_VAL(MY_LOG_MODULE), __VA_ARGS__)

If two or more logs have module values that resolve to the same number,
newt aborts the build with an error:

    Error: Log module conflicts detected:
        Module=100 Log=MY_LOG Package=sys/coredump
        Module=100 Log=YOUR_LOG Package=sys/coredump

    Resolve the problem by assigning unique module IDs to each log,
    or by setting the "guest" flag of all but one.

The "guest" flag, when set, allows a log to use the same module as
another without generating an error.

6 weeks agosyscfg: Extract setting reference functionality
Christopher Collins [Tue, 16 Oct 2018 01:22:52 +0000 (18:22 -0700)] 
syscfg: Extract setting reference functionality

A setting can refer to another with the `MYNEWT_VAL(...)` notation.
This commit extracts the code which detects such references and puts it
into separate functions.

6 weeks agoAllow branches with no default upstream
Christopher Collins [Fri, 19 Oct 2018 18:50:45 +0000 (11:50 -0700)] 
Allow branches with no default upstream

Some commands would fail when a repo had a branch with no default
upstream checked out.  The failures were as follows:

* `newt info`: Displayed a git "fatal" error instead of the correct
version (inferred version if `version.yml` is not present).

* `newt upgrade`: Aborted without performing the upgrade (displayed the
same "fatal" git error).

6 weeks agoRemove redundant version detection warning
Christopher Collins [Fri, 19 Oct 2018 18:44:22 +0000 (11:44 -0700)] 
Remove redundant version detection warning

This particular "Could not detect version of installed repo" warning was
reported in two places in the code.  Eliminate one of these redundant
instances.

6 weeks agoEnsure warnings only displayed once
Christopher Collins [Fri, 19 Oct 2018 18:43:57 +0000 (11:43 -0700)] 
Ensure warnings only displayed once

Some warnings were displayed repeatedly.  Only display each warnings
once.

7 weeks agosysdown: generate package shutdown function
Christopher Collins [Fri, 5 Oct 2018 01:53:19 +0000 (18:53 -0700)] 
sysdown: generate package shutdown function

Allow packages to specify a function to call when the system shuts down.
The syntax is:

    pkg.down:
        <C-function-name>: <stage-number>

e.g.,

    pkg.down:
        ble_hs_shutdown: 200

Lower stages execute before greater stages.  If two or more callbacks
have the same stage, they are sorted alphabetically by C function name.

7 weeks agoGenericize sysinit functionality
Christopher Collins [Thu, 27 Sep 2018 22:18:51 +0000 (15:18 -0700)] 
Genericize sysinit functionality

Create a `stage` package.  This package emits C code consisting of
a sequence of function calls.

7 weeks agoMerge pull request #222 from michal-narajowski/travis
Michał Narajowski [Mon, 22 Oct 2018 08:17:56 +0000 (10:17 +0200)] 
Merge pull request #222 from michal-narajowski/travis

Add Travis CI integration

7 weeks agoAdd Travis CI integration 222/head
Michał Narajowski [Tue, 16 Oct 2018 18:22:39 +0000 (20:22 +0200)] 
Add Travis CI integration

8 weeks agoMerge pull request #227 from sjanc/license
Szymon Janc [Thu, 18 Oct 2018 17:53:27 +0000 (19:53 +0200)] 
Merge pull request #227 from sjanc/license

Update Makefiles with APL 2.0 license

8 weeks agoUpdate Makefiles with APL 2.0 license 227/head
Szymon Janc [Thu, 18 Oct 2018 00:43:24 +0000 (02:43 +0200)] 
Update Makefiles with APL 2.0 license

8 weeks agoMerge pull request #226 from sjanc/rat
Szymon Janc [Wed, 17 Oct 2018 22:00:59 +0000 (00:00 +0200)] 
Merge pull request #226 from sjanc/rat

Update rat excludes

8 weeks agoMerge pull request #224 from andrzej-kaczmarek/build-profile-fix
Andrzej Kaczmarek [Wed, 17 Oct 2018 21:52:55 +0000 (23:52 +0200)] 
Merge pull request #224 from andrzej-kaczmarek/build-profile-fix

Update handling of package-level build profiles

8 weeks agoMerge pull request #225 from andrzej-kaczmarek/diff-friendly-size
Andrzej Kaczmarek [Wed, 17 Oct 2018 21:50:11 +0000 (23:50 +0200)] 
Merge pull request #225 from andrzej-kaczmarek/diff-friendly-size

Add diff-friendly output for "newt size"

8 weeks agobuilder: Fix inconsistent imports 224/head
Andrzej Kaczmarek [Wed, 17 Oct 2018 21:48:36 +0000 (23:48 +0200)] 
builder: Fix inconsistent imports

8 weeks agoUpdate rat excludes 226/head
Szymon Janc [Tue, 16 Oct 2018 21:35:55 +0000 (23:35 +0200)] 
Update rat excludes

8 weeks agobuilder: Add option to produce diff-friendly size statistics 225/head
Andrzej Kaczmarek [Wed, 17 Oct 2018 13:04:16 +0000 (15:04 +0200)] 
builder: Add option to produce diff-friendly size statistics

This adds "-d" flag to "newt size" which enabled more diff-friendly
output for sections statistics.

Diff-friendly output does not include percentages and sizes are only
printed for symbols, not for "containers". This means that diff will
pick up only lines where size of particular symbol has changed and not
lines where percentage or cumulative size also changed.

8 weeks agobuilder: Make size report formatting code more generic
Andrzej Kaczmarek [Wed, 17 Oct 2018 12:04:22 +0000 (14:04 +0200)] 
builder: Make size report formatting code more generic

This should allow some more customizable output.

8 weeks agobuilder: Use target build profile as fallback
Andrzej Kaczmarek [Wed, 17 Oct 2018 10:14:11 +0000 (12:14 +0200)] 
builder: Use target build profile as fallback

Since we can override build profiles on package-level it is possible
that someone will try to build package with build profile which does
not exist in his compiler used (because it was not update or smth).
To avoid this, let's just emit a warning and use target build profile
instead.

8 weeks agobuilder: Allow override per-package build profile in target
Andrzej Kaczmarek [Wed, 17 Oct 2018 10:11:19 +0000 (12:11 +0200)] 
builder: Allow override per-package build profile in target

This patch changes order of resolving package build profile so profile
specified by target takes precedence over profile specified by package.

This way we can *always* override build profile in target which was not
possible so in case package defined own build profile it was required
to hack in source code anyway.

8 weeks agoMerge pull request #223 from ccollins476ad/rm-viper
ccollins476ad [Tue, 16 Oct 2018 21:57:37 +0000 (14:57 -0700)] 
Merge pull request #223 from ccollins476ad/rm-viper

Remove unused viper fork

8 weeks agoNewt - revendor 223/head
Christopher Collins [Tue, 16 Oct 2018 21:20:09 +0000 (14:20 -0700)] 
Newt - revendor

8 weeks agoRemove unused viper fork
Christopher Collins [Tue, 16 Oct 2018 21:20:00 +0000 (14:20 -0700)] 
Remove unused viper fork

Newt uses its own configuration system now (YCfg), so this fork is no
longer needed.

8 weeks agoMerge pull request #220 from michal-narajowski/newt-compat-fix
Michał Narajowski [Tue, 16 Oct 2018 17:21:28 +0000 (19:21 +0200)] 
Merge pull request #220 from michal-narajowski/newt-compat-fix

Fix regression when verifying newt compatibility

8 weeks agoFix regression when verifying newt compatibility 220/head
Michał Narajowski [Tue, 16 Oct 2018 17:10:25 +0000 (19:10 +0200)] 
Fix regression when verifying newt compatibility

If repo is not installed it is not possible to check version.

8 weeks agoMerge pull request #219 from michal-narajowski/newt-compat
Michał Narajowski [Tue, 16 Oct 2018 16:29:11 +0000 (18:29 +0200)] 
Merge pull request #219 from michal-narajowski/newt-compat

Check newt compatibility on install/upgrade and other commands

8 weeks agoCheck newt compatibility on install/upgrade and other commands 219/head
Michał Narajowski [Mon, 15 Oct 2018 22:56:34 +0000 (00:56 +0200)] 
Check newt compatibility on install/upgrade and other commands

With this patch newt will warn/return error if you use any repository
is incompatible with current newt version. It will also warn/return error
when you are trying to install/upgrade a repository to a version
that is not compatible with current newt.

Example 1 (upgrading to incompatible version):
```
>newt upgrade
Skipping "apache-mynewt-nimble": already upgraded (1.0.0)
Making the following changes to the project:
    upgrade apache-mynewt-core (1.3.0 --> 1.4.1)
Error: This version of newt (1.3.0) is incompatible with your version of the
apache-mynewt-core repo (1.4.1); Please upgrade your newt tool to version 1.4.0
```

Example 2 (using an incompatible version):
```
>newt info
Error: This version of newt (1.3.0) is incompatible with your version of the
apache-mynewt-core repo (1.4.1); Please upgrade your newt tool to version 1.4.0
```

2 months agoUpdate go dep (with auto-removed files)
Fabio Utzig [Tue, 11 Sep 2018 23:31:42 +0000 (20:31 -0300)] 
Update go dep (with auto-removed files)

2 months agoAllow encrypted images using aes-128 keywrap
Fabio Utzig [Tue, 11 Sep 2018 23:27:27 +0000 (20:27 -0300)] 
Allow encrypted images using aes-128 keywrap

This adds an extra method of encrypted image creation, using
AES-128-KEK. This requires a recent version of mbedtls with nist_kw
support and decreases the flash usage by 8KB from RSA-OAEP. The key file
must be provided in base64 format and it's decoded content should be a
16 byte random key.

To generate a key:

> dd if=/dev/urandom of=/dev/stdout bs=1 count=16 | base64 > aes-128-kek.b64

2 months agoAdd vendored go-aes-key-wrap
Fabio Utzig [Tue, 11 Sep 2018 23:26:55 +0000 (20:26 -0300)] 
Add vendored go-aes-key-wrap

2 months agoAdd support for encrypted images
Fabio Utzig [Tue, 21 Aug 2018 18:22:42 +0000 (15:22 -0300)] 
Add support for encrypted images

This adds a new flag to `create-image` command: `-e <rsa-pub-key.pem>`
to allow generation of encrypted images. This adds a layer of secrecy
while transporting images to the device and for storing at an external
flash.

To encrypt, RSA-OAEP was used, mainly because it is well supported by
libraries. This requires the device to already have the private key
stored internally. The encryption process method follows these steps:

1) Generate a random AES-128 key
2) Use this key with AES-128-CTR to encrypt the image
3) Use RSA-OAEP to encrypt the key
4) Store this encrypted key in a new TLV (0x30)
5) A new header flag signals the image to be encrypted.

When doing a swap, the image is decrypted from slot1 -> slot0, and
re-encrypted when coming back from slot0 -> slot1 based on the header
flag.

The TLV adds about 256 bytes to the image, and RSA-OAEP in the firmware
increases some 12KB of flash required, so better key encryption methods
might be added later, like EICES (using eliptic curves) and AES-KEK
using a secret key to encrypt the encryption key itself.

2 months agoMerge pull request #216 from ccollins476ad/target-cmds
ccollins476ad [Tue, 2 Oct 2018 20:58:58 +0000 (13:58 -0700)] 
Merge pull request #216 from ccollins476ad/target-cmds

Fix `target set` and `target amend`

2 months agoFix `target set` and `target amend` 216/head
Christopher Collins [Tue, 2 Oct 2018 20:15:50 +0000 (13:15 -0700)] 
Fix `target set` and `target amend`

This fixes #209.

2 months agoFix usage of -f on target delete/init commands
Fabio Utzig [Mon, 24 Sep 2018 18:07:14 +0000 (15:07 -0300)] 
Fix usage of -f on target delete/init commands

2 months agoMerge pull request #206 from ccollins476ad/dirty
ccollins476ad [Wed, 19 Sep 2018 22:23:15 +0000 (15:23 -0700)] 
Merge pull request #206 from ccollins476ad/dirty

Improve `newt info` command; show repo ver

3 months agoMerge pull request #213 from michal-narajowski/cmake-print-error
Michał Narajowski [Tue, 11 Sep 2018 08:09:46 +0000 (10:09 +0200)] 
Merge pull request #213 from michal-narajowski/cmake-print-error

cmake: Print error info on fail

3 months agoMerge pull request #210 from michal-narajowski/cmake-cxx-fix
Michał Narajowski [Mon, 10 Sep 2018 11:15:41 +0000 (13:15 +0200)] 
Merge pull request #210 from michal-narajowski/cmake-cxx-fix

cmake: Add CXX to project languages

3 months agocmake: Print error info on fail 213/head
Michał Narajowski [Thu, 6 Sep 2018 13:41:43 +0000 (15:41 +0200)] 
cmake: Print error info on fail

3 months agocmake: Add CXX to project languages 210/head
Michał Narajowski [Wed, 5 Sep 2018 09:36:27 +0000 (11:36 +0200)] 
cmake: Add CXX to project languages

If a package contains .cpp files, CMake produces the following error:
```
CMake Error: Cannot determine link language for target <package-target>.
CMake Error: CMake can not determine linker language for target: <package-target>
```

Adding CXX to project languages if no package contains .cpp files doesn't affect the build.

3 months agoMerge pull request #207 from michal-narajowski/cxxflags
Michał Narajowski [Wed, 5 Sep 2018 08:57:15 +0000 (10:57 +0200)] 
Merge pull request #207 from michal-narajowski/cxxflags

Add support for specifying C++ compiler flags

3 months agoMerge pull request #208 from michal-narajowski/test-exclude-fix
Michał Narajowski [Wed, 5 Sep 2018 08:56:45 +0000 (10:56 +0200)] 
Merge pull request #208 from michal-narajowski/test-exclude-fix

Fix 'newt test' exclude option accepting fully-qualified pkg names

3 months agoFix 'newt test' exclude option accepting fully-qualified pkg names 208/head
Michał Narajowski [Tue, 4 Sep 2018 13:23:31 +0000 (15:23 +0200)] 
Fix 'newt test' exclude option accepting fully-qualified pkg names

`newt test` accepts an `--exclude` or `-e` switch. The argument to this
switch is a comma-separated list of packages to exclude from the test set.

The bug was that these package names must have *not* included their repo name.
The tests were only properly excluded if the repo name was missing.

E.g.,

```
newt test all -e fs/fcb
```
properly excluded the `fs/fcb` test, but

```
newt test all -e @apache-mynewt-core/fs/fcb
```
excluded nothing; the fcb test still run.

With this patch both of these examples correctly exclude fcb tests.

3 months agoAdd support for specifying C++ compiler flags 207/head
Michał Narajowski [Tue, 4 Sep 2018 10:59:49 +0000 (12:59 +0200)] 
Add support for specifying C++ compiler flags

3 months agoImprove `newt info` command; show repo ver 206/head
Christopher Collins [Tue, 28 Aug 2018 01:42:15 +0000 (18:42 -0700)] 
Improve `newt info` command; show repo ver

This commit adds some information to the output of the `newt info`
command.  If no arguments are specified, the command lists all repos in
the project, and appends the following flags as appropriate:

    * Currently installed version (or "not installed")
    * Dirty: <description of dirty state>

In addition, if the user specifies the `-r` (remote) switch, the command
fetches the latest `repository.yml` files and determines if any repos
can be upgraded.

If the user provides an argument, the command's old behavior is
retained.  I.e., the command prints a list of all packages belonging to
the specified repo.  This behavior is retained for backwards
compatibility.

3 months agoDon't start an upgrade or sync if repos are dirty
Christopher Collins [Tue, 28 Aug 2018 00:59:36 +0000 (17:59 -0700)] 
Don't start an upgrade or sync if repos are dirty

Before starting an upgrade or sync operation, check if any repos being
operated on are in a dirty state.  If any repo is dirty, abort with a
descriptive message.  Optionally, the user can specify `-f` (force) to
try the operation anyway.

A repo is dirty if any of the following is true:
    * Repo contains local changes
    * Repo contains staged changes
    * Repo contains unpushed commits

3 months agoAllow "@" in install / upgrade / sync arguments
Christopher Collins [Tue, 28 Aug 2018 01:03:59 +0000 (18:03 -0700)] 
Allow "@" in install / upgrade / sync arguments

Allow repo names to be prefixed with "@".

3 months agoPrint "Proceed [Y/n]" prompt when `-a` specified
Christopher Collins [Tue, 28 Aug 2018 00:56:21 +0000 (17:56 -0700)] 
Print "Proceed [Y/n]" prompt when `-a` specified

The `-a` (ask) option causes newt to wait for the user to confirm the
install / upgrade / sync operation.  However, no prompt was being
displayed, so it looked like newt was hanging.

3 months agoMerge pull request #203 from andrzej-kaczmarek/invalid-pkg-type
Andrzej Kaczmarek [Mon, 27 Aug 2018 19:53:41 +0000 (21:53 +0200)] 
Merge pull request #203 from andrzej-kaczmarek/invalid-pkg-type

Ignore packages without proper pkg.type

3 months agoIgnore packages without proper pkg.type 203/head
Andrzej Kaczmarek [Mon, 27 Aug 2018 09:17:52 +0000 (11:17 +0200)] 
Ignore packages without proper pkg.type

Invalid pkg.type values are silently ignored and package is assumed to
be of 'lib' type which may lead to confusing errors. Let's explicitly
ignore such package and display warning message.

Packages without pkg.type are still assumed to be 'lib'.

3 months agoMerge pull request #202 from andrzej-kaczmarek/pkg-transient
Andrzej Kaczmarek [Sat, 25 Aug 2018 10:37:32 +0000 (12:37 +0200)] 
Merge pull request #202 from andrzej-kaczmarek/pkg-transient

Add new package type -> transient

3 months agoFix confusing warning message 202/head
Andrzej Kaczmarek [Sat, 25 Aug 2018 10:34:16 +0000 (12:34 +0200)] 
Fix confusing warning message

3 months agoAdd new package type -> transient
Andrzej Kaczmarek [Fri, 24 Aug 2018 17:05:23 +0000 (19:05 +0200)] 
Add new package type -> transient

Transient package is a package which only links to other package (does
not have/need any configuration or source files). It can be used when
renaming package to keep package with old name still accessible without
need to keep two copies of the same package contents.

Including transient package in project will always emit a warning.

Transient package can be defined using following entries in pkg.yml:
> pkg.type: transient
> pkg.link: @repo/target-package

3 months agoMerge pull request #201 from andrzej-kaczmarek/syscfg-value-copy
Andrzej Kaczmarek [Thu, 23 Aug 2018 08:39:23 +0000 (10:39 +0200)] 
Merge pull request #201 from andrzej-kaczmarek/syscfg-value-copy

Allow setting value to reference other setting

3 months agoAllow setting value to reference other setting 201/head
Andrzej Kaczmarek [Tue, 21 Aug 2018 21:42:27 +0000 (23:42 +0200)] 
Allow setting value to reference other setting

This allows setting value to explicitly copy value from other setting.

Old way to do this was to set setting value to "MYNEWT_VAL_FOO" which
will be handled as string by newt and then resolved by preprocessor.
This however prevents some features in newt to work correctly (e.g.
restrictions) so it's more convenient to have value copying handled
by newt itself. Instead of 'MYNEWT_VAL_FOO' user can specifiy
'MYNEWT_VAL(FOO)' (so the same as in C code) as setting value and it
will be copied from setting named FOO.

4 months agoMerge pull request #185 from ccollins476ad/sync
ccollins476ad [Tue, 7 Aug 2018 21:58:14 +0000 (14:58 -0700)] 
Merge pull request #185 from ccollins476ad/sync

Sync: Pull from current upstream, not origin

4 months agoMerge pull request #197 from ccollins476ad/syscfg-err-detect
ccollins476ad [Fri, 3 Aug 2018 17:24:48 +0000 (10:24 -0700)] 
Merge pull request #197 from ccollins476ad/syscfg-err-detect

syscfg: error detection after API resolution

4 months agoMerge pull request #193 from ccollins476ad/relpath
ccollins476ad [Tue, 31 Jul 2018 19:59:01 +0000 (12:59 -0700)] 
Merge pull request #193 from ccollins476ad/relpath

Pass relative bin paths to load and debug scripts.

4 months agoMerge pull request #195 from ccollins476ad/pkg-profile
ccollins476ad [Tue, 31 Jul 2018 19:58:44 +0000 (12:58 -0700)] 
Merge pull request #195 from ccollins476ad/pkg-profile

Allow build_profile to be overridden per package

4 months agoAllow build_profile to be overridden per package 195/head
Christopher Collins [Tue, 17 Jul 2018 19:20:38 +0000 (12:20 -0700)] 
Allow build_profile to be overridden per package

This fixes #153.

The build profile can be overridden for a particular pacakge in two
ways:

* (1) Specify a "pkg.build_profile" value in the package's `pkg.yml`
  file.  E.g.,

   pkg.build_profile: debug

* (2) Specify the pacakge in the target's "target.package_profiles" map.
  E.g.,

    target.package_profiles:
        'apps/blinky': debug
        '@apache-mynewt-core/sys/log/full': debug

(1) takes priority over (2).

In addition, it is now possible to override the optimization setting
("-O<x>") in a package's `pkg.cflags`.  Prior to this change, the "-O"
setting specified by the compiler / build profile would always override
what other packages specify.

4 months agoAdd code to emit YAML
Christopher Collins [Tue, 17 Jul 2018 22:30:32 +0000 (15:30 -0700)] 
Add code to emit YAML

4 months agotarget: settings in YCfg, not map[string]string
Christopher Collins [Tue, 17 Jul 2018 19:19:02 +0000 (12:19 -0700)] 
target: settings in YCfg, not map[string]string

This change allows two things:
1. Processing of settings that don't have string values (e.g., sequences
and maps).
2. Override of some settings by syscfg values.

4 months agoPrevent original "-O" flag from being overridden
Christopher Collins [Tue, 17 Jul 2018 17:22:59 +0000 (10:22 -0700)] 
Prevent original "-O" flag from being overridden

If multiple packages specify a gcc optimization level ("-O<n>"), discard
all but the first.  This prevents the build profile "-O" setting from
overriding those specified in package-specific cflags.

4 months agosyscfg: error detection after API resolution 197/head
Christopher Collins [Wed, 25 Jul 2018 17:56:33 +0000 (10:56 -0700)] 
syscfg: error detection after API resolution

Prior to this commit, newt detected errors in the syscfg before API
requirements were satisfied.  Consequently, error detection was
happening before the full dependency graph had been generated, resulting
in an incomplete set of syscfg settings.  Parsing of restriction strings
might fail in this case, as unrecognized setting names are parsed as
string literals rather than expanded to the value that the setting would
ultimately have.

This commit delays error detection until after API resolution.

4 months agoMerge pull request #196 from ccollins476ad/syscfg-yaml-check
ccollins476ad [Thu, 19 Jul 2018 18:28:34 +0000 (11:28 -0700)] 
Merge pull request #196 from ccollins476ad/syscfg-yaml-check

Detect and report malformed `syscfg.yml` files

4 months agoDetect and report malformed syscfg.yml files 196/head
Christopher Collins [Thu, 19 Jul 2018 16:40:31 +0000 (09:40 -0700)] 
Detect and report malformed syscfg.yml files

Prior to this commit, malformed `syscfg.defs` or `syscfg.vals` maps
would trigger a panic.  Now, newt detects the problem and aborts the
operation with a descriptive error.

4 months agoUpdate newt_windows.rst
aditihilbert [Mon, 16 Jul 2018 22:24:12 +0000 (15:24 -0700)] 
Update newt_windows.rst

5 months agoSync: Pull from current upstream, not origin 185/head
Christopher Collins [Sat, 23 Jun 2018 02:03:44 +0000 (19:03 -0700)] 
Sync: Pull from current upstream, not origin

Prior to this commit, the `newt sync` command would assume the current
branch's upstream is origin.  This caused a number of issues:

1. If branch has an upstream other than origin, but there exists an
identically named branch in origin, then `origin/<branch>` is pulled
into the current checkout.  So, updates to one branch would get merged
into another, i.e., totally wrong.

2. If origin does not have an identically named branch, then the sync
operation would have no effect.

This commit changes newt to just pull from the currently tracked
upstream.

5 months agoutil: Distinguish fail-to-exec from nonzero exit.
Christopher Collins [Sat, 23 Jun 2018 02:02:28 +0000 (19:02 -0700)] 
util: Distinguish fail-to-exec from nonzero exit.

5 months agoDownloader API: Rename `UpdateRepo` --> `Pull`
Christopher Collins [Sat, 23 Jun 2018 01:42:53 +0000 (18:42 -0700)] 
Downloader API: Rename `UpdateRepo` --> `Pull`

Rename this function to use git language.