Commit graph

2587 commits

Author SHA1 Message Date
Martí Bolívar d406439570 gen_defines: don't emit comments with "# " lines
If the line is empty, just emit a single "#\n" instead of "# \n".

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 07:28:45 -06:00
Martí Bolívar c63069489c gen_defines: emit output for all nodes in dependency order
This makes the results easier to read, since node output appears in
the same order as the top level comment summarizing the tree.

Reorganize how flash partitions are emitted so they also appear in
dependency order, allowing us to extend the comment at the top of the
file to say that nodes are emitted in that order, along with other
useful information.

Print comments even for nodes that are disabled or have no binding,
to make it clearer that the script considered them and decided not to
output anything for them.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 07:28:45 -06:00
Frank Li 59208ac13b runners: pyocd: add --tool-opt parameter
add --tool-opt to support more pyocd parameter

Signed-off-by: Frank Li <lgl88911@163.com>
2020-02-03 13:32:38 -05:00
Patrik Flykt 65ffc71466 scripts: net: Add script for running sample tests
Add a script that sets up Docker networking and starts the net-tools
Docker container. If successful, run Zephyr with native_posix and
execute the appropriate net-tools container executable. The proper
net-tools executable and arguments is selected depending on the
basename of the sample directory. This script needs to be updated
if the net-tools Docker image is updated in some incompatible way.

The net-tools directory is assumed to exist at the same level as
the Zephyr base directory, but its location can be set using the
'-N' command line argument. Likewise, '-Z' sets the Zephyr top level
directory.

When stopping Zephyr, go through all child processes since running a
native posix or other variant of Zephyr may cause a hierarchy of
processes to be created.

Fixes: #19540

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2020-02-03 09:04:12 -05:00
Marcin Niestroj be0f5fe0b0 scripts/sanitycheck: fix merging OVERLAY_CONFIG extra args
Overlay files were concatenated into single string with no whitespace
between them. If '--extra-args OVERLAY_CONFIG="overlay-1.conf"
--extra-args OVERLAY_CONFIG="overlay-2.conf"' was used, then the result
was OVERLAY_CONFIG="overlay-1.confoverlay-2.conf".

Another thing was that overlay extra args were not properly removed from
the list of regular arguments. As a result we had incorrect list of
overlays and incorrect list of other arguments.

Rework code to extract overlays in loop in a safe manner. Use for that a
list of strings instead of string directly. Join those strings and form
a single OVERLAY_CONFIG argument just before running cmake.

Tested with following testcase.yaml line:

  extra_args: ARG1 OVERLAY_CONFIG="overlay-1.conf"
              ARG2 OVERLAY_CONFIG="overlay-2.conf"

Before this patch we got:

  args = ['OVERLAY_CONFIG="overlay-1.conf"',
    'OVERLAY_CONFIG="overlay-2.conf"']

After this patch we get:

  args = ['ARG1', 'ARG2',
    'OVERLAY_CONFIG="overlay-1.conf overlay-2.conf"']

While at it, fix also regex pattern by removing requirement of double
quotes around value. Match any option value instead and strip both
single and double quotes when match is positive. Tested with:

  $ ./scripts/sanitycheck -T samples/hello_world/ -p qemu_x86 \
      --extra-args OVERLAY_CONFIG=overlay1.conf '
      --extra-args OVERLAY_CONFIG=\"overlay2.conf\" '
      --extra-args OVERLAY_CONFIG=\'overlay3.conf\'

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-01-31 15:55:36 -05:00
Ulf Magnusson d0f082dd3b kconfig/devicetree: Print path to headers when configuring
Change the output during CMake configure from

    Devicetree configuration written to .../devicetree.conf
    Parsing /home/ulf/z/z/Kconfig
    Loaded configuration '.../frdm_kw41z_defconfig'
    Merged configuration '.../prj.conf'
    Configuration saved to '.../.config'

to

    Devicetree header saved to '.../devicetree_unfixed.h'
    Parsing /home/ulf/z/z/Kconfig
    Loaded configuration '.../frdm_kw41z_defconfig'
    Merged configuration '.../prj.conf'
    Configuration saved to '.../.config'
    Kconfig header saved to '.../autoconf.h'

devicetree_unfixed.h is more useful to be aware of than devicetree.conf
(still hoping we can get rid of it at some point), and seeing the
Kconfig header clarifies things to.

"Saved" instead of "written" for consistency. Maybe it could say
"Kconfig configuration" instead of "configuration" too, though it gets a
bit spammy in other contexts where the message shows up.

Updates Kconfiglib (and menuconfig/guiconfig, just to sync) to upstream
revision 061e71f7d7, to get this commit in, which is used to print the
header path:

    Return a message from Kconfig.write_autoconf()

    Like for Kconfig.write_config() and Kconfig.write_min_config(),
    return a string from Kconfig.write_autoconf() with a message saying
    that the header got saved, or that there were no changes to it. Can
    be handy in tools.

    Also make the "no change" message for the various files more
    specific, by mentioning what type of file it is (configuration,
    header, etc.)

    Return True/False from Kconfig._write_if_changed() to indicate if
    the file was updated. This also allows it to be reused in
    Kconfig.write_min_config().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-31 19:45:43 +01:00
Martí Bolívar 34346c41ac modules: fail on invalid ZEPHYR_EXTRA_MODULES
Add error checking in zephyr_module.py so that if the user manually
specifies ZEPHYR_EXTRA_MODULES and the list contains something that
isn't in fact a valid module, we scream and die.

This should help with diagnosing module errors.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-31 19:35:43 +01:00
Ulf Magnusson e2f647b08b scripts: kconfig: lint.py: Add check for missing CONFIG_ prefix
Add a new --check-missing-config-prefix check that looks for references
like

    #if MACRO
    #if(n)def MACRO
    defined(MACRO)
    IS_ENABLED(MACRO)

where MACRO is the name of a defined Kconfig symbol but doesn't have a
CONFIG_ prefix. Could be a typo.

Skip MACRO if it is #define'd somewhere, even if it looks like a Kconfig
symbol.

Found e.g. https://github.com/zephyrproject-rtos/zephyr/pull/22195.

Piggyback skipping binary files when grepping for Kconfig symbol
references.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-31 19:29:49 +01:00
Alberto Escolar Piedras 1a01a10a87 ci: Run also BT edtt_ble_test_app tests
Include in the CI run the EDTT tests

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2020-01-31 18:36:40 +01:00
Alberto Escolar Piedras 9338e9215b run_ci.sh: Set EDTT_PATH
So that the EDTT tool could be used by this script,
set its path so other scripts could find it

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2020-01-31 18:36:40 +01:00
Anas Nashif 471ffbe77d coverage: do not dump coverage data by default
Only dump data when we are interested in the analysing coverage. By
default just collect the data.

CONFIG_COVERAGE_DUMP is used to control this behaviour.

This will help speed up sanitycheck and will avoid lots of noise in the
log when some tests with coverage enabled failed. Dumping data to
console is also suspected to be one of the reason why qemu hangs in CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-30 16:04:03 -05:00
Henrik Brix Andersen deccb71f1d west: commands: sign: look for imgtool.py in path
If 'imgtool' is not found in PATH look for 'imgtool.py' before bailing
out.

This allows adding the mcuboot/scripts directory to PATH and have
'west sign -t imgtool' automatically locate the 'imgtool.py' script.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-30 14:17:07 -05:00
Anas Nashif 923ca14b7d sanitycheck: show which threads are stuck
Print a warning if some threads are taking more time and seem to be
stuck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-30 16:49:03 +01:00
Anas Nashif 2c1c399872 sanitycheck: minor comment and style cleanup
Remove an unrelated comment and a minor style change.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-30 16:49:03 +01:00
Ulf Magnusson edfe5a653e dts: gen_defines.py: Save final devicetree to zephyr/zephyr.dts
Add a '--dts-out <file>' flag to gen_defines.py that saves the final
devicetree to <file>, in DTS format, using the new EDT.dts_source
attribute.

Handy to have available as a debugging aid. Unused otherwise.

Also write a dummy <BOARD>.dts_compiled file that tells people to look
at zephyr.dts, for people that might be used to that file. It was
removed in commit 8d8b06978c ("dts: Remove generation of
<BOARD>.dts_compiled").

Fixes: #22272

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-30 04:27:39 -06:00
Ulf Magnusson a758af4988 dts: edtlib: Add an EDT.dts_source attribute that holds the source code
EDT.dts_source is the source code of the loaded .dts file, after merging
nodes.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-30 04:27:39 -06:00
Ulf Magnusson 8dfbd9f080 kconfig.py: Error/warning formatting nits
Include the "warning: "/"error: " part of the string when wrapping
lines, and consistenly start messages with a capital letter.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-30 03:51:04 -06:00
Ulf Magnusson ac78e2d37a kconfig.py: Add a description at the top of the file
Give a short overview of what the script is about.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-30 03:51:04 -06:00
Ulf Magnusson bf4133d262 kconfig.py: Flag selects with unsatisfied deps and remove whitelisting
Turn the warning for selecting a symbol with unsatisfied dependencies
into an error. The last instance has been fixed (that triggers in CI at
least).

Also remove the warning whitelisting functionality, which was only used
to whitelist that warning. It hasn't been used for anything else in over
a year, so it probably wouldn't be useful to keep. Getting rid of it
makes the script easier to read.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-30 03:51:04 -06:00
Ulf Magnusson 88db84b89b dts: edtlib: Turn Node.instance_no into EDT.compat2enabled
Add an EDT.compat2enabled attribute that maps compatibles to enabled
devicetree nodes that implement them. For example,
EDT.compat2enabled["foo"] is a list of all enabled nodes with "foo" in
the 'compatible' property.

The old Node.instance_no functionality can be implemented in terms of
EDT.compat2enabled, so remove Node.instance_no. EDT.compat2enabled is
more flexible and easier to understand.

Simplify main() in gen_defines.py by using EDT.compat2enabled to
generate the DT_COMPAT_<compatible> existence macros. The behavior is
slightly different now, as DT_COMPAT_<compatible> is generated for
enabled nodes that don't have a binding as well, but that might be an
improvement overall. It probably doesn't hurt at least.

EDT.compat2enabled simplifies the implementation of the new
$(dt_compat_get_str) preprocessor function in
https://github.com/zephyrproject-rtos/zephyr/pull/21560. That was the
original motivation.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-29 09:46:38 -06:00
Kuba Sanak c0e31e7d71 flashing: don't give bossac offset parameter unless explicitly provided
This fixes a problem which appeared after bossac version was downgraded
to 1.7 which no longer accepts the -o/--offset parameter. Now the offset
is fed to bossac executable only if it's explicitly provided and not by
default.

Signed-off-by: Kuba Sanak <contact@kuba.fyi>
2020-01-28 12:53:13 -06:00
Ulf Magnusson 3e37447802 dts: gen_defines.py: Do not crash on 'type: path' properties
'type: path' was added to edtlib for completeness in commit 23a5b4963b
("dts: edtlib: Add 'type: path' for path references"). gen_defines.py
crashes if it's ever used though, because it gets confused for a
'type: phandle-array'.

Ignore 'type: path' properties in gen_defines.py, like how
'type: phandle' and 'type: phandles' are currently ignored too.

(Note that gen_defines.py is only one possible user of edtlib.)

Fixes: #22197

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-28 12:51:35 -06:00
Ulf Magnusson cf89ba33ea global: Fix up leading/trailing blank lines in files
To make the updated test in
https://github.com/zephyrproject-rtos/ci-tools/pull/121 clean, though it
only checks modified files.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-27 17:41:55 -06:00
Peter Bigot ab7773dae8 sanitycheck: leave non-tty terminal unmodified on exit
The terminal configuration should not be reset on exit if
sanitycheck's output is being directed to something that mediates the
terminal control, such as a pager.  Only do the reset if stdout is
interactive.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:54:41 +01:00
Ulf Magnusson 08484d0ac4 dts: gen_defines.py: Convert to use f-strings
Use f-strings instead of .format() to makes all the macro identifier and
multiline comment building easier to read.

f-strings were added in Python 3.6, which is required by Zephyr now.

Convert some

    ... + "_" + ...

string building to f-strings as well.

f-strings are a bit faster too (because they avoid format()/str()
lookups), though it's not likely to be noticeable here.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-24 21:33:28 -05:00
Ulf Magnusson a5f6233428 kconfig.py: Convert to use f-strings
Use f-strings instead of .format() to make things more readable. They
were added in Python 3.6, which Zephyr requires now.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-24 15:57:23 +01:00
Ulf Magnusson ba2f95ab39 kconfig: Show unsatisfied deps. when assignments don't take
Show which dependencies are unsatisfied when symbols don't get their
assigned value.

For example, assume that FOO below is assigned with CONFIG_FOO=y. Note
that BAR, BAZ, and STR = "hmm" are 'n'.

    config FOO
           bool "foo"
           depends on BAR && BAZ && QAZ && STR = "hmm"

    config BAR
           def_bool n

    config BAZ
           def_bool n

    config QAZ
           def_bool y

    config STR
           def_string "zmh"

This now prints this warning:

    warning: FOO (defined at /home/ulf/z/z/Kconfig:10) was assigned the
    value 'y' but got the value 'n'. Check these unsatisfied
    dependencies: BAR (=n), BAZ (=n), STR = "hmm" (=n). See ...

Fixes: #21888

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-23 23:04:09 +01:00
Anas Nashif dd65f7c38a sanitycheck: change distribution of tests per set
Sort by testcase name and path and not by platforms. This way we do not
have the same platform executing on CI system causing failures to
overload.

Right now we have almost all qemu targets executing on 1 or 2 nodes,
causing those systems to be overloaded. Instead of taking the default
sorting by platforms, we now sort by testcases, so the distribution is
more "random", but still reproducible.

Remove the ordering function that would put native_posix in the first
set, it is not being used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-23 14:02:59 -05:00
Rihards Skuja f59b92b3ee runners: openocd: don't throw when no config is provided
In some cases the config is already provided for us e.g. when setting
OPENOCD_NRF5_SUBFAMILY. Also it looks like config was always supposed to
be optional (there are checks for it on do_run()).

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2020-01-23 10:38:57 -05:00
Flavio Ceolin 661035a6b8 west: runners: stm32: Remove unecessary assignment
msg_text is unconditionally assigned later and this inital value is
never used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-01-22 17:37:41 -05:00
Flavio Ceolin 9dbb50bac8 scripts: sanitycheck: Simplify if statement
Outer if is checking if the variable is in a list with two options
which means that we can just do an if / else and remove an assignment.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-01-22 17:37:41 -05:00
Ulf Magnusson 45050dda48 kconfig/cmake: Improve reconfiguration behavior
There are some issues with the behavior when rerunning CMake in an
already initialized build directory:

 1. The check for assignments to promptless symbols in configuration
    fragments isn't run when reconfiguring, because it only runs if
    zephyr/.config doesn't exist

 2. As outlined in
    https://github.com/zephyrproject-rtos/zephyr/issues/9573, you can
    get into situations where zephyr/.config is invalid (e.g. due to
    being outdated), but menuconfig/guiconfig can't be run to fix it

 3. If kconfig.py fails while merging fragments during reconfiguration,
    it will ignore the fragments during the next reconfiguration and use
    the existing zephyr/.config instead, because the fragment checksum
    is calculated and saved before running kconfig.py

(Footnote: The input configuration file(s) to kconfig.py can be either a
list of configuration fragments, when merging fragments, or just
zephyr/.config, if the merged configuration is up-to-date. The output
configuration file is always zephyr/.config.)

To fix the first two issues, explicitly tell kconfig.py when it's
dealing with handwritten configuration input (fragments), via a new
--handwritten-input-configs flag. This is more robust than checking
whether zephyr/.config exists, which was the old logic.

When dealing with handwritten input, there should be no assignments to
promptless symbols. Assignments to promptless symbols is expected in
zephyr/.config however, because it doubles as configuration output.

When running menuconfig/guiconfig, the input configuration is
zephyr/.config rather than configuration fragments, so this change also
makes sure that menuconfig can always be run as long as zephyr/.config
exists and is up-to-date.

To fix the last issue, only write the checksum for the configuration
fragments if kconfig.py succeeds (which means it wrote a
zephyr/.config).

Also improve naming a bit, add help texts for the command-line
parameters to kconfig.py, and simplify write_kconfig_filenames() by
moving logic into it.

Partial fix for
https://github.com/zephyrproject-rtos/zephyr/issues/9573, without the
part in #issuecomment-469701831. Can still run into issues when e.g.
when CMake files can't make sense of settings.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-22 18:28:07 +01:00
Anas Nashif e337882189 sanitycheck: fix reporting of timeouts
Timeouts were not reported correctly in the XML file as failures,
causing some confusion in the shippable results.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-22 01:39:28 -05:00
Anas Nashif 9fe1e2a663 sanitycheck: support excluding platforms
It is often needed to run sanitycheck and exclude a specific platform or
multiple platforms. Add an option to provide this using
--exclude-platform. The option can be used multiple times to exclude
multiple platforms at the same time.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-21 21:10:49 -05:00
Ulf Magnusson 7419f4f46f scripts: kconfig.py: Simplify write_kconfig_filenames()
The assert has never hit and probably won't be useful. Shorten the code
a bit.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 19:39:14 +01:00
Ulf Magnusson 7a531ea22b scripts: kconfig.py: Use err() helper for warnings-turned-errors
De-spams the code a bit.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 19:39:14 +01:00
Ulf Magnusson 7a148ef9da scripts: kconfig.py: Rename verify_*() functions to check_*()
Bit shorter, matches the devicetree code.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 19:39:14 +01:00
Ulf Magnusson bb4a4e79dc scripts: kconfig.py: Detect all assignments to promptless symbols
Assigning to promptless symbols has no effect.

Previously, the only check was for whether the value assigned to a
symbol matched its final value. This misses cases where a promptless
symbol is assigned to and just happens to get the assigned-to value as
its final value.

Instead, detect whether configuration files are being merged (by
checking if zephyr/.config already exists), and explicitly check for
assignments to promptless symbols in that case. We can't do it when
zephyr/.config already exists (and is being loaded), because it includes
values for promptless symbols as well.

With the no-prompt check moved out, also use a more specific message for
it, and remove stuff related to prompts elsewhere. Shorten messages a
bit at the same time, and add two warn() and err() helpers.

Fixes: #20697

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 19:39:14 +01:00
Ulf Magnusson 4e85006ba4 dts: Rename generated_dts_board*.{h,conf} to devicetree*.{h,conf}
generated_dts_board.h is pretty redundant and confusing as a name. Call
it devicetree.h instead.

dts.h would be another option, but DTS stands for "devicetree source"
and is the source code format, so it's a bit confusing too.

The replacement was done by grepping for 'generated_dts_board' and
'GENERATED_DTS_BOARD'.

Two build diagram and input-output SVG files were updated as well, along
with misc. documentation.

hal_ti, mcuboot, and ci-tools updates are included too, in the west.yml
update.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 17:57:59 +01:00
Anas Nashif d6d0b6454b ci: do not display timestamps
With timestamps enabled, the log in shippable is very difficult to read,
so remove those and enable them when needed for debugging only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-17 08:30:23 -06:00
Anas Nashif 1342d21fc0 sanitycheck: support runtime artifact cleanup
Using --runtime-artifact-cleanup, the script will now remove all
artifacts of passing tests. This is useful for running sanitycheck on
systems with little disk space.

Fixes #21922

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-16 19:19:07 -05:00
Ulf Magnusson d0f7652858 dts: gen_defines.py: Rename *_dev() to *_node()
out_dev(), etc., as a name is a holdover from before commit 73ac1466fb
("scripts: edtlib: Call nodes "nodes" instead of "devices""). It's
confusing for the same reasons as mentioned in that commit.

Renamings:

 - dev_ident()            -> node_ident()
 - out_dev()              -> out_node()
 - out_dev_s()            -> out_node_s()
 - dev_aliases()          -> node_aliases()
 - dev_path_aliases()     -> node_path_aliases()
 - dev_instance_aliases() -> node_instance_aliases()

Also clean up comments to talk about nodes instead of devices where it
makes sense.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-16 18:32:58 +01:00
Martí Bolívar 60db6a6e2f scripts: runners: nrfjprog: sort SNR list before prompting
This guarantees muscle memory will work over multiple runs when the
same boards are connected. (The "nrfjprog --help" output for --ids
does not guarantee an order.)

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-16 10:20:39 -05:00
Martí Bolívar e4768ad7e7 scripts: runners: nrfjprog: restrict when we guess snr
Right now, the nrfjprog runner will prompt the user for which board to
use if there are multiple possibilities and the --snr command line was
not given to specify one ahead of time.

Tweak this so it only happens if standard input is connected to a
terminal. This should avoid stalling the process on board farms when
this runner is used in automation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-16 10:20:39 -05:00
Martí Bolívar ae2f27cf16 scripts: runners: defer ensure_snr() to run in nrfjprog
The create() classmethod should not be doing any I/O -- its only job
is to create the ZephyrBinaryRunner instance. It's currently trying to
figure out what the serial number of the board is, though. Let's defer
that work to do_run(), so it gets handled by run_common's exception
handler.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-16 10:20:39 -05:00
Martí Bolívar 8837469492 scripts: runners: improve error handling CLI
Catch RuntimeError when calling runner.run() and print a message
instead of dumping stack unless in verbose mode.

This improves the command line interface when runners raise exceptions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-16 10:20:39 -05:00
Andrew Boie 75bd9b6ce0 sanitycheck: improve summary output
Show how many tests passed out of those that were actually
performed, not including skipped tests (which we also report
a count of)

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-14 23:26:06 -05:00
Anas Nashif cd1f017468 sanitycheck: set extra_args from command line
Missed setting extra_args coming from command line in the testsuite.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-14 13:39:46 -05:00
Ulf Magnusson 75621c3b45 dts: gen_defines.py: Add should_write() helper for properties
should_write() returns False for properties that are skipped in
write_properties(). Shortens write_properties() a bit.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-14 17:31:59 +01:00
Ulf Magnusson 776de86dc7 menuconfig: Update to work around resizing crash on macOS
Update menuconfig (and kconfiglib and guiconfig, just to sync) to
upstream revision 424d0d38e7, to get this commit in, which works around
a crash on some macOS Python installations.

    menuconfig: Work around crash on resize on some macOS systems

    get_wch() has started raising curses.error when resizing the
    terminal on some macOS Python installations. Work around for now by
    falling back on getch(), which still works.

    See https://github.com/ulfalizer/Kconfiglib/issues/84. Needs more
    investigation, but I don't have a Mac handy.

    Based on https://github.com/ulfalizer/Kconfiglib/pull/85, but with
    some more comments.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 14:03:12 +01:00
Ulf Magnusson 02dab5a5a8 dts: gen_defines.py: Add helper for outputting {} initializers
The

    "{" + ", ".join(...) + "}"

pattern is in a bunch of places now. Add an out_dev_init() helper for
it, with the same parameters as out_dev().

Also makes "{" vs. "{ " consistent, picking the first one.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 13:50:15 +01:00
Ulf Magnusson 405daa0081 dts: edtlib: Add helper for testing error messages and test _slice()
Add a helper function verify_error() to testedtlib.py that takes a DTS
source and verifies that it generates a particular EDTError.

Use it to test the hints that the previous commit added to errors
generated by _slice().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 13:49:33 +01:00
Ulf Magnusson 57b2d2749c dts: edtlib: Improve error for wrong reg/ranges/interrupts size
Show how the element size was calculated in the error message when a
'reg', 'ranges', or 'interrupts' property has the wrong size. This
should help with debugging. Also mention that #*-cells properties come
from the parent node, which can be subtle.

Came up in https://github.com/zephyrproject-rtos/zephyr/issues/21607
(though it seems the comment disappeared).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 13:49:33 +01:00
Ulf Magnusson b4e18072a8 kconfig: Fix wrong max argument count for some preprocessor functions
dt_chosen_reg() and dt_node_reg() take between 1 and 3 arguments, not
between 1 and 4 arguments. The implicit name argument isn't included in
the count.

These functions implement $(dt_chosen_reg_*) and $(dt_node_reg_*).

Giving the right max argument count makes Kconfiglib generate error
messages that give the location of the call, instead of getting a
cryptic generic Python error.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-13 13:48:17 +01:00
Erwan Gouriou a11405df52 scripts: requirements: Request version 0.24.0 for pyocd
pyocd 0.24.0 provides support for more user options.
This enables flashing of additional boards using pyocd.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-13 11:49:57 +01:00
Anas Nashif e7656ea831 sanitycheck: do not log stderr from BinaryHandler
stderr from the binary handler (native_posix for example) was redirected
to the logger as errors, this is confusing the console and users, so
remove this.

Fixes #21784

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-09 14:28:32 -05:00
Andrew Boie 9b34ecd0c8 userspace: fix incorrect linker routing
The _thread_idx_map bitfield which has '1' set for free
thread indexes really needs to live in the
data section reserved for kernel object metadata, as this
is a part of memory that is allowed to shift addresses
between zephyr_prebuilt.elf and zephyr.elf.

However, if an application defines enough static threads
that there are no free indexes, the entire bitfield will
be zeroed and the bitfield will end up in the main BSS
section.

Force this data to always be in the .kobject_data.data
section regardless of its contents.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-09 09:13:23 -08:00
Ulf Magnusson 5372dedf2f scripts: kconfig: lint.py: Improve error reporting
If the working directory for a command was missing (usually due to
forgetting to run 'west update'), you'd get a FileNotFoundError
exception along with a cryptic error like

    'git' not found

Only catch OSError instead (which is a base class of FileNotFoundError),
and always show the exception message. It makes it clear that it's the
working directory that's missing.

Add some other misc. improvements too:

 - Turn stderr output from external commands into a warning instead of
   an error

 - Add err() and warn() helpers

 - Include the command name in messages

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-09 11:19:57 -05:00
Ulf Magnusson 23a5b4963b dts: edtlib: Add 'type: path' for path references
Add binding support for a 'path' property type, for properties that are
assigned node paths. Usually, paths are assigned with path references
like 'foo = &label' (common in /chosen), but plain strings are accepted
as well as long as they're valid paths.

The 'path' type is mostly for completeness at this point, but might be
useful for https://github.com/zephyrproject-rtos/zephyr/issues/21623.
The support is there already in dtlib.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-08 08:02:00 -06:00
Olof Johansson 8067aca7e9 gen_defines: close files before exit
In some cases, we've seen the output files be truncated when the
python script has been rebuilt into a .pex before running it --
likely due to buffering.

Closing files explicitly is the right thing to do anyway, so let's
do it.

Signed-off-by: Olof Johansson <olof@lixom.net>
2020-01-07 21:06:58 +01:00
Ulf Magnusson def1f0e2d5 devicetree: Remove DT_SRAM_{BASE_ADDRESS,SIZE}, use CONFIG_* versions
The SRAM address and size are currently available as both
DT_SRAM_{BASE_ADDRESS,SIZE} and as CONFIG_SRAM_{BASE_ADDRESS,SIZE} (via
the Kconfig preprocessor).

Use the CONFIG_SRAM_* versions everywhere, and remove generation of the
DT_SRAM_* versions from gen_defines.py.

The Kconfig symbols currently depend on 'ARC || ARM || NIOS2 || X86'.
Not sure why, so I removed it.

It looks like no configuration files set CONFIG_SRAM_* at the moment, so
another option might be to use the DT_* symbols everywhere instead. Some
Kconfig.defconfig.series files add defaults to them though.

Also improve the help texts for CONFIG_SRAM_* to say that they normally
come from devicetree rather than configuration files.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-07 17:19:36 +01:00
Ulf Magnusson 95c18f1e6b dts: gen_defines.py: Clean up 'reg' code
Reorganize write_regs() to reuse more code for *_BASE_ADDRESS and
*_SIZE, and get rid of reg_addr_ident() and reg_size_ident().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-07 16:42:33 +01:00
Anas Nashif e9450065de sanitycheck: additional scripting hook after flashing
Support custom hooks after flashing is completed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 4522e10d65 sanitycheck: report overflow on SRAM overflow
Instead of failing, report overflow when the SRAM overflows.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif bdffb88950 sanitycheck: close pipe file handles
Make sure we close the pipe file handles after we are done, otherwise we
will end up with too many open file descriptors and crash...

Fixes #20974
Fixes #21637

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 64c84b15ce sanitycheck: more debug messages
More debug messages to help locate issues and debug bugs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 1b1a7e242b sanitycheck: run pre/post script using dedicated function
Reduce duplicated code by introducing a dedicated function for running
custom scripts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 32e924459d sanitycheck: log errors when executing binaries
Add some verbosity into the log file to help with debugging.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 52b66c6ad1 sanitycheck: when timing out in handler, show correct log file
Fix issue where we timeout in handler and show the device.log file
instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 813deb7967 sanitycheck: use Unknown instead of N/A for fail reason
Instead of N/A, use Unknown which is more appropriate, N/A does not
really apply here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Anas Nashif 5c331f95ad sanitycheck: add Digilent to device discovery
Some platforms use this USB device for serial, detect it when generating
hardware map.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-06 13:58:10 -05:00
Andrew Boie bd13710524 sanitycheck: use abs path for logs
Makes it much easier to inspect them in a different terminal
from where the test was run. These paths tend to be long
anyway, even if relative.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-03 08:40:34 -05:00
Andrew Boie 114c01b3b9 sanitycheck: allow outdir to be overwritten
Sanitycheck used to delete the output directory if -n
wasn't used, but now it renamed it. Add a new flag to
enable the old behavior.

Do not use logging for these early messages, logger
hasn't been set up yet.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-03 08:40:34 -05:00
Andrew Boie 2d8d4c5562 sanitycheck: fix early messages
When managing build artifacts the logger hasn't been
initialized. Use print() here instead.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-03 08:40:34 -05:00
Andrew Boie 1fe1f3a23d sanitycheck: clean up TTY on exit
The code has a lot of sys.exit() calls, but internally these
just raise a special exception. Add a try...finally block
to ensure 'stty sane' is run before leaving the script.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-03 08:40:34 -05:00
Håkon Øye Amundsen c9a2a5e7fb scripts: cmake: move print from python to cmake
Prior to this all hex files included in a merge would
be printed on every invokation of cmake.

Allow the user to explicitly require this information
by moving the print to a VERBOSE-only cmake message.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-01-03 08:20:08 -05:00
David B. Kinder 17299f0734 doc: document python build scripts
We have a collection of python scripts that are part of our build
system.  This PR collects docstring comments added to these scripts into
a summary document.  Previous references to just the script name in
other documentation are updated to point to this build tool
documentation.

Some of the scripts needed an update to be processed (via include
directives) consistently.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-02 17:09:29 -05:00
Erwan Gouriou 17537c77c8 script/Kconfig: kconfig functions: Add shields_list_contains function
Add shields_list_contains Kconfig function which return bool based on
check of shield presence in cmake SHIELD_AS_LIST.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-02 17:02:41 -05:00
Ulf Magnusson e181e1b773 kconfiglib: Update to hide tracebacks for expected errors
Update Kconfiglib to upstream revision 9c0b562c94 to get this commit in:

    Add Kconfig.__init__() helper flag for suppressing tracebacks

    Tools that don't use standard_kconfig() currently generate spammy
    tracebacks for e.g. syntax errors.

    Add a suppress_traceback flag to Kconfig.__init__() for catching
    "expected" exceptions and printing them to stderr and exiting with
    status 1. Use it to make all tools consistently hide tracebacks.

Use the new flag to hide tracebacks for expected exceptions in
kconfig.py, lint.py, and genrest.py.

Some menuconfig robustness tweaks for wonky terminals are included as
well, and a new feature for customizing .config and autoconf.h header
comments via environment variables.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-20 19:48:09 -05:00
Anas Nashif 2a5d61d3ea sanitycheck: define schema for hardware map
Add schema for hardware map and verify it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-19 22:55:16 -05:00
Anas Nashif fc85ff052f sanitycheck: support pre/post flash scripts
This is needed when a board needs to be reset using an external commands
or tools that are not part of the flash command. For example, power
reset or by poking a GPIO header on the board using external wiring.

add post_flash/pre_flash to the platform section in the hardware map.
For example:

- available: true
  connected: true
  id: OSHW000032254e4500128002ab98002784d1000097969900
  platform: reel_board
  post_script: /tmp/post_flash.sh
  pre_script: /tmp/pre_flash.sh
  product: DAPLink CMSIS-DAP
  runner: pyocd
  serial: /dev/ttyACM11

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-19 22:55:16 -05:00
Sebastian Bøe bb95dce98c west: Fix defining modules without a module.yml
It is supported to have a zephyr module that does not have a
module.yml, but zephyr_module.py does not support it and will drop
such modules.

To fix this we add support in zephyr_module.py.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-12-19 15:52:44 -05:00
Martí Bolívar 150eb6575c scripts: west build: slight --help tweak
We have an open request to make the help for the -t option a little
easier. Try to do that without adding too much length to the short
help.

Fixes: #16202
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-12-19 11:29:39 +01:00
Ulf Magnusson 5e55eda30e scripts: edtlib: Support nested nodes on buses
For the following devicetree, view 'nested' as being on the bus.
Previously, only 'node' was considered to be on the bus.

    some-bus {
    	compatible = "foo,bus-controller";
    	node {
    		nested {
    			compatible = "foo,device-on-bus";
    		};
    	};
    };

In practice, this means that a 'bus:' key in the binding for
'foo,bus-controller' will now get matched up to an 'on-bus:' key in the
binding for 'foo,device-on-bus'.

Change the meaning of Node.bus and add two new attributes Node.on_bus
and Node.bus_node, with these meanings:

    Node.bus:
      The bus type (as a string) if the node is a bus controller, and
      None otherwise

    Node.on_bus:
      The bus type (as a string) if the node appears on a bus, and None
      otherwise. The bus type is determined from the closest parent
      that's a bus controller.

    Node.bus_node:
      The node for the bus controller if the node appears on a bus, and
      None otherwise

It's a bit redundant to have both Node.bus_node and Node.on_bus, since
Node.on_bus is the same as Node.bus_node.bus, but Node.on_bus is pretty
handy to save some None checks.

Also update gen_defines.py to use Node.on_bus and Node.bus_node instead
of Node.parent wherever the code deals with buses.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-19 11:02:28 +01:00
Ulf Magnusson 379145ffce scripts: edtlib: Rename 'child-bus:'/'parent-bus:' to 'bus:'/'on-bus:'
I keep mixing these up, so that's probably a sign that the names are
bad. The root of the problem is that "parent-bus" can be read as both
"this is the parent bus" and as "the parent bus is this".

Use 'bus:' for the bus "provider" and 'on-bus:' for nodes on the bus
instead, which is less confusing.

Support the old keys for backwards compatibility, along with a
deprecation warning.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-19 11:02:28 +01:00
Anas Nashif 0c69c285ec sanitycheck: cleanup hardware map display
Add a static method for dumping hardware map and reuse it across the
script reducing duplicated code.

Fixes #21475

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-18 21:52:02 +01:00
Anas Nashif 81b2f37a9d ci: run sanitycheck in verbose mode
Call sanitycheck in verbose mode

Fixes #21483

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-18 12:07:49 -05:00
Andrew Boie 13b8b41676 drivers: watchdog: add system calls
wdt_install_timeout() was skipped as it installs an ISR-context
callback handler function. The rest are simple wrappers.

Added myself as the maintainer of the syscall handlers. WDT
subsystem appears to not currently have an owner.

Fixes: #21432

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-18 09:28:52 -05:00
Maksim Masalski 1b4b9ef535 sanitycheck: hardware map added support of the microchip board
Added support of the Microchip with FTDI serial devices to be able
create a hardware map for them. In the future that hardware map
for the Microchip board will let run automatic Sanitycheck tests on it.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-12-18 08:05:05 -05:00
Ulf Magnusson 36b7ca44b8 scripts: edtlib.py: Deprecate 'title:'
Most bindings look something like this:

    title: Foo

    description: This binding provides a base representation of Foo

That kind of description doesn't add any useful information, as it's
just the title along with some copy-pasted text. I'm not sure what "base
representation" was supposed to mean originally either.

Many bindings also put something that's closer to a description in the
title, because it's not clear what's expected or how the title is used.
In reality, the title isn't used anywhere. 'description:' on the other
hand shows up as a comment in the generated header.

Deprecate 'title:' and generate a long informative warning if it shows
up in a binding.

Next commits will clean up the 'description:' strings (bringing them
closer to 'title:' in most cases) and remove 'title:' from all bindings.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-18 11:52:45 +01:00
Anas Nashif 17d066b9dc sanitycheck: fix reporting of timeouts
timeouts were not reported correctly and we were getting the default
'N/A' in case of a timeout.

Fixes #21438

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 3cfc608934 sanitycheck: remove commented out code
Remove commented out debug code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 9744568350 sanitycheck: use colorama module for colors
Use colorama module for colors instead of custom codes.

Fixes #21409

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif ebf8dae241 sanitycheck: fix legacy device testing support
When testing with one device and without a hardware map, make sure we
load the temporary map into the suite.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif d988238970 sanitycheck: pylint issues
run through pylint and fix.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 7148021627 sanitycheck: remove unused globals
A few globals that were never used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif c5ee3951fd sanitycheck: get rid of more global options
More global option cleanup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif e9eb00945d sanitycheck: move log_info_* to ProjectBuilder class
Move this to where it is being used and called.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 56656848f5 sanitycheck: do not use gloabl options
More changes moving away from using global options and instead using
class variables and parameters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif fa8085eb7b sanitycheck: all output from flasher goes to logger.debug
Redirect all output from flasher to logger.debug().

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif f16ed8e0b8 sanitycheck: move global info() into Testsuite class
This function is not used anywhere else now that we use logging module,
so push this into the class where it is being used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 67f9ecb79b sanitycheck: consistent output from logger
Make all output consistent with logger and report errors correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 6d66a7a933 sanitycheck: use logger instead of print
Use logger instead of print for consistency.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif d4cef07200 sanitycheck: reenable --timestamps option with loggging module
--timestamps now just enables a different formatter with asctime.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif f5e5ef0bd8 sanitycheck: reduce usage of global options
The use of a global options variable is making it very difficult to
create a testsuite for this script, so reduce and push options into
arguments instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 7a361b82a2 sanitycheck: use logging module for all console output
Drop custom output functions and use logging mode for almost all
reporting. Also log everything into sanitycheck.log so detailed run
information can be inspected later, even if we did not run with
--verbose mode on the console.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 6c0e17056b sanitycheck: cleanup setting binary options
Stop using global options and instead set binary options using class
variables.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 9e7a2cdb86 sanitycheck: use outdir from TS instance
Stop using global options and instead use propagated variable.
This is to make testing of sanitycheck easier.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 51ae4ed446 sanitycheck: move job setting to main()
Report about number of jobs in the main() function and not in the class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 11ee52594c saniytcheck: fixed pylint issues
Fixed a few pylint issues, including space and indent reported by
flake8.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 8f95e4d3a1 sanitycheck: fix typo
retyring -> retrying
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif e5006d169a sanitycheck: output hardware registery after scanning
Show a list of all refistered devices after scanning with

sanitycheck --generate-hardware-map

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 2ebb2ea5e8 requirements: require tabulate and anytree modules for sanitycheck
tabulate: Needed to show list of devices in a well formatted table.
anytree: needed to list testsuite in a tree form.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 33ed7aabd3 sanitycheck: handle flashing issues with --device-testing
When something goes bad during the flashing process set the reason
correctly and put the error messages from the flasher into device.log
and display the location of that file instead of an empty handler.log
right now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 5f908829b2 sanitycheck: move hardware map generation out of main
Move all hardware map generation/usage to a seperate class. This will
make it easier to extend the supported hardware in the future.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-17 17:21:56 -05:00
Anas Nashif 36e1fb630b ci: run sanitycheck on tests and samples
If modules announce they have tests, run sanitycheck on those modules.
This will run on first matrix node and as the last step after running
regular testsuite.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-16 18:56:28 +01:00
Anas Nashif 286a9eda84 modules: support tests/samples/boards in modules
Generate options for sanitycheck to run tests and samples in modules.
Use the --sanitycheck-out <file> to generate a file that can be supplied
to sanitycheck on the commandline which will add additional testroots
and boards if the module does contain out of tree boards.

the module.yaml file now accepts the following:

samples:
  - path/to/samples
tests:
  - path/to/tests
boards:
  - path/to/boards

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-16 18:56:28 +01:00
Torsten Rasmussen b3da9efbec scripts: using Path and PurePath for path handling in zephyr modules
Now using only Path and PurePath in zephyr_modules.py to handle module
processing.
This make the code cleaner as well as remove an issue where a module
name would become an empty string when module path contained trailing
path separators.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2019-12-13 14:08:22 +01:00
Andrew Boie f290ab595c kernel: fix 64-bit for kobject generation
We need a format code for struct packing that fits in
a pointer value, "I" is fixed at 32-bit.

The conversion of string to pointer value now prints
8 bytes. This works for 32-bit since the leading
4 digits are always zero.

The replaced length check uses sizeof(void *) and not 4.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-12-12 14:48:42 -08:00
Andrew Boie e48ed6a980 kernel: use uintptr_t for kobject data
This has to be wide enough to store a pointer.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-12-12 14:48:42 -08:00
Kumar Gala 34b1ef8dd8 sanitycheck: Fix process termination with newer ninja version
It appears that ninja 1.6.0 or greater don't seem to send SIGTERM down
to the child processes and thus we don't terminate correctly.  This
causes a hang with renode simulations.

Change terminate call to 'self.try_kill_process_by_pid()' when test
state is updated (i.e. done running with either passed or failed), in
order to explicitly send a SIGTERM to the simulator process before
sending a SIGTERM to ninja.

Refactor the terminate code so we encapsulate the behavior in one place
for a BinaryHandler.

Based on change from Stephanos Ioannidis <root@stephanos.io>

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-12 09:17:31 -05:00
Peter Bigot bed6eb9ed9 dts: edtlib: remove diagnostic on required with default
A property may be optional with a default in a base yaml, then
overridden to be required in a subordinate file.  Don't prevent this
by complaining about having a default on a required property.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-12-12 07:55:34 -06:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Anas Nashif d91f993e66 sanitycheck: export compile commands on --cmake-only
export compile commands when running with --cmake-only, this can be used
for analysis and coverage statistics.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-11 11:33:44 -06:00
Alberto Escolar Piedras dfed64c2a4 nrf52_bsim: Use HW models from new west module
Fetch HW models from a new west module.
And, remove all pre-west glue which was used to:
 * Fetch them in CI
 * Validate their vesion
 * Modify the include path and link to them

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-12-11 11:33:02 +01:00
Ulf Magnusson 94d1db03af ci: run_ci: Remove semicolons at ends of lines
Not needed in sh.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-10 14:34:46 -08:00
Ulf Magnusson 85625aa27f ci: run_ci: Use lowercase for internal vars
This makes it possible to tell at a glance which variables are internal
to the script and which ones are parameters to it, which is very
helpful.

This convention is pretty common. See e.g. Google's shell style guide at
https://google.github.io/styleguide/shell.xml#Naming_Conventions, and
https://github.com/icy/bash-coding-style#naming-and-styles. It's older
than those though.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-10 14:34:46 -08:00
Martí Bolívar 0186eade51 scripts: add new west build "build.cmake-args" config option
This option, if set, will add arguments to CMake whenever a new build
system is being generated.

It doesn't affect other invocations of CMake, such as when cmake(1) is
run in build tool mode to actually compile the application.

See the documentation changes for details.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-12-10 16:19:18 +01:00
Stephanos Ioannidis 432c93bb55 scripts: dts: Support GIC interrupt type-specific IRQ number fix up.
The ARM Generic Interrupt Controller (GIC) supports multiple interrupt
types whose linear IRQ numbers are offset by a type-specific base
number.

This commit adds a function to automatically fix up ARM GIC interrupts
in order to output a linear IRQ number that is offset by the interrupt
type-specific base number.

For more details, refer to the issue #19860.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-12-10 06:59:55 +01:00
Anas Nashif e0d931f6b8 sanitycheck: enable size tracking with size related options
Make sure we do enable size tracking with options that depend on the
size of generated binaries to be available.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 22:46:21 -05:00
Anas Nashif 0b6a1041e1 release: fix sanitycheck release file
File was generated with footprint data by mistake, regenerated with
correct options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 22:46:21 -05:00
Ulf Magnusson 53392ad403 scripts: gen_defines.py: Move flash-related code into separate function
Shortens main() a bit and makes it easier to read.

Rename write_flash() to write_flash_node(), and let write_flash() be the
top-level function. Also move the looking-up of the /chosen properties
into the the various helper functions themselves, and shorten some names
that are clear in context.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 20:00:47 -06:00
Ulf Magnusson f575724634 scripts: gen_defines.py: Improve output formatting and shorten main()
Make the node/ordinal list a part of the header comment to make the
output prettier.

Before:

    /*
     * Generated by gen_defines.py
     *
     * DTS input file:
     *   rv32m1_vega_ri5cy.dts.pre.tmp
     *
     * Directories with bindings:
     *   $ZEPHYR_BASE/dts/bindings
     */

    /* Nodes in dependency order (ordinal : path): */
    /* 0 : / */
    /* 1 : /aliases */
    /* 2 : /chosen */
    /* 3 : /connector */
    /* 4 : /cpus */
    /* 5 : /cpus/cpu@0 */
    /* 6 : /gpio_keys */
    /* 7 : /soc */
    ...

After:

    /*
     * Generated by gen_defines.py
     *
     * DTS input file:
     *   rv32m1_vega_ri5cy.dts.pre.tmp
     *
     * Directories with bindings:
     *   $ZEPHYR_BASE/dts/bindings
     *
     * Nodes in dependency order (ordinal and path):
     *   0   /
     *   1   /aliases
     *   2   /chosen
     *   3   /connector
     *   4   /cpus
     *   5   /cpus/cpu@0
     *   6   /gpio_keys
     *   7   /soc
     *   ...
     */

Also move the writing of the top comment and the node comments into
separate functions, to shorten main() and make it easier to follow.

Piggyback some minor comment-related simplifications.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 20:00:47 -06:00
Christian Taedcke ed22c5efe9 sanitycheck: Add option to use gcovr for coverage
gcovr is already a dependency in scripts/requirements.txt. The
visualization is different, but the functionality should be the same.
Tested with gcovr 4.2.

Relates to #17626.

Signed-off-by: Christian Taedcke <hacking@taedcke.com>
2019-12-09 17:36:29 -05:00
Kumar Gala c8c35f76ab scripts: dts: Remove deprecated extract_dts_includes.py script
We now use EDTS and gen_defines.py to generate DTS defines.  We
deprecated the old script and defines several releases ago, so lets now
remove them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-09 16:31:42 -05:00
Anas Nashif 434995cc99 sanitycheck: print testsuite tree
Print all tests using a tree structure (depends on anytree module). This
now can be done using --test-tree option.

sanitycheck --test-tree  -T tests/kernel/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 15:53:44 -05:00
Anas Nashif c1c3cc6ad9 sanitycheck: output a sort list of tests
Make --list-tests output a sorted list.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 15:53:44 -05:00
Lauren Murphy e0b2fb75db hardening: Introducing hardenconfig tool
Basic tool to help checking Kconfig options against a list of
hardening preferences.

This tool is available as a kconfig target, so to run it:

make/ninja hardenconfig

[Flavio Ceolin: Simplify logic and fix python lint issues]

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-12-09 12:54:29 -05:00
Steven Wang 6a407f4fe0 sanitycheck: remove "--detailed-report" from help message.
The option has been deprecated. So remove it from help message.

Signed-off-by: Steven Wang <steven.l.wang@linux.intel.com>
2019-12-09 12:51:09 -05:00
Ulf Magnusson fc5cd772da scripts: dts: Accept 'status = "ok"'
Erroring out for 'status = "ok"' broke backwards compatibility for a
downstream project. Accept it instead.

Maybe the error could be selectively re-enabled later.

The rest of the code only checks for 'status = "disabled"' (like the old
scripts), so no other updates are needed.

(It's a bit weird that we duplicate the property check in base.yaml.
Thinking of including base.yaml implicitly. Could clean things up then.)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 12:49:32 -05:00
Flavio Ceolin e86ec977fb syscalls: Remove references to __syscall_inline
There is no code to handle __syscall_inline so it is better removing
it from doxygen and checkpatch.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-12-09 12:47:15 -05:00
Christian Taedcke cac5e8f251 west: openocd: Add config file dir to search path
Use the folder the config file is in as an additional search directory
for openocd. This way additional files, like custom debug interface
files can be put in the support folder of a board and the openocd.cfg
can use them.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2019-12-09 12:46:10 -05:00
Anas Nashif a4dd49b380 sanitycheck: parse testcase names correctly
We were parsing random FAIL messages from the output of test runs ad
testcases and capturing them in the xml output. Now we only parse the
name if it starts with test_.

Fixes #21162

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 10:30:48 -05:00
Flavio Ceolin f4adf107f3 syscalls: Remove gen_syscall_header.py
gen_syscall_header.py is not longer necessary, it was just creating a
file including syscall.h. This header is now included directly by
gen_syscalls.py.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-12-09 16:08:50 +01:00
Anas Nashif f3a0ad013b release: update sanitycheck release file
Update sanity_last_release.csv required for footprint comparisons.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-07 19:17:08 -06:00
Martí Bolívar 2024fb531a scripts: runners: fix blackmagicprobe SIGINT behavior
The blackmagicprobe runner's Python process fails to ignore SIGINT
when it runs GDB from the debug and flash callbacks, which is wrong.

The other runners tend to use run_server_and_client() to properly
handle this, since they start a GDB server and connect to it with a
client. The BMP USB device presents itself as a serial device which
speaks the GDB serial protocol instead, so there's no server/client,
and thus no call to run_server_and_client().

The problem is that blackmagicprobe essentially uses
subprocess.check_call() to start GDB directly, without ignoring SIGINT
in the python process. Easy fix.

Fixes: #21139

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-12-03 14:15:30 -06:00
Anas Nashif 9091a0103d sanitycheck: fix parsting tests from source files
Fixed bug in parsing testnames from source files. We added 1cpu testing
but did not update the regex and we have been passing wrong path to the
glob as well, meaning tests were not parsed at all.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-25 21:43:22 -05:00
Anas Nashif b846c9a53d sanitycheck: enabling coverage should not imply --enable-slow
Those are two unrelated options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-25 21:43:22 -05:00
Anas Nashif 83a98e5a29 sanitycheck: report results before coverage generation
First report results, then start with coverage processing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-25 21:43:22 -05:00
Anas Nashif d11fd78591 sanitycheck: fix --sub-test option
This option was not working, make it work again using the new function
for managing test inventory.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-25 21:43:22 -05:00
Anas Nashif 19ca7833e5 sanitycheck: add option to print duplicate identifiers
A new option to list all duplicate identifiers. This now will output the
following:

sanitycheck --list-test-duplicates

Tests with duplicate identifiers:
- arch.interrupt
  - tests/arch/arm/arm_interrupt/arch.interrupt
  - tests/kernel/interrupt/arch.interrupt
- system.settings.nffs.config_empty_lookups
  - tests/subsys/settings/nffs/base64/system.settings.nffs
  - tests/subsys/settings/nffs/raw/system.settings.nffs
- system.settings.nffs.config_insert
  - tests/subsys/settings/nffs/base64/system.settings.nffs
  - tests/subsys/settings/nffs/raw/system.settings.nffs
- system.settings.nffs.config_getset_unknown
  - tests/subsys/settings/nffs/base64/system.settings.nffs
  - tests/subsys/settings/nffs/raw/system.settings.nffs
- system.settings.nffs.config_getset_int
  - tests/subsys/settings/nffs/base64/system.settings.nffs
  - tests/subsys/settings/nffs/raw/system.settings.nffs
..
..
..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-25 21:43:22 -05:00
Anas Nashif eabaa7f8bf sanitycheck: cleanup test inventory
Cleanup how we list testcases with --list-tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-25 21:43:22 -05:00
Peter Bigot 57c635587f sanitycheck: remove serial port assignment from unconnected devices
When storing an updated hardware list remove the serial property value
from entries that are not connected, to reduce confusion about exactly
what ttyACM0 is connected to.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Peter Bigot 3d46ea5946 sanitycheck: summarize device testing targets before starting
Confirm to the user what devices were found and where they are before
starting a long run that might not have found everything it was supposed
to test.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Peter Bigot da7384846e sanitycheck: allow device runner board-id to differ from board id
Boards like mimxrt1060_evk are recognized by the scanner through their
USB device which has an ID, but in some cases the board may be
programmed using an external J-Link probe.  Support this by adding a
probe_id key that can be added to the yaml dictionary to override the
use of id for this purpose.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Peter Bigot 52356ebde4 sanitycheck: recognize more hardware
Add manufacturer and product identifiers to produce board information
for SiLabs and NXP hardware when using --generate-hardware-map.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-25 07:52:23 -05:00
Christian Taedcke c415a4ef2d sanitycheck: Fix --enable-coverage option
This commit fixes the issue, that --enable-coverage alone did not create
coverage information. It also required to give --coverage-platform.
Now the fallback for coverage-platform to platform works as documented
also for enable-coverage, not only for coverage option.

Signed-off-by: Christian Taedcke <hacking@taedcke.com>
2019-11-24 11:54:16 -05:00
Anas Nashif 19d67e4cd2 sanitycheck: support on windows
We now support building on windows. Running in Qemu still does not work.

Partially addresses #2664

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-24 07:49:44 -05:00
Anas Nashif 12d8cce8b7 sanitycheck: fix documentation of --discard-report
The discard report is now generated for every run as
sanity-out/sanitycheck_discard.csv, the option --discard-report was
dropped.

Fixes #20804

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-20 14:01:34 -05:00
Arnaud Pouliquen 724bb7d240 scripts: dts: Add new chosen declaration for the IPC shared memory
The interprocessor communication can be based on shared memory.
Allow to declare this memory as with a generic name derived from
chosen declaration.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2019-11-20 19:29:06 +01:00
Martí Bolívar d8f459ab2e scripts: west sign: use edtlib for flash configuration
This command needs access to DT configuration, but can no longer
access it through BuildConfiguration since
9da1d41a12.

Import edtlib and use that instead.

Fix up some other error handling and output issues while we're here to
make the script's behavior easier to inspect and debug.

Fixes: #20545
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-15 07:53:25 -06:00
Anas Nashif 3a00d0ca75 sanitycheck: record results when running on devices
Write recording.csv file when running on devices.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-15 08:05:33 -05:00
Kumar Gala a4b2b5bbf8 sanitycheck: Add support for TI XDS110 to --generate-hardware-map
Add support for boards that utilize the TI XDS110 like the CC3220SF,
CC3235SF, CC1352R1 and CC26x2R1 LaunchXL boards.  The XDS110 can expose
multiple serial endpoints one for the uart device, but another for a
trace buffer.  We assume that endpoint 0 will be the UART device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-14 09:16:50 -05:00
Kumar Gala 1ad3543ada sanitycheck: add setting runner type for J-Link & STLink
Add setting runner type to jlink for 'J-Link' and openocd for
'STM32 STLink' when generating the hardware map.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-14 09:16:50 -05:00
Martí Bolívar 483adc984e scripts: fix misc-flasher runner
This makes the misc-flasher runner usable by passing the build
directory to the underlying tool.

Fixes: #20658
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-13 23:49:28 -05:00
Martí Bolívar 59e2f230e0 scripts: dts: improve error message on compatible type error
Print the offending value and its type.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-13 15:07:29 -06:00
Stephanos Ioannidis e1827c04d3 sanitycheck: Relocate QEMU-specific code to QEMUHandler.
This commit relocates the QEMU-specific code that currently resides in
ProjectBuilder.run to QEMUHandler.handle, in order to align with what
other handlers are doing.

For more details, refer to the PR #20573.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-13 06:32:31 -06:00
Stephanos Ioannidis 938890041a sanitycheck: Fix incorrect QEMUHandler status reporting.
The current QEMUHandler implementation in sanitycheck does not check
for the process exit code and reports "PASS" even when either the QEMU
executable cannot be launched or exited immediately due to an error
(e.g. unsupported machine type, missing file, ...).

This commit adds QEMU process exit code check and error reporting when
the exit code is a non-zero value.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-13 06:32:31 -06:00
Ulf Magnusson d55ed93636 scripts: edtlib: Move imports after overview comment
Might make the comment easier to spot.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-12 17:57:50 -06:00
Ulf Magnusson 72158858ac scripts: dtlib/edtlib: Make output consistent on Python 3.5-
Python 3.5 and earlier do not preserve dictionary insertion order when
iterating over dictionaries, and do not give the same order between
runs. This broke the dtlib and edtlib test suites and made the output
jump around randomly between runs. It also made device INST_<n> numbers
non-deterministic, which broke some code on Python 3.5 (though
hardcoding device instance numbers in the code might be a bit shaky).

Fix it by using collections.OrderedDict instead of plain dict wherever
order matters. This makes the output identical on all supported Python
versions. It also allows testdtlib.py and testedtlib.py to run in CI,
which uses Python 3.5.

Fixes: #20571

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-12 17:57:50 -06:00
Ulf Magnusson 0e23994d23 scripts: edtlib: Avoid modifying the global yaml.(C)Loader
edtlib is a library, and modifying yaml.(C)Loader directly interferes
with any binding loading in edtlib clients. To avoid that, add a custom
loader for bindings.

Internally, PyYAML does this, which is why defining a separate class
works:

    @classmethod
    def add_constructor(cls, tag, constructor):
        if not 'yaml_constructors' in cls.__dict__:
            cls.yaml_constructors = cls.yaml_constructors.copy()
        cls.yaml_constructors[tag] = constructor

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-12 17:57:50 -06:00
Anas Nashif c724033acc west: prepend -c to openocd commands
commit 0df4a53107 changed the behavior of
how openocd commands are passed to openocd. We used to add -c to each
command, now the commands are being added without -c causing an error.

This adds "-c" to all commands instead of just passing a list.

Also fixes #20449.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-12 14:37:34 -05:00
Ioannis Glaropoulos 2293b57638 scripts: west_commands: nrfjprog: extend nrfjprog.py runner for nrf53
This commit extends the nrfjprog.py runner script so it adds
support for nRF53. In the wake of the changes done in the
runner script, we extend the testing done in test_nrfjprog.py,
adding the required coverage for the nRF53.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-08 19:26:35 +01:00
Andrew Boie 4f77c2ad53 kernel: rename z_arch_ to arch_
Promote the private z_arch_* namespace, which specifies
the interface between the core kernel and the
architecture code, to a new top-level namespace named
arch_*.

This allows our documentation generation to create
online documentation for this set of interfaces,
and this set of interfaces is worth treating in a
more formal way anyway.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-11-07 15:21:46 -08:00
Henrik Brix Andersen a2a7b776cb drivers: eeprom: add API for EEPROM devices
Add API for accessing Electrically Erasable Programmable Read-Only
Memory (EEPROM) devices.

EEPROMs have an erase block size of 1 byte, a long lifetime, and allows
overwriting data on byte-by-byte access.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-11-07 16:32:15 -05:00
Kumar Gala 9da1d41a12 scripts: runners: Drop loading symbols from generated_dts_board.conf
Now that DT symbols from generated_dts_board.conf are deprecated remove
loading symbols from it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-07 08:43:16 -06:00
Ulf Magnusson f4296a03ca kconfig: Update Kconfiglib and use new helpers in kconfig.py
Update Kconfiglib, menuconfig, and guiconfig to upstream revision
faa1d21998, mostly to get this commit in:

    Add public helpers for generating "<name> (defined at ...)" strings

    Have Symbol/Choice.name_and_loc return strings like

        "MY_SYM (defined at foo:1, bar:2)"
        "<choice> (defined at foo:4)"

    I've added a function like that in at least four different scripts
    now, so that's probably a sign that it's a worthwhile helper.

    Clean up the tests/Klocation tests a bit while adding tests.

Use the new helper to simplify kconfig.py a bit. Also clean it up a bit
by removing some unused stuff.

Some other minor improvements are included as well, e.g. to make
menuconfig/guiconfig give more helpful errors on invalid arguments.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-07 15:34:09 +01:00
Ulf Magnusson a328c5190d kconfig: Add linting script
Add a cleaned-up version of a script I used to find a bunch of unused
symbols and some other Kconfig issues. It's set up to be run directly,
with few environment dependencies.

West is required, because the checks need to see Kconfig files and
source code from all modules.

Checks so far:

 - Symbols that can never be anything but n/empty

 - Symbols that look unused

 - menuconfig symbols with empty menus

 - Symbols only defined in Kconfig.defconfig files

See the help strings for the command-line flags for more information.

Some of these checks could probably be checked in CI later, though the
always-n and unused-symbol checks are a bit heuristic and might need a
lot of whitelisting.

Another reason I want to get this in is to have a clean standalone
reference for how to set up the environment for parsing the Kconfig
files. It's gotten trickier over time.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-07 15:32:50 +01:00
Ulf Magnusson 2e1d2889e2 dts: edtlib: Turn edt.required_by()/depends_on() into Node attributes
Turns

    edt.required_by(node)
    edt.depends_on(node)

into

    node.required_by
    node.depends_on

which might be a bit more readable.

One drawback is that @property hides that there's some slight overhead
in accessing them, but I suspect it won't be meaningful. Caching could
be added if it ever turns out to be.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-06 17:33:59 -08:00
Ulf Magnusson cffb9ad7c6 dts: grutils: Remove spaces before '(' in function definitions
Just to make it a bit more consistent with the rest of the code.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-06 17:33:59 -08:00
Ulf Magnusson c7c9e02a11 dts: testedtlib: Fix broken Node.dep_ordinal test
Updating the test was overlooked when Node.ordinal was renamed to
Node.dep_ordinal.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-06 17:33:59 -08:00
Martí Bolívar 50df6f3734 scripts: runners: sort runner lists
This should help avoid merge conflicts in the future.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 17:31:53 -08:00
Martí Bolívar 07a40cbbcf scripts: runners: add misc-flash runner
Some boards require specific sequences of commands to run which aren't
generally useful for other boards. Add a catch-all runner to handle
these cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 17:31:53 -08:00
Stephanos Ioannidis 2d7460482d headers: Refactor kernel and arch headers.
This commit refactors kernel and arch headers to establish a boundary
between private and public interface headers.

The refactoring strategy used in this commit is detailed in the issue

This commit introduces the following major changes:

1. Establish a clear boundary between private and public headers by
  removing "kernel/include" and "arch/*/include" from the global
  include paths. Ideally, only kernel/ and arch/*/ source files should
  reference the headers in these directories. If these headers must be
  used by a component, these include paths shall be manually added to
  the CMakeLists.txt file of the component. This is intended to
  discourage applications from including private kernel and arch
  headers either knowingly and unknowingly.

  - kernel/include/ (PRIVATE)
    This directory contains the private headers that provide private
   kernel definitions which should not be visible outside the kernel
   and arch source code. All public kernel definitions must be added
   to an appropriate header located under include/.

  - arch/*/include/ (PRIVATE)
    This directory contains the private headers that provide private
   architecture-specific definitions which should not be visible
   outside the arch and kernel source code. All public architecture-
   specific definitions must be added to an appropriate header located
   under include/arch/*/.

  - include/ AND include/sys/ (PUBLIC)
    This directory contains the public headers that provide public
   kernel definitions which can be referenced by both kernel and
   application code.

  - include/arch/*/ (PUBLIC)
    This directory contains the public headers that provide public
   architecture-specific definitions which can be referenced by both
   kernel and application code.

2. Split arch_interface.h into "kernel-to-arch interface" and "public
  arch interface" divisions.

  - kernel/include/kernel_arch_interface.h
    * provides private "kernel-to-arch interface" definition.
    * includes arch/*/include/kernel_arch_func.h to ensure that the
     interface function implementations are always available.
    * includes sys/arch_interface.h so that public arch interface
     definitions are automatically included when including this file.

  - arch/*/include/kernel_arch_func.h
    * provides architecture-specific "kernel-to-arch interface"
     implementation.
    * only the functions that will be used in kernel and arch source
     files are defined here.

  - include/sys/arch_interface.h
    * provides "public arch interface" definition.
    * includes include/arch/arch_inlines.h to ensure that the
     architecture-specific public inline interface function
     implementations are always available.

  - include/arch/arch_inlines.h
    * includes architecture-specific arch_inlines.h in
     include/arch/*/arch_inline.h.

  - include/arch/*/arch_inline.h
    * provides architecture-specific "public arch interface" inline
     function implementation.
    * supersedes include/sys/arch_inline.h.

3. Refactor kernel and the existing architecture implementations.

  - Remove circular dependency of kernel and arch headers. The
   following general rules should be observed:

    * Never include any private headers from public headers
    * Never include kernel_internal.h in kernel_arch_data.h
    * Always include kernel_arch_data.h from kernel_arch_func.h
    * Never include kernel.h from kernel_struct.h either directly or
     indirectly. Only add the kernel structures that must be referenced
     from public arch headers in this file.

  - Relocate syscall_handler.h to include/ so it can be used in the
   public code. This is necessary because many user-mode public codes
   reference the functions defined in this header.

  - Relocate kernel_arch_thread.h to include/arch/*/thread.h. This is
   necessary to provide architecture-specific thread definition for
   'struct k_thread' in kernel.h.

  - Remove any private header dependencies from public headers using
   the following methods:

    * If dependency is not required, simply omit
    * If dependency is required,
      - Relocate a portion of the required dependencies from the
       private header to an appropriate public header OR
      - Relocate the required private header to make it public.

This commit supersedes #20047, addresses #19666, and fixes #3056.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-06 16:07:32 -08:00
Ulf Magnusson eef8d19a27 dts: edtlib: Add simple generic support for pinctrl-<index> properties
(pinctrl-<index> is documented in
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt in
Linux.)

Add a new Node.pin_states property, derived from any pinctrl-<index>
properties on the node. Node.pin_states holds a list of PinState
objects, where each PinState represents a single pinctrl-<index>
property.

For example, Node.pin_states will have two elements for the 'device'
node below:

	device {
		pinctrl-0 = <&state_0>;
		pinctrl-1 = <&state_1 &state_2>;
		pinctrl-names = "default", "sleep";
	};
	pincontroller {
		state_0: state_0 {
			...
		};
		state_1: state_1 {
			...
		};
		state_2: state_2 {
			...
		};
	};

Each PinState holds the list of configurations nodes in
PinState.conf_nodes. For the node above, node.pin_states[1].conf_nodes
will contain the pincontroller/state_1 and pincontroller/state_2 nodes,
for example.

The new functionality isn't used by gen_defines.py yet, so this change
is a no-op in itself, except it adds some error checking for
pinctrl-<index> properties.

If needed, support for #pinctrl-cells and 'pinmux' (not the same thing
as the 'pinmux' properties in Zephyr I think) could be added separately
later. Not sure what belongs in edtlib.py there yet.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-06 21:39:13 +01:00
Martí Bolívar 0df4a53107 scripts: runners: new openocd fixes and features
Let the user specify these arguments as many times as they want:

--cmd-pre-init
--cmd-pre-load
--cmd-post-verify

This makes it a bit easier to handle scripts that need to do a few
things in a row depending on conditions.

Handle --cmd-pre-init and the port arguments properly in the debug
related targets.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 21:15:39 +01:00
Martí Bolívar 23a5bcc7cc scripts: runners: make $BOARD_DIR/support/openocd.cfg optional
I'd like to support nRF boards in a more generic way, so make it
optional. We can clean up the STM32 files later if there's a lot of
overlap in their .cfg files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 21:15:39 +01:00
Martí Bolívar c82e8f8923 scripts: runners: whitespace cleanups for openocd.py
This line is meaningless and exists to pacify a commit linter.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 21:15:39 +01:00
Andrew Boie 9ff64bb497 userspace: don't split args on 64-bit systems
None of the splitting logic is needed if 64-bit return
values or parameters fit inside a register.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-11-06 09:04:16 -08:00
Andrew Boie 800b35f598 kernel: use uintptr_t for syscall arguments
We need to pass system call args using a register-width
data type and not hard-code this to u32_t.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-11-06 09:04:16 -08:00
Torsten Rasmussen bb672a5d7c cmake: ensure zephyr_module.py creates posix path output for cmake
This commit fixes an issue in windows where zephyr_modules.txt contains
a \ as path separator.
This causes issues later when using the path generated by
zephyr_module.txt are used as variables in CMake on windows.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2019-11-06 16:18:43 +01:00
Kumar Gala ae88e442d6 sanitycheck: fix filtering for boards without DTS
If we don't have a DTS (like nrf52_bsim) we shouldn't try and create an
EDT, but we still need to call expr_parser.parse to filter testcases.
So move the os.path.exists(dts_path) around the creation of the EDT.

Fixes: #20371

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-06 13:48:08 +01:00
Kumar Gala b66ee9df6e scripts: dts: Fix generation of -name properties.
If we have something like dma-names we should ended up generating
something like:

  DT_ST_STM32_I2S_40015000_RX_DMAS_CONTROLLER_1

This isn't quite what we expect.  We should instead get:

  DT_ST_STM32_I2S_40015000_RX_DMAS_CONTROLLER
  DT_ST_STM32_I2S_40015000_DMAS_CONTROLLER_1

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-06 10:34:37 +01:00
Anas Nashif 556f3cbaaa sanitycheck: deal with board that have no DTS
nrf52_bsim does not generate any DTS data to be processed by
sanitycheck, skip filtering if we have no dts data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-05 19:39:39 -05:00
Thomas Kupper ef0e3ed31d west: runner: add support for stm32flash runner
Add stm32flash runner and 8 stm32flash runner tests

Signed-off-by: Thomas Kupper <thomas.kupper@gmail.com>
2019-11-05 15:02:53 -05:00
Peter A. Bigot ea956f4ac3 scripts: dts: add dependency information to edtlib
Device tree nodes have a dependency on their parents, as well as other
nodes.  To ensure driver instances are initialized in the proper we
need to identify these dependencies and construct a total order on
nodes that ensures no node is initialized before something it depends
on.

Add a Graph class that calculates a partial order on nodes, taking
into account the potential for cycles in the dependency graph.

When generating devicetree value headers calculate the dependency
graph and document the order and dependencies in the derived files.
In the future these dependencies may be expressed in binding data.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-05 17:03:23 +01:00
Anas Nashif 4f04386e61 sanitycheck: exit thread executor on exceptions
When something goes wrong, exit thread execution pool and report and
error.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-05 10:06:00 -05:00
Anas Nashif 89c83044c8 sanitycheck: get environment regardless of option specified
environment is passed to execution thread and should be available
regardless of SAN being enabled or not.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-11-05 10:06:00 -05:00
Peter Bigot 1042b04152 scripts/requirements: update PyYAML to >=5.1
sanitycheck now requires yaml.FullLoader to support generating
hardware maps.  This feature was introduced in PyYAML 5.1.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-11-05 08:30:30 -05:00
Kumar Gala 07e5d89d86 kconfig: Add dt_chosen_enabled function
Add function that will return 'y' or 'n' if a node pointed to by a
chosen property exists and is enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-05 12:04:33 +01:00
Jan Van Winkel 21212f30b5 sanitycheck: native: Added option to enable ASAN & LSAN
Added option to sanitycheck script to enable address - and leak
sanitizer.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-04 17:38:39 +01:00
Kumar Gala 9b5720d76c sanitycheck: remove import of dt kconfig symbols
All users of dt kconfig symbols for tests and samples are using dt
functions instead so we can remove the support for parsing the
generated file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-04 09:02:14 -05:00
Kumar Gala 7733b94224 sanitycheck: Add functions to query device tree for filters
Add the following functions to allow filtering based on device tree

dt_compat_enabled(compat) - Returns true if a device tree node
compatible matches 'compat' and the node is enabled.

dt_alias_exists(alias) - Returns true if a device tree node exists with
'alias' and the node is enabled.

dt_compat_enabled_with_alias - Returns true if a device tree node
compatible matches 'compat' and the node has 'alias' and the node is
enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-04 09:02:14 -05:00
Ulf Magnusson 97c310e225 sanitycheck: Remove pointless shutdown() from BoundedExecutor
Just calls through to concurrent.futures.Executor.shutdown() in the base
class, which has the same signature. Removing it means the base class
version will get used directly.

Fixes this pylint warning:

    W0235: Useless super delegation in method 'shutdown'
    (useless-super-delegation)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 08:42:12 -05:00
Ulf Magnusson e73d286b89 sanitycheck: Make log_info_file() a regular function
Fixes this pylint warning:

    R0201: Method could be a function (no-self-use)

Could also make it a class method.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 08:42:12 -05:00
Ulf Magnusson 5c2e814212 sanitycheck: Suppress bogus not-subscriptable pylint warning
pylint gets confused by contextlib.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 08:42:12 -05:00
Daniel Leung fca4ead397 west: add flash runner for DediProg
This adds a flash runner for DediProg using the dpcmd command.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-11-03 12:30:45 +01:00
Andrew Boie 6f9280941f samples: add userspace producer/consumer sample
We try to demonstrate some concepts for user mode:

- Multiple logical applications, each with their own memory
  domain
- Creation of a sys_mem_pool and assignment to a memory
  partition
- Use of APIs like k_queue_alloc_append() which require
  thread resource pools to be configured
- Management of permissions for kernel objects and drivers
- Show how application-specific system calls are defined
- Show IPC between ISR and application (using k_msgq) and
  application-to-application IPC (using k_queue)

Fixes: #14683

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-10-31 14:46:08 +01:00
Ulf Magnusson f3f88a8e58 scripts: dts: Format multi-line comments nicely
Multi-line comments were stuck as-is between /* and */ in the generated
header, which looks ugly and confusing e.g. for multi-line
binding/property descriptions.

Use this format for multi-line comments in the header instead:

    /*
     * First line
     * Second line
     *
     * Line after blank line
     */

Also clean up the output a bit by turning some things that were separate
comments into a single multi-line comment. Add some air and reduce line
lengths too.

Before:

    /*  Generated by gen_defines.py  */
    /*  DTS input file: hifive1.dts.pre.tmp  */
    /*  Directories with bindings: $ZEPHYR_BASE/dts/bindings  */

    /*  Devicetree node: /cpus/cpu@0/interrupt-controller  */
    /*  Binding (compatible = riscv,cpu-intc): $ZEPHYR_BASE/... */
    /*  Binding description: This binding describes the RISC-V ...

    Some extra lines
    for testing  */
    #define DT_INST_0_RISCV_CPU_INTC                    1

After:

    /*
     * Generated by gen_defines.py
     *
     * DTS input file:
     *   hifive1.dts.pre.tmp
     *
     * Directories with bindings:
     *   $ZEPHYR_BASE/dts/bindings
     */

    /*
     * Devicetree node:
     *   /cpus/cpu@0/interrupt-controller
     *
     * Binding (compatible = riscv,cpu-intc):
     *   $ZEPHYR_BASE/dts/bindings/interrupt-controller/...
     *
     * Description:
     *   This binding describes the RISC-V CPU Interrupt Controller
     *
     *   Some extra lines
     *   for testing
     */
    #define DT_INST_0_RISCV_CPU_INTC                    1

Also tweak Node.description and Property.description in edtlib to be
strip()ed instead of rstrip()ed. There's probably no reason to
preserving leading whitespace in them either.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-30 08:15:31 +01:00
Ulf Magnusson b92ceb78dd scripts: edtlib/extract_dts_includes.py: Speed up 2x+ with yaml.CLoader
Use the LibYAML-based yaml.CLoader if available instead of yaml.Loader,
which is written in Python and slow. See
https://pyyaml.org/wiki/PyYAMLDocumentation.

This speeds up gen_defines.py from 0.2s to 0.07s on my system, for
-DBOARD=hifive1. It should also make scripts/kconfig/kconfig.py faster,
because it indirectly uses edtlib via
scripts/kconfig/kconfigfunctions.py.

yaml.CLoader seems to be available out of the box when installing with
pip on Ubuntu at least.

Helps with https://github.com/zephyrproject-rtos/zephyr/issues/20104.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-30 07:52:27 +01:00
Peter A. Bigot c1c82b7570 scripts: dts: generate array values as initializer lists
Simplify use of property values that have multiple elements by
providing all of them in an initializer list, in addition to each one
as an enumerated value.

For example if a driver requires a sequence of operations with
instance-specific delays between stages the durations can be specified
with:

    delays = <30000 20 45000>;

and the driver can use:

    static u32_t delays[] = DT_INST_0_COMPAT_DELAYS;

rather than enumerating the instances.  This is particularly useful
when the number of entries in the array varies per instance, in which
case such an initialization is not easily expressed in code.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-10-29 00:55:01 +01:00
Anas Nashif c1ea45280b sanitycheck: enable valgrind checking using an option
Enable valgrind using --enable-valgrind option and fix reporting.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-24 12:24:48 -04:00
Kumar Gala 22e7449b73 kconfig: Introduce typed dt kconfig functions
Replace:
  dt_chosen_reg_addr
  dt_chosen_reg_size
  dt_node_reg_addr
  dt_node_reg_size

with:
  dt_chosen_reg_addr_int
  dt_chosen_reg_size_int
  dt_chosen_reg_addr_hex
  dt_chosen_reg_size_hex
  dt_node_reg_addr_int
  dt_node_reg_size_int
  dt_node_reg_addr_hex
  dt_node_reg_size_hex

So that we get the proper formatted string for the type of symbol.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-10-24 08:51:06 -05:00
Flavio Ceolin ca1feea5bb sanitycheck: Fix --log-file option
save_reports should be one of the last tasks executed because it
closes the log file. Withouth it, other functions that use debug
functions like info and error will try to write into a close file.

This fixes the following problem:

sanitycheck -x=USE_CCACHE=0 -p native_posix -T samples/hello_world/ -b
-N --log-file sanity.log
JOBS: 8
Building initial testcase list...
1 test configurations selected, 0 configurations discarded due to filters.
Adding tasks to the queue...
total complete:    1/   1  100%  skipped:    0, failed:    0
1 of 1 tests passed (100.00%), 0 failed, 0 skipped with 0 warnings in
2.91 seconds
Traceback (most recent call last):
  File "./zephyr/scripts/sanitycheck", line 3866, in <module>
    main()
  File "./zephyr/scripts/sanitycheck", line 3854, in main
    suite.summary(options.disable_unrecognized_section_test)
  File "./zephyr/scripts/sanitycheck", line 2306, in summary
    self.duration))
  File "./zephyr/scripts/sanitycheck", line 432, in info
    log_file.write(what + "\n")
