Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target [sysinit | sysdown] commands #230

Merged
merged 9 commits into from Nov 1, 2018

Conversation

ccollins476ad
Copy link
Contributor

@ccollins476ad ccollins476ad commented Oct 25, 2018

NOTE: This PR includes #221. That PR should be reviewed before this one.

This PR 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. The sysdown commands are similar; they show sysdown entries rather than sysinit entries.

This PR attempts to address two problems:

  • It is difficult to know the exact order of package initialization / shutdown. The brief commands allow this information to be visualized in a condensed table.
  • The sysinit or sysdown stages chosen used by third-party packages may not be suitable for a particular target. This PR allows syscfg settings to be used as stage numbers. The expectation is that all packages will define syscfg settings for their sysinit and sysdown stages. This allows the target to reorder the stages by overriding the corresponding syscfg settings.

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:
 STAGE   | PACKAGE                             | FUNCTION                 | SETTING
---------+-------------------------------------+--------------------------+----------------------------
 50      | sys/config                          | config_pkg_init          | CONFIG_SYSINIT_STAGE_1
 100     | sys/log/full                        | log_init                 | LOG_SYSINIT_STAGE_MAIN
<snip>

@ccollins476ad ccollins476ad force-pushed the target-sysinit branch 2 times, most recently from 04a7ac0 to a175d9f Compare October 25, 2018 20:47
ccollins476ad added a commit to ccollins476ad/mynewt-core that referenced this pull request Oct 26, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to ccollins476ad/mynewt-nimble that referenced this pull request Oct 26, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
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.
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.
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)     |
@@ -0,0 +1,46 @@
package val
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apache license missing.

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
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.
Clean up `target_cmds.go` by moving the following commands to a new file:
    * target config
    * target logcfg
    * target sysinit
    * target sysdown
@ccollins476ad ccollins476ad merged commit 2f34faf into apache:master Nov 1, 2018
ccollins476ad added a commit to ccollins476ad/mynewt-core that referenced this pull request Nov 7, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to ccollins476ad/mynewt-nimble that referenced this pull request Nov 19, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to ccollins476ad/mynewt-nimble that referenced this pull request Nov 21, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to apache/mynewt-nimble that referenced this pull request Nov 21, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to ccollins476ad/mynewt-core that referenced this pull request Nov 28, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to ccollins476ad/mynewt-core that referenced this pull request Dec 12, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
ccollins476ad added a commit to apache/mynewt-core that referenced this pull request Dec 12, 2018
This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(apache/mynewt-newt#230).  Older versions of
newt fail to parse the updated `pkg.yml` files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants