Commit graph

2587 commits

Author SHA1 Message Date
Kumar Gala
b379e4547f Revert "scripts: gen_defines: tweak out_define() whitespace"
This reverts commit 3b7ddc83d1.

Reverted as the changes to gen_defines.py break things.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-14 10:38:52 -06:00
Corey Wharton
86bfc489f4 scripts: Replace hard-coded subsystem list with __subsystem annotations.
This change removes the hardcoded subsystem list in gen_kobject_list.py
favor of marking the relevant driver API structs with the _subsystem
sentinel.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-03-11 17:13:39 +02:00
Corey Wharton
ccd15df510 scripts: Dynamically add driver subsystems to subsystems list
This change extends the parse_syscalls.py script to scan for a
__subsystem sentinal added to driver api declarations. It thens
generates a list that is passed into gen_kobject_list.py to extend
the subsystems list. This allows subsystems to be declared in the
code instead of a separate python list and provides a mechanism for
defining out-of-tree subsystems.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-03-11 17:13:39 +02:00
Kumar Gala
0353d22202 kconfig: Add dt_nodelabel_enabled function
Add a function takes a 'label' and returns "y" if we find an
"enabled" node that has a 'nodelabel' of 'label' in the EDT
otherwise we return "n"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 07:59:38 -06:00
Martí Bolívar
7846fd103d edtlib: add 'labels' attribute to Node class
This corresponds to the attribute by the same name in dtlib.Node.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
3b7ddc83d1 scripts: gen_defines: tweak out_define() whitespace
Pad node identifiers to 60 characters. This results in better
alignment in practice than the current value of 40, which is a bit
low.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
47073fd11c scripts: gen_defines: remove out()'s aliases kwarg
Write the same results explicitly in its only remaining caller.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
3939556fc3 scripts: gen_defines: re-work write_bus() with augmented nodes
This too is an attempt to reimplement the previous behavior exactly,
modulo the order in which things are defined.

This is the last function which is calling into the previous
implementation's out_node and node_*_alias() functions, so these can
be removed now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
0471199e63 scripts: gen_defines: re-work write_spi_dev() with augmented nodes
This uses augmented nodes in the same way as done previously.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
86645aafdf scripts: gen_defines: re-work write_props() with augmented nodes
This is similar to the work already done for regs.

Other than the order in which they appear and comments, the output
before and after this patch should be exactly the same.

We're intentionally leaving some of the helpers in module scope here
to use some of the subroutines elsewhere later on when reworking
write_spi_dev().

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
c048f872d7 scripts: gen_defines: re-work write_clocks() with augmented nodes
Mirror the change already done to write_regs().

Other than the order in which they appear and comments, the output
before and after this patch should be exactly the same.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
f68da76d36 scripts: gen_defines: re-work write_irqs() with augmented nodes
Use augmented nodes to print macros grouped by namespace.

Other than the order in which they appear and comments, the output
before and after this patch should be exactly the same.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
ba1c8b523c scripts: gen_defines: re-work write_regs() with augmented nodes
Group the macros together by namespace rather than putting all the
BASE_ADDRESS macros together and all the SIZE macros together. E.g.,
all the DT_INST_<x> namespace macros for each node now appear
consecutively.

Add a comment making it clear that this output comes from "regs",
since "BASE_ADDRESS" and "SIZE" are not property names.

Other than the order in which they appear and comments, the output
before and after this patch should be exactly the same.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Martí Bolívar
dd1d58cad6 scripts: gen_defines: augment edtlib nodes
Add additional attributes to each edtlib.Node we process, before
calling into the write_foo() routines.

This includes the identifier returned by node_ident(), which is used
as the primary identifier for the node, as well as lists for instance
and aliases nodes, and a catchall list that contains all the other
identifiers in addition to the primary one.

Use this information in a new for_each_ident(node, ident) def that
will be put to use in the various write_foo() routines.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Ulf Magnusson
8cacb9fd8c dts: edtlib: Turn global spi_dev_cs_gpio() into Node.spi_cs_gpio
spi_dev_cs_gpio() takes a Node and returns the chip select GPIO for it.
Having that information available directly from Node is neater, so turn
it into a Node.spi_cs_gpio property instead.

That gets rid of the only public global function in edtlib, which might
make the API design clearer too.

Tested with the sensortile_box board, which uses SPI chip select.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Ulf Magnusson
35166c45d9 dts: edtlib/gen_defines: Fix API design re. dtc flags
It's better to allow per-instance EDT configuration than to set a global
variable on the edtlib module. Enable/disable the warning for reg/unit
address mismatches via a flag to EDT.__init__(), instead of via a global
variable. That makes it consistent too.

Another option would be to pass the 'dtc' flags to EDT.__init__(), but
it makes the interface a bit ugly. Maybe if it needs to emulate lots of
other flags later.

Clarify that edtlib itself isn't meant to have any state in the comment
at the top of the module.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-03-11 07:59:38 -06:00
Patrik Flykt
cbef6760c1 scripts: net: Enhance error reporting
Enhance error reporting by returning immediately when the calling
function reports an error.

Signed-off-by: Andrei Laperie <andrei.laperie@intel.com>
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2020-03-10 16:43:10 +02:00
Patrik Flykt
3401192e7f scripts: net: Add option to keep container after test
Add '--keep' option to leave Docker container and network running
after the test.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2020-03-10 16:43:10 +02:00
Patrik Flykt
ad1b38bebe scripts: net: Return final return value from Docker test
Return the final return value from Docker script when running echo
client in the container, first for UDP and then TCP, for both IPv4
and IPv6.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2020-03-10 16:43:10 +02:00
Patrik Flykt
8f451b7338 scripts: net: Add overlay file to sample script
Add an '--overlay' command line option in order to use an overlay
file when compiling Zephyr.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2020-03-10 16:43:10 +02:00
Martí Bolívar
34a59168d5 build: clean up west build
The header printed at the beginning of every west build is kind of
annoying. Let's remove it and just print the application source
directory at cmake time instead. The build directory and board are
already printed there, anyway, and that's all IDE users will see.

Let's clean up the BOARD to make it say "board" instead. That matches
the west build --board option name a bit more closely and is still
legible.

Likewise, let's not print any west build messages if we're just
incrementally recompiling. That's noisy.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-10 14:53:28 +02:00
Mikkel Jakobsen
98eb316bdf scripts: build.py: make _sanity_check() case insensitive on windows
When checking build directory against cache on windows, certain
corner cases can end up failing the comparison because of case
difference on an otherwise identical path. This can be avoided
by ignoring case on windows.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2020-03-10 12:19:35 +02:00
Anas Nashif
497fe4267a release: update sanitycheck footprint file
Update for latest release.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-09 23:40:45 +02:00
Martí Bolívar
67d8f755e2 runners: misc-flasher: hotfix
The 'command' command line argument for this flasher is now being
overridden by common code, which attaches the west subcommand name to
this.

Let's just hotfix this by renaming the argument in misc-flasher.
We can revisit the boundary between run_common.py arguments and
runners package arguments after the release.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-04 21:48:09 +02:00
Martí Bolívar
24ce05c841 doc: improve west flash help for dfu-util
Try to make it clearer what's going on here.

Suggested-by: Lucian Copeland <hierophect@gmail.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-03 09:30:32 +02:00
Martí Bolívar
dc0948424e scripts: run_common: fix command line --hex-file and friends
This is yet another bug introduced by the move to runners.yaml.
Sigh. I should have tested this better.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-29 19:38:49 +02:00
Martí Bolívar
f8cb3d4d53 scripts: run_common: rename 'args' to 'user_args'
This will also make the reason for a following bug fix easier to see.

Update a comment block to include all the work that needs doing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-29 19:38:49 +02:00
Martí Bolívar
97dbda2088 scripts: run_common: rename unknown_args to user_runner_args
This makes its true value clearer, and will make a later bug fix patch
easier to understand.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-29 19:38:49 +02:00
Martí Bolívar
6dab163cad scripts: fix west sign when ZEPHYR_BASE is unset
Due to cleanups in west targeted at getting rid of zephyr-specific
code, extension commands can no longer rely on ZEPHYR_BASE being set
in the calling environment at import time (it's still set at run()
time for now, though, to keep west build working).

Add a new helper to make dealing with this easier from west sign.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Martí Bolívar
eb95bed552 scripts: west_commands: fix argument handling with runners.yaml
Refactor the code to support the new runners.yaml file created by the
build system.

Compared to fishing around in the CMake cache, this makes it trivial
to put all the command line arguments to a runner-based command on
equal footing, regardless of if they're defined in the runners package
proper or defined in run_common.py.

This allows board.cmake files to do things like this:

   board_set_runner_args(foo
     --bin-file=${PROJECT_BINARY_DIR}/my-signed.bin)

While at it, make some other cleanups:

- Stop using the obsolete and deprecated west.cmake module while we're
  here in favor of the zcmake.py module which was added to Zephyr a long
  time ago. Yikes. I had forgotten this was still here.

- Stop using west.util's wrap function in favor of raw use of
  textwrap. The west function splits on hyphens, which is breaking
  runner names like "em-starterkit".

- Clean up the --context output a bit

Fixes: #22563
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Stephanos Ioannidis
354f2bbf1e sanitycheck: Update section names for memory size calculation
This commit updates the section names for memory size calculation in
the sanitycheck script as follows:

1. Remove `_TEXT_SECTION_NAME_2` section, which no longer exists, from
  the `rw_sections`.

2. Add `rom_start` section, which mostly contains read-only data such
  as the exception vector table, to the `ro_sections`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-18 12:59:25 -05:00
Alexey Brodkin
5bd2857c73 board: arc: Switch to generic OpenOCD runner
We used to use "em-starterkit" runner for ARC which is
basically heavy-modified "openocd" runner tweaked to
use GDB for loading and starting Elf files.

Now when loading and running Elf files is possible with generic
"openocd" runner we may us it. So we switch and get rid of
"em-starterkit" as well since we no longer need it.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-13 10:45:44 +02:00
Alexey Brodkin
83b346edef runners: opeocd: Allow loading Elf-files
In some cases especially for on-going development & debugging of real
application it might be useful to load and run not from flash but
from RAM in that case there's one catch: we cannot reset the board
after loading memory with our app.

That's because:
 a) RAM we use might be either cleared on reset or might enter
    unpredictable state with portion of previously loaded data
    being corrupted.
 b) Reset vector most probably still point to ROM/flash and so
    our current application won't be executed on reset.

So instead of "run reset" command of OpenOCD we'll use
"resume 0x12345678". Where 0x12345678 is our application's
entry-point (which BTW may very well not match beginning of
the .text section or link base).

Now to extract the entry-point we need our application's zephyr.elf
and since we already have a requirement for Elf we may use it for
loading because OpenOCD does it perfectly fine moreover automatically
detecting loaded image type (binary, hex, Elf etc).

And to use that nice feature just add "--use-elf" to west's
command-line for boards that use "openocd" runner. Like that:
----------->8--------------
west flash --use-elf
----------->8--------------

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-13 10:45:44 +02:00
Alexey Brodkin
5a4237ed3b west: openocd: Allow to specify FTDI instance by its serial number
To be used in setups with multiple boards attached to the same one
host we need to have an ability to specify precisely which JTAG probe
to use for a particular board.

This is done by passing "ftdi_serial XXX" command to OpenOCD.
And the serial ("XXX") is supposed to be passed from higher level,
typically via west's options. And exactly for that we add another
"openocd" runner option "--serial=XXX" which sets
a Tcl's "_ZEPHYR_BOARD_SERIAL" variable that later gets passed
to OpenOCD's "ftdi_serial" command.

See more discussions on the matter here:
https://github.com/zephyrproject-rtos/zephyr/issues/22543

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-13 10:45:44 +02:00
Kumar Gala
0ce53610f8 scripts/requirements: Remove unused packages
Remove 'git-spindle' as there are not users in any scripts or build
system and not references in any of our docs.

Remove 'wheel' as nothing seems to use or need it directly.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-12 10:30:56 -06:00
Martí Bolívar
dc1edb946f scripts: zephyr_module: hack to match west 0.7 output
The west command line output is not stable and has changed for 0.7.
Match it in zephyr_module.py's check for whether we are in a
workspace.

The real fix is to start using 'west topdir' whenever the west version
is at least 0.7.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-12 11:37:52 +01:00
Andy Ross
7353c7f95d kernel/userspace: Move syscall_frame field to thread struct
The syscall exception frame was stored on the CPU struct during
syscall execution, but that's not right.  System calls might "feel
like" exceptions, but they're actually perfectly normal kernel mode
code and can be preempted and migrated between CPUs at any time.

Put the field on the thread struct.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Kumar Gala
b81eec951b sanitycheck: make pyserial optional
We only need pyserial python module if we are doing device testing.
Treat it similar to how we treat tabulate module.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-07 19:48:24 -06:00
Anas Nashif
a9f2fcb64a requirements: require gcovr >= 4.2
This is the version needed to generate coverage using sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:14:24 -05:00
Anas Nashif
323161dfcd sanitycheck: point to correct gcov path
The SDK has a new path for x86 gcov, point to the new binary. Also, do
not clean artifacts when running coverage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:14:24 -05:00
Martí Bolívar
cea6e3f17a scripts: west_commands: fix help text for flash
The 'command' variable points at a python command object, not a
string. Take its name so the help text for west flash -h correctly
says 'flash' instead of 'debug'.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-06 23:06:04 -05:00
Ulf Magnusson
fad697aed9 scripts: gen_defines.py: Add out_dev() flag for deprecated macros
Add a 'deprecation_msg' string/flag to out_dev(). When 'deprecation_msg'
is passed, all generated macros include

    __WARN(<deprecation_msg>)

which prints a custom warning if the macro is used.

Meant to be used when improving the output format.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-06 17:27:49 -06:00
Kumar Gala
2fd7876aa7 ci: github: west: Add a GH workflow to run the west command tests
Replace running west command tests in run_ci.sh with a github workflow.
This provides some benefits in that we can run the west command tests on
multiple python versions and host OSes (linux, mac and windows).

Also have the benefit that the tests are only run on modifications to
files in scripts/west_commands/ or scripts/west-commands.yml.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-06 08:34:43 -06:00
Martí Bolívar
1c80d79fdd scripts: west_commands: skip bossac tests unless on linux
That's the only platform the tool is available.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-06 08:34:43 -06:00
Wentong Wu
c35fa6caa6 scripts: add script for usb backend to receive tracing data
Add script for usb backend to receive tracing stream data. This
script, trace_capture_usb.py, is based on pyusb, so install it
correctly before using the script.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Wentong Wu
b4449a0c2c scripts: add script to capture tracing data with UART backend
Add script to capture tracing stream data with UART backend. This
script is developed based on pyserial, so install it correctly
before using the script.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Kumar Gala
de70e9c5ba scripts/sanitycheck: be more fair with dividing subsets
Since we do interger division to determine how many items are in each
set, its possible we can have bad rounding error and the last set having
a much larger amount of items compared to all other sets.

For example, total = 3740, sets = 300:
	per_set = 3740 / 300 = 12.466 = 12
	last_set = 3740 - 299 * 12 = 152

So instead of doing simple division, we add on extra item to the early
sets and we've exhausted the rounding error:

	num_extra_sets = total - per_set * sets
		   140 = 3740 - 12 * 300

So the first 140 subsets will have 13 per_set, and the last 160 will
have 12 per_set.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 18:57:49 -05:00
Andrei Gansari
e87fec1554 scripts: simple-bus warning suppression
Single-bus warning in python parsing of device tree is suppressed if
this is also suppresed in the device tree compiler.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2020-02-05 13:04:44 -06:00
Andrei Emeltchenko
d44d986a03 west: Add signing support using the rimage tool from SOF
This way "west sign" can be used for signing images.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2020-02-05 10:43:25 -05:00
Martí Bolívar
54ddd514ae scripts: grutils: tweak sort keys to group siblings
Change the key function used to sort nodes so that unit addresses, if
present, break ties between sibling nodes. This orders siblings in
increasing order by unit-address in any gen_defines output that is
sorted by ordinal.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-04 07:28:45 -06:00
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