ValueError: I/O operation on closed file.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-10-23 16:05:39 -04:00
Thomas Stilwell 5310510d07 sanitycheck: fix --board-root parser to enable multiple path args
accidently removed during sanitycheck refactor

Signed-off-by: Thomas Stilwell <Thomas.Stilwell@nordicsemi.no>
2019-10-23 16:00:53 -04:00
Anas Nashif a5984ab1c6 sanitycheck: fail on warnings
Missed adding extra cflags to fail on warning. Adding those back.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-23 10:47:22 -04:00
Martí Bolívar 34ca048d4b scripts: use compatible release specifiers in requirements.txt
Using exact versions for our PyPI dependencies (i.e. requirements.txt
lines that look like "dependency==X.Y.Z") is rude since we're asking
users to install these dependencies outside of any virtual
environment. This causes conflicts with other packages which may
depend on the same things as us.

Use inclusive ordered comparison (>=) release specifiers instead:

https://www.python.org/dev/peps/pep-0440/#inclusive-ordered-comparison

If this causes problems for individual packages, we can refine them
using compatible release specifiers (~=):

https://www.python.org/dev/peps/pep-0440/#compatible-release

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-10-23 14:43:06 +02:00
Anas Nashif e645d9ffd5 scripts: add script for listing closed bugs
Script to be used when creating a release. For regular releases this can
be called this way:

$ list_issues.py -f issues.md -s 2019-09-01

Will list all closed issues since september 1st, 2019 and will create a
markdown file with all issues that can be added as is to the release
notes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-22 15:11:09 -04:00
Alberto Escolar Piedras 2092645736 lvgl: Suppress memory leak errors detected by valgrind
The lvgl library is configured in some tests to use
the libC malloc to allocate heap. In native_posix this
ends up in the underlying OS heap, which cannot be safely
freed in general when the program finnishes, and
ends up being reported by valgrind as leaked on exit. See
https://github.com/zephyrproject-rtos/zephyr/pull/18471
for a longer discussion.

Instead of trying to fix the leak, let's just accept it
but suppress the errors so it does not confuse other
developers

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-10-21 12:26:35 -07:00
Anas Nashif f72d1904f5 sanitycheck: fix error handling with host binaries
Failed unit tests were setting wrong fail string (error instead of
failed) which made unit tests always pass.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-21 09:50:48 -04:00
Flavio Ceolin 063ab90dd8 sanitycheck: Making child thread exits when main thread dies
Set threads spawned by BinaryHandler dameon, so when the main thread
exits for some unusual reason (e.g SIGINT) the child threads are
automatically killed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-10-18 08:09:09 -05:00
Paul Sokolovsky 3ea18692c6 sanitycheck: Use os.makedirs to create --report-dir.
os.mkdir() is not suitable to create arbitrary directory path (can
create only a subdir of an existing dir, will error out if already
exists), os.makedirs() should be always used in such cases.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-10-15 11:07:12 -07:00
Ulf Magnusson e311380584 scripts: edtlib: Forbid multiple bindings with the same compatible
Previously, if two bindings had the same 'compatible:'/'parent-bus:'
values, the binding that happened to be loaded last would get used.

Turn it into an error instead. This avoids tricking people into thinking
that bindings get loaded in a defined order.

Maybe overriding bindings could be allowed later, if we need it.

Fixes: #19536

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-15 10:34:44 +02:00
Ulf Magnusson 72bfa83670 scripts: edtlib: Turn Node.description into a @property
Simplifies the code a bit.

Looks like the description wasn't rstrip()ed when it came from a
'child-binding:' either. This also indirectly fixes that.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-15 10:34:44 +02:00
Anas Nashif 33e6384e48 ci: cleanup test manifests
Make sure we cleanup the manifest files at the right spot of the CI
process. When not building a PR, behavior is different.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-11 20:05:03 +02:00
Anas Nashif 2f0be4334b ci: adapt ci script for new sanitycheck
We now run sanitycheck with different options, so adapt script.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-11 07:28:19 -07:00
Anas Nashif 83fc06a8fe sanitycheck: Complete overhaul and job handling rework
A complete overhaul of the sanitycheck script and how we build and run
tests. This new version of sanitycheck uses python for job distribution
and drop use of Make.

In addition to the move to python threading library, the following has
been changed:

- All handlers now run in parallel, meaning that any simulator will run
in parallel and when testing on multiple devices (using
--device-testing) the tests are run in parallel.

- Lexicial filtering (using the filter keyword in yaml files) is now
evaluated at runtime and is no long being pre-processed. This will allow
us to immediately start executing tests and skip the wait time that was
needed for filtering.

- Device testing now supports multiple devices connected at the same
time and is managed using a hardware map that needs to be generated and
maintained for every test environment. (using --generate-hardware-map
option).

- Reports are not long stored in the Zephyr tree and instead stored in
the output directory where all build artifacts are generated.

- Each tested target now has a junit report in the output directory.

- Recording option for performance data and other metrics is now
available. This will allow us to record the output from the console and
store the data for later processing. For example benchmark data can be
captured and uploaded to a tracking server.

- Test configurations (or instances) are no longer being sorted, this
will help with balancing the load when we run sanitycheck on multiple
hosts (as we do in CI).

And many other cleanups and improvements...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-11 07:28:19 -07:00
Anas Nashif ba696c0354 scripts: remove unused waitpid script
Was used previously by sanitycheck, not being used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-11 07:28:19 -07:00
Anas Nashif fe1e888821 scripts: remove obsolete conversion script ini2yaml.py
script is old and unused.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-11 07:28:19 -07:00
Peter Bigot 03c22b8c94 scripts/coccinelle: add k_thread create/define to timeout standardization
k_thread_create and K_THREAD_DEFINE both take a delay as the final
parameter.  Most uses of K_THREAD_DEFINE pass either `K_NO_WAIT` or
`K_FOREVER`.  Ensure that all uses of K_THREAD_DEFINE follow that
practice, and that the runtime k_thread_create calls do so as well.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Peter Bigot f0c0b3b5dc scripts/coccinelle: add sleep to int literal to timeout standardization
k_sleep uses the same underlying thread infrastructure as the other
functions that take timeouts, so the delay should be specified as a
timeout rather than milliseconds.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Peter Bigot 567d3c4a3e scripts/coccinelle: more cleanup of int literal to timeout
Sort the functions within the regular expression so they can be
checked more easily.

Remove k_thread_deadline_set as it takes an argument in cycles.  (The
one in-tree call to this function was not affected by this error.)

Add missed k_mbox_data_block_get.

Fix an overly ambitious multi-match disjunct that covered some
non-existent functions.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Peter Bigot 3a0a582119 scripts/coccinelle: updates and improvements for integer timeout values
Add support for the report and patch modes so this can be invoked by
coccicheck.

Use PCRE options to make the kernel timeout API identifier rule more
readable.  Extend the pattern to new API.

Use rule extends and depends clauses, and pattern disjunction, to
avoid replicating metavariable content.

Hint that using --include-headers may be helpful (some patterns can be
found in static inline functions).

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-04 16:23:57 -04:00
Rihards Skuja 6b9f0df7da runners: pyocd: add --telnet-port parameter
With multiple debug probes attached, attempting to launch multiple debug
servers resulted in "OSError: [Errno 98] Address already in use" despite
explicitly setting --gdb-port to unique values.

The issue was caused by the default telnet port: 4444. Adding
--telnet-port parameter allows to explicitly define the address to a
unique value and avoid the socket exception.

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2019-10-03 19:19:39 -05:00
Ulf Magnusson 0c4f4a91b0 scripts: edtlib: Fix broken 'required: true' check for booleans
Node._prop_val() returned too early for non-existent booleans, letting
missing 'required: true' booleans slip through without an error.

Fix it by rearranging the code to always do the 'required' check before
returning.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-03 16:29:11 -07:00
Ulf Magnusson 178f16f9e9 scripts: dts: Output paths relative to $ZEPHYR_BASE
Requested by Marc Herbert. Makes the output deterministic as long as all
binding directories are within $ZEPHYR_BASE (and a bit less spammy too).

Example output for header:

Before:

    /*  Directories with bindings: /home/ulf/z/z/dts/bindings  */
    ...
    /*  Binding (...): /home/ulf/.../arm,v7m-nvic.yaml  */

After:

    /*  Directories with bindings: $ZEPHYR_BASE/dts/bindings  */
    ...
    /*  Binding (...): $ZEPHYR_BASE/dts/.../arm,v7m-nvic.yaml  */

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-03 11:59:33 -07:00
Peter Bigot 0e5329331b scripts/coccinelle: add conversion of integers to timeout values
Some legacy code still passes integer literals in milliseconds as the
value to functions that take a timeout.  This usage interferes with
plans to replace the millisecond representation with a more generic
k_timeout_t value.  Add a Coccinelle script to convert call sites to
use the proper constants and macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-03 11:55:44 -07:00
Ulf Magnusson bc22b3a020 scripts: testedtlib.py: Simplify warning test a tiny bit
verify_eq() can be used instead of verify_streq(), since
warnings.getvalue() already returns a string.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-03 05:57:26 -07:00
Anas Nashif b61f86d2c0 west: openocd: support pre init command option
With ST boards it is possible to specify the board ID when flashing using
openocd. This is very useful when having multiple devices connected.

This change allows us to address a device directly:

west flash -- --cmd-pre-init  "hla_serial 066BFF535254887767174558"

This needs to be called before init, hence the new option.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-02 21:44:16 -04:00
Ulf Magnusson 7c26c17be6 scripts: edtlib: Add easy redirection of warnings
Add a 'warn_file' parameter to EDT.__init__() that gives a 'file' object
to write warnings to. Use it to capture and verify warnings generated
for deprecated features in testedtlib.py. This indirectly gets rid of
possibly broken-looking output when running it.

Because any function that writes warnings now needs to use EDT._warn()
(as self._warn()), some functions were moved into the EDT class.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-02 11:49:58 -07:00
Ulf Magnusson 567c348167 scripts: dts: Generalize '#cells' to allow multiple sources
Implement a nice generalization suggested by Bobby Noelte.

Instead of having a generic #cells key in bindings, have source-specific
*-cells keys. Some examples:

    interrupt-cells:
        - irq
        - priority
        - flags

    gpio-cells:
        - pin
        - flags

    pwm-cells:
        - channel
        - period

This makes bindings a bit easier to read, and allows a node to be a
controller for many different 'phandle-array' properties.

The prefix before *-cells is derived from the property name, meaning
there's no fixed set of *-cells keys. This is possible because of the
earlier 'phandle-array' generalization.

The older #cells key is supported for backwards compatibility, but
generates a deprecation warning.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-02 11:49:58 -07:00
Sebastian Bøe ba287d2b27 cmake: Fix bug where DTS_BINDINGS_DIRS could only have one entry
Fix a bug where DTS_BINDINGS_DIRS could only have one entry. When
there were more than one entry the command for invoking menuconfig
became corrupted.

This changes the separator of DTS_BINDINGS_DIR from a space to ? so
that the shell does not interpret the space as an argument separator.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-10-01 10:35:23 -07:00
Stephanos Ioannidis 2a1c6258fa scripts: gen_syscalls: Add compiler check to pragma.
This commit addresses the following portability issues:
1. gen_syscalls incorrectly assumes that the compiler is always GCC.
2. pragma GCC diagnostic push and pop are not supported in GCC < 4.6.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-09-27 23:10:04 -04:00
Ulf Magnusson a7c43079b6 kconfiglib: Fix preprocessor issue for nested parentheses
Prompted by an upstream bug report. Nothing in Zephyr triggers this at
the moment, but might as well fix it.

Update Kconfiglib to upstream revision 7d05084b7e, to get this commit
in:

    Fix handling of parentheses in macro argument values

    As an oversight, there was no check for nested parentheses in macro
    arguments, making the preprocessor think the call ended after
    'void)' in

        def_bool $(success,echo 'void foo(void) { asm inline (""); }' \
                   | $(CC) -x c - -c -o /dev/null)

    This broke the latest linux-next kernels (with a Kconfig error),
    starting with commit eb111869301e1 ("compiler-types.h: add
    asm_inline definition").

    I remember seeing this when going through the C code, but somehow
    forgot to put it in. Fix it, and clean up _expand_macro() a bit at
    the same time.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-27 11:05:56 +02:00
Ulf Magnusson b97ed9e4b4 scripts: dts: Generalize handling of phandle-array types
Generating generic information for 'type: phandle-array' properties in
edtlib was difficult due to defining phandle-array as just a list of
phandles and numbers. To make sense of a phandle-array property like
'pwms', you have to know that #pwm-cells is expected to appear on
each referenced controller, and that the binding for the controller has
a #cells.

Because of this, handling of various 'type: phandle-array' properties
was previously hardcoded in edtlib and exposed through properties like
Node.pwms, instead of through the generic Node.props (though with a lot
of shared code).

In practice, it turns out that all 'type: phandle-array' properties in
Zephyr work exactly the same way: They all have names that end in -s,
the 's' is removed to derive the name of related properties, and they
all look up #cells in the binding for the controller, which gives names
to the data values.

Strengthen the definition of 'type: phandle-array' to mean a property
that works exactly like the existing phandle-array properties (which
also means requiring that the name ends in -s). This removes a ton of
hardcoding from edtlib and allows new 'type: phandle-array' properties
to be added without making any code changes.

If we ever need a property type that's a list of phandles and numbers
but that doesn't follow this scheme, then we could add a separate type
for it. We should check if the standard scheme is fine first though.

The only property type for which no information is generated is now
'compound'.

There's some inconsistency in how we generate identifiers for clocks
compared to other 'type: phandle-array' properties, so keep
special-casing them for now in gen_defines.py (see the comment in
write_clocks()).

This change also enabled a bunch of other simplifications, like reusing
the ControllerAndData class for interrupts.

Piggyback generalization of *-map properties so that they work for any
phandle-array properties. It's now possible to have things like
'io-channel-map', if you need to.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-26 15:30:23 -07:00
Ulf Magnusson 6b8750490d scripts: edtlib: Rename Interrupt/GPIO/etc. 'specifier' field to 'data'
'Specifier' is devicetree specalese for data associated with interrupts,
GPIOs, etc., e.g. <1 2> and <3 4> in

    pwms = <&ctrl-1 1 2 &ctrl-2 3 4>;

It's probably unnecessarily confusing to call it that. Call it 'data'
instead, which is a bit more straightforward.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-26 05:23:28 -07:00
Ulf Magnusson 73ac1466fb scripts: edtlib: Call nodes "nodes" instead of "devices"
edtlib.Device is just a devicetree node augmented with binding
information and some interpretation of properties. Rename it to
edtlib.Node to make that clearer. That also avoids calling things like
flash partition nodes "devices", which is a bit confusing.

I called it edtlib.Device instead of edtlib.Node originally to avoid
confusion with dtlib.Node, but in retrospect it probably makes it more
confusing on the whole. Something like edtlib.ENode might work too, but
it's probably overkill. Clients of edtlib.py only interact with
edtlib.Node, so the only potential for confusion is within edtlib.py
itself, and it doesn't get too bad there either.

Piggyback some documentation nits, and consistently write it
"devicetree" instead of "device tree", to match the spec.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-26 05:23:28 -07:00
Daniel Leung be8cb89ebd west: esp32: use Python interpreter to execute ESP tool
The ESP tool is being executed directly in the esp32 runner,
assuming the tool is executable by itself. However, it would
fail under Windows as subprocess.check_call() cannot execute
Python scripts directly. The fix is to execute the Python
interpreter and passing the script path as a command line
parameter.

Fixes #19098

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-09-25 17:33:28 +02:00
Ulf Magnusson 4c6ea2d160 scripts: edtlib: Skip fully loading bindings in more cases
As a slightly hairy but important optimization inherited from the old
scripts, the binding loading code only looks at binding files whose raw
text contains one of the compatible strings from the devicetree. For
such files, a second pass parses the file as YAML and tries to extract a
compatible string, and skips the file if it fails (e.g. due to spurious
text matches in 'include'd binding fragments).

Until now, the binding would always get fully loaded (have 'include'd
files merged in, checks run, etc.) if the second pass managed to extract
a compatible.

Do slightly better by only fully loading the binding if the extracted
compatible from the second pass appears in the devicetree. This gets rid
of unnecessary binding loading in rare cases.

Discovered by test-bindings/deprecated.yaml getting loaded even when
everything that referenced it in test.dts was commented out, because it
happened to mention 'child-binding' in a comment.

Also add a check for YAML errors in the second pass, to be slightly more
robust. Print a warning if a file that isn't valid YAML is found.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-22 09:17:53 -05:00
Ulf Magnusson 110526ec0e scripts: edtlib: Add a Device.children attribute with child Devices
API oversight. This was meant to be there all along together with
Device.parent, for navigating the devicetree, but since a need for it
never came up in gen_defines.py, it got overlooked.

Devices are just devicetree nodes augmented with binding information and
some interpretation of devicetree properties. I wonder if the name
should be changed to something like edtlib.Node to make that clearer.
Calling something like a flash partition a "device" is a bit weird, as
Galak pointed out.

I think I went with Device originally to avoid confusion with
dtlib.Node, but since edtlib users don't directly interact with dtlib,
it might not be that confusing in practice.

Piggyback some documentation clarifications.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-21 09:10:36 -05:00
Ulf Magnusson 2f2642d5f6 scripts: testedtlib.py: Generate SystemExit on test failures
The devicetree check in check_compliance.py in ci-tools expects the
dtlib/edtlib test suites to exit with sys.exit() (which raises
SystemExit) on test failures, and interprets Exception as an internal
error in the test suite.

testedtlib.py accidentally raised Exception on test failures, making
check_compliance.py error out and skipping the rest of the tests when
there were failures. Fix it.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-21 09:08:56 -05:00
Jorgen Kvalvaag d50fb31e19 scripts: sanitycheck: Multiple --west-flash arguments
Make --west-flash support multiple arguments

Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
2019-09-19 22:19:49 -04:00
Wentong Wu 09af98aba9 scripts: gen_relocate_app.py: add custom align size for relocation
add custom align size for code relocation to reduce alignment memory
wasting.

Fixes: #17337.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-09-19 21:38:31 -04:00
Marc Herbert f987029282 gen_syscalls.py: make 'noweak' a list instead of a random order set
Python's Sets are not deterministic. This causes the following lines to
be emitted in random order in generated/syscall_dispatch.c

extern u32_t z_mrsh_k_object_release(u32_t arg1, ...
extern u32_t z_mrsh_k_object_access_grant(u32_t arg1, ...
extern u32_t z_mrsh_k_object_alloc(u32_t arg1, ...

Change noweak to a basic list.

Reproducibility regression introduced by commit 6564974bae

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-09-19 20:59:06 -04:00
Ulf Magnusson 0b1ab4ab09 scripts: dts: Replace 'sub-node:' with more general 'child-binding:'
Deprecate 'sub-node:' and add a more general 'child-binding:' mechanism
to bindings. Keep supporting 'sub-node:', but print a deprecation
warning when it's used.

Like 'sub-node:', 'child-binding:' gives a binding to child nodes, but
the binding is required to be a complete binding, and is treated (and
checked) like a normal binding.

'child-binding:' can in turn contain another 'child-binding:', up to any
number of levels. This is automatic from treating it like a normal
binding, and from the code initializing parent Devices before child
Devices.

This lets nodes give bindings to grandchildren.

For example, take this devicetree fragment:

    parent {
            compatible = "foo";
            child-1 {
                    grandchild-1 {
                            ...
                    };
                    grandchild-2 {
                            ...
                    };
            };
            child-2 {
                    grandchild-3 {
                            ...
                    };
            };
    };

The binding for 'foo' could provide bindings for grandchild-1/2/3 like
this:

    compatible: "foo"

    # Binding for children
    child-binding:
        title: ...
        description: ...

        ...

        # Binding for grandchildren
        child-binding:
            title: ...
            description: ...

            properties:
                ...

Due to implementation issues with the old devicetree scripts, only two
levels of 'child-binding:' is supported for now. This limitation will go
away in Zephyr 2.2.

Piggyback shortening 'description:' and 'title:' in some bindings that
provide child bindings. This makes the generated header a bit neater.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-19 08:39:22 -05:00
Håkon Øye Amundsen 4e13501a37 scripts: pep8 gen_relocate_app.py
Add styling to make it more pep8 compliant.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-09-19 00:34:38 -04:00
Paul Sokolovsky 8c6d2e23f6 sanitycheck: Merge common vs per-test "filter" field values semantically
Currently, string values comming from "common" test definition section
and from test-specific section are just concatenated. Suppose, we want
to define some common filter condition, and also per-test additional
criteria. Currently, that leads to following syntax:

common:
  filter: TOOLCHAIN_FOO == 1
tests:
  sample.net.sockets.http_get.posix:
    filter: and not CONFIG_BAR

That's arguable quite adhoc, and the only way to figure it out for
most people will be to add debug logging.

This patch proposes to use the expected syntax (i.e.
"filter: not CONFIG_BAR"), and combine conditions properly based on
their semantic meaning (which also includes parans for proper
evaluation order).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-09-19 00:29:41 -04:00
Kumar Gala 127a245fb0 ci: run_ci: Refactor west setup into a function
Move west setup into its own function.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:13:37 -05:00
Kumar Gala 87c81b7547 ci: run_ci: merge two if blocks
The same if check is done twice back to back, we can merge into a single
if block.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:13:37 -05:00
Kumar Gala 020f87eae8 ci: run_ci: Move functions
Move functions up to make the code a bit more readable.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:13:37 -05:00
Kumar Gala e717d45ac1 ci: run_ci: handle if the git dir isn't named zephyr
For cases like zephyr-test or for other reasons the repo dir might not
be called zephyr.  Just use the basename of the dir instead of assuming
its called zephyr.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:13:37 -05:00
Kumar Gala 3209cad030 ci: run_ci: Remove stale DOC_MATRIX variable
The script doesn't use DOC_MATRIX so remove this stale variable.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:13:37 -05:00
Ulf Magnusson 1ebe945643 scripts: dts: Change 'child/parent: bus: ...' to 'child/parent-bus:'
Instead of

    child:
        bus: foo

    parent:
        bus: bar

, have

    child-bus: foo

    parent-bus: bar

'bus' is the only key that ever appears under 'child' and 'parent'.

Support the old keys for backwards compatibility, with a deprecation
warning if they're used.

Also add 'child/parent-bus' tests to the edtlib test suite. It was
untested before.

I also considered putting more stuff under 'child' and 'parent', but
there's not much point when there's just a few keys I think. Top-level
stuff is cleaner and easier to read.

I'm planning to add a 'child-binding' key a bit later (like 'sub-node',
but more flexible), and child-* is consistent with that.

Also add an unrelated test-bindings/grandchild-3.yaml that was
accidentally left out earlier.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-17 14:37:43 -05:00
Peter A. Bigot 5611beeec1 scripts: elf_helper.py: fix C++ template constexpr value processing
Some DWARF symbols for members of template classes members such as
numeric_limits<unsigned int> reference are static constexpr values
that do not have a data member location.  Avoid attempting to
dereference the value for that attribute when it isn't present.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-09-17 20:49:34 +08:00
Jan Van Winkel e483b11a90 sanitycheck: native: Removed --coverage from EXTRA_LDFLAGS
Removed redundant linker flag --coverage from native posix
EXTRA_LDFLAGS.

The correct linker flags will be set by defining the Kconfig flag
CONFIG_COVERAGE, either by sanitcheck it self or via the test/sample
prj.conf.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-09-17 11:25:29 +02:00
Alberto Escolar Piedras af30f2b7d4 sanitycheck: Use system gcov for unit testing by default
As a nicety for users, also select by default the system
gcov for unit_testing

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-09-17 11:17:56 +02:00
Peter A. Bigot 372a4fe5be kconfig: support multiple DTS bindings directories
Some confluence of recent changes resulted in builds with
application-specific bindings being unable to find bindings present in
the system directory.  Add quotes and splits as necessary to propagate
multiple directories through the system.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-09-16 05:29:27 -05:00
Kumar Gala 29e55d74e8 rtc: Remove old rtc functionality
Remove the old rtc functionality as its been deprecated for 2 releases
now.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-14 07:33:38 -05:00
Ulf Magnusson a0136b9850 gen_syscalls.py: Remove semicolons, unused variables, and a '!= None'
Fix new pylint warnings:

    scripts/gen_syscalls.py:195:0: W0301: Unnecessary semicolon
    (unnecessary-semicolon)

    scripts/gen_syscalls.py:249:0: W0301: Unnecessary semicolon
    (unnecessary-semicolon)

    scripts/gen_syscalls.py:251:0: W0301: Unnecessary semicolon
    (unnecessary-semicolon)

    scripts/gen_syscalls.py:253:0: W0301: Unnecessary semicolon
    (unnecessary-semicolon)

    scripts/gen_syscalls.py:264:0: W0301: Unnecessary semicolon
    (unnecessary-semicolon)

    scripts/gen_syscalls.py:265:0: W0301: Unnecessary semicolon
    (unnecessary-semicolon)

    scripts/gen_syscalls.py:152:8: W0612: Unused variable 'i'
    (unused-variable)

    scripts/gen_syscalls.py:231:18: W0612: Unused variable 'argname'
    (unused-variable)

    scripts/gen_syscalls.py:344:7: C0121: Comparison to None should be
    'expr is not None' (singleton-comparison)

None is a global object, so 'is' (which is like a pointer comparison) is
cleaner, and more idiomatic Python.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-14 13:36:41 +08:00
Ulf Magnusson d8accb55d1 scripts: footprint: Fix pylint warnings
- Remove unused variables and an unused 'sys' import

 - Simplify 'if len(foo) != 0' to 'if foo'. Non-empty lists/dicts/etc.
   are truthy in Python.

 - Use a raw string to fix this warning:

       scripts/footprint/size_report:270:0: W1401: Anomalous backslash
       in string: '\.'. String constant might be missing an r prefix.
       (anomalous-backslash-in-string)

   The issue is that '\.' just happens to work due to not being
   recognized as an escape sequence.

   Escape sequences are not interpreted in raw strings, so they're safer
   for regexes.

 - Replace 'is 0' with '== 0'. 'is' is for testing object identity, and
   0 isn't guaranteed to be a unique object (but always is in practice).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-14 13:35:08 +08:00
Kumar Gala 1baf2f3e6f kconfig: Mark dt_{int,hex,str}_val as deprecated
As we work on removing the .conf file that is generated by the dt
scripts, mark dt_{int,hex,str}_val functions as deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-13 11:42:34 -05:00
Kumar Gala 8ce0cf0126 kconfig: Convert device tree chosen properties to new kconfigfunctions
Convert how we get the various chosen properties like "zephyr,console"
to use the new kconfig functions like dt_chosen_to_label.

Because of how kconfig parses things we define a set of variables of the
form DT_CHOSEN_Z_<PROP> since comma's are parsed as field seperators in
macros.

This conversion allows us to remove code in gen_defines.py for the
following chosen properties:

zephyr,console
zephyr,shell-uart
zephyr,bt-uart
zephyr,uart-pipe
zephyr,bt-mon-uart
zephyr,uart-mcumgr
zephyr,bt-c2h-uart

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-13 11:42:34 -05:00
Kumar Gala 5735397b9b kconfig: Add new functions to kconfigfunctions to use EDT
Add a new set of functions that utilize EDT so we can move away from the
generated .conf file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-13 11:42:34 -05:00
Peter A. Bigot be2a885d42 scripts/dts/gen_defines.py: exclude initializer lists from conf file
Things that parse generated_dts_board.conf can't deal with entries
like:

    DT_GPIO_KEYS_BUTTON_1_GPIOS={"GPIO_0", 14, 256}

so keep them from being added there.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-09-12 15:51:08 -05:00
Peter A. Bigot f62ae3e8ef scripts/dts/gen_defines.py: generate initializers for phandle/val lists
When a phandle-array (compound) has multiple members generate a define
that says how many there are; generate an initializer for each
individual member; and generate an initializer for the sequence of
members.

This allows drivers that expect multiple values in a compound to process
them without horrendous conditional compilation code attempting to
detect the number of elements in the compound.

It also eliminates the need to repeat the long prefix when initializing
a structure with the fields of a single compound.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-09-12 13:31:48 -05:00
Peter A. Bigot 392845b13f scripts/dts/gen_defines.py: return macro identifier in out functions
The lowest level output function is the one that determines the full
name of the macro, including DT_ prefix.  Return the name of the macro
that provides the value for an identifier so that it can be used in
higher layers of the generator.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-09-12 13:31:48 -05:00
Peter A. Bigot e9a173120f scripts/dts/gen_defines.py: generalize string escape
Add str2str to make the conversion of a string into a C literal with all
necessary escapes and enclosing double quotes available outside a
function that emits a define.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-09-12 13:31:48 -05:00
Andy Ross 6564974bae userspace: Support for split 64 bit arguments
System call arguments, at the arch layer, are single words.  So
passing wider values requires splitting them into two registers at
call time.  This gets even more complicated for values (e.g
k_timeout_t) that may have different sizes depending on configuration.
This patch adds a feature to gen_syscalls.py to detect functions with
wide arguments and automatically generates code to split/unsplit them.

Unfortunately the current scheme of Z_SYSCALL_DECLARE_* macros won't
work with functions like this, because for N arguments (our current
maximum N is 10) there are 2^N possible configurations of argument
widths.  So this generates the complete functions for each handler and
wrapper, effectively doing in python what was originally done in the
preprocessor.

Another complexity is that traditional the z_hdlr_*() function for a
system call has taken the raw list of word arguments, which does not
work when some of those arguments must be 64 bit types.  So instead of
using a single Z_SYSCALL_HANDLER macro, this splits the job of
z_hdlr_*() into two steps: An automatically-generated unmarshalling
function, z_mrsh_*(), which then calls a user-supplied verification
function z_vrfy_*().  The verification function is typesafe, and is a
simple C function with exactly the same argument and return signature
as the syscall impl function.  It is also not responsible for
validating the pointers to the extra parameter array or a wide return
value, that code gets automatically generated.

This commit includes new vrfy/msrh handling for all syscalls invoked
during CI runs.  Future commits will port the less testable code.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-09-12 11:31:50 +08:00
Ulf Magnusson 2845d8f404 scripts: edtlib: Make order irrelevant when including multiple files
When foo.yaml set some property 'required: true' and bar.yaml set the
same property 'required: false', the check for changing
'required: false' to 'required: true' would raise an error for

    include: [bar.yaml, foo.yaml]

(with that particular order due to implementation details).

The order files are included in shouldn't matter. To fix it, change the
logic so that 'required' values are ORed together between included files
(so that 'required: true' is always respected), and remove the
'required' true-to-false check when merging included files.

Keep the true-to-false check when merging the (merged) included files
into the main binding (the binding with the 'include:' in it). This
might give a good organization, and the old scripts do it too.

Piggyback two fixes/cleanups:

 - 'compatible' should be allowed to appear in included files

 - No need to allow an 'inherits' key in _check_binding(), because
   it has been removed before then, when merging bindings

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-11 07:50:30 -05:00
Ulf Magnusson a5f4ad8df3 scripts: dts: Fix wrong filename in 'include:' code in old scripts
The 'fname' parameter to merge_included_bindings(), giving the path to
the top-level binding file, was accidentally shadowed in the
'for fname in fnames:' loop. This could lead to the wrong filename being
used in error messages.

Discovered via this pylint warning:

    scripts/dts/extract_dts_includes.py:225:12: R1704: Redefining
    argument with the local name 'fname' (redefined-argument-from-local)

Improve naming a bit to fix it.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-10 11:34:03 -05:00
Ulf Magnusson 6fd7c69999 scripts: elf_helper.py: Simplify tests with chained comparisons
'a < b and b < c' can be simplified to 'a < b < c' in Python.

Fixes this pylint warning:

    R1716: Simplify chained comparison between the operands
    (chained-comparison)

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-10 16:22:48 +02:00
Ulf Magnusson 9460708d3d scripts: elf_helper.py: Make functions that don't use 'self' static
Fixes this pylint warning:

    R0201: Method could be a function (no-self-use)

Another option would be to turn them into regular functions, but that'd
be a bigger change.

Piggyback a small ElfHelper.error() improvement: Passing a string to
sys.exit() prints it to stderr and exits with status 1.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-10 15:49:55 +02:00
Ulf Magnusson b918e25921 dts: scripts: Require properties to be declared in bindings
Except for a few special properties like 'interrupts' and '#size-cells',
require all devicetree properties on nodes with bindings to be declared
in the binding.

This will help catch misspellings, and makes refactoring and cleanups
safer.

Suggested by Peter A. Bigot.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-10 07:42:02 -05:00
Kumar Gala c16537fbde scripts/dts: Generate IRQ values for multi-level IRQs
When we have multi-level (ie chained interrupt controllers) Zephyr has a
schemee to encode the multi-level and IRQ values along the level's into
a single 32-bit value.  This is the "IRQ" value expected by Zephyr APIs.

The encoding scheme is documented here:

doc/reference/kernel/other/interrupts.rst

Update the device tree generation to walk the interrupt levels and
generate the expected encoded value for the IRQ.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-10 07:34:57 -05:00
Olle Norelius 5a53e21966 scripts: dts: Fix generation of single-value phandle/value array
Put a type check in the offending method.
Now any scalar will be put in a list for
compatibility with following code.

Signed-off-by: Olle Norelius <norelius.olle@gmail.com>
2019-09-09 14:15:44 -05:00
Ulf Magnusson cbb332369f kconfiglib: Expose parsing location to Python preprocessor functions
Update Kconfiglib (and menuconfig/guiconfig, just to sync) to upstream
revision f2ce282eca, to get this commit in:

    Allow preprocessor user functions to access the parsing location

    Just requires making Kconfig.filename/linenr public.

    'lineno' would be a more standard name, but be consistent with
    MenuNode.linenr.

This can be used to give friendly errors in
scripts/kconfig/kconfigfunctions.py, e.g. for
https://github.com/zephyrproject-rtos/zephyr/pull/18752.

Some minor optimizations are included too.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-09 19:48:44 +02:00
Ulf Magnusson ff1f75293e dts: edtlib: Support giving missing properties a default value
For missing optional properties, it can be handy to generate a default
value instead of no value, to cut down on #ifdefs.

Allow a default value to be specified in the binding, via a new
'default: <default value>' setting for properties in bindings.
Defaults are supported for both scalar and array types. YAML arrays are
used to specify the value for array types.

'default:' also appears in json-schema, with the same meaning.

Include misc. sanity checks, like the 'default' value matching 'type'.

The documentation changes in binding-template.yaml explain the syntax.

Suggested by Peter A. Bigot in
https://github.com/zephyrproject-rtos/zephyr/issues/17829.

Fixes: #17829
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-09 08:47:49 -05:00
Ulf Magnusson c191156454 ci: scripts: Suppress pylint warnings for the sh library
pylint does not like how this library works and generates spurious
warnings like

    scripts/ci/get_modified_tests.py:55:13: E1121: Too many positional
    arguments for function call (too-many-function-args)

    scripts/ci/get_modified_tests.py:57:13: E1123: Unexpected keyword
    argument '_tty_out' in function call (unexpected-keyword-arg)

These warnings are useful enough to want to have enabled in the upcoming
pylint CI check, so suppress them here.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-08 22:22:35 -04:00
Ulf Magnusson ec116e4298 filter-known-issues.py: Remove '== True' test
Fixes this pylint warning:

    Comparison to True should be just 'expr' (singleton-comparison)

Getting rid of pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-08 22:20:20 -04:00
Ulf Magnusson 1c57b223ef zephyr_commit_rules.py: Fix pylint warning by simplifying conditional
Non-empty sequences are truthy in Python, so len() can be skipped in
tests.

Fixes this pylint warning:

    scripts/gitlint/zephyr_commit_rules.py:115:11: C1801: Do not use
    `len(SEQUENCE)` to determine if a sequence is empty
    (len-as-condition)

Fixing warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-08 22:19:37 -04:00
Ulf Magnusson 50b9b1249b scripts: Simplify code with sys.exit(<string>)
Promote a handy and often-overlooked sys.exit() feature: Passing it a
string (or any other non-int object) prints it to stderr and exits with
status 1.

See the documentation at
https://docs.python.org/3/library/sys.html#sys.exit.

This indirectly prints some errors to stderr that previously went to
stdout.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-08 12:34:16 +02:00
Ulf Magnusson a0fceff1a2 scripts: dts: Simplify and improve 'compatible' matching
Instead of

    properties:
        compatible:
            constraint: "foo"

, just have

    compatible: "foo"

at the top level of the binding.

For backwards compatibility, the old 'properties: compatible: ...' form
is still accepted for now, and is treated the same as a single-element
'compatible:'.

The old syntax was inspired by dt-schema (though it isn't
dt-schema-compatible), which is in turn a thin wrapper around
json-schema (the idea is to transform .dts files into YAML and then
verify them).

Maybe the idea was to gradually switch the syntax over to dt-schema and
then be able to use unmodified dt-schema bindings, but dt-schema is
really a different kind of tool (a completely standalone linter), and
works very differently from our stuff (see schemas/dt-core.yaml in the
dt-schema repo to get an idea of just how differently).

Better to keep it simple.

This commit also piggybacks some clarifications to the binding template
re. '#cells:'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 1467480491 scripts: dts: Replace bare 'except's in old scripts
A bare 'except:' can do some annoying stuff like eat Ctrl-C (because it
catches KeyboardInterrupt). Better to use 'except Exception:' as a
catch-all.

Even better might be to catch some more specific exception, because even
'except Exception:' eats stuff like misspelled identifiers.

Fixes this pylint warning:

    W0702: No exception type(s) specified (bare-except)

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson cff38cf0ef scripts: edtlib: Fix bad block indentation
Reported by pylint.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 8f22529e74 scripts: edtlib: Make _binding_include() global to fix pylint warning
Doesn't use 'self'. Fixes this pylint warning:

    scripts/dts/edtlib.py:272:4: R0201: Method could be a function
    (no-self-use)

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 8d317bc665 scripts: edtlib: Add backwards compatibility for 'category:'
Having backwards compatibility for !include and 'constraint:' is silly
without also having backwards compatibility for 'category:', because
that forces a binding change anyway.

Add backwards compatibility for 'category:', and just print a
deprecation warning when it's used.

Also move tests for deprecated features into a dedicated
test-bindings/deprecated.yaml binding, instead of piggybacking on other
tests.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson ba76b82f5a scripts: dtlib: Suppress _init_tokens() pylint warning
Suppress this pylint warning so that it can be enabled in the upcoming
CI check. The code is safe.

    scripts/dts/dtlib.py:1904:13: W0631: Using possibly undefined loop
    variable 'i' (undefined-loop-variable)

Also add some more comments to clarify _init_tokens().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson a67eb7825a scripts: dts: Remove unused variable in old scripts
Detected by pylint. Getting rid of pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson c1f6fe85f7 scripts: dts: devicetree.py: Fix pylint warning for iffy \w escape
"\w" gives a two-character string, but is iffy, because it relies on \w
not being defined as an escape sequence. r"\w" is better.

Fixes this pylint warning:

    scripts/dts/devicetree.py:134:0: W1401: Anomalous backslash in
    string: '\w'. String constant might be missing an r prefix.
    (anomalous-backslash-in-string)

Wondering if I should exclude the old DTS scripts from the pylint CI
check, but doesn't hurt to fix it at least.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 6c6336af11 scripts: dtlib: Refactor to fix two no-self-use pylint warnings
Move some property fetching and node deletion code from the DT class
over to the Node class. Reads pretty nicely, and indirectly gets rid of
two unused 'self' arguments.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00