Commit graph

4869 commits

Author SHA1 Message Date
Daniel Leung
4d914f4f89 toolchain: move CONFIG_LLVM_USE_LD into cmake/toolchain/llvm
This moves CONFIG_LLVM_USE_LD into cmake/toolchain/llvm as this
is a toolchain kconfig. Also make it a choice to allow the use
of LLVM's lld as linker.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Jamie McCrae
ef146c3dbd scripts: compliance: Add MCUboot Kconfig to allow list
Adds a Kconfig for MCUboot which is used in the documentation to
the CI Kconfig check allow list.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-29 11:30:36 +02:00
Jamie McCrae
c5fbcc468e snippets: Fix cmake path output on Windows
Uses linux style path output instead of windows style to prevent
issues with cmake assuming the slashes are for escape code
sequences.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-27 14:44:39 +00:00
Carles Cufi
e0c90b9393 scripts: requirements: Move requests and pyserial to base
Both the requests and pyserial Python packages are used by west commands
(west fetch and west build -b esp* respectively) so move them to the
requirements-base.txt file.

Fixes #56215.
Fixes #56224.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-27 07:12:27 -07:00
Martí Bolívar
1f9ab85354 west: build: appease the linter
The linter is complaining about unnecessary parens.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Marti Bolivar
5880feee33 west: build: add -S <snippet> argument
Writing '-S foo' is a convenience shorthand for adding snippets at
CMake time without having to add '-- -DSNIPPET=foo' to the west build
command line. It is worth adding a new one-letter command line option
because snippets are anticipated to be a very commonly used feature.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Marti Bolivar
3f282da0e8 zephyr modules: add 'snippet_root' support to module.yml
This key may appear in a module.yml's 'settings' map, and works
analogously to the already existing 'board_root', 'dts_root', etc.
keys: if set, its value is interpreted as a directory that will be
added to SNIPPET ROOT.

For example, if a module.yml contains:

  settings:
    snippet_root: foo

Then 'foo', relative to the module's base directory, will be added to
SNIPPET_ROOT. This then means that any snippets in foo/snippets will
be discovered by the build system.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Marti Bolivar
06c9bf47b3 snippets: initial snippet.yml support
Add a new script, snippets.py, which is responsible for searching
SNIPPET_ROOT for snippet definitions, validating them, and informing
the build system about what needs doing as a result.

Use this script in snippets.cmake to:

- validate any discovered snippet.yml files
- error out on undefined snippets
- add a 'snippets' build system target that prints all snippet
  names (analogous to 'boards' and 'shields' targets)
- handle any specific build system settings properly,
  by include()-ing a file it generates

With this patch, you can define or extend a snippet in a snippet.yml
file anywhere underneath a directory in SNIPPET_ROOT. The snippet.yml
file format has a schema whose initial definition is in a new file,
snippet-schema.yml.

This initial snippet.yml file format supports adding .overlay and
.conf files, like this:

  name: foo
  append:
    DTC_OVERLAY_FILE: foo.overlay
    OVERLAY_CONFIG: foo.conf
  boards:
    myboard:
      append:
        DTC_OVERLAY_FILE: myboard.overlay
        OVERLAY_CONFIG: myboard.conf
    /my-regular-expression-over-board-names/:
      append:
        DTC_OVERLAY_FILE: myregexp.overlay
        OVERLAY_CONFIG: myregexp.conf

(Note that since the snippet feature is intended to be extensible, the
same snippet name may appear in multiple files throughout any
directory in SNIPPET_ROOT, with each addition augmenting prior ones.)

This initial syntax aligns with the following snippet design goals:

- extensible: you can add board-specific support for an existing
  snippet in another module

- able to combine multiple types of configuration: we can now apply a
  .overlay and .conf at the same time

- specializable: this allows you to define settings that only apply
  to a selectable set of boards (including with regular expression
  support for matching against multiple similar boards that follow
  a naming convention)

- DRY: you can use regular expressions to apply the same snippet
  settings to multiple boards like this: /(board1|board2|...)/

This patch is not trying to design and implement everything up front.
Additional features can and will be added to the snippet.yml format
over time; using YAML as a format allows us to make
backwards-compatible extensions as needed.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Martí Bolívar
bcc0a3b9aa scripts: add list_devicetree_bindings_changes.py
This automates much of the drudgery of enumerating changes to
devicetree bindings at release time. Some customizations and
release-specific tweaks to the script will probably always be needed,
but it's a good starting point.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-03-25 11:12:38 +01:00
Evgeniy Paltsev
f2d04ab189 twister: fix timeout status for the device handler
Currently in binary handler and qemu handler we have status `failed`
in case of test timeout, but in device handler we have status `error`

This not only adds inconsistency between handlers, but also prevents
us from usage test retry functionality for the runs on HW.

Fix timeout status by changing it to `failed` instead of `error`.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-03-22 09:34:33 +01:00
Jason Kridner
f36be35600 scripts: compliance: allow webp image files
WebP images are smaller for similar resolutions and quality while being
compatible with web browsers and other image processing tools.

For higher resolution images, be sure to limit the display size to make
the rendered pages look reasonable.

This was approved by Benjamin Cabé (@kartben) in this discussion thread:
https://github.com/zephyrproject-rtos/zephyr/pull/55488#issuecomment-1461792751

Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
2023-03-21 16:03:43 -04:00
Nicolas VINCENT
fa7170b846 west: runner: Use --verify and --verify-only with openocd and hex files
the options --verify and --verify-only where only used when flashing elf
files and were ignored for flashing hex files for example when using
openocd runner.
The command to verify the image is now dependant on the presence of
--verify or --verify-only, and the load command is not executed if
--verify-only is provided.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2023-03-21 09:36:29 +01:00
Evgeniy Paltsev
6599c3796d west: runners: mdb-hw: add hostlink-awareness
Add hostlink-awareness to mdb-hw runner. The mdb-nsim and arc-nsim
runners (as well as cmake scripting for nSIM boards) doesn't require
any changes.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-03-17 11:49:02 +01:00
Yuval Peress
36c8b433c8 scripts: Print file causing error for syscalls
I was using a source file provided by TDK for a sensor driver
and the file was (originally) not encoded as UTF-8. When the read()
function was called, the build would fail but I had no idea why.

This change wrapps the 'read()' call and prints the error with
the file name as context.

Signed-off-by: Yuval Peress <peress@google.com>
2023-03-17 11:48:36 +01:00
Carles Cufi
341c01fcd0 scripts: runners: nrf_common: Fix QSPI erase switch
The QSPI erase switch is not part of the "firmware" dict, but rather
placed in the overall operation dict.

Fixes #55625.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-15 12:36:33 +00:00
Grzegorz Chwierut
33220ef086 twister: extend --force-platform to skip platform_allow options
In many of test specifications yaml files (testcase.yaml, sample.yaml)
section `platform_allow` is added. This change allows to test some
scenarios on platforms, that are not added yet to platform allow
list (or are not going to be added for some reasons).

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-03-14 10:13:01 -04:00
Dmitrii Golovanov
77b02252c0 twister: Fix DeviceHandler serial leftover cleanup
Fix how DeviceHandler class does 'serial leftover' cleanup
with loss of test output observed on fast console connections,
e.g. over telnet: either 1 sec. of output might be missed,
or up to 1000 bytes/chars, whatever happens first.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-03-13 09:15:22 +01:00
Daniel Leung
751de22ca4 syscalls: skip generating mrsh.c if not userspace
There is no need to generate all the *_mrsh.c files for
marshalling syscall arguments when userspace is not enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-11 19:45:23 +01:00
Anas Nashif
8f45c0db79 twister: fix wrong reason when timeout occurs
We are wrongly claiming no console output, yet console output is there
and the failure is just a regular timeout, i.e. the test did not
complete within allocated time.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-03-10 11:38:29 +01:00
Jamie McCrae
df9027a64a sysbuild: support Zephyr modules
This commit extends the Zephyr module yaml scheme with additional
entries for sysbuild in the build section.

This allows for Zephyr modules to extend the sysbuild infrastructure
by providing additional CMake and Kconfig files to be included in
sysbuild.

The new settings are:
build:
  sysbuild-cmake: <path>
  sysbuild-kconfig: <path>/<file>
  sysbuild-ext: <true>|<false>
  sysbuild-kconfig-ext:  <true>|<false>

those settings follow the same pattern as the equivalent Zephyr build
settings but are processed by sysbuild.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-09 09:25:00 +01:00
Anas Nashif
14d88f8425 twister: add support for levels and test configuration
Add support test levels and the ability to assign a specific test to one
or more levels. Using command line options of twister it is then possible
to select a level and just execute the tests included in this level.

Additionally, a test configuration allows definiing level
dependencies and additional inclusion of tests into a specific level if
the test itself does not have this information already.

In the configuration file you can include complete components using
regular expressions and you can specify which test level to import from
the same file, making management of levels easier.

To help with testing outside of upstream CI infrastructure, additional
options are available in the configuration file, which can be hosted
locally. As of now, those options are available:

- Ability to ignore default platforms as defined in board definitions
  (Those are mostly emulation platforms used to run tests in upstream
  CI)
- Option to specify your own list of default platforms overriding what
  upstream defines.
- Ability to override build_onl_all options used in some testscases.
  This will treat tests or sample as any other just build for default
  platforms you specify in the configuation file or on the command line.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-03-07 15:49:16 +01:00
João Dullius
79d9f45296 scripts: runners: bossac: Enable BOSSAC to run on Windows (native)
Fixes #37538 by correctly detecting WSL and blocking bossac from running
on that platform, but allowing it to run on Windows native.

Signed-off-by: João Dullius <joaodullius@bpmrep.com.br>
2023-03-06 13:17:09 -08:00
Carles Cufi
e073210ec2 scripts: runners: nrfjprog: Use --tool-opt in all operations
Pass on the tool-specific options to nrfjprog during all operations, and
not only when programming. This is useful when combined with options
like --ip, that allows west flash to be used over the network.

Fixes #55340.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Carles Cufi
ba86759a79 scripts: runners: tests: nrfjprog: Test --tool-opt
Add tests for the --tool-opt command-line switch, to ensure that if the
user includes additional tool options those get passed on to nrfjprog at
the end of the command-line to override any preceding ones.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Carles Cufi
8fc87c87b8 scripts: runners: nrf: Add support for multiple nRF backends
Generalize the logic that was previously in nrfjprog.py into a new
nrf_common.py, which can then use specific tool subclasses, one of which
is nrfjprog.py, to implement the actual tool invocation.

This commit lays down the groundwork for the addition of a new backend
for nRF boards, the new nrfutil tool from Nordic. Both nrfjprog and
nrfutil will coexist in the immediate future, but nrfutil is expected to
be the sole tool for everything nRF in due time.  This is why the internal
representation of the operations is based in JSON and is using the exact
format that nrfutil expects when using the 'execute-batch' option, that
takes a JSON file with an array of operations to be executed.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Carles Cufi
c34da24596 scripts: west: runners: Support class hierarchies in the runners
Allow for multiple levels of inheritance in the runners in order to make
it possible to share common infrastructure in similar runners.
Also check if the class can be instantiated (i.e. it is not abstract) to
avoid returning abstract base classes.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Maciej Perkowski
85dd4975a4 twister: cmake: Add prefiltration based on cmake package helper script
Twister allows filtering based on kconfigs and dts, however the
filtration is a part of the cmake stage, i.e. the stage has to pass
first and then twister checks if required properties are available.
This causes problems, when the full cmake stage is unable to pass.
If so, other filtration methods had to be used, e.g. platform_allow.
The commit modifies the twister workflow:
if a test defines filters based on kconfig/dts first a cmake package
helper script is used to extract dt and/or kconfigs and if the
conditions are fulfilled  it proceeds to a regular cmake stage.
If not, test is skipped.

Co-authored-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2023-03-02 15:38:08 -05:00
Benjamin Cabé
b00c63e764 footprint: ci: Remove audio SOF samples
Removes audio SOF samples from footprint test plan as they no longer
live in-tree

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-03-02 11:46:54 -05:00
Marc Herbert
7249594cd1 west: sign: rimage: log("Prefixing with xman...") only when doing it
Fixes commit 2fdc551acc ("sign.py: stop ignoring the -- -c foo.toml
option passed to rimage")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-02 10:54:13 +01:00
Tristan Honscheid
1eb0452fcb twister: Fields for Kconfig and DT overlay files in testcase.yaml
This is an implementation of issue #48334 and adds support for
specifying additional config and device tree overlays through fields in
the testcase.yaml file, which is more readable than having to cram these
in to `extra_args`.

Consider this example which shows the original and new ways to add
config and DT overlays:

```
common:
  extra_args: "CONF_FILE=a.conf;b.conf
DTC_OVERLAY_FILE=w.overlay;x.overlay OVERLAY_CONFIG=e.conf
UNRELATED=abc"
tests:
  utilities.base64:
    extra_conf_files:
      - "c.conf"
      - "d.conf"
    extra_overlay_confs:
      - "extra_overlay.conf"
    extra_dtc_overlay_files:
      - "y.overlay"
      - "z.overlay"
    extra_configs:
      - CONFIG_SAMPLE=y
    tags: base64
    type: unit
```

The new fields are `extra_conf_files`, `extra_overlay_confs,
`extra_dtc_overlay_files`. Files specified in these sections are appended
to any `CONF_FILE`, `OVERLAY_CONFIG`, or `DTC_OVERLAY_FILE` fields in
`extra_args`, causing the following args being passed in to
`self.run_cmake` at `runner.py:850`:

```
['-DUNRELATED=abc',
 '-DCONF_FILE=a.conf;b.conf;c.conf;d.conf',
 '-DDTC_OVERLAY_FILE=w.overlay;x.overlay;y.overlay;z.overlay',
 '-DOVERLAY_CONFIG=e.conf extra_overlay.conf '
 '<build_dir>/twister/testsuite_extra.conf']
```

These fields can be used in the common or scenario-specific YAML
sections and will be merged in order of least to most specific:

 1. config files extracted from common's extra_args
 2. files listed in common's {extra_conf_files or extra_overlay_confs
    or extra_dtc_overlay_files}
 3. config files extracted from test scenario's extra_args
 4. files listed in test scenario's {extra_conf_files or
    extra_overlay_confs or extra_dtc_overlay_files}

Specifying these files in extra_args now triggers a deprecation warning,
as the direct YAML fields are preferred for readability. They will still
function for now but support will be dropped in the future.  One
testcase.yaml
(`zephyr/tests/cmake/overlays/var_expansions/testcase.yaml`) is
converted to use the new fields. A follow-up PR will convert the
remaining files to the new format.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-03-01 16:52:01 -05:00
Martí Bolívar
513e03ad68 edtlib: extract _slice() code to new helper module
This will make it more convenient to use it from multiple different
places, which we will have a need for in the future.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
c0a024253f edtlib: fix typo
Trivial fix.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
3bb1aaebd5 dtlib: fix pretty-printing in pdb
We need to have an _include_path attribute to pretty-print
this object from within pdb, for some reason. Add it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
2d86e1b05d dtlib: add missing type annotations
This allows mypy to check the internal variable type annotations
within the function.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
78fca3c19c dtlib: fix comment header
The following section of code has nothing public inside.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
6ac19439b2 dtlib: remove dead code
There's no need for _parse_node() to return the Node instance that is
its sole argument. The only user of the return value is a dead store.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
5272e7f681 dtlib: add DT.move_node()
This helper lets you place a node (really the entire subtree rooted at
that node) elsewhere in the devicetree. This will be useful when
adding system devicetree support, when we'll want to be able to, for
example, move the CPU cluster node selected by the current execution
domain to /cpus.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
e479d3f7c6 dtlib: use new helper in test cases
Using dtlib_raises() throughout the test cases saves some typing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
2063ddbc93 dtlib: add new test case helper
Introduce a context manager that will save some typing
when dealing with expected exceptions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Martí Bolívar
faa7e530c2 dtlib: clean up a documentation string
The standard way we write this in the library is 'documentation
string', not 'docstring'.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 17:44:45 +01:00
Anas Nashif
4a572ac86f twister: fixed non-verbose output and line breaks on errors
Percentage calculation was off due to a recent fix in counting and lines
were not breaking correctly on errors.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-27 07:47:12 -05:00
Grant Ramsay
090b13cf1e scripts: ci: check_compliance: Ignore undefined CONFIG_CMD_CACHE
CONFIG_CMD_CACHE is a U-Boot config, mentioned in docs.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-02-24 18:11:56 +01:00
Dominik Ermel
86c4b4caa9 west/sign: Move from using partition label property
MCUmgr no longer uses DTS node property label to identify
slots for image upload and running application. It now uses DTS node
labels for that purpose.
This commit moves `west sign` from using label properties
to DTS node labels, same way the MCUmgr does.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-22 09:32:51 -08:00
Anas Nashif
cd26df75b5 twister: cleanup: fixed typo preventing runtime cleanup
Fixed runtime cleanup option. A typo in a conditional prevented the
cleanup from happened when a test has passed.

Fixes #54240

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 06:07:29 -05:00
Anas Nashif
cdffe5080e twister: define variable earlier to use it in exception
Define suite_path earlier, so that in case of an exception it can be
used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 05:31:07 -05:00
Anas Nashif
78a741f1b4 twister: schema: make tests a required key
Catch any test definitions not defining any tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 05:31:07 -05:00
Anas Nashif
59b3e5ba11 ci: elasticsearch: do not set id for documentats.
Do not set id for docuemnts, lets elasticsearch do that on its own.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-21 13:06:29 -05:00
Anas Nashif
39324048eb ci: elasticsearch: set run date when uploading data
To get consistent and 1 single rundate per CI run, set run_date when
we upload the data. This is optional mostly for CI and to avoid
duplication when we re-run jobs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-21 13:06:29 -05:00
Fabio Baltieri
9b30667c77 build: drop LEGACY_INCLUDE_PATH support
LEGACY_INCLUDE_PATH has been defaulting to "n" and marked as deprecated
in both v3.2 and v3.3. Drop the option entirely for v3.4.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-21 15:06:48 +01:00
Marcin Niestroj
faee6c90b8 twister: coverage: initialize 'use_system_gcov'
Initialize 'use_system_gcov', so it is always set before being referenced
in "elif" statement.

Fixes: 1440b19bde ("twister: restore logic to determine which gcov we
  should use")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-02-20 09:29:35 -05:00
Peter Johanson
26a04adb8b west: runners: uf2: Add new UF2 runner.
Add a new UF2 runner, supporting only the flash capability.

Searches for FAT partitions containing `INFO_UF2.TXT` files,
and can optionally filter on a matching `Board-ID` value in
that file.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-02-20 12:50:38 +01:00
Anas Nashif
5770bdeb1a twister: better handling of error reporting
Stop counting errors as failures and report them as is. This fixes
issues with counting when retrying failures and errors.
We have been adding errors to failures and then double count them when
displaying information on the screen instead of keep an accurate count
in the counter class.

This is now fixed and we do report errors seperately, ie. build errors.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-20 10:20:14 +01:00
Radosław Koppel
14a1b2ffec dts: Add _STRING_UNQUOTED string and string-array
This commit adds access to the string values without a quotes.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Co-authored-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-20 09:49:00 +01:00
Anas Nashif
1440b19bde twister: restore logic to determine which gcov we should use
We do not want to use gcov from the SDK for native posix and unit tests,
instead we want the system gcov. Restore logic that determines that.

Fixes #54226

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-19 20:59:56 -05:00
Allan Norgaard
23cacb3766 scripts: dts: gen_driver_kconfig_dts: Skip empty yaml files
The YAML parsing will currently return a None-type if no input data
is empty, and the subsequent check for a substring will cause an
exception.

Signed-off-by: Allan Norgaard <allannk@gmail.com>
2023-02-19 20:46:44 -05:00
David Reiss
2d8271dca1 pytest: Log pytest command
This makes it easy to run the command manually, possibly with edits to
change the test behavior.

Signed-off-by: David Reiss <dreiss@meta.com>
2023-02-19 20:41:34 -05:00
Nikolay Agishev
0dec4cf927 toolchain: Move extra warning options to toolchain abstraction
Move extra warning option from generic twister script into
compiler-dependent config files.
ARCMWDT compiler doesn't support extra warning options ex.
"-Wl,--fatal-warnings". To avoid build fails flag
"disable_warnings_as_errors" should be passed to twister.
This allows all warning messages and make atomatic test useles.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-02-19 20:34:13 -05:00
Marti Bolivar
2149d2127a scripts: zephyr_commit_rules: improve commit error messages
Make the error messages which appear in CI for invalid commit messages
match the text in the documentation which describes the rules for
commit messages exactly. This hopefully makes it easier for people to
read failing CI results and map them to documentation links describing
what to do instead.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-08 15:03:56 -08:00
Carlo Caione
16248180c5 code_relocation: Fix Warning
The script is generatinga void instead of return. Fix it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-02-08 12:11:14 +01:00
Andrey Borisovich
802600da7b scripts: twister: west twister error codes match twister direct call
This commit fixes #54492 where return code 1 is returned
when twister tests fail when twister is called directly and
return code 0 in similar scenario but twister is invoked using
west.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
2023-02-07 09:22:34 -08:00
Gustavo Romero
7ab955ec1f tracing: scripts: Fix spelling
Fix the spelling of Babeltrace library in the warning message displayed
when such a library can not be imported.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
2023-02-08 01:09:31 +09:00
Maciej Perkowski
40a21f61c2 bugfix: twister: Fix interaction between quarantine integration mode
Tests under quarantine are not treated as errors in the integration
mode. However --quarantine-verify argument allowing to execute just
test under quarantine and skipping others was not considered in
relation to integration mode. Those skips are wrongly threated as
errors. This commit fix this relation and makes thoses skips not
turned to errors.

fixes: #54516

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2023-02-08 01:06:30 +09:00
Anas Nashif
1bed8accd1 twister: fix some pylint warnings
Unnecessary parens after '=' keyword (superfluous-parens)

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-06 10:03:52 +01:00
Anas Nashif
5ab9bcfdf3 twister: fix reporting and example in synopsis
Take an instance that has failed and not whatever was last processed in
the for loop.

Also, change instructions to use `west twister` rather than
`./scripts/twister` to be consistent.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-06 10:03:52 +01:00
Anas Nashif
66fa169623 ci: do not hardcode es server in script
Use environment variable instead of hardcoding server in script. This
will allow reuse.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-03 20:53:20 +09:00
Anas Nashif
fcd60cf789 ci: make any arch/ changes trigger kernel testing as well
This should fix issue like #54337 where architecture code changes were
filtering out kernel tests, where those changes are being tested. Kernel
and arch code is tightly coupled and we need to run kernel tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-03 10:09:26 +09:00
Marti Bolivar
a2f203dd1a runners: restore obsolete synonyms for -i/--dev-id
This is a partial revert of commit
2cee5ff519
("scripts: west_commands: runners: remove deprecated options").

I remarked at the time that the removal of the older way of writing
things from the runners themselves seemed gratuitous since they are
easy to continue to support indefinitely and people may have been used
to the old way of doing things. It didn't seem worth the fight to push
for a revert at the time, though.

Since then I've run into real problems that their removal has caused
in the wild and I am convinced that this part of that patch was wrong.

Restore the original, undeprecated forms of these options, but make it
clear in the command line help that they're just obsolete alternative
spellings at this point.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-02 09:47:17 -08:00
Evgeniy Paltsev
c85e5438b9 ARC: west runner: mdb-hw: fix incorrect argument handling for jtag
Currently we just pass in case of the unsupported jtag adapter
is selected. Fix that by rising ValueError as we do in case of
other incorrect arguments.

While I'm at it add few missing test-cases for mdb west runners.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-02 09:05:18 -08:00
Evgeniy Paltsev
963c7a2d40 ARC: west runner: mdb: fix unexpected empty argument pass to MDB
Currently, in case of multi-core target or in case jtag adapter
auto-selectio, we pass unexpected empty argument (empty quotes `''`)
to MDB binary due to argument generation error.

Fix that.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-02 09:05:18 -08:00
Evgeniy Paltsev
d2d5177e58 ARC: west runner: mdb: remove dead code
Remove code which looking for `cld` process pid - this functionality
isn't use anymore by twister. And as manual MDB termination is also
fixed now this functionality isn't required for anything now.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-01 10:06:26 -08:00
Evgeniy Paltsev
0206effb46 ARC: west runner: mdb: fix unusable console after flash / debug
Currently we try to start MDB (MetaWare Debugger) in background
with ignored sigint no matter if we are planing to do debug
session (via `west debug`) or just run something on HW or on
nSIM (via `west flash`)

That cause really bad user experience as after we do
`west debug` or `west flash` we can't terminate the debugger
from the console. Moreover even if we terminate the debugger
process from separate terminal the console stil would be
broken so we need to do `stty sane` in it to make it usable
again.

Fix all that by proper starting the debugger process.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-01 10:06:26 -08:00
Fabio Baltieri
317b3c6897 scripts: compliance: pass argv explicitly to parse_args
Change the check_compliance main invocation to pass an explicit argv
list from main to parse_args(). This does not change anything for direct
invocation, but allows wrapping the compliance script and using it as a
library while controlling its behavior by passing the intended flags to
main().

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-01 17:17:34 +09:00
Anas Nashif
ef9d5bbddf twister: print synopsis at the end and instruction for reproducing
If errors are found and tests are failing, print a brief summary showing
the top 10 items failing with instructions on how to reproduce either
with twister or west.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-28 17:05:19 -05:00
Anas Nashif
79b955c80a west: build: allow --test-item to accept twister style instance names
This will allow something like this:

west build -b qemu_x86  -T samples/hello_world/sample.basic.helloworld

instead of:

cd samples/hello_world
west build -b qemu_x86  -T sample.basic.helloworld

Using this option will allow to take twister output and just pass it to
west to reproduce failures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-28 17:05:19 -05:00
Anas Nashif
1008124358 west: build: handler errors in west build with --test-item
Handle errors and wrong test meta-data when using --test-item.

Fixes #52614

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-28 17:05:19 -05:00
Henrik Brix Andersen
fba6c7f210 scripts: kconfig: add function to determine if GPIO hogs are enabled
Existence of enabled GPIO hog nodes cannot be determined using any of the
existing kconfig functions. Add custom kconfig helper function to determine
whether any GPIO hogs nodes are enabled.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-27 14:38:52 -08:00
Henrik Brix Andersen
28819152cb scripts: dts: add special tooling for handling GPIO hog nodes
GPIO hog nodes contain a "gpios" property, but unlike other "*-gpios"
properties, these are not phandle-arrays as they only carry the data part
(e.g. pin, flags) but lack the phandles to the (parent) GPIO controller.

Add special devicetree tooling to handle the "gpios" property of GPIO hog
nodes and generate special devicetree helper macros as if they were phandle
arrays.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-27 14:38:52 -08:00
Anas Nashif
712d682cf7 twister: fix initialization of job server option
Do not set default for jobserver variable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-28 02:24:09 +09:00
Anas Nashif
e4d48545a3 twister: make job server default only on Linux
Job server only works on Linux, revert to original behaviour when
running on Windows or MacOS.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-27 11:53:13 -05:00
Anas Nashif
fd702ebb34 ci: push test results to elasticsearch instance
Move away from opensearch and switch to elasticsearch for reporting.
The results will be available at https://kibana.zephyrproject.io/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-27 22:57:26 +09:00
Torsten Rasmussen
cb690ec56e cmake: implement build infrastructure for supporting SCA tools.
Static code analyser (SCA) tools are important in software development.

CMake offers built-in support for some tools, such as cppcheck and
clang-tidy.

Other tools, such as sparse, are not directly supported.

This commit provides a uniform way for users to specify a supported
SCA using `ZEPHYR_SCA_VARIANT=<tool>` which is consistent with how
toolchains are specified.
ZEPHYR_SCA_VARIANT can be set using `-D` or in environment.

Support for an SCA tool is done in `cmake/sca/<tool>/sca.cmake`.
SCA_ROOT can be used to specify additional search paths when looking up
implementation for a tool. SCA_ROOT can also be specified in
`zephyr/module.yml` as setting. This makes it possible to provide SCA
tool implementation as part of a Zephyr module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-01-27 20:28:58 +09:00
Fabio Baltieri
16d723ee1b scripts: set_assignee: don't skip assignment on too many labels
The set assignee script currently exits if there's too many labels
associated with a PR. Change that to just skip the label assignment, but
continue on to assign a maintainer based on the most relevant area.

Tested with:

  ./scripts/set_assignees.py -v --dry-run -P 52716

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-26 14:57:29 -05:00
Jamie McCrae
d72e135b2b scripts: ci: Enable pylint check for argument parser abbreviations
Enables running CI checks which will now search for initialisation
of argument parser where abbreviations are not disabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00
Jamie McCrae
101ba4ae09 scripts: pylint: Add argument parser abbreviation checker
Adds a pylint checker for ensuring that the argument parser
library is setup with abbreviations disabled.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00
Jamie McCrae
ec7044437e treewide: Disable automatic argparse argument shortening
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00
Fabio Baltieri
d428c8c836 scripts: compliance: support not writing output to files
Support running the compliance check script without writing the output
to any file.

This adds a check for the --output flag to not write to the output file
if the value is empty, and add a second flag for inhibiting the
individual case files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-26 10:10:58 +00:00
Jeremy Bettis
fae717305b twister: Implement GNU make jobserver support
When twister is started from make, use the information in MAKEFLAGS to
participate in the job server started by make.

When twister is running standalone, start a jobserver to share with
child processes. If using the kitware version of ninja, then this will
prevent ninja+twister from starting more processes than XX when twister
is run with -jXX.

There is no implementation for windows yet.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2023-01-25 20:06:13 -05:00
Anas Nashif
c2b2486072 twister: adapt tests after revert of namespacing
Remove prefix with path from tests, we do not have  namespacing anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-24 20:21:57 -05:00
Anas Nashif
eb56ea4d42 Revert "twister: tests: Add unit tests for names of external and module tests"
This reverts commit 45e1ff94cd.

This is not needed after removal of namespacing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-24 20:21:57 -05:00
Anas Nashif
a4b2d58d3f Revert "twister: Update path structure for tests"
This reverts commit 21eb27c5c0.

This change has been a source of much trouble and ends up preventing us
from tracking test results across tree. It uses the repo name as the
namespace, and that is not always the same and does not have to be
called 'zephyr', depending on where you are running and in which
environment.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-24 20:21:57 -05:00
Tom Burdick
23d8d0d0ae twister: Better messages for keyed test exclusions
Improves the message for tests being excluded using the platform key,
describes the key already found and the platform being used to run the test
in its place.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-20 12:17:29 +01:00
Dominik Ermel
807ad96e21 scripts/utils/migrate_mcumgr_kconfigs.py: Fix missing Kconfigs
Add missing Kconfig translations.

Fixes #53306

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-01-20 11:58:47 +01:00
Grzegorz Chwierut
0a7a61f15c twister: docs: Update twister docs with quarantine
Docs updated with changes proposed in #52179
Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Grzegorz Chwierut
6809c05d09 twister: quarantine: Added pytests
Implemented scenarios to test the quarantine in twister
Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Grzegorz Chwierut
bac1a955d0 twister: quarantine: Added simulations field and regex to filter fields
Regex are allowed on every field, not only scenarios.
Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Grzegorz Chwierut
d95eab1ce6 twister: Refactor and extend quarantine implementation in twister
Implementation ported from TwisterV2.
- quarantine handled by separate module
- multiple yaml allowed from args: --quarantine-list
- scenarios, platforms, architectures keywords in
quarantine yaml are optional, if not given - means take it all

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Fabio Baltieri
79856e7637 west: runners: blackmagicprobe: guess the gdb port based on the OS
Add some logic in blackmagicprobe.py to guess the GDB serial port based
on the OS instead of just trying the flag or /dev/ttyACM0.

The new logic explicitly looks for the well known path for BMP on Linux
(/dev/ttyBmpGdb), so that we can remove it from the board files that
have it set explicitly right now. At the same time it still allows
setting the port from the flag and also checks an environment variable,
so that it can be used for systems with multiple probes.

As a fallback, it looks for a valid serial port, picking the first one
(the probe creates two, the GDB one is the first one), and raise an
exception if nothing is found.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2023-01-19 10:16:00 +01:00
Fabio Baltieri
dabfffaf26 west: runners: blackmagicprobe: update reset on connect command
Recently the blackmagicprobe command for "connect under reset" has been
updated from "connect_srst" to "connect_rst". Update the flag name in
the west blackmagicprobe binding, keep the old one as well for
compatibility with out of tree boards, and send both the old and new
commands to GDB so that it works with both the old and new firmware. GDB
is going to get a "command not supported by this target" for one of the
two and proceed with the other one.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2023-01-19 10:16:00 +01:00
Anas Nashif
fef2bb0866 twister: run as device, even if simulation is supported
Some hardware boards are supported in qemu as simulation platforms. If
we are testing with the real hardware, make sure we treat this as a
device and not as a simulator. First priority when initializing a
handler is to check if device testing is requested, then we can handle
the rest without --device-testing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-17 16:10:17 -05:00
Daniel DeGrasse
ca14626120 scripts: build: update gen_relocate_app.py to use new argument separators
Update gen_relocate_app.py to use "|" to separate code relocation
directives, and ";" to separate multiple files in a relocation directive.
This will enable multiple files to be passed to zephyr_code_relocate,
as well as multiple files to be passed from a CMake generator expression.
The script will then seperate these files and relocate each according to
the arguments given to zephyr_code_relocate.

Note! This commit will break support for zephyr_code_relocate until
the CMake function is updated

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-17 18:08:37 +01:00
Chris Duf
92897ef011 python-devicetree: bump version to 0.0.2
Inconsistency between python-devicetree version numbers
may be confusing:
- the last version at PyPI is 0.0.2
- zephyr-rtos/python-devicetree/setup.py sets the version
  to 0.0.2 (this is probably the setup file used when uploading
  to PyPI)
- zephyr-rtos/zephyr/scripts/dts/python-devicetree/setup.py sets
  the version to 0.0.1

This may suggest that the mirror repository, and PyPI, are more
up-to-date than zephyr-rtos/zephyr/scripts/dts/python-devicetree.

Repositories being otherwise mostly identical (1), also bumping
the python-devicetree's version here seems a sane option.

(1) Ignoring the doc directory (only at zephyr-rtos/python-devicetree).

Signed-off-by: Chris Duf <chris@openmarl.org>
2023-01-16 11:19:54 +00:00
Chris Duf
436616c66b python-devicetree: unpin types-PyYAML version
This is essentially a revert of PR #46311 "python-devicetree: CI hotfix",
assuming the original issue has been resolved, either upstream in
types-PyYAML or in Zephyr itself.

Tested with types-PyYAML 6.0.12.2 (current version at PyPI):

  $ python -m mypy --config-file=tox.ini --package=devicetree
  dtlib.py:962: note: By default the bodies of untyped functions [...]
  dtlib.py:964: note: By default the bodies of untyped functions [...]
  dtlib.py:965: note: By default the bodies of untyped functions [...]
  dtlib.py:967: note: By default the bodies of untyped functions [...]
  Success: no issues found in 4 source files

The "notes" above are harmless (use of type hinting to define local
variables while mypy won't "check the bodies of untyped functions").

References:
- python-devicetree tox run fails (issue #46286)
- python-devicetree: CI hotfix (PR #46311)
- python-devicetree: CI hotfix (commit f6a6843)

Signed-off-by: Chris Duf <chris@openmarl.org>
2023-01-16 11:19:54 +00:00
Al Semjonovs
a7d6ca2bd9 west: west twister integration
Add twister command to west.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-13 15:39:04 -08:00
Al Semjonovs
d09fd2259f twister: move main to twisterlib/twister_main.py
This allows for ability to import main to be used
within west

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-13 15:39:04 -08:00
Al Semjonovs
067ba65e10 twister: Split up argument parsing into smaller functions
Split argument parsing into smaller functions to be leveraged
by west twister extension.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-13 15:39:04 -08:00
Tom Burdick
38385ed3ff twister: Platform key for test suites
Adds an option to inform twister a testsuite should only be built and
run for platforms with unique sets of attributes. This enables
for example keying on unique (arch, simulation) platforms to run the test
suite on.

The most common usage may be test suites configured to run once per
(arch, simulation) pair as being enough. Additional information about
platforms may enable running a test once per hardware IP block or once
per soc family or soc avoiding duplicated effort in building and running
tests when once suffices.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-12 10:30:57 -05:00
Anas Nashif
73584dfe8d twister: support namespacing of extra configs
We want to be able to have platform or architecture extra configs
without having to duplicate a whole section of the test specification.

This adds support for namespacing of extra configs, for example:

arch:nios2:CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

or

platform:qemu_x86:CONFIG_FOO=y

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-12 10:00:05 +01:00
Anas Nashif
5fd629b48b twister: package artifacts for testing
Package artifact for later use with --test-only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-11 10:35:08 -05:00
Anas Nashif
3ae7b250c7 twister: do not log on waiting for devices
Do not log anything about waiting for devices, this is very noisy in
some environments.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-11 10:35:08 -05:00
Anas Nashif
1ffeaac92a twister: improve handling of artifacts with --prep-artifacts-for-testing
Previous commit dealing with cleanup (c304db56f1) was not taking
--prep-artifacts-for-testing into consideration. Fix this and make sure
we do cleanup when this option is enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-11 10:35:08 -05:00
Anas Nashif
21077b7cf2 twister: support custom test binaries
Have boards define what binaries should be kept for device testing. The
purpose of this is to reduce the amount of artifacts and just keep the
binaries needed for flashing a device, reducing the size of the final
payload.

A board can have twister keep multiple binaries needed for testing when
--prep-artifacts-for-testing option is used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-11 10:35:08 -05:00
Henrik Brix Andersen
d151424a6d scripts: west: runners: canopen: add SDO block transfer support
Add SDO block transfer support for the CANopen program download west
runner. SDO block transfers are experimental in the underlying CANopen for
Python.

Reduce the program download chunk size to half the program download buffer
size to avoid blocking IO.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-11 09:39:57 +01:00
Grzegorz Chwierut
f016761859 twister: fix hardware map updates
When re-generating hardware map for DKs with more than 1 serial port (more
enries in the hardware map), then we keep enfo only about the last entry.
For boards like nrf5340 it works, because the last serial port is used,
but for nrf52840 with two ports, the first one is important, so after
re-generating the hardware map it does not work.
The solution is to keep all entries after re-generating the hardware map.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-11 09:39:03 +01:00
Stephen Stauts
d4b8db792d scripts: kconfig: Add functions for array/chosen props
Expands kconfigfunctions to include checks for value existence in
an array property by nodelabel, or a chosen's boolean prop value.

Signed-off-by: Stephen Stauts <stephen.stauts@nordicsemi.no>
2023-01-10 07:10:07 -08:00
Fabio Baltieri
9d3681c10c scripts: compliance: add support for YAMLLint
Add a YAMLLint compliance check that uses the yamllint package to report
linting error on YAML files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 17:29:23 +01:00
Moritz Fischer
7dd05967f7 scripts: dts: gen_driver_kconfig_dts: Use SafeLoader
Using SafeLoader is preferrable where possible.

Signed-off-by: Moritz Fischer <moritzf@google.com>
2023-01-04 07:38:56 -08:00
Maciej Perkowski
474a8cf25f twister: bugfix: Make elf scan more precise.
When scanning for available elfs, twister discards ones with `_pre`
in their name, to not include prebuilds like 'zephyr_pre0.elf`.
However, the scan looks at the whole test name. If _pre is in the name
(e.g. _precision) it would be wrongly discarded ending with twister
reporting error that no elfs were found. This commit makes the discard
to look only at the last part of the name (i.e. not including test name
but only a lowest level, where zephyr.elf etc are located.)

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2023-01-04 08:48:16 -05:00
Fabio Baltieri
0daa3a78a9 yamllint: indentation: fix files in scripts/
Fix the YAML files indentation for files in scripts/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Fabio Baltieri
7dd902d035 yamllint: fix all yamllint comments-indentation errors
Fix all comments-indentation errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(comments-indentation)'

This checks that the comment is aligned with the content.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Fabio Baltieri
5c32300861 yamllint: fix all yamllint truthy errors
Fix all thruthy errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(truthy)'

This only accepts true/false for boolean properties. Seems like python
takes all sort of formats:

https://github.com/yaml/pyyaml/blob/master/lib/yaml/constructor.py#L224-L235

But the current specs only mention "true" or "false"

https://yaml.org/spec/1.2.2/#10212-boolean

Which is the standard yamllint config.

Excluding codeconv and workflow files, as some are using yes/no instead
in the respective documentation.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Yuval Peress
47b675c6ee twister: Set a default gcov-tool for llvm
When using llvm we need to set the gcov-tool to "llvm-cov gcov" but
the lcov tool is incapable of passing arguments to the gcov-tool. i.e.
the following cannot work:

$ lcov --gcov-tool "llvm-cov gcov" ...

Instead, create a symlink to llvm-cov prefixed as `gcov` which by the
documentation of llvm-cov will alias to `llvm-cov gcov` subcommand.

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-03 11:01:16 +01:00
Fabio Baltieri
f33d43795d scripts: compliance: add a check for MAINTAINERS.yml format
Add a compliance check that tries to load MAINTAINERS.yml with
get_maintainer.Maintainers() if it's been modified by the CL, and fail
compliance if it fails to be parsed.

Example output:

```
ERROR   : Test MaintainersFormat failed:
Error parsing MAINTAINERS.yml: MAINTAINERS.yml: YAML error: while
scanning a simple key
  in "MAINTAINERS.yml", line 976, column 1
could not find expected ':'
  in "MAINTAINERS.yml", line 977, column 3
```

```
ERROR   : Test MaintainersFormat failed:
Error parsing MAINTAINERS.yml: MAINTAINERS.yml: glob pattern
'drivers/regulator' in 'files' in area 'Drivers: Regulators' matches a
directory, but has no trailing '/'
```

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-29 14:42:02 +01:00
Martí Bolívar
374411dfaf west: runners: improve pyocd runner test coverage
Make sure that this runner can handle multiple --tool-opt arguments,
and that the options specified for pyocd are passed to that tool in
order.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-12-29 10:36:02 +01:00
Fabio Baltieri
e7a4aec3c9 scripts: compliance: check for bindings in subdirectories
Change the bindings file filter to check for "dts/bindings/" as a
substring rather than prefix. This makes the check catch files in
subdirectories as well (for sample tests and samples), and makes the
check usable on external projects where the bindings may not live in the
project root.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-28 19:01:57 +01:00
Fabio Baltieri
5bf79ed9cd scripts: compliance: use get_files filter for dts checks
Drop the custom logic to skip deleted files, use get_files filter
instead.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-28 19:01:57 +01:00
Fabio Baltieri
afc2ad34bd scripts: compliance: move binding file cycle in run()
Move the file iteration loops of the bindings compliance check in the
callers, so that if we add more checks we don't have iterate on each one
of them and a check works on a single file.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-28 19:01:57 +01:00
Fabio Baltieri
ab4d87dd41 scripts: compliance: add an ImageSize check
Add a check to validate and limit the size of images in the repository,
setting stricter limit for files in boards/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-22 17:01:54 +01:00
Fabio Baltieri
30fd28d9f0 scripts: compliance: move isfile() check in get_files()
Git normally only works on files, but can include directories if there's
any submodule in the repository. This is currently checked in
filter_py(), move the check into get_files() so it does not have to be
copied around.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-22 17:01:54 +01:00
Fabio Baltieri
5d23505336 scripts: compliance: fix DevicetreeBindingsCheck
DevicetreeBindingsCheck is missing the splitlines() call to process the
get_files() output, hence cycling through each character of the output
rather than each file, which causes the check to never run on anything.

Fix it by moving the splitline call into get_files() itself, since every
caller is going to use it anyway.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-12-22 17:01:54 +01:00
Dominik Ermel
d492c0d79a scripts/utils/migrate_mcumgr_kconfigs.py: Script for migrating MCUmgr
Script that provides aid with converting project files to
new Kconfig option names.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-12-22 12:36:34 +01:00
Tristan Honscheid
ea33f2fce4 twister: Allow passing additional args to native_posix test binary
This commit expands Twister's CLI so that arguments passed after
a double dash (`--`) get forwarded to the ztest test executable when
run. When built for native_posix, ztest provides a useful CLI that
allows filtering individual suites and tests, adjusting timing settings,
and controlling the shuffling seed. Currently there is no easy way to
use these (with the exception of `--seed`) without needing to dig out
the resulting `zephyr.exe` binary from the build dir and invoke it
manually.

 ### Examples

Run a specific ztest suite only (useful when writing tests and you don't
want to run a long testcase in its entirety)

```
$ scripts/twister \
    -p native_posix \
    -s
zephyr/tests/lib/cmsis_dsp/complexmath/libraries.cmsis_dsp.complexmath \
    -- -test=complexmath_q31::*
```

Unrecognized arguments that precede the double dash will result in an
error message:

```
$ scripts/twister \
  -p native_posix \
  --foobar 123 \
  -- -test=basic_math_q7::*

...
Unrecognized arguments found: '--foobar 123'. Use -- to delineate extra
arguments for test binary or pass -h for help.
```

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-12-20 23:35:36 -05:00
Keith Short
42f746c8d0 clang-format: Enable InsertBraces option
Zephyr's coding guidelines require braces on every code block body.
Enable InsertBraces option so clang-format automatically adds these
braces.

Signed-off-by: Keith Short <keithshort@google.com>
2022-12-20 22:51:57 +01:00
Carles Cufi
c0455b836f scripts: ci: compliance: Remove Codeowners check
This check is no longer used and will be replaced by the maintainers
file, remove it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-12-20 17:34:35 +01:00
Stephanos Ioannidis
6bf275a8ca hardening: Require CONFIG_TIMER_RANDOM_GENERATOR=n
This commit adds the requirement for the `TIMER_RANDOM_GENERATOR`
Kconfig to be set to `n` because it enables timer-based pseudo-random
number generator, which is only intended to be used for testing
purposes.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-15 22:35:31 +01:00
Anders Bjørn Nedergaard
53227f1f13 scripts: migrate_includes: add .hpp to extension list
The script will now also migrate includes in files with the suffix `hpp`.

Signed-off-by: Anders Bjørn Nedergaard <ape.anp@gmail.com>
2022-12-15 10:29:46 +01:00
Stephanos Ioannidis
0e5762e56e scripts: compliance: Fix misdetection of Kconfig choices as undefined
This commit updates the KconfigCheck to add the Kconfig symbols from
both "config" and "choice" symbol lists to the defined symbol list, as
opposed to the "config" list only, in order to prevent any references
to the choice symbols outside the Kconfig files (e.g. in documentation)
from being reported as undefined.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-13 17:20:10 +09:00
Tristan Honscheid
ae97971a61 gitlint: Add "commit" to violation messages
This PR clarifies the violation messages emitted by gitlint when
checking the commit message. For example:

 * Before: `43: UC4 Line exceeds max length (N>75): "..."`
 * After: `43: UC4 Commit line exceeds max length (N>75): "..."`

This makes it easier to identify the source of the error since there is
currently no additional context besides the error code UC*. I recently
pushed a commit that had some sample code as part of the commit body
that exceeded the lenght limit, and thought the error was referring to
one of my source files based on the line it showed. (feel free to laugh
at me, but let's make it better for the next person)

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-12-07 07:58:05 -05:00
Madhurima Paruchuri
fa738b0f74 usb-c: Generate USB-C connector VIF policies XML file
Generates XML file containing VIF policies by reading the device tree
using EDT.pickle generated during build
This script writes a subset of general and sink-pdo VIF policies in
output file
This script gets invoked during build if enabled through kconfig
The generated XML containing USB-C VIF policies could be used by
USB PD/Type-C analysers/testers to understand USB-C properties and
perform tests accordingly

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2022-12-02 08:46:04 -06:00
Anas Nashif
bbf03fd991 ci: twister: fixed path for tag based filtering
path for posix was not being matched correctly due to a missing /. So
some posix tests were excluded and not excercised.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-12-02 07:31:37 -05:00
Gerhard Jörges
87a751c266 west: runners: add file argument
adds --file argument to west flash/debug as described in #52262.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-12-01 06:53:58 -08:00
Håkon Øye Amundsen
325e35036b checkpatch: update --exclude docs
The current docs are incorrect as comma separated paths
are not working. Providing a separate --exclude argement
per path does however work.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2022-12-01 15:48:30 +01:00
Anas Nashif
1217d850f5 twister: instance: fix layout
Fix indentation of return.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-12-01 06:07:30 -05:00
Anas Nashif
3677a10834 twister: ignore unit tests/EFI images with --show-footprint
Ignore unit tests and EFI binaries when calculating footprints with
--show-footprint, or we will get a build error.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-12-01 06:07:30 -05:00
Gerard Marull-Paretas
2cee5ff519 scripts: west_commands: runners: remove deprecated options
The --snr (nrfjprog) --id (jlink) and --board-id (pyocd) options were
deprecated a long time ago in favor of --dev-id. It is time to remove
them.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-30 14:15:30 +01:00
Katarzyna Giądła
14358aee1c twister: get information about memory footprint from build.log
This commit calculate memory footprint from build.log and
proposes an alternative approach to #2465.

Signed-off-by: Katarzyna Giądła <katarzyna.giadla@nordicsemi.no>
2022-11-29 16:17:32 -05:00
Evgeniy Paltsev
ae79de1930 ARC: MWDT add TLS support
Add thread local storage support for ARC MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:23 +01:00
Anas Nashif
ef7d0d6c01 twister: fix simulation conditional
non-simulation platforms set key to 'na', we need to check for that
instead of just checking for existance of key.

Fixes #52595

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-28 10:47:32 -08:00
Carles Cufi
76499a6127 scripts: compliance: Move Kconfig-related items to the class
Both get_defined_syms and UNDEF_KCONFIG_WHITELIST are used exclusively
by the Kconfig check, so move them to the class.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Carles Cufi
b8a6a510aa scripts: compliance: Resolve ZEPHYR_BASE in _main()
Instead of globally resolving ZEPHYR_BASE, move it to _main() so we can
catch potential exceptions when doing so and for consistency with the
rest of globals, like GIT_TOP. This also includes documenting a new
"<zephyr-base>" path hint for classes.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Carles Cufi
e60c1e024b scripts: compliance: Clean up ZEPHYR_BASE usage
The global variable ZEPHYR_BASE is always set in the script, so no need
to check for its existence.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Carles Cufi
5f094fbbf5 scripts: compliance: Make line optional in fmtd_failure()
Some errors are attributable to a specific file, but not a specific line
within that file. Allow for formatted errors that refer to a file but
not a line.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Carles Cufi
28c2932a1d scripts: compliance: Consolidate 'git diff' calls in get_files()
Many tests invoke `git diff` independently with very similar parameters
to obtain a filtered list of files.
Consolidate those into a new `get_files()` function.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Carles Cufi
5fbfd72f9d scripts: compliance: Remove old TODO
This TODO doesn't seem to apply anymore based on its description, so
remove it altogether.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Carles Cufi
bafec6bbde scripts: compliance: Remove unneeded workaround
The workaround for old pytest bug
https://github.com/PyCQA/pylint/issues/2906
is not required anymore after more than 3 years, so remove it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-29 01:40:33 +09:00
Anas Nashif
808266a493 tests: use ignore_fault field instead of tags
Use dedicated field in the yaml file instead of mixing this testing
feature with tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:38:05 -05:00
Anas Nashif
a90d711c7d twister: add simulation handler
Simplify the code a bit by introducing a simulator handler class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Anas Nashif
dae4720703 boards: native: mark as simulator
Mark native_posix platform as a simulator.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Anas Nashif
3bd819c09d twister: treat default platforms without a mean to run as any other
If a default platform is not able to run for whatever reason, treat it
as any other platform. Default platforms shall ALWAYS be runnable in CI,
or else we are just re-building for no good reason.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Anas Nashif
3e870495f2 boards: add simulation executable for 3rd party sims
Provide the information as part of the board yaml file, this way we will
know what binary to check for.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Hake Huang
70553a64a3 test: twister: add more exception protection
the ser.in_wait sometime meet issue like serial handler error.
This is because the serial port is in reset status.
add final protection to retry later

error log:

Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "zephyr/scripts/pylib/twister/twisterlib/handlers.py", line 345,
    in monitor_serial
    if not ser.in_waiting:
  File "~/python3.10/site-packages/serial/serialposix.py", line 549,
     in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 9] Bad file descriptor

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2022-11-25 10:46:30 +01:00
Carles Cufi
a4600b0470 scripts: compliance: Use f-strings when appropriate
There were many instances in the code where f-strings were more
appropriate or fitting, change those to use them.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-24 09:34:25 +01:00
Carles Cufi
ba295755ce scripts: compliance: Add Nordic copyright
Add Nordic Semi as a contributor to this file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-24 09:34:25 +01:00
Carles Cufi
4654bb6a1e scripts: compliance: Clean up import statements
Sort them alphabetically and by stdlib vs 3rd-party modules.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-24 09:34:25 +01:00
Carles Cufi
d9aa61f74e scripts: compliance: Use subprocess.run()
As per the current Python documentation, use subprocess.run() since the
other, older methods are not recommended anymore.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-24 09:34:25 +01:00
Carles Cufi
b7cb3af443 scripts: compliance: checkpatch: Fix regex
The checkpatch regex matched too greedily, so that descriptions with ":"
would match too much, example:

-:20: ERROR:SPACING: spaces required around that '=' (ctx:VxW)

Would match "SPACING: spaces required around that '=' (ctx" instead of
just "SPACING".

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-24 09:34:25 +01:00
Andrzej Głąbek
6c21c9635d scripts: gen_relocate_app: Fix a typo in parse_input_string()
This is a follow-up to commit b1a3ce4016.

`parse_input_string()` needs to use `:NOCOPY:`, not `:NOCOPY`, when
partitioning input lines, otherwise, when a line contains the NOCOPY
flag, the file name returned by the function starts with `:` and the
file cannot be then found by the script.
Such problem can be observed in the code_relocation_nocopy sample,
which without this fix does not actually relocate code from ext_code.c.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-11-23 16:49:03 -05:00
Fabio Baltieri
7b57d3c5bb scripts: compliance: check for binary files
Add a compliance check that fails if the diff is adding any binary file
to prevent committing them by mistake.

Only check for added files and explicitly allow image files in doc/ and
boards/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-11-21 16:12:04 -05:00
Carles Cufi
49b01b39b6 scripts: compliance: Remove unconditional debug output
This prevents us from parsing the scripts' output correctly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 11:02:39 -05:00
Carles Cufi
66ad0e68a6 scripts: compliance: Use consistent naming convention
Tests are named with CamelCase in general, use that in the names.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 11:02:39 -05:00
Carles Cufi
8c12efe2e5 scripts: compliance: Make test filtering case insensitive
To simplify using the -m and -e command-line options make the test
filtering case insensitive.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 11:02:39 -05:00
Carles Cufi
95053c8358 scripts: compliance: Fix DT Bindings check name
Check names must not contain spaces, since they are passed via `-m` in
the command-line.

Also update .gitignore and compliance.yml.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 11:02:39 -05:00
Carles Cufi
8275457709 scripts: compliance: Fix wrong call
Fix call to parse_dt_bindings() in the Devicetree Bindings check.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 11:02:39 -05:00
Veijo Pesonen
606515c6c4 scripts: requirements: extras: add zcbor
Add ZCBOR to the requirements-extras.txt and require at least version
0.6.0 which is the current version of the ZCBOR C library.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-11-21 16:11:04 +01:00
Cong Nguyen Huu
c304db56f1 twister: add option cleanup all tests
add 2 choices for '--runtime-artifact-cleanup' option,
'passing' to delete artifacts of passing tests,
'all' to delete artifacts of both passing tests
and failing tests

keep testcase_extra.config, it contains some extra Kconfig
needed for the tests and they is only generated first time
when run retry failed

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2022-11-21 08:39:13 -05:00
Daniel DeGrasse
6aa7194d48 scripts: kconfig: add dt_node_has_compat kconfig function
Add dt_node_has_compat kconfig function, to check if a node path has a
given compatible string while parsing kconfig files

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-11-21 13:03:26 +01:00
Daniel DeGrasse
db9bcd90ce scripts: kconfig: add dt_node_parent kconfig function
Add dt_node_parent kconfig function, to get parent path for a given
devicetree path when parsing kconfig files

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-11-21 13:03:26 +01:00
Chris Friedt
5e7a86e1f9 scripts: compliance: add devicetree binding compliance check
Add `DevicetreeBindingsCheck` and `required_false_check()`, which
checks to make sure that no new Devicetree bindings add the
redundant `required: false` property.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-20 13:12:44 -05:00
Anas Nashif
ae24329daa twister: show duplicates correctly
Find duplicate test identifiers and report them with
--list-test-duplicates.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-18 09:19:47 -05:00
Gerard Marull-Paretas
537133fe44 devicetree: edtlib: tests: add coverage for child includes
Add test coverage for the child-binding include feature. It includes
verification of included properties as well as usage of allow/blocklist.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-17 06:57:46 -06:00
Joe Perches
6cdeefcabb checkpatch: improve the indented label test
checkpatch identifies a label only when a terminating colon
immediately follows an identifier.

Bitfield definitions can appear to be labels so ignore any
spaces between the identifier terminating colon and any digit
that may be used to define a bitfield length.

Miscellanea:

o Improve the initial checkpatch comment
o Use the more typical '&&' instead of 'and'
o Require the initial label character to be a non-digit
  (Can't use $Ident here because $Ident allows ## concatenation)
o Use $sline instead of $line to ignore comments
o Use '$sline !~ /.../' instead of '!($line =~ /.../)'

Link: https://lkml.kernel.org/r/b54d673e7cde7de5de0c9ba4dd57dd0858580ca4.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Manikishan Ghantasala <manikishanghantasala@gmail.com>
Cc: Alex Elder <elder@ieee.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-11-17 01:02:03 +09:00
Daniel DeGrasse
a766e4c4fb scripts: Fix header ifdef guard for gen_image_info.py
gen_image_info.py was generating invalid include guard. Properly strip
all special characters from filename to generate include guard #ifdef

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-11-15 14:46:02 +01:00
Daniel DeGrasse
c303c6fae7 scripts: pylib: remove west log dependency from domains.py
Convert domains.py to use basic python logging module implementation to
remove west logging dependency. This removes hard dependency on west from
twister.

Fixes #51731

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-11-14 10:12:31 +00:00
Maciej Perkowski
45e1ff94cd twister: tests: Add unit tests for names of external and module tests
Add test cases verifing that test id for external and module tests is
not --testsuite-root dependant.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-11-13 17:45:09 -05:00
Maciej Perkowski
21eb27c5c0 twister: Update path structure for tests
With the patch a relative path between a test and west's project top
directory is always calculated instead of being relative to zephyr
base. The test names and results structur change by addition of one
level. This way the names/structure conventon for tests from zephyr and
modules is alligned.
For external tests ".." parts are replaced with "external".
This allows to maintain unified folder structure also for results of
external tests.
Without this patch the folder/name allignment is lost for
external and module test becaming depandant on a way how
twister was called.
.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-11-13 17:45:09 -05:00
Maciej Perkowski
e27c9fe6b9 twister: tests: Fix os.path.join usage in twister unit test
From docs "If a component is an absolute path, all previous
components are thrown away and joining continues from the
absolute path component." This commit fixes the args and
corrects the expected value.
https://docs.python.org/3/library/os.path.html#os.path.join

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-11-13 17:45:09 -05:00
Carles Cufi
1e203ea15e scripts: compliance: Ensure lxml is installed
See https://github.com/weiwei/junitparser/issues/99.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Carles Cufi
1951071f14 requirements: Add lxml as a requirement
junitparser has a bug that prevents it from working correctly when lxml
is not installed.

See this GH issue for more information:
https://github.com/weiwei/junitparser/issues/99

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Carles Cufi
1ee0d60990 scripts: compliance: Parse the pylint output
Parse the output generated by pylint and store it as FmtdFailure
instances, so that they can be annotated later.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Carles Cufi
edd2c83dd4 scripts: compliance: Modernize pylint invocation
The current recommended API call for subprocess instantiation is run(),
so replace the low-level Popen and communicate() with it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Carles Cufi
8275d21a6c scripts: compliance: Add GitHub-compatible annotation support
Add support for GitHub workflow annotations, so that errors are
displayed inline with the Pull Request diff.

More info here:
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#about-workflow-commands

Enable the new option in the compliance GitHub action.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Carles Cufi
89c3885c28 scripts: compliance: Add a new formatted failure method and class
Format the JUnit failure according to the standard:
https://www.ibm.com/docs/en/developer-for-zos/14.2?topic=formats-junit-xml-format

This also includes a new FmtdFailure class, which will be used in
subsequent commits to implement GitHub-compatible annotations. A list of
FmtdFailure instances is kept in the ComplianceTest instance because
the TestCase instance cannot restore classes derived from Result that
the junitparser module doesn't know about.

Use the new function to format checkpatch errors.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Carles Cufi
e9415cf929 scripts: compliance: Rename add_failure to failure
For consistency with error() and skip(), rename add_failure() to
failure().

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-13 06:25:59 -05:00
Emil Gydesen
08c5a826e9 footprint: Update conf files for nrf5340_cpunet rpmsg
Update the configuration files for the footprint
tracking for the nrf5340dk_nrf5340_cpunet iso-broadcast
and iso-receive, after the files were recently renamed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-11-11 08:46:46 +00:00
Martí Bolívar
b907f74326 runners: trace32: mypy fixes
Fixes for the following issues that a new version of mypy started
reporting recently:

runners/trace32.py:34: error: Incompatible default for argument
"startup_args" (default has type "None", argument has type
"List[str]") [assignment]

runners/trace32.py:137: error: Incompatible default for argument
"cfg" (default has type "None", argument has type "Path") [assignment]

runners/trace32.py:34: note: PEP 484 prohibits implicit Optional.
Accordingly, mypy has changed its default to no_implicit_optional=True

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-09 11:10:09 -05:00
Mariusz Skamra
8bbd2e1488 footprint: Add unicast_audio_{server, client} samples to tracking
Add a Bluetooth unicast audio samples to track their footprint.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-11-09 09:40:01 +00:00
Carles Cufi
2e66fac6d3 scripts: compliance: Fix inheritance of KconfigBasicCheck
KconfigBasic should not be inheriting from both KconfigCheck and
ComplianceTest. This was a workaround to find all inheritors of
ComplianceTest, so fix the inheritors search instead.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-08 07:20:21 -05:00
Carles Cufi
aed9622a1e scripts: compliance: Allow for custom message and type
Instead of arbitrarily storing the string provided by the caller in
either the message attribute or the element text, let the reporter
choose instead.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-08 07:20:21 -05:00
Carles Cufi
72fde1b9b3 scripts: compliance: Generate one Result per issue encountered
Instead of accumulating failure information in a single Result instance,
located at index 0, generate one Result sub-class instance per
failure/error/skip as it is intended in the original library.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-08 07:20:21 -05:00
Carles Cufi
5ae70b9b77 scripts: compliance: Use standard TestCase class
No need to define a custom class anymore.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-08 07:20:21 -05:00
Carles Cufi
f090efa793 scripts: compliance: Remove unused info message handling
No need to keep this in the tree if it's not used at all.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-08 07:20:21 -05:00
Carles Cufi
c3933561b0 scripts: compliance: Use text setter/getters
The junitparser Python module now comes with a setter and getter for
Result.text, use them instead of peeking into the underlying XML.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-08 07:20:21 -05:00
Tom Burdick
e3d877f811 rtio: Userspace support
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.

For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.

The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-08 10:44:03 +01:00
Anas Nashif
e2cd634185 ci: also upload results of twiser a week full builds
Upload results of full runs we do twice a week to opensearch.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-07 14:20:02 -06:00
Martí Bolívar
a97295b6a2 edtlib: re-appease the linter
At some point in the past, we had to suppress a couple of false
positive pylint warnings to pass CI. But now the linter seems to have
figured out its original mistake and is complaining about a useless
supression. Sigh. Play along.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
15e3e317f7 dtlib: implement copy.deepcopy() for DT
The standard library copy module allows you to implement shallow and
deep copies of objects. See its documentation for more details on
these terms.

Implementing copy.deepcopy() support for DT objects will allow us to
"clone" devicetree objects in other classes. This in turn will enable
new features, such as native system devicetree support, within the
python-devicetree.

It is also a pure feature extension which can't harm anything and is
therefore safe to merge now, even if system devicetree is never
adopted in Zephyr.

Note that we are making use of the move from OrderedDict to regular
dict to make this implementation more convenient.

See https://github.com/devicetree-org/lopper/ for more information on
system devicetree. We want to add system devicetree support to dtlib
because it seems to be a useful way to model modern, heterogeneous
SoCs than traditional devicetree, which can really only model a single
CPU "cluster" within such an SoC.

In order to create 'regular' devicetrees from a system devicetree, we
will want a programming interface that does the following:

   1. parse the system devicetree
   2. receive the desired transformations on it
   3. perform the desired transformations to make
      a 'regular' devicetree

Step 3 can be done as a destructive modification on an object-oriented
representation of a system devicetree, and that's the approach we will
take in python-devicetree. It will therefore be convenient to have an
efficient deepcopy implementation to be able to preserve the original
system devicetree and the derived regular devicetree in memory in the
same python process.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
3c976cc3b6 devicetree: stop using OrderedDict
Regular dicts are insertion-ordered since CPython 3.6 and Python 3.7.
Zephyr now requires Python 3.8, so it should be OK to replace
OrderedDict with regular dict now. This results in less typing and
more readable object representations.

A nitpicker could argue that this is a functional change, since if a
user is doing 'assert isinstance(node.props, OrderedDict)', that will
fail now, but:

 1. nobody is doing something like that in the zephyr tree
 2. that would be a silly thing to do
 3. we don't currently make any API stability guarantees
    for this module right now anyway

so it should be fine.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
c25dde3511 dtlib: fix Property.labels docstring
The value of the 'labels' attribute is a list, not a set.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
b64d5d6d19 dtlib: move some internal code around
Refactor the file parsing methods for readability by moving the
_parse_header() and _parse_memreserves() calls from _parse_dt() to
_parse_file(). The header and memreserves are not part of the 'tree'
part of the devicetree; now that we have a dedicated _parse_file()
helper, it makes more sense to me to have them there.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
c875cb0f94 dtlib: fix Property.type type annotation
Holy overloaded technical terms, Batman.

Here, 'property' and 'type' each mean two different things, which
we can distinguish like this:

- Property (capital P): dtlib.Property class, represents
  a property in a devicetree node
- @property: a Python property
- type(): an "@property" in the Property class, that returns
  a dtlib.Type value
- Type (capital T): dtlib.Type class, represents the devicetree
  type of a Property value (dtlib.Type.BYTES, etc.)

The type() @property in the Property class currently has an 'int' as
its Python return type annotation. It really returns a dtlib.Type,
which is an int (since it's an IntEnum), but that's not the same thing
as an int.

Change this to Type to be clear that not just any int can be returned
by this @property.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
cd18ffee22 dtlib: clean up Property initialization
Make attribute initialization order match the order that attributes
appear within the class docstring. Move the 'type' property definition
up by the constructor to make it more obvious that this 'attribute' is
a (Python) property. This is for readability.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
47789aa1fa dtlib: clean up Node initialization
Reorder attribute initialization to match the order that attributes
appear in the class level docstring. This is for readability.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Martí Bolívar
cb78a5c322 dtlib: clean up DT initialization
Initialize all the public API interface related attributes within the
constructor instead of scattering them throughout the implementation
of the class, and make sure they all have type annotations.

Move all the parsing code away from the init routines and public API
down to the main parsing block.

This is for readability and paves the way for later changes that
affect the way initialization happens.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-07 19:00:31 +01:00
Anas Nashif
8f5d0a77b0 twister: set both commit and run date in json report
Version is not enough, we need the run date but also the commit date, to
ease reporting and use in dashboards.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-06 22:27:07 -05:00
Anas Nashif
148a6e2ee1 twister: do not recorde a null version
In some scenarios we might end up with a null version value in the json
file, if the version can't be determined, set it to Unkown instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-06 22:27:07 -05:00
Ederson de Souza
b1a3ce4016 scripts/build: Add program header support for gen_relocate_app.py
Some linker scripts also associate memory regions with program headers
(PHDRS [1]). This patch adds support on gen_relocate_app.py to also
place a phdr alongside the memory region.

To keep things simple (and more natural), the format is basically the
same used in linker scripts - an space followed by ':<phdr_name>', like:

  SRAM2\ :phdr0:COPY:/home/xyz/zephyr/samples/hello_world/src/main.c

(Note the escape char before the space.)

[1] https://sourceware.org/binutils/docs/ld/PHDRS.html

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-11-03 10:25:07 +01:00
Anas Nashif
662aed81d2 actions: Upload test results to opensearch service
On push, upload test results to opensearch for analysis and reporting.
Goal is to use this data to understand test coverage better and use this
services for all test reporting, also for results coming from testing on
hardware.
Opensearch is currenly being used for evaluation, we are considering
the switch to elasticsearch later.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-02 10:26:43 -04:00
Anas Nashif
b89a3d955a twister: count retries after failures or errors
When twister is set to retry any failures, count the number of retries
and record the number in the json file. This will help us identify
unstable tests or tests requiring attention.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-31 12:33:28 -04:00
Filip Zajdel
4508681020 kconfig: wrap description in guiconfig
Modify description frame to wrap the text so the window
doesn't have to be scrolled horizontally.

Signed-off-by: Filip Zajdel <filip.zajdel@nordicsemi.no>
2022-10-31 23:23:46 +09:00
Carles Cufi
192d01eea1 checkpatch: Document both endianness macros
Both CONFIG_BIG_ENDIAN and CONFIG_LITTLE_ENDIAN can be used in the code,
so reflect that in the error message in checkpatch.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-28 22:06:17 +09:00
Carles Cufi
43ae4a7025 checkpatch: Disallow using __BYTE_ORDER__
The canonical way of determining endianness is now CONFIG_BIG_ENDIAN
instead in Zephyr.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-28 19:23:46 +09:00
Adrian Bonislawski
30e4a4b71e west: sign: remove -i 3 parameter
in some builds there is need to pass different value for -i parameter
and current code will override it to 3
Also in rimage i parameter is by default set to 3

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-10-27 11:02:35 +02:00
Daniel DeGrasse
b579a44e9c scripts: twister: update twister to support QEMU platforms with sysbuild
Update twister to support running QEMU platforms with sysbuild, by parsing
domains.yaml and executing the "run" target of the default application.
This will allow twister to test QEMU targets with sysbuild. It is assumed
that QEMU targets will add any external images they need in the build
phase

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00
Daniel DeGrasse
6a5b88e523 scripts: west: move domains.py to a generic library folder
Since twister can make use of domains.py as well, refactor west's use
this file so that domains.py can be moved to a generic library folder.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00
Jeremy Bettis
a84c271e58 twister: Fix OUTPUT: blank lines after test end
When running twister -vv many blank lines would be logged.

Fix handing of empty lines from the reader thread. Real blank likes will
be b"\n" not b"".

Change open call to use with, and logger to use %s to fix pylint
warnings.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-10-25 09:28:15 -04:00
Markus Swarowsky
1fb23b6509 west: nrfjprog: Allow flashing UICR without erase
Currently, it is not possible to use a normal flash command to flash two
hex files that contain data in the UICR region, even though these
data don't conflict with each other.
However, that is not a technical limitation of the device, but of the
nrfjprog runner as it fails as soon as the hex file contained UICR data
and there was no --force/--erase/--recover used.
That approach was used in the past as program operation was used
without --verify, but as this option was added a while ago it is an
unnecessary limitation.

If the UICR wasn't erased before programming, the verify of the program
operation will now fail, so giving the user a warning in this case that
the hex files contain data in the UICR will still give the user a hint
of what might have caused the failing verify.
Additionally, it enables partial programming of the UICR without the
use of the --force option.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2022-10-24 21:35:24 +02:00
Piotr Węgliński
08eb361846 ci: twisterlib: Modify the overlay regular expression
Modify the regex used to merge overlays specified for
test samples in twister tests.
Overlays without any prefixes will be merged and passed to cmake.
Overlays with prefixes won't be merged but passed to cmake as they are.

Signed-off-by: Piotr Węgliński <piotr.weglinski@nordicsemi.no>
2022-10-24 08:26:17 -04:00
Stephanos Ioannidis
faf4208295 scripts: set_assignee: Make review requests more deterministic
When there are more than 15 reviewers, the `set_assignee` script was
adding the reviewers more or less on a random basis because the input
set was arbitrarily ordered (thanks to how Python "set" works), and the
attempt to add any reviewers beyond the count of 15 results in the
previoulsy added reviewer being removed.

This commit updates the `set_assignee` script such that:

1. The collaborator list (input for generating the reviewer list) is
   ordered by the area match, such that the collaborators of the most
   relevant area come first.

2. The reviewers of the relevant areas are added first, until the total
   reviewer count is 15. The script does not attempt to add more than
   15 reviewers because that can result in the previously added
   reviewers being removed from the list.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-10-20 23:52:49 +09:00
Ming Shao
75914111d9 twister: fix the mis-placed drain logic.
The logic to drain the leftover logs of previous test should be
put before the monitor_serial(). It was misplaced when re-adding
this logic back.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-20 15:42:25 +02:00
Torsten Rasmussen
36ea41fad3 samples: introduce 'with_mcuboot' sample to show sysbuild feature
This sample is intended to show users how they can create a sample which
has dedicated configuration files for extra images included in a build.

MCUboot is used as example on how its default can be adjusted and
MCUboot itself automatically be included in the build when using
sysbuild.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-18 14:13:27 +02:00
Manuel Arguelles
31b3993d58 scripts: west: introduce Lauterbach TRACE32 runner
This patch introduces a West runner for flashing and debugging with
Lauterbach TRACE32 debuggers. The runner consists of a wrapper around
TRACE32 software, and allows a Zephyr board to execute a custom start-up
script (Practice Script) for the different commands supported, including
the ability to pass extra arguments from CMake. Is up to the board using
this runner to define the actions performed on each command.

The `debug` command launches TRACE32 GUI to allow debug the Zephyr
application, while the `flash` command hides the GUI and executes the
start-up script in a background process.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-10-14 09:51:14 +02:00
Anas Nashif
d8197f7535 ci: testplan: error out if we find mis-configured tests
If we find errors during test plan creation, stop execution and report
out the issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-13 06:23:46 -04:00
Anas Nashif
cc7d337ea7 twister: do not error on intentionally skipped tests
if we mark a test to be skipped, do not error in integration mode about
filter conflicts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-13 06:23:46 -04:00
Anas Nashif
6a5af72d66 twister: count errors identified during evaluation of tests
Some tests report errors based on configuration, those need to be
captured.

Fixes #51202.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-13 06:23:46 -04:00
Chris Duf
e067be5f0c Devicetree: edtlib: fix possible TypeError in Binding.__repr__()
Calling Binding.__repr__() when the attribute Binding.path is None
would raise TypeError: expected str, bytes or os.PathLike object,
not  NoneType.

Known bindings that may not have a path (Binding.path is None)
include bindings for properties such as 'compatible', 'reg', 'status'.

Signed-off-by: Chris Duf <chris@openmarl.org>

Co-authored-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-10-13 12:02:31 +02:00
Chris Duf
230c80e000 Devicetree: edtlib: fix possible AttributeError in Property.description
Attempting to access the property Property.description
when Property.spec.description is None would raise
AttributeError: 'NoneType' object has no attribute 'strip'.

Known properties that may not have a description
(Property.spec.description is None):
- 'compatible' for nodes such as / /soc /soc/timer@e000e010 /leds /pwmleds
- 'reg'        for nodes such as /soc/timer@e000e010
- 'status'     for nodes such as /soc/timer@e000e010
- 'gpios'      for nodes such as /leds/led_0 /buttons/button_0
- 'pwms'       for nodes such as /pwmleds/pwm_led_0

This patch checks the PropertySpec.description attribute before calling
strip(): will return None, and not raise AttributeError.

Signed-off-by: Chris Duf <chris@openmarl.org>

Co-authored-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-10-13 16:03:49 +09:00
Christopher Friedt
ef142c117e scripts: net: add enumerate_http_status.py
Add a script to extract HTTP status values and format them
in a way that is both human readable and machine parseable.

Each line of output is of the form:

```
HTTP_{key}_{upper_val} = {key}, /**< val */
```

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Chris Duf
5abce9b8ec Devicetree: edtlib: fix possible KeyError in Binding.description
Attempting to access the Binding.description property
when the description is unavailable would raise KeyError: 'description'.

Known bindings that won't define a 'description' key in the
Binding.raw dictionary include the 'compatible' property's binding
of nodes such as /, /soc, /leds or /pwmleds.
Note that this may also occur when a proper YAML
binding file is available (e.g. pwmleds.yaml).

This patch simply substitutes the Binding.raw dictionary indexing
with the get() function: will return None and not raise KeyError.

Signed-off-by: Chris Duf <chris@openmarl.org>
2022-10-12 18:45:32 +09:00
Gerard Marull-Paretas
882162357c scripts: build: gen_handles: use Z_DECL_ALIGN
Instead of hardcoding alignment size for pass 2 device handles, use
Z_DECL_ALIGN. This makes sure gen_handles.py is always in sync with the
type defined in device.h. The build assert in device.h can be removed as
a result, since we do not hardcode handles size anywhere else.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:11:47 +02:00
Evgeniy Paltsev
d9a64b7b23 twister: fix UnicodeDecodeError on input handling in BinaryHandler
In BinaryHandler we process input from simulator with decode('utf-8')
to convert it to string. decode has strict error handling by default -
so it raises UnicodeDecodeError exception if it can't decode input
binary sequence.

So if test start to print some junk to uart console we get
UnicodeDecodeError exception which cause the whole twister crash.

To fix that switch decode to less strict error handling when it
just replace undecoded binary sequence with unicode replacement
character.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-10-11 08:25:39 -04:00
Anas Nashif
b2a95831eb Revert "twister: temporarily disable mec15xx boards"
This reverts commit b3ead37efa.

This is no longer needed, pinmux was removed and deprecated.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 07:46:39 -04:00
Martí Bolívar
98bcc2d88e west: runners: blackmagicprobe: fix on windows
We need to give gdb slash-separated paths to ELF files on Windows.
Just make sure we always have slash-separated paths. We use this
technique in various places around the tree.

Fixes: #50789
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-10-10 09:54:14 +02:00
Erwan Gouriou
7b31b0e23c scripts: west_commands: openocd: Use 'reset init' by default
Instead of 'reset halt', default the command to reset and halt the target
to 'reset init'.

OpenOCD strictly requires 'reset init' to halt and prepare the device
before flash programming.
See https://openocd.org/doc/html/Flash-Commands.html chapter
"12.2 Preparing a Target before Flash Programming."

For targets implementing the init hook, it will allows to perform some
target specific init improvements (such as speed flash improvements).
Targets not implementing this hook will end up executing the usual and
previous 'halt'.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-10-07 12:19:46 -07:00
Maureen Helm
e73c363346 scripts: edtlib: gen_defines: Add model name macros based on compat
Follow up to 5b5aa6ebba adding model name
and existence macros for all compatibles of a node that match an entry
in vendor prefixes.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-07 11:48:02 -07:00
Emil Gydesen
4c7c36cae8 footprint: Remove bt_hap_ha for nrf52840dk
Remove the tracking of that sample as it does not build due
to missing BT ISO support.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-10-07 10:09:25 +00:00
Carles Cufi
2da82552f5 west: completion: bash: Clean up, fix and add missing options
Although 8644b333cd added support for some
missing commands an options, the bash completion file was still in bad
need for some cleanup, fixes and additions.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-07 10:01:23 +02:00
Cong Nguyen Huu
4d41f54d08 twister: support generate hardware map on windows
On windows, some board manufacturers have name that is "Microsoft"
instead of real its name. Need add it to manufacturer list.
Product information is missing. we can assign it "unknown" and
then add missing informations  by hand.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2022-10-06 07:23:17 -04:00
Cong Nguyen Huu
5b2b5dfec0 twister: run tests on device with twister on windows
Currently, support for Twister on Windows is only build.
The only thing that needs to be ported is that select()
cannot wait on file descriptors on Windows. Therefore
the serial monitor function needs to be reworked to
support both OSes.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2022-10-06 07:23:17 -04:00
Daniel DeGrasse
602b8b485d scripts: twister: add support for sysbuild
Add support for building with sysbuild using twister, via the "sysbuild"
yaml property in testsuites. This will currently disable Kconfig and
devicetree filtering.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-04 14:06:58 -04:00
Fabio Baltieri
279ab43bdd scripts: set_assignees: move misplaced log entry
The log refers to Platform taking precedence but the loop handles
Documentation as well. Move it under the proper section, drop "Drivers"
as that is not handle in any special way.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-10-04 15:14:27 +00:00
Fabio Baltieri
d06450b055 scripts: set_assignees: handle the documentation + unmaintained case
The script right now assumes that all the areas have a maintainer and
that the second area in particular has one in case of Documentation,
that results in a ValueError when it's not the case. Handle that by
checking the lists before using them.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-10-04 15:14:27 +00:00
Gerard Marull-Paretas
fdea3c9a44 devicetree: add DT(_INST)_FOREACH_PROP_ELEM_SEP(_VARGS)
Add a new set of helpers for expanding property entries with a
separator. These macros complement DT(_INST)FOREACH_PROP_ELEM(_VARGS) by
adding the capability to expand with a custom separator between property
entries. This allows, in some cases, to re-use existing macros (e.g.
DT_PROP_BY_IDX) without creating an auxiliary macro that just appends a
separator. Example:

```dts
n: node {
	...
	my-gpios = <&gpioa 0 GPIO_ACTIVE_HIGH>,
		   <&gpiob 1 GPIO_ACTIVE_HIGH>;
};
```

Before:

```c
 #define GPIO_DT_SPEC_BY_IDX_AND_COMMA(node_id, prop, idx) \
	GPIO_DT_SPEC_BY_IDX(node_id, prop, idx),

struct gpio_dt_spec specs[] = {
	DT_FOREACH_PROP_ELEM(DT_NODELABEL(n), my_gpios,
			     GPIO_DT_SPEC_BY_IDX_AND_COMMA)
};
```

After:

```c
struct gpio_dt_spec specs[] = {
	DT_FOREACH_PROP_ELEM_SEP(DT_NODELABEL(n), my_gpios,
				 GPIO_DT_SPEC_BY_IDX, (,))
};
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-03 10:11:18 +02:00
Ming Shao
8b46675e2b twister: add comment about stats logic
Add comments and docstring to class  ExecutionCounter to explain
the twsiter stats logic.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-01 06:42:54 -04:00
Ming Shao
94f2d2437f twister: refine the twister test plan generation
Due to the diverse coding styles and lack of preprocessing when
scanning for test cases, there were many unintended combinations
of yaml test scenarios and C test functions with the regex-based
test case discovery, which caused an inaccurate test plan and test
result stats.

As the new ztest fx is used, the test cases of a test instance can
be accurately determined via zephyr.symbols file.

Because the zephyr.symbols file is not available until after build,
test cases determination is placed right after the build stage of
the pipeline and before the runtime test collection.

For those test instances that don't go through the build stage,
such as those with "Skip filtered" (statically filtered) reason
before entering the pipeline, they are not affected.

This patch also adjust the stats logic because the zephyr.symbols
file is generated after build. So ExecutionCounter update is split
and some must be postponed until test execution pipeline is completed.

Some concepts:

A test instance = a yaml scenario + a platform
"Test instance" and "test config" are synonyms in twister, unfortunately
excessive IMHO...

A test instance can be filtered or skipped in 3 ways.
Let's define "runtime" as "after entering the execution pipeline".

1) statically filtered (before runtime)
   Such test instance is filtered by analyzing the yaml and never
   enters the execution pipeline.
2) cmake filtered (runtime)
   Such test instance enters pipeline and is filtered at cmake stage.
3) build skipped (also runtime)
   Such test instance enters pipeline and is skipped at build stage.

All the test instances that enter the execution pipeline will go
through the report stage, where ExecutionCounter is further updated.

The meaning of the fields of ExecutionCounter are:

 .skipped_configs = static filtered + cmake filtered + build skipped
 .skipped_runtime = cmake filtered + build skipped
 .skipped_filter = static filtered
 .done = instances that enter the execution pipeline
 .passed = instances that actually executed and passed

Definition of the overall stats:
total_complete = .done + .skipped_filter
total = yaml test scenario * applicable platforms
complete percentage = total_complete / total
pass rate = passed / (total - skipped_configs)

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-01 06:42:54 -04:00
Stephanos Ioannidis
b8643cb429 twister: size_calc: Remove stale k_mem_pool_area reference
This commit removes the stale reference to `k_mem_pool_area` for the
memory pool API, which was removed in the v2.5.0 release.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Fabio Baltieri
d43e4e9ca4 scripts: dump_bugs_pickle: strip bug titles
Strip trailing and leading whitespaces from but titles so that they can
be used directly in the release notes.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-27 16:51:45 -05:00
Fabio Baltieri
47ae66d828 scripts: release: strip title names
Make sure listed titles have no trailing/leading space (they often do
and right now they have to be cleaned manually before going into the
release notes file).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-27 16:51:45 -05:00
Fabio Baltieri
daff79b957 scripts: release: set per_page=100 for issue requests
GitHub issue API allows a max of 100 entries per page (up to a default
of 30). Use it for list_issues, makes the script runs a lot faster.

Api documentation:
  https://docs.github.com/en/rest/issues/issues
  https://docs.github.com/en/rest/pulls/pulls

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-27 16:51:45 -05:00
Stephanos Ioannidis
f503847d14 doc: Do not use Sphinx 5.2.0.post0
Sphinx 5.2.0.post0 release has a known compatibility issue with the
`sphinx_rtd_theme` (see the issue readthedocs/sphinx_rtd_theme#1343).

Revert this commit once this compatibility issue is resolved.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-09-25 10:37:32 +02:00
Ming Shao
2cea5850e2 twisterlib: re-add the logic to drain the serial leftover
This logic was added before but seems to be missed during the
twister refactoring.

Some tests can cause serial leftover logs buffered somewhere.
Such leftover can interfere with the next test case because the
serial log monitoring thread is started before a board is flashed.
And the monitoring thread can be fooled by such leftover logs and
make incorrect judgement of the test result.

A simple ser.flush() is not enough to eliminate such leftovers.
So add explicit readline() to drain such logs which ensures a clean
serial context for the case that follows.

An example from reel board captured with this patch:

leftover log of previous test: b'.287 seconds\r\n'
leftover log of previous test: b' - SKIP - [...test_coredump_backend]...
leftover log of previous test: b'\r\n'
leftover log of previous test: b'------ TESTSUITE SUMMARY END ------\r\n'
leftover log of previous test: b'\r\n'
leftover log of previous test: b'=====================================...
leftover log of previous test: b'RunID: 4e93757ad...53dcab9f0f5c6\r\n'
leftover log of previous test: b'PROJECT EXECUTION SUCCESSFUL\r\n

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-09-22 15:15:55 -05:00
Fabio Baltieri
96fc137654 twister: treat imgtool image exceeded as flash overflow
Twister detects FLASH overflow and skips tests that trigger that
condition by default, but sometimes images are just on the flash size
limit and then overflows at a later stage when imgtool adds a trailer,
which gets detected as a build fail and fails the run.

This detects the imgtool flash overflow together with the normal build
ones, causing the build to be skipped on imgtool flash overflow as well.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-22 12:41:25 +00:00
Anas Nashif
b3ead37efa twister: temporarily disable mec15xx boards
A workaround to exclude boards from twister. Other solutions do not work,
setting twister fields to false in the board yaml file is not enough,
given that this board has many associated samples and tests, so it can't
be disabled on its own.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-21 18:05:51 +00:00
Martí Bolívar
22012894c0 dtlib: error out on duplicate node names
Attempts to define two nodes with the same name within a single set of
curly brackets should fail.

For example, this is invalid DTS according to dtc:

    / { foo {}; foo {}; };

By contrast, this is valid since the node named 'foo' appears twice in
two different sets of curly brackets:

    / { foo {}; };
    / { foo {}; };

Zephyr's dtlib currently does not error out on the invalid condition.

Now that Zephyr itself has been updated to not include such nodes (to
the best of my ability), we can fix this divergence from current dtc
behavior and add a regression test in dtlib.

Fixes: #49590
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-09-21 07:55:40 -07:00
Yves Vandervennet
9a4272853e west: jlink: adding optional flash loader flag required for some boards
With revision 7.70d, Segger changed the command line interface of the
jlink client, requiring some flash specific information, such as
the base address and the type of memory, e.g. QSPI.

This commit adds an optional argument to the West jlink runner,
'--loader' which passes the information to the jlink client.
This change is backward compatible with versions of jlink older
than v7.70d which introduces the CLI change.

Fixes: #50327

Signed-off-by: Yves Vandervennet <yves.vandervennet@nxp.com>
2022-09-21 09:33:42 -05:00
Daniel DeGrasse
6064da8690 scripts: kconfig: update size functions to convert bits to bytes
Update size functions within kconfig helpers to support converting
values stored in kilobits, mebibits, or gibibits to kilobytes,
mebibytes, and gibibytes via use of different size arguments.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-09-21 15:22:36 +02:00
Torsten Rasmussen
65f45507a5 west: fix warning on user args in run_common
When using west runners with multi domains we want to warn users when
they user runner args on multi domain builds.

Therefore fix the `>1` to the correct `>0` which ensures the warning
is printed in all expected cases.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-20 16:58:09 +02:00
Daniel Leung
418c915f1b dts: add primitive support for multi-bus in bindings
For a single bus that supports multiple protocols, e.g. I3C and I2C,
the single value "bus:" setting is no longer sufficient, as a I3C bus
cannot be matched to a device having "on-bus: I2C". This commit
extends the "bus:" setting so that it can accept a list of values.
This change allows corresponding devicetree macros to be generated
so that DT_ON_BUS() can work properly in this scenario.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Stephanos Ioannidis
3e706376e6 scripts: ci: test_plan: Specify ZEPHYR_BASE for list_boards
The commit c3620c8a8e changed the
`list_boards` script such that it no longer searches the boards from
the `ZEPHYR_BASE` path by default.

This commit updates the `test_plan` script to invoke the `list_boards`
script with the `ZEPHYR_BASE` as a search path.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-09-08 18:17:10 +09:00
Martí Bolívar
7ef9c4b20e edtlib: remove python 3.5 workaround
Remove a yaml monkeypatch. It is no longer needed since we support 3.6
or later on Zephyr v2.7 LTS and 3.8 or later on what will become v3.2.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-09-07 15:38:26 +02:00
Gerard Marull-Paretas
e6fca0ef89 scripts: ci: check_compliance: ignore missing APP_LOG_LEVEL
Application log level is not detected correctly as the option is defined
using a template, so it can't be grepped.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-07 11:18:27 +00:00
Carles Cufi
13ea65b6a9 west: Add completion support for zsh
As part of the overall work on improving west integration with Zephyr,
add support for zsh completion in the `west completion` command.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-09-06 08:43:15 -07:00
Gerard Marull-Paretas
b0d4aea769 scripts: migrate_includes: migrate zephyr.h to kernel.h
The script will now automatically migrate all <zephyr.h> or
<zephyr/zephyr.h> (for already migrated projects) to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-09-05 16:31:47 +02:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Emil Gydesen
174c74206e footprint: Add bt_hci_rpmsg with ISO for the nRF5340 netcore
Add footprint tracking of the samples/bluetooth/hci_rpmsg
sample for the nRF5340 with ISO broadcast and ISO receive respectively.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-02 11:08:31 +00:00
Maureen Helm
5b5aa6ebba scripts: gen_defines: Add vendor name macros based on vendor prefixes
Adds vendor name and existence macros for all compatibles of a node that
match an entry in the vendor prefixes file.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-09-01 14:53:55 -07:00
Maureen Helm
a1b0c39c37 scripts: edtlib: Add compat2vendor LUT constructed from vendor prefixes
Adds a new compat2vendor lookup table that maps compatibles to vendor
names, constructed from the vendor prefixes file. This approach is a
more scalable alternative to adding a vendor name property to devicetree
bindings, as was previously proposed.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-09-01 14:53:55 -07:00
Torsten Rasmussen
8d2998d4f9 cmake: rework of host tools and generic toolchain handling
Follow-up: #41301

This commit is a rework and cleanup of the tools handling in Zephyr
CMake build system.

Instead of directly loading code a CMake modules for tool lookup, the
host tools now follows the CMake `find_package()` pattern for finding
programs / tools in module mode.

This makes it more clear which modules are responsible for finding tools
and which modules provides build integration / features.

The following tools can now be found using `find_package()`:
- Zephyr-sdk        : find_package(Zephyr-sdk <version>)
- Generic host tools: find_package(HostTools)

This further allows us to decouple the `verify-toolchain` CMake script
part required by `twister` into a tool lookup module and a dedicated
CMake script which utilizes the lookup module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Tristan Honscheid
52db2d8279 twister: Remove import exception handler for psutil
`handlers.py` treats the `psutil` package as optional and quietly prints
a message to stdout if it is not present, but it is actually a hard
requirement for the base `Handler` class. This try/except block is bad
as it hides the requirement until a timeout occurs and the handler
attempts to use `psutil` in the terminate method, which will crash if
the module happens to be missing.

This PR removes the try/except guard so missing `psutil` will cause
twister to immediately fail. `psutil` is already specified in the
`requirements.txt` file, so this should only affect users who
unwittingly have an outdated/incorrect environment.

Also update the Github Action for twister tests to install from
requirements files.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-09-01 06:22:04 -04:00
Erwan Gouriou
7cd727b003 scripts: requirements-extras: Request imgtool 1.9 for write-block-size > 8
On some targets (such as STM32U5) using write-block-size >8, imgtool
should be called using option '--align 16/32' which is only available
starting version 1.9.

Update requirement for imgtool to make it available to such platforms.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-09-01 10:28:33 +02:00
Andrzej Kaczmarek
868acfd505 scripts: Add ezFlashCLI runner
This adds support for ezFlashCLI tool to allow flashing DA1469x MCU
family from Renesas.

The tool is available at https://github.com/ezflash/ezFlashCLI or can
be installed via pip.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Ben Lauret <ben.lauret.wm@renesas.com>
2022-08-31 20:32:03 +02:00
Emil Gydesen
6cc8b57bc5 footprint: Add bt_hci_rpmsg for the nRF5340 netcore
Add footprint tracking of the samples/bluetooth/hci_rpmsg
sample for the nRF5340. This is a BT controller-only build
for the nRF5340 with minimum features.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-31 10:41:32 +02:00
Carles Cufi
8644b333cd west: Update bash autocomplete file
Update the existing bash autocomplete with the latest commands and
command-line switches.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-31 10:38:01 +02:00
Gerard Marull-Paretas
fff9ecbc7f devicetree: add DT_(INST_)FOREACH_CHILD(_STATUS_OKAY)_SEP(_VARGS)
It is frequent to see in Devicetree code constructs like:

```c
 #define NAME_AND_COMMA(node_id) DT_NODE_FULL_NAME(node_id),

const char *child_names[] = {
	DT_FOREACH_CHILD(DT_NODELABEL(n), NAME_AND_COMMA)
};
```

That is, an auxiliary macro to append a separator character in
DT_FOREACH* macros. Non-DT API, e.g. FOR_EACH(), takes a separator
argument to avoid such intermediate macros.

This patch adds DT_FOREACH_CHILD_SEP (and instance/status okay/vargs
versions of it). They all take an extra argument: a separator. With this
change, the example above can be simplified to:

```c
const char *child_labels[] = {
	DT_FOREACH_CHILD(DT_NODELABEL(n), DT_NODE_FULL_NAME, (,))
};
```

Notes:
- Other DT_FOREACH* macros could/should be extended as well

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Gerard Marull-Paretas
d77f4e61de scripts: dts: gen_defines: add DT_DEBRACKET_INTERNAL helper
Add a utility macro used to remove brackets from around a single
argument. While __DEBRACKET exists in util_internal.h, this change makes
DT independent (otherwise we should include util_internal.h, which is
another option).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Thomas Stranger
f123094482 scripts: west: runners: stm32cubeprogrammer: enable exec from PATH
Allows to use the stm32cubeprogrammer runner on Linux to be executed
from any installation directory as long as the executable is found
in PATH.

Until now on Linux the programmer could only be used if it either has
been installed in the default location or if the executable path was
passed via the cli parameter.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-08-29 17:31:56 +02:00
Carles Cufi
035dffcfcf scripts: modules: Mark the build as tainted if blobs present
Whenever binary blobs are present in the filesystem (i.e. fetched,
regardless of whether they are up-to-date or not) we consider the Zephyr
build as tainted. In order to ensure that it is marked as so, add a
Kconfig `select` statement whenever this is the case.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-29 15:57:59 +02:00
Carles Cufi
b662bc9093 scripts: modules: Move blob processing to zephyr_module.py
In preparation for the handling of taint flags in zephyr_module.py, move
blob-processing code from the west command to it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-29 15:57:59 +02:00
Yuval Peress
7187d8b7fc ztest: add framework tests for failed states
Add specialized tests that execute another test indirectly and ensure
that the results report errors correctly. See the README.rst file
provided with this commit for details.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Jeremy Bettis
562b291704 twister: Set stdin explicitly on stty calls
stty operates on the file descriptor from stdin, but we want to operate
on stdout. If stdin and stdout are not the same tty then stty prints an
error.

Redirect stdout to stdin for stty calls.

Tested by running twister -T tests/subsys/shell </dev/null

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-08-26 12:51:28 +02:00
Martí Bolívar
88aa873fbc twister: improve logging of cmake commands
With verbose output enabled, twister logs the cmake arguments as a
python array whenever it invokes cmake to generate a build system.

This is clunky output for manual reproduction, because it forces the
developer to manually join the arguments together for consumption by
the shell.

As an enhancement for this use case, use the standard library
shlex.join() function to produce a string that can be copy/pasted
directly into the shell on POSIX platforms.

We should use this function instead of str.join, because it correctly
handles things like shell quoting for options with spaces in them.

This function is not available on Windows, so we fall back on behavior
that is similar to the old one there.

The main difference on Windows is that the output now includes the
path to cmake as well, and not just its arguments. (This is the same
on POSIX, and is intended to help debug if multiple cmakes are
installed on the same machine.)

We are running cmake from a couple of different places, so doing this
cleanly requires adding a shared module with the platform abstraction.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-26 08:53:14 +02:00
Kumar Gala
f1660f4d51 edtlib: allow const arrays
Allow for having array types (array, uint8-array, string-array) be const.
This would allow for something like:

properties:
    reg-names:
        const: ["foo", "bar"]

To be supported.

Renamed function _check_prop_type_and_default to _check_prop_by_type
as part of this change and Moved the check for 'const' types into
_check_prop_by_type as its similar to the prop_type check and it was
easier to implement in _check_prop_by_type as we already extract
prop_type from the option in that function.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-25 18:11:27 -07:00
Kumar Gala
8a5d568a79 dts: Standardize string token names for arrays
Use the same postfixes for string arrays as we use for strings.  Keep
just the _STRING_*_TOKEN) variants.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-25 15:00:24 -07:00
Carles Cufi
25db534a07 west: blobs: Finally fix the --format option handling
Turns out that `Namespace.format` was not a good fix to the issue
described in f033040812, it was returning
the default format even when the user specified -f/--format.

Replace "getattr" with a simple logical operation.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 17:31:24 +02:00
Carles Cufi
f033040812 west: blobs: Fix --format handling
There were two issues with the original commit
e04487cad2:

- getattr() doesn't seem to work properly with args
- Comparison between bound methods with "is" seems not to work, so
  replace it with a simpler string comparison

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:38:42 -07:00
Carles Cufi
8f0af41fd8 scripts: compliance: Add commit range info output
Log at the info level the commit range that the script is acting upon.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:40:27 -04:00
Carles Cufi
0082dbfbd5 scripts: compliance: Remove unused command-line args
There were a bunch of old command-line arguments that haven't been used
in a while, remove them.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:40:27 -04:00
Carles Cufi
73598db4db scripts: compliance: Tiny cleanup for -c
Use a common source for default and doc.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:40:27 -04:00
Carles Cufi
c10a0f28b4 scripts: compliance: Clean up logging
- Add a choice in the cmd-line param
- Use the logger object everywhere
- Remove stale todo

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:40:27 -04:00
Carles Cufi
d160d0c20c scripts: compliance: Complete transition to junitparser v2
Follow-up to b187477fe7.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:40:27 -04:00
Carles Cufi
5ee76c97ab scripts: compliance: Remove unused variable
EDIT_TIP has not been used for a while now, remove it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:40:27 -04:00
Peter Marheine
d400b8135c arch/riscv: support CONFIG_CODE_DATA_RELOCATION
This implements support for relocating code to chosen memory regions via
the `zephyr_code_relocate` CMake function for RISC-V SoCs. ARM-specific
assumptions that were made by gen_relocate_app.py need to be corrected,
in particular not assuming any particular name for the default RAM
section (which is 'SRAM' for most ARM pltaforms) and not assuming 32-bit
pointers (so the test works on RV64).

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-08-24 10:08:06 +02:00
Peter Marheine
9bd46852a3 build: don't assume FLASH is the ROM region
Most ARM platforms name their ROM region `FLASH`, but this assumption is
not portable. Have gen_relocate_app refer to ROMABLE_REGION instead of
hard-coding the platform-specific memory region name.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-08-24 10:08:06 +02:00
Peter Marheine
3a8c20d849 build: don't assume .symtab section type
Only the elftools SymbolTableSection section type provides an
iter_symbols() method, and compilers are free to emit sections that
include the substring '.symtab' in their name which causes errors if
gen_relocate_app examines only the section name. Instead check whether a
section is a symbol table to skip attempting to inspect sections that
are not actually symbol tables.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-08-24 10:08:06 +02:00
Kumar Gala
4f84bc8f40 scripts/ci/check_compliance.py: Allow to run w/ZEPHYR_BASE
Tweak check_compliance.py to allow user to run it w/o having
ZEPHYR_BASE set.  This is similar to what we do for twister.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-23 13:26:27 +02:00
Radosław Koppel
7614110a20 dts: Add _STRING_TOKEN and _STRING_UPPER_TOKEN to string-array
This commit adds string token versions of the values also
in items inside string-array.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Co-authored-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Co-authored-by: Kumar Gala <galak@kernel.org>
2022-08-22 13:58:30 -05:00
Martí Bolívar
21214cc83f west blobs: decrease verbosity
Make some no-op log messages require 'west -v blobs ...'.

The current implementation won't scale as the number of blobs goes up.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar
e04487cad2 west blobs: fix --format handling
This option does not apply to 'west blobs clean' or 'west blobs
fetch'. Error out if it is given to either of those.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar
b4c4736fb0 west blobs: tweak --format help
Make it consistent with the usual argparse style by using lower case
and no period at the end.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar
a3f4edb127 west blobs: fix modules help
The help text is mixing up 'blobs' with 'modules', and doesn't
document the new behavior that uses all modules when nothing is
mentioned. Fix both issues.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar
3b84dff0a5 west blobs: fix subcmd help
Without this patch, "west blobs -h" says:

  {list,fetch,clean} Select the sub-command to execute. Sub-commands
  available: - list: list binary blobs - fetch: fetch and store binary
  blobs - clean: remove fetched binary blobs

With this patch:

  {list,fetch,clean}    sub-command to execute

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Kumar Gala
f16e2a9d80 twister: Add esp32 section name to overflow check
esp32 platforms can overflow their dram0_1_seg so add that section name
to the overflow check in twister.  We were seeing this with the
samples/arch/smp/pi/sample.smp.pi test and would get:

 zephyr_pre0.elf section `noinit' will not fit in region `dram0_1_seg'
 region `dram0_1_seg' overflowed by 17456 bytes

Fixes #49164

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-22 12:04:24 -04:00
Martí Bolívar
b3151bcea3 scripts: fix "kconfig: tweak dt_chosen_label"
Commit 57538262e1
(" scripts: kconfig: tweak dt_chosen_label") forgot to update the
docstring for a function whose behavior was changed. Fix it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-19 07:03:31 -05:00
Gerard Marull-Paretas
2d712c6c55 scripts: west_commands: runners: jlink: support pylink >= 0.14.2
It looks like the latest release, 0.14.2, changed the contents of
JLINK_SDK_NAME as it was before 0.14.0 release. That means that the
previous fix is only applicable to a couple of releases: 0.14.0/0.14.1.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 14:00:26 +02:00
Torsten Rasmussen
f249f278bf west: warn that using runner args on multiple domains is experimental
The introduction of sysbuild and west build / flash / debug / etc.
support raises questions regarding how to handle user specified runner
arguments.

Some arguments may be acceptable for all domains, whereas others are
only valid for a single or few domains in a multi domain build.

Therefore, consider the usages of runner specific options experimental
when applied to multiple domains.

The following warning is printed to the user when using runner specific
arguments on multiple domains:
> WARNING: Specifying runner options for multiple domains is
> experimental.
> If problems are experienced, please specify a single domain using
> '--domain <domain>'

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-19 09:21:38 +02:00
Carles Cufi
0424509d6e west: blobs: Ensure that folder exists before fetching
The `<module>/zephyr/blobs/` folder, as well as any additional
sub-folders that might be required under `blobs/` may not exist when
fetching a blob. Ensure that the folder exists, create it if it doesn't.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Carles Cufi
5524f7a950 west: blobs: Add a clean sub-command
The new "clean" blobs sub-command deletes any blobs present on the
filesystem.

Also improve the help text for sub-commands.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Carles Cufi
02c95c64fe west: blobs: Rework the -m option
To align with other commands, such as "west update", convert the
accumulative -m option into an nargs="*"-type one that takes the list of
modules directly without a flag.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Carles Cufi
389af0885c west: blobs: Default to listing and fetching all blobs
Instead of both listing and fetching only the blobs in the
modules listed by the user in the command-line, default to
listing/fetching them all for ease-of-use and consistency with other
commands. Remove the --all options since it's meaningless now.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Daniel Leung
835680f0e7 twister: enhance support for board@revision as platform name
This adds an extra layer to match the revision part where this
needs to be of permitted patterns as described in.
cmake/modules/extensions.cmake. Without this, the matching
may produce undesirable results. For example, if there is
a file named qemu_x86_tiny_1.conf, the testplan will create
a board name qemu_x86@tiny.1 (which is definitely not correct).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-18 17:23:18 +02:00
Torsten Rasmussen
c3620c8a8e scripts: remove ZEPHYR_BASE as default root for board listing
Remove ZEPHYR_BASE as default root in list_boards.py.

This allows list_boards.py to be used to only print boards at given
root(s) without printing Zephyr default boards.

Secondly it remove the need in list_boards.py to have any knowledge of
ZEPHYR_BASE.

The `west boards` command already has ZEPHYR_BASE knowledge and can
easily add ZEPHYR_BASE to the list of roots it is already constructing,
thus removing the need for knowing that ZEPHYR_BASE is always added.

Update boards.cmake to pass ZEPHYR_BASE as an additional arch root, as
arch.cmake has not yet been processed,which means ZEPHYR_BASE is missing
in ARCH_ROOT list at this point in time.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Eivind Jølsgard
3865e08c96 scripts/Kconfig: add dt_node_array_prop Kconfig functions
The motivation is to allow accessing array elements from device tree
properties in Kconfig.
* Add dt_node_array_prop and _node_array_prop functions to extract the
array elements from properties.
* Add 'dt_node_array_prop_int' and 'dt_node_array_prop_hex' keys to use
in Kconfig.

Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
2022-08-18 12:21:33 +02:00
Andy Ross
e05d0132fd scripts/twister: Kill qemus with SIGKILL, not SIGTERM
On qemu_cortex_a53 with icount enabled, the qemu process will spin
hard at the end of its run (common with icount), but will also ignore
the SIGTERM twister is sending to terminate the (successful!) test
run.  The resulting zombie spinning processes end up accumulating and
poisoning the test run.

Just use a hard KILL instead of trying to be a good citizen (and in
lieu of fixing the upstream qemu bug).  I can't see why this should be
a problem.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-18 10:19:19 +02:00
Enjia Mai
a2160efed3 twister: fix the hanging up on an exception happens during west flash
Fix the missing logic of setting the flash_error flag when
caught the exceptions. And we should let the serial thread
can be run first if flash error. Otherwise the twister will
hang up while an exception happens on closing serial, after
the #47820 got merged. This mostly happens on frdm_k64f.

Fixes #49086

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-17 15:24:13 -05:00
Enjia Mai
ad8f211729 runner: intel_adsp: no need to specify host in --pty if no port assign
No need to specify host again in --pty when not specifying the port,
slightly reduce the input.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Enjia Mai
d935ec3a03 runner: intel_adsp: add parameters --tool-opt
Add parameter for possible extending in the future, --tool-opt
passes arguments to execution of the run service.
Ex.
  --tool-opt=--arg='white space' --tool-opt=-r --tool-opt=12345

will be parsed as ['--arg=white space', '-r', '12345']

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Enjia Mai
a38f533278 soc: xtensa: tools: remove dependency of netifaces package
Because we use INADDR_ANY by default now, specifying a net interface
is no longer needed. Remove it and remove the dependency of the
netifaces python package.

Fixes. #48584

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Enjia Mai
e33fd73546 soc: xtensa: add support for specifying the service port
Add specifying the port for the remote cavstool remote service.
Ex.

    west flash --remote-host {host}:{port} \
               --pty {host}:{port}

Specify the port is optional when running west.

And another major change is now we have to specify the remote log
service by --pty to make it output the log message immediately.
Previously it will output directly. Why we make this change is
because this is more close to the behavior we use west flash.

Fixes. #46865

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Carles Cufi
336aa9dc88 modules: Basic binary blob infrastructure
This patch introduces the basic infrastructure to list and fetch binary
blobs. This includes:

- The new 'blobs' extension command
- An implementation of the `west blobs list` command
  with custom formatting
- A very simple mechanism for loading fetchers
- A basic implementation of an HTTP fetcher

In order to ensure consistency among the west extension commands in the
main zephyr tree, we reuse a similar class factory pattern that is present
for ZephyrBinaryRunner instances in the ZephyrBlobFetcher case. This
could be achieved with a simpler mechanism, but opted for consistency
before simplicity.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-16 05:59:02 -07:00
Carles Cufi
57e5cd41ca scripts: modules: Use pathlib to locate the module file
Instead of using strings, use pathlib's functionality to handle the
fact that it can have two different extensions.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-16 05:59:02 -07:00
Christoph A Schnetzler
6fc4bb9486 kernel: Prevent Wundef
prevent `Wundef` warnings from occurring due to
missing CONFIG_ symbols and __cplusplus.

Signed-off-by: Christoph A Schnetzler <Christoph.Schnetzler@husqvarnagroup.com>
2022-08-15 14:36:47 +02:00
Guo Lixin
0ea346009f twister: avoid monitor serial when flash error
Currently, twister keeps on monitoring serial output until timeout
even if we have a flash error. And the error reason will be reported
as 'No Console Output(Timeout)', which is not accurate.
So add a flash_error flag to control if we need to monitor the output.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-08-13 08:52:03 -04:00
Anas Nashif
f28a8d2240 twister: fix bug retrieving subtests
During the recent overhaul, some code was left retrieving cases the old
way.

Fixes #48897

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-12 17:39:35 +02:00
Torsten Rasmussen
5fa4156462 doc: sysbuild documentation guide
This is this initial sysbuild guide on what sysbuild is and how to build
a sample using sysbuild.

It provides an architectural overview of sysbuild.
Descriptions on how to use `west build` or `cmake` + `ninja` to build
projects with the sysbuild infrastructure.

Flashing is described through the use of `west flash`.

Extending sysbuild with additional Zephyr based applications are
described, and reference to CMake documentation for including non-Zephyr
based applications are provided.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-12 13:56:55 +02:00
Gerard Marull-Paretas
d9ed09357e doc: update requirements
Update to Sphinx 5.x, also update breathe since version 4.34 is the
first to officially support Sphinx 5.x.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-12 11:04:26 +02:00
Fabio Baltieri
0226e53e23 Restore "cmake: remove device_extern.h logic"
This reverts commit 87c6789355, restoring
commit 3b341085a2.

Restore the original change now that the underlying issue has been fixed
in 6cfb18686e.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-12 07:45:01 +01:00
Fabio Baltieri
87c6789355 Revert "cmake: remove device_extern.h logic"
This reverts commit 3b341085a2.

Seems to be breaking CI for few qemu platforms.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-11 17:21:46 -05:00
Emil Gydesen
5cff937b3a footprint: Add Hearing Access Hearing Aid BT Audio sample
Add the hearing aid sample to the footprint tracking for the
nrf52840dk_nrf52840 and nrf5340dk_nrf5340_cpuapp.

The sample should represent a simple hearing aid implementation,
and is thus a very good candidate for tracking the footprint
of LE Audio in Zephyr.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-08-10 13:08:18 +02:00
Carles Cufi
a580b3d174 west: Fix handling of modules in the boards command
The boards command was not properly using the zephyr_module
functionality to obtain the board roots of all modules. Fix that by
moving the functionality required to the core zephyr_module file and
reuse it from external scripts.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-09 16:07:51 +02:00
Chen Peng1
7f105cea87 twister: support board@revision in platform filter
support to use board@revision as platform filter when running
twister, like "twister -p nucleo_f030r8@1 ...".

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-08-09 08:45:55 -04:00
Martí Bolívar
3b341085a2 cmake: remove device_extern.h logic
This file is no longer used by device.h, so let's avoid spending time
generating the content formerly in it.

In order to leave a pointer in place for users who are expecting to
see it or are pulling it into their own builds, however, replace its
contents with an #error directive that tells them what happened. This
can be removed later on when we expect people are used to the
transition.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Martí Bolívar
f0d11f780c gen_defines: add helpers for iterating over the entire tree
Add two helper macros:

- DT_FOREACH_HELPER
- DT_FOREACH_OKAY_HELPER

These are internal generated macros which will be used to define
devicetree.h APIs for iterating over every node in the tree, and every
node in the tree with status "okay", respectively.

We can use these new APIs to implement the functionality in
device_extern.h natively from device.h without requiring a generated
header. It will also be useful for other purposes later on.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Martí Bolívar
190197ec97 gen_defines: trivial rename
Generalize a function name as prep for extendings its scope.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Kumar Gala
57538262e1 scripts: kconfig: tweak dt_chosen_label
Now that we've removed the label property from most devicetree nodes
the dt_chosen_label will end up returning "" in most cases.  For the
small handful of cases that the function is used, return the node.name
instead as this matches what DEVICE_DT_NAME will do.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-08 10:41:34 +02:00
Keith Short
f896fc2306 scripts: gen_handles: Sort the device handles
Replicate the devicetree dependencies into a sorted list. This ensures
that the structures added to the .__device_handles_pass2 section are
reproducible from build to build.

Tested with: west build -b native_posix tests/drivers/build_all/sensor

Without this change, two consecutive builds do not compare.

Signed-off-by: Keith Short <keithshort@google.com>
2022-08-05 13:00:35 +02:00
Gerard Marull-Paretas
a57001347f scripts: west_commands: runners: jlink: support pylink >= 0.14
pylink 0.14.0 changed the class variable where JLink DLL library name
(libjlinkarm) is stored. This patch adds support for new pylink
libraries while keeping backwards compatibility.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-05 12:58:23 +02:00
Gerard Marull-Paretas
7007451955 scripts: build: elf_parser: use node name for Graphviz diagrams
The elf_parser library now generates a dot file with device dependencies
that can be later rendered using Graphviz. Each node in the diagram
contains the device label (taken from DT node). In some cases the label
property can be None, leading to build failures like:

```
line 273, in device_dependency_graph
text = '{:s}\\nOrdinal: {:d} | Handle: {:d}\\n{:s}'.format(
TypeError: unsupported format string passed to NoneType.__format__
```

This patch switches to node name instead, which will always be set to
some value. This value is actually what devices get now as a name if
they do not have a label set.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-04 18:36:35 +02:00
Torsten Rasmussen
69f4fa6a4e west: adding --domain to west build synopsis
Adding `--domain DOMAIN` to the west build synopsis.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-04 13:06:13 +02:00
Henri Xavier
b187477fe7 scripts: Upgrade to junitparser v2+
There is a breaking change in Junitparser 'TestCase.result' between
v1.x and v2.x.

Update check_compliance.py minimally to take into account this change.

This avoids relying on an outdated package.

Signed-off-by: Henri Xavier <datacomos@huawei.com>
2022-08-03 14:04:36 -04:00
Torsten Rasmussen
8408af6d7c scripts: west commands to support --domain
This commit extends the west commands build, flash, and debug to support
--domain when having multiple domains (images) defined in a domains.yaml
build file.

The domains.yaml uses the following yaml format to specify the
build directory of each domain in the multi image build:
> default: <domain-n>
> domains:
>   <domain-1>:
>     build_dir: <build_dir-domain-1>
>   <domain-2>:
>     build_dir: <build_dir-domain-2>
>   ...

`west <build|flash|debug>` has been extended to support
`--domain <domain>`.

`west build` calls CMake to create the build system, and if `--domain`
is given, then the build tool will be invoked afterwards for the
specified domain.

`west flash` will default flash all domains, but `--domain <domain>`
argument can be used to select a specific domain to flash, for example:
> west flash --domain mcuboot

`west debug` only a single domain can be debugged at any given time.
If `--domain` is not specified, then the default domain specified in the
domains.yml file will be used.
Users can still select a different domain, for example with:
> west debug --domain mcuboot

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Torsten Rasmussen
5fe5d6b43d scripts: extend west build command to support sysbuild CMake project
west build now support the sysbuild CMake project which allows users
to easily enable and build a bootloader together with any sample.

This will allow for cleaning up samples and boards which already does
custom multi image in a non-generic way, for example:
- mps2_an521 which includes a build for remote board
- samples/ipc/ which includes a samples for remote board
- esp32 which includes custom bootloaders

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Martí Bolívar
65e3593bf9 west_commands: runners: reserve -O for --tool-opt
The --tool-opt runner option is the recommended practice for allowing
runners to take additional arguments that are passed on to the
underlying tool. It exists because we don't want to add one runner
option for every single tool option that users might want to tweak --
that would be a nightmare.

Enough runners are using this option that it's time to promote it to a
common runner capability with consistent behavior, the same way we did
for the --dev-id option in the past. This removes boilerplate from
individual runner files and ensures consistent argument handling for
this option when it is supported.

Since --tool-opt is a bit long to type, and we've had some complaints
about that, take this as an opportunity to standardize on -O as a
short option equivalent for it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-03 05:06:53 +01:00
Anas Nashif
0200da97c2 ci: fix pattern for skipping boards in testplan.py
boards have their own unique pattern, use that for proper skip.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-02 13:05:39 -04:00
Reto Schneider
80270727d0 scripts: requirements: extras: Suitable clang-format version
Even when BreakBeforeBraces is set to Linux, implying BraceWrapping for
AfterEnum to be true, clang-format version 12 puts the opening brace of
an enum declaration on a new line. [1]

One possible workaround would be to change AllowShortEnumsOnASingleLine
from false to true, but that would yield a different kind of unwanted
formatting.

clang-format version 13 and newer have this issue fixed, therefore
bumping the minimal version.

[1] https://github.com/llvm/llvm-project/issues/48983

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-08-02 15:17:18 +02:00
Piotr Golyzniak
4484f68d02 twister: verify platform names from quarantine
Add verification of platform name from quarantine list.

Fixes: #43450

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-08-01 09:29:03 -04:00
Jordan Yates
13f2494f4c device: symetric injected dependencies
If a device manually specifies that it depends on a second DT device,
add the first device to the second devices list of supported devices.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Jordan Yates
29942475c5 scripts: gen_handles: output dependency graph
Output the final dependency graph as a `.dot` file, which when rendered
by graphviz can be easier to comprehend than the text descriptions.

This output is optional in that it will not be generated if `graphviz`
is not installed.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Jordan Yates
8d17e857a1 scripts: gen_handles: use elf_parser.py
Use the new elf_parser module to simplify the process of generating the
final device handle arrays.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Jordan Yates
06b0d5a4fb scripts: elf_parser: added
Adds a python module intended to simplify other scripts that need to
work with device information compiled into the first pass `.elf` file.

Scripts utilizing this module can focus on iterating over dependency
graphs to generate the desired output, instead of also needing to
extract and build the graphs in the first place.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Jordan Yates
cfb8c5e70f pm: device: rename placeholder variable
Rename the placeholder variable generated for PM slots so that the
prefix doesn't colide with the PM structs declared by devices. This
simplifies the process of searching for symbols in `.elf` files.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Anas Nashif
c0317fba1f twister: handler quotes in extra_args
Escape quotes provided in extra arguments on the command line.

example: ... -x "CONFIG_COMPILER_OPT=\"-fanalyzer\""

Fixes #46382

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-29 05:58:15 -04:00
Tristan Honscheid
4a8ffee1d8 twister: Don't run coverage report when --build-only is used
When doing a split build and test with coverage enabled, (i.e.
`twister --coverage --build-only` followed by `twister --coverage
--test-only`), Twister attempts to run coverage reports immediately
after building, which fails because tests haven't actually run yet
and causes several error messages to print in to the log.

This change causes twister to skip the call to `run_coverage()` if
`--build-only` is set and print an info message. This suppresses the
error messages from the coverage report tool complaining about missing
coverage files, but still instruments the built code for coverage data
collection. When twister is invoked again, but with `--test-only`
instead, the coverage files will be emitted and the reports
successfully generated.

 #### Testing

I ran...

```
$ zephyr/scripts/twister -T zephyr/tests/lib/cmsis_dsp/basicmath/
--coverage -p native_posix --build-only
$ zephyr/scripts/twister -T zephyr/tests/lib/cmsis_dsp/basicmath/
--coverage -p native_posix --test-only
```

... followed by a combined build and test ...

```
$ zephyr/scripts/twister -T zephyr/tests/lib/cmsis_dsp/basicmath/
--coverage -p native_posix
```

... as a control and diffed the HTML coverage reports, which were
identical other than a timestamp.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-07-28 05:58:52 -04:00
Piotr Golyzniak
7ce914b7f4 twister: verify all platform names
Fix bug in verify_platforms_existence method - make it possible to
verify all platform names from list - not only first.

Fixes: #48321

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-07-26 20:42:20 -04:00
Stephanos Ioannidis
0f9588e51f scripts: twisterlib: Fix default value for --ninja argument
This commit makes the `--ninja` argument default to `true` when neither
`-k` nor `--make` is specified (i.e. when Make generator is not
selected).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-26 20:17:59 -04:00
Stephanos Ioannidis
1f81d2cd97 scripts: twisterlib: Fix --short-build-path argument handling
When `--short-build-path` argument is specified to the twister, the
following error message is displayed because the Python argparse module
does not allow specifying a mutually exclusive argument as required:

  ValueError: mutually exclusive arguments must be optional

This commit removes the `required` parameter when adding the `--ninja`
argument, which is a mutually exclusive argument, and adds a manual
check to validate this condition instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-26 20:17:59 -04:00
Anas Nashif
5432cac806 ci: testplan: still run default tests with global changes
In cases of global changes where 100s of nodes are launched, i.e. on
samples and tests (more than 20 tests/samples changed), do a full
covrage run.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-22 11:00:23 -04:00
Kumar Gala
ccb9b6b5ba scripts: check_compliance: generate Kconfig.dts
Generate a Kconfig.dts to allow check_compliance to run.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 09:39:49 -07:00
Kumar Gala
b109a0a9f7 dts: Add simple script to generate Kconfig.dts based on bindings
Given binding dirs the script will generate a Kconfig.dts of the
form:

    DT_COMPAT_ADI_ADT7420 := adi,adt7420

    config DT_HAS_ADI_ADT7420_ENABLED
            depends on DTS_HAS_ADI_ADT7420
            def_bool $(dt_compat_enabled,$(DT_COMPAT_ADI_ADT7420))

Than a driver Kconfig can use these Kconfig symbols as follows:

    menuconfig ADT7420
            bool "ADT7420 Temperature Sensor"
            default y
            depends on DT_HAS_ADI_ADT7420_ENABLED
            ...

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 09:39:49 -07:00
Bartosz Bilas
3322aad03b scripts: pylib: twister: twisterlib: fix typo
s/enviornment/environment

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-07-19 11:41:54 -04:00
Alex Kolosov
f59e9dd857 scripts: runners: improvements for spi_burn west runner
Following changes has been made by this commit:
    - fix issue when a binary is not able to be found by relative path
    - implement "west debug" command
    - implement --dt-flash option

Signed-off-by: Alex Kolosov <rikorsev@gmail.com>
2022-07-19 12:23:47 +00:00
Anas Nashif
6027152408 scripts: set_assignee: handle exceptions
Deal with exceptions that happen when a user does not exist on GH.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-18 21:41:22 -04:00
Martí Bolívar
d6f68f0bbb scripts: gen_defines: fix tokenization of array elements
This fixes commit
3d5cc38cf6.

That commit only works if removing the quotes from e.g. a string in an
array actually results in a token. If the string's value is something
like

  "foo,bar"

though, it will result in the "token"

  foo,bar

in the generated output.

This is wrong; fix it using the new edtlib.str_as_token() API
introduced to allow callers to perform the same procedure as that
library for fixing up strings.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-07-18 17:50:44 -05:00
Martí Bolívar
7b2a728584 scripts: gen_defines: add a missing comment
Adding a comment at this point in the header file splits these macros
into their own section. They are presently grouped together with the
previous section, which is unrelated. This is confusing; fix it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-07-18 17:50:44 -05:00
Martí Bolívar
4ef8c8e447 edtlib: expose str_as_token() API
Some callers need to be able to convert strings to tokens in the same
way edtlib does. Make this possible by exposing the internal helper
function used to do that under a suitable name.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-07-18 17:50:44 -05:00
Martí Bolívar
19bb6b330c edtlib: fix error handling in an internal helper
The error message emitted by _interrupt_parent() is wrong; it
mistakenly says:

  node None has an 'interrupts' property, but [...]

This 'None' is appearing because the same routine overwrites the
'node' argument that the caller is asking about with node parents
until it hits the root, at which point root.parent is None.

Fix it by caching the original node and using that in the error
message instead.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-07-18 17:50:44 -05:00
Jason Wright
c6c7dde969 scripts: better logging for --coverage-formats option
Adds additional log messages for coverage reports
beyond HTML format.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-07-18 15:03:13 -04:00
Jason Wright
60c4d20548 scripts: restrict --coverage-formats option to gcovr
Generates an error if --coverage-formats option is supplied without
coverage tool being set to gcovr.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-07-18 15:03:13 -04:00
Jason Wright
786f28f162 scripts: add --coverage-formats option for use with gcovr
Adds optional twister flag to support gcovr output report formats.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-07-18 15:03:13 -04:00
Christopher Friedt
3783cf8353 scripts: release: list_backports: use older python dict merge method
In Python versions >= 3.9, dicts can be merged with the `|` operator.

This is not the case for python versions < 3.9, and the simplest way
is to use `dict_c = {**dict_a, **dict_b}`.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-19 00:20:13 +09:00
Christopher Friedt
aa4e437573 ci: backports: check if a backport PR has a valid issue
This is an automated check for the Backports project to
require one or more `Fixes #<issue>` items in the body
of the pull request.

Fixes #46164

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-18 20:09:44 +09:00
Christopher Friedt
57762ca12c scripts: release: list_backports.py
Created list_backports.py to examine prs applied to a backport
branch and extract associated issues. This is helpful for
adding to release notes.

The script may also be used to ensure that backported changes
also have one or more associated issues.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-18 20:09:44 +09:00
Christopher Friedt
3b3fc27860 scripts: release: use GITHUB_TOKEN and start_date in scripts
Updated bug_bash.py and list_issues.py to use the GITHUB_TOKEN
environment variable for consistency with other scripts.

Updated bug_bash.py to use `-s / --start-date` instead of
`-b / --begin-date`.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-18 20:09:44 +09:00
Torsten Rasmussen
6066ab43b3 kconfig: add support for warnings when enabling deprecated features
This adds two new Kconfig settings.

The first setting `DEPRECATED` which is a promptless symbol.
This symbol must be selected by any deprecated setting when enabled.

The second setting is `WARN_DEPRECATED` which is a user controlled
setting that configures the build system to print a warning when a
deprecated feature is enabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-07-15 09:53:08 -05:00
Kumar Gala
b200b9a9e0 dts: bindings: bus labels are now optional
All in tree device drivers on a bus use some form of DEVICE_DT_GET
so we no longer need to require label properties.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-14 09:19:35 -07:00
Chen Peng1
e7088743df scripts: twister: only load connected hardwares.
only load hardwares with connected is true in
hardware map files.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-07-13 06:18:08 -04:00
Chen Peng1
1d5c37ab96 script: twister: fix hardware runner_params parsing.
The specific hardware instance is already got from
device_is_available function, we don't need to
iterate all hardwares again.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-07-13 06:18:08 -04:00
Anas Nashif
a0c3bdafbf twister: do not modify testplan on subsequent runs
Do not modify testplan.json if it already exists. Testplan is only
created once and any work in the same worskpace should not change it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif
a2fbb783dd twister: fix new ztest parsing
Somehow this change was dropped (rebase?), this is needed to parse new
ztest test correctly, otherwise will have many tests missing from the
plan.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif
5f146dcaf9 twister: prep for device testing
Add option to prepare for device testing by only building and storing
the needed data that can then later be executed and run on DUT using
--test-only.

This adds --prep-artifacts-for-testing which is the same as --build-only
and --device-testing and other options that were needed to make this
operational and produce the right binaries and files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif
68a8613a92 twister: fix --build-only argument help
Minor fix to the --build-only option help.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif
398e9902b8 twister: rename argument group: serial -> device
using serial as the group name is misleading, so call it 'device' which
is what all those options about.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif
e1e43015ec twister: also parse cpp files in app root
Fix wildcard to also scan cpp files in root folder of test application.

Fixes #47220

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 23:24:41 -04:00
Gerard Marull-Paretas
0a4b248047 scripts: checkpatch: add Atmel Pwm typedef
Add Atmel Pwm typedef so that when doing `Pwm * const pwm` definition
checkpatch doesn't complain about the position of the '*'. If not added,
we must define `Pwm *const pwm` to make checkpatch happy, but,
clang-format results in `Pwm * const pwm` (correct).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-07-12 17:51:23 +02:00
Anas Nashif
01582f80b7 scripts: move gen_cfb_font_header.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
61f672607a scripts: move file2hex.py to scripts/build/file2hex.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
92575fdac8 scripts: move parse_syscalls.py to scripts/build/
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
98ab67d7dc scripts: move user_wordsize.py to scripts/build/user_wordsize.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
a8a976647e scripts: move uf2conv.py to scripts/build/uf2conv.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
9ee1e32b57 scripts: move subfolder_list.py to scripts/build/subfolder_list.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
d859997994 scripts: move process_gperf.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
72e7fa8176 scripts: move mergehex.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
09b4becaee scripts: move gen_image_info.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
967f9b437b scripts: move dir_is_writeable.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
c74d20e433 scripts: move gen_syscalls.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
4f65bf6412 scripts: move gen_strerror_table.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
d589e7f04e scripts: move gen_relocate_app.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
e234c21ab2 scripts: move gen_offset_header.py to scripts/build/
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
d5dcf20382 scripts: move gen_kobject_placeholders.py to scripts/build/
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
efbadbb677 scripts: move gen_kobject_list.py to scripts/build/gen_kobject_list.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
c36307ea86 scripts: move gen_isr_tables.py to scripts/build/gen_isr_tables.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
80f4b5db21 scripts: move gen_handles.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif
6e1a335447 scripts: move gen_app_partitions.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Pieter De Gendt
657a67d090 scripts/requirements: Replace protobuf with grpcio-tools
The nanopb module generates source files from .proto files,
however the latest protobuf v4.21.0 python package breaks
compatibility.
Using grpcio-tools instead fixes this.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-07-11 14:15:06 +02:00
Torsten Rasmussen
f08af4ce68 west: zcmake.py: support UNINITIALIZED type if CMakeCache.txt file
A variable set by the user with `-DVAR=<val>` will be given the type
UNINITIALIZED.

This results in the variable not being read into the cmake_cache.

Support reading of CMake cache variables of type UNINITIALIZED.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-07-11 11:33:15 +02:00
Carlo Caione
5a4affdcda gen_isr_tables.py: Move to scripts directory
There is no reason to have this script in a different place than all the
other python scripts. Move it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-07 17:58:34 +00:00
Anas Nashif
9e3d697f15 twister: fix calculation of testsuite names
We were omitting one element of the path by mistake.
Also fix some naming issues in the testsuite.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 15:07:35 -04:00
Anas Nashif
89b8c2b892 twister: adapt twister testsuite
Adapt with new way for parsing testsuites.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
1463f4bdc5 twister: rework testsuite parsing
Move testsuite setup and parsing to the testsuite class. Simplify
reading data from yaml.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
4789f07a8f twister: fixups to various files
Various fixups, will be folded in correct commits eventually.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
087f1e4a63 twister: fixed various pylint issues
Fix various pylint issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
3d1971dee3 twister: adapt and fix testsuite tests
Re-add testsuite tests, include file scanning.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
1a6948ac26 twister: move file scanning out of class
This is all static functions that can maintained outside of the class
and called only in one place, so move this to the testsuite file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
9437e6d963 twister: fix twister testsuite
Make testsuite work again.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
08caa71de7 twister: testplan: get options directly
Get options from passed environment class instead of using command line
options to the init function.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
76d5543c9b twister: fix main script returns and error handling
Propagate errors to the main routine and do not exit early in case of
errors.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
91b2cce64e twister: fix subset processing
Process subsets was done in the wrong step, so make it apply and
generarte subsets correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
79d7d0188b twister: make ninja the default
Using ninja is up to 50% faster, make it the default and add an option
to build with Make.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
7149173627 twister: simplify handler options
Depend on global options instead of passing them around for each class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
f2b5a6674a twister: move harness class to class folder
harness class moved along size other classes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
57dbaa3da3 twister: move more code from main script
Move code from twister script into respective classes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
f539f1dc48 twister: move size report into size calc class
Move from main script into size_calc class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
806722cdbf twister: move device testing code
Move device handling code into hardware map class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
f7d501447d twister: move cleanup and classification of code
Move code out of the main script and use global options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
396b8574eb twister: testplan: move calls to json loading/filter into class
Move all code related to instance filtering and loading into the class
instead of having it in the main script. Simplify option passing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
f85d1eb4e1 twister: rework testplan and main twister script
Move all testplan related code to the testplan class and cleanup main
twister script.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
b8735b3300 twister: more cleanup to option passing
Use global options rather than passing them individually.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
facc685ae9 twister: move runner code into runner class
Move all code related to test execution into runner class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
20f257a97d twister: move execution code out of testplan
Move all code related to execution into runner class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
d43e03e19e twister: isolate testplan class
Move testplan class into own file and rename the original twisterlib.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
96b9ff6b5e twister: move runner classes out
Move runners into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
1084869634 twister: minor cleanups in main script
Move code around in the main script and cleanup some of the options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
e5c2e797c9 twister: move test instance class out
Move test instance class into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
adfa6c7777 twister: move coverage classes out
Move coverage related classes out into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
78d9dab7f3 twister: cleanup imports and move size classes out
More python import optimizations and cleanup and move size_calc class
out into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
75eee4b1f3 twister: move platform class out
Move both platform and config parser into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
0779ccc5fc twister: import cleanup
python import cleanup and simplification.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
f490b059ad twister: move handlers class out
Split handlers into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
2b213d3231 twister: split hardwaremap class out
Split hardware map class into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
d5424d5116 twister: split report classes out
Move report classes out into own file and split out of testplan class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
d8d217d2ea twister: move testsuite, testcase classes out
Move testsuite/testcase and supporting classes into own files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
521ce42161 twister: move cmake cache class
Move cmake cache classes into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
e01cbbe31f twister: add environment class
Add environment class to discover toolchain, zephyr version and other
items.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif
acda94be2d twister: optimize file scanning
We have been scanning code for tests for every scenario defined in the
yaml file. This needs to only be parsed once and not more. We are
dealing with the same files for each scenario.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Bartosz Bilas
888ce37799 runners: jlink: allow passing file path with spaces
Put file path within the " " marks to allow
passing file path with spaces.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-07-05 13:20:17 +02:00
Christopher Friedt
4cc443705d libc: minimal: add strerror and strerror_r function
Add simple strerror() and strerror_r() implementations.

Fixes #46099

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-04 22:53:36 +02:00
Enjia Mai
ce18d3c4ff requirements: add netifaces, needed by adsp runner
Needed for running tests on intel_adsp_cavs boards, the cavstool.py
are using it to get the host ip address automatically.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-04 16:33:03 +02:00
Reto Schneider
35f9a32781 twister: Remove testcase-root reference
--testcase-root got renamed to --testsuite-root

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-07-02 19:24:58 -05:00
Sylvio Alves
60417bad79 scripts: runners: esp32: add erase option
Adds option for erasing esp32 SoC.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2022-07-01 16:25:34 +02:00
Henrik Brix Andersen
e12d06690e scripts: west: openocd: respect pre-load and post-verify cmds for elf
Respect --cmd-pre-load and --cmd-post-verify when flashing ELF files
(--use-elf).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-01 16:12:52 +02:00
Anas Nashif
33dd2146bb twister: use original reason with qemu failures
If we already have recorded the reason during the qemu run, do not
override it at the final stage of status processing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-01 07:31:08 -04:00
Anas Nashif
1cdada84ff twister: also paese ZTEST_USER and ZTEST_USER_F cases
Parse additional ztest types with new API that were missed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-01 06:28:35 -04:00
Hake Huang
5ae7d41111 twister: test: add default harness check
below command line need has fixture configured in map.yml,
if not, it shall be skipped
twister -p frdm_k64f --device-testing \
--hardware-map map.yml -T tests/subsys/modbus/ -vv

add harness check with testcase harness by default
will fix this issue

Fixing: #46635

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2022-07-01 11:36:10 +02:00
Abramo Bagnara
795500bbe3 coding guidelines: comply with MISRA C:2012 Rule 9.3
MISRA C:2012 Rule 9.3 (Arrays shall not be partially initialized.)

Systematically use `{0}' to specify full 0 initialization
(not `{}', not `{0U}').

Signed-off-by: Abramo Bagnara <abramo.bagnara@bugseng.com>
Signed-off-by: Simon Hein <SHein@baumer.com>
2022-06-30 17:34:05 -04:00
Carles Cufi
f9739ab41d python: Fix the requirement for libmagic to be installed
The Python python-magic module that we install for compliance checks
requires libmagic to be installed on the system to work. This requires
extra OS packages on Ubuntu and macOS, and an extra wheel on Windows.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-30 13:34:26 +02:00
Marc Herbert
9782b2cc05 scripts: intel_adsp: always invoke west sign
west flash invokes west build and we have no way to tell whether there
was any code change.

Also remove the rename() trick that achieved the same effect in a
a confusing way; just use copy() instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-06-30 10:34:30 +02:00
Marc Herbert
739aa951cd scripts: intel_adsp: don't invoke west sign with --tool-path None
When there is no rimage found in the path, don't invoke west sign with
"-tool-path None". This enhances the error message from the somewhat
cryptic:

  ERROR: --tool-path None: not an executable

... to the user friendlier:

  FATAL ERROR: rimage not found; either install it or provide --tool-path

Also log the complete west sign command at the "info" level before
running it to show that no signed firmware was found, to show which
rimage is used and in case other rimage problems arise. Invoking an
external command is an important "checkpoint".

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-06-30 10:33:53 +02:00
Henrik Brix Andersen
3d5cc38cf6 scripts: dts: gen_defines: define _TOKEN + _UPPER_TOKEN for string arrays
Generate definitions for *_IDX_n_TOKEN and *_IDX_n_UPPER_TOKEN for all
string-array type properties.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-06-28 20:46:11 +02:00
Henrik Brix Andersen
27820e9dcb scripts: requirements: extras: add clang-format
Add clang-format to the requirements-extras.txt and require a version
compatible with the configuration options present in the .clang-format
file.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-06-28 11:09:14 +02:00
Andrzej Głąbek
fb3e8138a2 west_commands: nrfjprog: Add handling of data targeting the XIP region
When a hex file contains some data that needs to be programmed using
the QSPI peripheral (because it targets the XIP region), nrfjprog
needs to be provided with an option that specifies the QSPI erase
method to be used (otherwise, reprogramming will fail).
This commit adds the "--qspisectorerase" option when needed and it
also fixes the programming routine for nRF53, so that data for the
XIP region is not incorrectly interpreted as intended for the network
core.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-06-24 20:29:00 +02:00
Lauren Murphy
318e6db239 debug: coredump: add xtensa intel adsp, support toolchains
Adds compatibility with Intel ADSP GDB from Zephyr SDK and
from Cadence toolchain to coredump_gdbserver.py.

Adds CAVS 15-25 (APL) register definitions. Implements
handle_register_single_read_packet to serve ADSP GDB
p packets.

Prevents BSA from changing between stack dump printout
and coredump by taking lock. Observed to be necessary for
accurate results on slower simulated platforms.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2022-06-23 15:44:45 -04:00
Maciej Perkowski
dfffc27039 twister: Delete less files during artifact cleanup
Option --runtime-artifact-cleanup/-M allows to clean build artifacts
during runtime to save space usage. However, if one wanted to combine
it with --build-only and then --test-only, they would get an error.
This commit expands the list of files stored with -M with files
required to made --test-only also to work afterwards. Such change can
be useful for setups where building is done on one node and then
minimal amount of artifacts are transfered to another one.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-06-23 09:11:40 +02:00
Jeremy Bettis
3b2d3129a5 west: Fix --openocd-search argument
Running west flash with the --openocd-search arg will result in the
openocd command being run with a -s param added for every character in
the passed DIR.

Fix the argparser to append all openocd-search DIRs into a list, instead
of just passing a string to the subcommand.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-06-20 10:26:23 +02:00
Anas Nashif
d63c2c44b5 ci: do not add assignees if already set
If PR already has an assignee, do not add additional assignees to the
PR. Each PR should only have one assignee (in most cases)

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-17 11:56:07 -04:00
Gerard Marull-Paretas
abaa5b8dfa scripts: checkpatch: allow leading spaces in multi-lines macros
With the current clang-format rules, we have that multi-line macros that
contain empty lines (usual in driver definition macros) are formatted
with spaces only, no leading tabs. For example:

```c
 #define MYDRIVER_DEFINE(i)                 \
 	 struct mydriver_data data##i;      \
                                            \ /* starts with spaces */
	 struct mydriver_config config##i;  \
	 ...
```

This patch makes checkpatch ignore such cases, so that clang-format can
be used in tree while keeping checkpatch happy.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-17 10:18:37 +02:00
Gerard Marull-Paretas
d89dc22665 uncrustify: remove configuration file
Remove uncrustify configuration file in favor of using clang-format, a
tool that is nowadays more popular/powerful for code formatting.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:37:30 -04:00
Benjamin Gwin
3f8d5c49b3 twister: Exit with a bad status if there were build errors
Previously, twister would exit with a 0 status code if there were build
failures but no execution failures. This makes it easier to catch
build breakages when using twister in CI workflows.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-14 21:56:51 -04:00
Anas Nashif
071f62cb75 west: remove intel_s1000_crb runners
Remove runners specific to the intel_s1000_crb board. it is no longer
available or supported in the zephyr tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-13 16:19:51 -04:00
Adrian Bonislawski
def0127f34 requirements: bump pyelftools to >=0.27
The minimum version of pyelftools is 0.27 to make it working
with databse_gen.py

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-06-10 09:46:31 +02:00
Anas Nashif
2e1814263e twister: rename add_missing_testscases
add_missing_case_status is more appropriate for this function.
We are adding missing status, not cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-09 12:15:28 -04:00
Anas Nashif
87be2f591f twister: rework how we discard tests
Add a filter type to distinguish between testsuite filters that are
maintained in the testcase.yaml file and those provided on the command
line.

The issue was that when something is excluded deliberately on the command
line twister would report an error if that filter would filter out an
integration platform. We do not want that, because the filtering is
being done by the caller knowing that some tests would be not run, even
if those are integration platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-09 12:15:28 -04:00
Ming Shao
0e79dc393c twisterlib: drain the serial leftover before new test
Some tests can cause serial leftover logs buffered on board.
A simple ser.flush() is not enough. So add explicit readline()
to drain such logs which prepares a clean serial context for
the case that follows.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-06-09 06:35:48 -04:00
Anas Nashif
20483161b2 scripts: introduce script to set labels, assignees and reviewers
Use MAINTAINERS.yml file to set lables, assignees and reviewers for
specific PRs or all unassigned PRs since a given date.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-08 22:49:13 +09:00
Anas Nashif
c62ee3be4e twister: remove fallback testcase if cases added at runtime
The fallback testcase, which is the scenario name from the yaml file is
added if we did not discover any testcases via parsing. It can be
removed if we discover testcaes at runtime or otherwise it is added as
skipped...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-07 06:02:00 -04:00
Anas Nashif
bcf4e23562 twister: do not set case status on flash timeout
Status was set for testcases after a timeout on flash, which does not
abort the process and continues with test execution and eventually
passes the test.

Setting status on the testcases was done too early and before we have
executed the tests.

Also increase the flash timeout to 60s.

Fixes #45845

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-07 06:02:00 -04:00
Anas Nashif
eeffdc373e twister: do not mark tests as blocked if a testsuite has passed
Do not set status as blocked on testsuites which passed. The sub cases
with no status will get a processed later.

Fixes #45845

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-07 06:02:00 -04:00
Martí Bolívar
f6a6843471 python-devicetree: CI hotfix
Pin the types-PyYAML version to 6.0.7. Version 6.0.8 is causing CI
errors for other pull requests, so we need this in to get other PRs
moving.

Fixes: #46286

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-06-06 09:09:27 -07:00
Jordan Yates
57fa9121a1 scripts: gen_handles: injected device handles
Update the device handle array for injected devices to output device
handles, not device ordinals. This requires that the extra ordinals
provided to `DEVICE_DT_INST` map to an existing device in order to
appear in the final handle array.

This is required for the injected handles to be useful, no meaningful
operations can be done on device ordinals.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-05 14:26:39 +02:00
Jordan Yates
2e014ec1cb scripts: gen_handles: fix extra DEVICE_HANDLE_SEP
Remove an extra `DEVICE_HANDLE_SEP` that was being inserted into the
handle array when injected dependencies were present.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-05 14:26:39 +02:00
Enjia Mai
2674c44a59 twister: passing a pty pararmeter to intel_adsp runner
Add a pty parameter from twister to intel_adsp when west-flash,
to tell the intel_adsp runner to change the way it outputs the
log.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-06-05 14:13:57 +02:00
Enjia Mai
12c44aaec7 scripts: runner: add a intel_adsp west runner
Add a intel_adsp west runner instead of using misc-flasher for
intel_adsp boards. Now running the test on intel_adsp_cavs by:

  west build -b intel_adsp cavs25 ...
  west flash --remote-host [remote hostname or ip addr] \
             --rimage-tool [path to rimage tool] \
             --config-dir [path to dir of .toml config file] \
             --key [path to signing key]

The intel_adsp west depends on the cavstool_server.py running
on the remote host machine.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-06-05 14:13:57 +02:00
Martí Bolívar
b964f0b156 scripts: add dump_bugs_pickle.py
This prints the contents of a zephyr-bugs-$DATE.pickle file in a
format similar to the output of list_issues.py.

It will be useful to have this in tree so that we can better record
the known issues at the time of a particular zephyr release.

The pickle file itself should be created using the bug snapshot
workflow defined in .github/workflows/bug_snapshot.yaml, which can be
triggered manually from this URL:

https://github.com/zephyrproject-rtos/zephyr/actions/workflows/bug_snapshot.yaml

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-06-03 19:19:25 -05:00
Evgeniy Paltsev
554aa9cde3 ARC: west: mdb runner: change folder to run MDB
Make the build folder the place where MDB is run. Otherwise mdb
will store the .sc.project folder in the place where twister is
launched (so .sc.project folder will be shared across the runs)

For that we add **kwargs argument to popen_ignore_int method
so we can pass a cwd argument to the Popen constructor.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-06-02 13:09:51 +02:00
Ming Shao
33795e3776 twisterlib: fix the execution time for device testing
At the end of DeviceHandler.handle(), the execution time
should be recorded no matter what the harness.state is.
This reflects how much time has been spent on the device.
And it is also used later to determine if a test has been
attempted on a real device or just build-only.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-05-30 10:30:00 +02:00
Fabio Baltieri
93f20d7a7a include: add zephyr/ on script generated #include
Fix few script generated #include that needed the zephyr/ prefix.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Hake Huang
75845f5f4e test: twister: fix false negative in device test
in device test when harness is Test, if there is no console output,
the self.state is None, as at this time self.instance.state
is "pass", as the last step cmake is "pass". So it will report "pass",
but actually there is no console output issue

you can easily reproduce this issue by set
line='' at the begining of the Test.handle function

fixing: #45942

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2022-05-26 11:39:14 +02:00
Stephanos Ioannidis
39956ec835 twister: Add option to always force color output
Colorama, by default, strips out the color escape characters when the
output is redirected, and this may have an unintended consequence of
disabling color outputs when using a utility such as `tee` and in the
CI runners that redirect the stdout and stderr console outputs.

This commit adds a new command line option called `--force-color` to
always force the ANSI color escape sequence output even when the output
is redirected.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-25 12:48:31 +09:00
Yuval Peress
86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Martí Bolívar
78edc12c1b scripts: add make_bugs_pickle.py
This is a simple script which snapshots open bugs in the
zephyrproject-rtos/zephyr repository using the GitHub REST API.

It relies on the 'github' module, which is a de-facto standard for
accessing this API in Python:

  https://pygithub.readthedocs.io

We are already using this package in scripts/release/bug_bash.py, so
this is not a new dependency, even though it's a third party package
not available in the standard library.

The resulting bugs are stored in the standard library's 'pickle'
format, as a list of github.Issue.Issue objects. For more on pickle,
see:

  https://docs.python.org/3/library/pickle.html

I am choosing pickle because it is standard, easy to use, and we are
already using it in the build system to store the edtlib.EDT object
created by gen_defines.py. This is also therefore not a new
dependency (and even if it were, it's in the standard library).

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-05-24 18:48:03 +02:00
Martí Bolívar
8aaea6d200 scripts: add github_helpers.py
This is meant to be a place where we can store generic zephyr wrappers
around the de-facto standard github API for python.

The first 'customer' will be a script that snapshots our open bugs at a
particular point in time, which will be added in a later patch.

I think it's useful to factor this file out of there from the
beginning just to keep things clean, even though I don't have a second
customer in mind at the moment.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-24 18:48:03 +02:00
Stephanos Ioannidis
e332ddb5b4 scripts: tracing: Initialise Colorama during module load
This commit adds a call to the Colorama initialisation function during
the module execution so that ANSI color sequences are properly
converted to the relevant Win32 API calls on the Windows.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-24 09:00:16 -07:00
Stephanos Ioannidis
847ff98bb3 scripts: dictionary: Initialise Colorama during module load
This commit adds a call to the Colorama initialisation function during
the module execution so that ANSI color sequences are properly
converted to the relevant Win32 API calls on the Windows.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-24 09:00:16 -07:00
Stephanos Ioannidis
2ee02f9dfa scripts: fpdiff: Initialise Colorama during start-up
This commit adds a call to the Colorama initialisation function during
the module execution so that ANSI color sequences are properly
converted to the relevant Win32 API calls on the Windows.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-24 09:00:16 -07:00
Stephanos Ioannidis
aae454708d twister: Initialise Colorama during module load
This commit adds a call to the Colorama initialisation function during
the module execution so that ANSI color sequences are properly
converted to the relevant Win32 API calls on the Windows.

Note that the init function needs to be called per module, hence it is
also called in the `twisterlib.py`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-24 09:00:16 -07:00
Anas Nashif
88d4299d88 scripts: fpdiff: iterate on namespaces
Iterate on 3 main namespace to avoid collision in identifiers sharing
the same name at the top level when creating the diff.

Fixes #44940

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-24 08:57:55 -07:00
Erwan Gouriou
4d073a755d scripts: west: openocd runner: Add an option to specify target handle
Provide a way to specify the openocd target script handle used to
describe the core target.
In most target scripts '_TARGETNAME' is used, but it can happen that
'_TARGETNAME.foo' or '_CHIPNAME.bar' is used, specially on SoCs subject
to multicore.

Today, this option is required to enable rtos thread awareness,
using '$_TARGETNAME configure -rtos Zephyr' command, which is generated
by this runner.
It could be useful for similar needs in future.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-24 08:52:16 -07:00
Jordan Yates
06aae61019 scripts: zspdx: fix writing custom license IDs
The builtin list function `.sort()` sorts the list in-place and returns
None. As this is an invalid type for iteration, use the builtin `sorted`
function, which returns a sorted copy of the list, which we can iterate
over.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-23 10:18:06 +02:00
Fabio Baltieri
bd61ced760 twister: fix wrong flag name in the helpdoc
The flag --testcase-root has been renamed to --testsuite-root in

15bc98eb50 twister: rename TestCase -> TestSuite

Fix the --help text to reflect the change.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-20 19:22:20 -07:00
Henrik Brix Andersen
c6b3094d5e scripts: kconfig: kconfigfunctions: use relative ZEPHYR_BASE path
Use a path relative to the script itself to determine the ZEPHYR_BASE path
instead of relying on the environment variable.

This allows for modules to use the Zephyr kconfiglib without having
ZEPHYR_BASE set in the environment.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-05-18 11:02:26 -07:00
Stephanos Ioannidis
f2b0991147 scripts: check_compliance: Fix broken links to Contribution Guidelines
This commit fixes the broken links to the Contribution Guidelines in
the Compliance Check script.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-17 13:40:27 -04:00
Anas Nashif
734c345457 twister: sort hardware map based on id
Serial is not required, in some cases it might be set to null or we
might be using serial_pty, so sort existing map file based on ID
instead.

Fixes #45713

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-17 08:29:42 -04:00
Chen Peng1
ca08d2e4a6 twister: ignore serial device SerialException.
For some boards, like up_squared and ehl_crb, they need do a
power off/on operation and use bios to load and execute zephyr
test binary, during the power off, it may meet this SerialException,
but the serial object still works well after power on, we can continue
to get all results from serial, so we don't need to close it,
it's ok to ignore this exception.
BTW, even if we ignore this exception here, it doesn't influence twister
function, because if it was really caused by disconnection, the test would
still be judged as failed due to timeout and serial would be closed later
in main thread, it doesn't impact results.
On the contrary, close serial directly in the monitor serial thread, it
will cause later tests failed due to mismatch errors.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-05-16 16:55:42 +02:00
Anas Nashif
a6f924db7f twister: add support for platform_type filter
Instead of relying on runtime filter to limit scope to emulation
platforms, use the type attribute for each platform and do the filtering
very early on. This will speed things up for tests where we only run on
emulation platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-14 14:49:59 -04:00
Daniel DeGrasse
fbefc50a9c scripts: kconfig: add dt_chosen_has_compat
Add dt_chosen_has_compat kconfig helper function. This function checks
if a given `chosen` node has a provided compatible string in its
compatible list. Returns "y" if compatible string is present, and "n"
otherwise.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-05-13 10:57:08 -07:00
Jordan Yates
8e4107f9be scripts: ensure intended path for edtlib imports
When updating `sys.path` to allow importing the pickled edtlib instance,
add the path to the front of `sys.path`, not the end. This ensures that
the `devicetree.edtlib` module that is imported is the one relative
to the files being run, not some other version which may exist on the
path.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-13 10:09:45 -07:00
Anas Nashif
f089f964fd twister: update ci options for twister
Now that we have partially oerhauled twister in the tree, modify actions
with new options:
- not reporting filtered tests is now default
- output is json, not csv

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:57:37 -04:00
Anas Nashif
3ae685ef8d twister: for ci and in twister.yml, treat built tests as passed
For CI and for the condensed version of the report, consider built tests
as passed and do not mark them as skipped. Tests that are built only
will be reported as skipped in the full and suite reports.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
bd1b364c2e twister: do not report filtered tests by default
Filtered tests are now not being reported by default to allow generation
of reports that are easier to parse and work with in different tools.

The complete filtered set of tests is still available in the json output
for review and verification.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
0313c5ce6f twister: hwm: rename forgotten connected_hardware -> duts
This was forgotten from an early overhaul, fix this as
connected_hardware attribute does not exist anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
7a83d4fe02 twister: reports: add timestamp to junit report
Add a timestamp to junit reports as per specification.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
fd75aa6286 twister: generate junit report with testsuites rather than platforms.
We have been generating reports with the platform being used as the
testsuite, ie. all testcases would land under one single big testsuite,
which is very difficult to use or read.

This change uses testsuites as intended and does that for each defined
testsuite (or scenario). Platforms are added as properties among other
things.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
6404988e3b twister: fix setting of reason value on tests to be run
When loading tests from json file we want to reset the reason for those
tests that are to be run and remove whatever we had when the test was
only built.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
c8adf8808c twister: set type of built only tests correctly
we mark built only tests as skipped, however, the type was still the
same as other skipped tests, set this to 'built' to indicate the tests
was only built.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
bad8a0f9ef twister: xunit: we do not use the results of xunit
Remove return that is not being used anywhere.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
c5ea3af001 twister: fix hardware map generation an serial detection on mac
Do not fail on serial not being available.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
d5a5cc131f twister: cleanup status and reason setting
Remove some legacy code and set status and failure/skip reason directly
without set_state and get_state.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
03dca681d3 twister: fix status handling on build errors and overflows
Handle build errors due to overflows correctly and do not report those
as failures if not requested.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
c88d8c07c7 twister: fix --build-only followed by --test-only usecases
Set status correctly when building and executing tests in 2 different
steps.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
bf48c12b14 twister: set status for subcases when blocked
When we have a build failure or anything that would prevent execution of
the test, set the status for all subcases accordignly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
7f3a62f2ce ci: keep old name of testplan file for now
Until we are ready to change workflow file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
41cb42d4db ci: testplan converted to use json
twister now exports json instead of csv, so we make the testplan read
the json data and generate the consolidated plan for the workflow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
7d23e509a3 twister: finetune reporting for misconfigured testsuites
Report misconfigued testsuites and subcase parsing issues instead of
erroring out. This should help us fix those tests and then enforce
accurate result capturing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
9328285b1d twister: status: fix status evaluation
Fix some inconsistencies with status and execution time setting in
multiple areas.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
79693590d4 twister: reporting: set default status to 'Unknown'
Set status to unknown when we do not have any status set or status is
None.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
c820ffe18c twister: remove unused arguments in reporting functions
Remove unused arguments that became obsolete through the refactoring.
- filter_status
- only_failed
- json_report

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
b156f2dbea twsiter: also count errors for the plan
Count the errors found during setup and update counter.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
dbd460fd04 twister: apply_filter: discards is not part of TestPlan
Use class member instead of local variable of discards.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
26e3c30234 twister: report: capture failures per testcase
Capture failures per testcase so that we can include the output in
reports for only failed testcases and not include the whole log which
can be overwhelming.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
b86895adbb twister: reports: attach logs to xunit reports
This was missed in the report generation step, we now add them to the
xml file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
58f1926c93 twister: xunit: Fix conversion to text alignment
Do not create testsuite entries if all tests are being filtered.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
ab15d1ad8b twister: tests: remove tests of dropped features
Removed tests for dropped functionality.

Renamed classes and files to reflect new structure.

As we refactor the reporting infrastructure, tests will follow once we
have everything in place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
61f11536f9 twister: fix initial stats about discards
Fix discard stats in the summary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
8e805596d5 twister: support defining testcases in yaml file
Some complex testsuite use macros and other mean to define testcases
which makes them unparseable. This ends up in a descripency between the
testplan and the test results.

Allow adding the testcases into the yaml and use those instead of
parsing the C files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
e08760e507 twister: support per case duration
We are now able to capture individual case duration and can display this
as part of the reports instead of using the overall test instance
execution time.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
4a1695acf5 twister: add testcase class
Now we can add the TestCase class which will hold all information about
individual testcases, their status and why they are not passing, etc.

Test cases are parsed initially and testsuite is populated with the list
of testcases it contsins. This list is duplicate for each instance
(scenario) and used to capture test case data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
111097098e twister: rename more testCase -> testsuite usages
More renaming and change to variable names to make it less confusing.
Especially, renames of tc to become ts where applicable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
15bc98eb50 twister: rename TestCase -> TestSuite
TestCase in the old terminology is the test application, but we have
just freed up TestSuite, so use TestSuite here to signify the test
application which consists of many test scenarios and testcases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
7424c65779 twister: rename TestSuite -> TestPlan
Change terminology and fix usage based on the current hierarchy. A
testsuite is each test application we have in the tree. The top class is
where we detect all the test suites and create the testplan to be run
later.
Content of testplan will have to split out, so it only deals with the
plan and not the overall execution of tests. This step will be done at a
later point.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
d70b267e3e twister: set correct status when loading json
When loading json, make sure we set the status correctly depending on
the type of the testscase.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
ba8b557433 twister: fix some pylint issues
Fix a few pylint issues after the refactoring.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
2de0366784 twister: re-enable report filtering
Re-enable option to filter out skipped test cases as a result of
configuration or runtime filters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
c9daae592a twister: fix reporting of status and duration
Various fixes to reporting and filtering of results.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
eba9792a1b twister: generate unit from json
We now have all the logic for generating data suitable for reports in
one single place (json). The junit reports and in the future other
reports will be using this as input and generate reports using the json
data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
1de0a3dc93 twister: remove release data handling
An obsolete feature that is no longer being used due to the amount of
data that is needed per release and the fact it becomes stale very fast.
Instead, point to files directly for comparison.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
106521074e twister: remove --export-tests option
We now have a better format for exports (json), use that instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
3dcc038274 twister: use json instead of csv for everything
Drop CSV generation which was the standard for sharing information since
the early days and instead use json with more content to share
information across sessions and for report generation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
17b654c19f twister: rework json reports
Refine structure and accomodate more data, this report will serve as the
source for a testplan, reports and retries.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
d5dbeb2f17 twister: improve reporting of filtered and built cases
Specify why something was skipped (either filtered or through a ztest
case) and do not report testcases that are only being built as passed,
mark those tests as skipped with the reason specified as "Build only".

Keeping --no-skipped-report for now, although it has no impact.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
ffc37f38e5 twister: move noop options out
Many option cancel out very already on,. so lets do this as part of the
option processing function first before we create workspace.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
57fa5fbb6d twister: move logging setup into own function
Cleanup main() and move logging code into own function.
This reduces clutter in main function and simplifies workflow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Aastha Grover
eee56d8840 scripts/check_complaince: Add configs to UNDEF_KCONFIG_WHITELIST
Adding LOG_BACKEND_MOCK_OUTPUT_DEFAULT &
LOG_BACKEND_MOCK_OUTPUT_SYST to UNDEF_KCONFIG_WHITELIST as Kconfig
options generated by a template under testcases are not
identified by Compliance check by default.

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2022-05-12 07:39:06 -04:00
Al Semjonovs
ce54efaf70 twister: Add seed as argument for native_posix builds
Use the seed as arg for ZTEST_SHUFFLE enabled builds

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-05-11 12:14:31 -04:00
Enjia Mai
4966de2014 twister: add a hardware map support for using serial pty
The hardware map feature can be used with serial pty mode in
this change. And also add an runner_params option for passing
more parameters from hardware map file to west runner. Note
that you need to create this map file manually because it
cannot be scanned out correctly due to pty is not a physical
HW device existing in system.

And also update doc/develop/test/twister.rst for the usage.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-05-11 05:54:23 -04:00
Gerard Marull-Paretas
0d18e911fc scripts: utils: add include migration script
All includes are now prefixed with <zephyr/...>, even though the old
include paths can still be used when CONFIG_LEGACY_INCLUDE_PATH=y, an
option still enabled by default. Migrating large projects can be tedious
and time consuming. This patch provides a script that can be used to
migrate any Zephyr-based project to the new include path. It is used
like this:

  python $ZEPHYR_BASE/scripts/utils/migrate_includes.py \
         -p path/to/zephyr-based-project

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-11 10:55:35 +02:00
Mark Holden
d04ab82943 coredump: adjust mem_region find in gdbstub
Adjust get_mem_region to not return region when address == end
as there will be nothing to read there. Also, a subsequent region
may have that address as a start address and would be a more appropriate
selection.

Signed-off-by: Mark Holden <mholden@fb.com>
2022-05-10 15:26:31 -04:00
Esteban Valverde
74ae6f654e scripts: west_commands: runners: add runner for Cyclone V SoC FPGA DK
Add a runner to "flash" and "debug" Cyclone V SoC FPGA Development Kit
the runner is based on OpenOCD and GDB

Signed-off-by: Esteban Valverde <esteban.valverde.vega@intel.com>
2022-05-10 13:29:47 -04:00
Tristan Honscheid
dbbe80226d twister: Fix dependency on west when checking for projects
Twister should be partially usable even without West installed, however,
Twister unconditionally tries to import it when initializing to check
for west projects and crashes if it is not there.

This PR changes the behavior to return None if the west imports failed,
which appears to be more in line with what was intended. This allows
Twister to proceed and successfully run tests in a non-west environment.
There is no impact on environments that do have west installed.

Fixes #45355

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-05-09 13:48:17 -07:00
Daniel Leung
2e2c8cc931 scripts: logging/dictionary/sys-t: log module info in collateral
This updates the MIPI Sys-T collateral generation to include log
modules in the XML file. This allows the parser to show where
each log message is coming from.

Note that the addition of Name propety in sys:Client is to clarify
that this collateral is from Zephyr.

Also note he addition of Mask property in syst:Guid is for parser
to match this collateral to any incoming messages, as the module
IDs are encoded in the set bits in the GUID. Without the mask,
the parser will discard any messages with non-zero module IDs.
This is based on the observation of the reference parser,
systprint, where pseudo GUIDs are generated from the module/unit
IDs (origin unit) in the incoming messages for matching with
collaterals.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-05-09 12:54:53 -05:00
Gerard Marull-Paretas
8f09118b4a scripts: gen_handles: update to handle <zephyr/...> include prefix
Update the script so that it handles generates files using the
<zephyr/...> include prefix.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Gerard Marull-Paretas
cf8d9f88fe scripts: gen_syscalls: update to handle <zephyr/...> include prefix
Update the script so that it handles generates files using the
<zephyr/...> include prefix.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Anas Nashif
94b316eacf ci: testplan: limit test scope on global changes
When doing global changes, like typo fixes or header changes, keep
default scope and do not build each test for each platform.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-06 08:19:49 -04:00
Evgeniy Paltsev
7353ea5886 twister: implement platform-specific test timeout management
Twister allows us to control maximum execution time for each
test with timeout value in test .yaml configuration. This
helps us to prevent slow tests from stopping by timeout.

However it's hard to choose test timeout for all platforms
as some platforms are naturally slow. It could be a HW board with
power-efficient but slow CPU or simulation platform which
can perform instruction accurate simulation but does it slowly.

As we don't want to increase test timeout infinitely to meet
the needs of the slowest platform let's introduce
platform-specific test timeout management. It's implemented as
an optional 'timeout_multiplier' field in board .yaml
configuration. Setting it to some value multiplies each test
timeout by this value. By that we can increase timeouts only
for the platforms where it's required.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-05-04 19:01:11 -04:00
Maciej Perkowski
53d3aa199d twister: Modify twister test for run_id in csv files
CSV file is expanded to store run_id and the corresponding test
requires a modification.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-05-04 09:39:50 -05:00
Maciej Perkowski
edcc85d3d5 bugfix: twister: Store run_id in csv meta file so it can be reused
A unique run_id is now also added to the twister.csv file. This
file is used to store meta-data, in particular for `--test-only`
option. The run_id is then reused in `--test-only` calls to verify
if the id from readout matches the expected one.

fixes: #45278

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-05-04 09:39:50 -05:00
Fabio Baltieri
d42b2e6bed scripts: gitlint: block Change-Id tags in commit message
Add a new gitlint user rule to block unwanted commit tags, and set it up
to block Gerrit Change-Id tags.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-04-20 20:59:33 -04:00
Bartosz Bilas
fc88ddf59c scripts: checkpatch: add Co-authored-by tag
Add Co-authored-by tag which is mainly used by Github.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-21 02:02:39 +09:00
Stephanos Ioannidis
5a93798b22 Revert "scripts: check_compliance: check for commit message errors"
This reverts commit e61c534e52, which
enabled commit message checking via the checkpatch script.

The checkpatch commit message checking is currently causing more
problems that it fixes, for example:

1. the rules that are supposed to be specific to the "header" (commit
   message) are being applied to the diffs.

2. there are some rules that do not fully make sense for the Zephyr
   and the way we have been doing things.

Note that we currently have the 'gitlint' checking the commit messages,
so reverting this feature does not completely take away the commit
message checking in the CI.

If we are to ever re-introduce this feature, all of the aforementioned
issues need to be addressed, and the effects and ramifications of
enabling this feature must be thoroughly analysed.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-04-20 22:31:57 +09:00
Anas Nashif
f429f339fc twister: allow filtering based on modules
Support new keyword in the testcase.yaml to allow filtering based on
enabled modules. This is useful when you only whitelist a limited set of
modules in your project and want to only run those samples that have
their dependencies satisfied and those modules available.

The option allows adding multiple modules, all of which need to be
enabled in the manifest.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-19 09:38:55 -04:00
Piotr Golyzniak
b029bfd65c twister: set encoding during open log file
Set the same encoding for collected CMake output and file where this
output will be saved.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-04-19 08:40:34 -04:00
Flavio Ceolin
d02a1e9879 pm: Only resize power domains
Instead of resizing all devices handles, we just resize devices that are
power domains. This means that a power domain has to be declared as
compatbile with "power-domain" in device tree node.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Flavio Ceolin
0b13b44a66 pm: device: Dynamically add a device to a power domain
Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.

The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Fabio Baltieri
e61c534e52 scripts: check_compliance: check for commit message errors
Change CheckPatch() compliance test to call checkpatch.pl directly
rather than through git diff. This has the advantage of including the
commit message in what is being checked, which is useful to catch stuff
like spurious Gerrit commit ids.

The --mailback does not seem to work correctly in this mode, but since
the output is filtered by checking the command exit code anyway, that
option is redundant, so drop that as well.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-04-15 10:35:09 -07:00
Piotr Golyzniak
d54cb04fb7 twister: option to disable suite name check
Add option to disable ZTest test suite name verification.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-04-14 10:16:06 -04:00
Moritz Fischer
6a76b9844d scripts: get_maintainer: Use SafeLaoder for yaml
Using SafeLoader is preferrable where possible

Signed-off-by: Moritz Fischer <moritzf@google.com>
2022-04-13 13:48:18 -07:00
Alexander Mihajlovic
099c126c36 scripts: Teach zephyr_module.py to find module.yaml
The zephyr_module.py script now accepts module.yaml
in addition to module.yml when processing modules.

Signed-off-by: Alexander Mihajlovic <a@abxy.se>
2022-04-13 13:48:00 -07:00
Mark Holden
eba9c872b1 coredump: Add callee registers to arm arch block
Add version 2 to coredump arm_arch_block
which includes callee registers

Signed-off-by: Mark Holden <mholden@fb.com>
2022-04-13 13:26:37 -07:00
Anas Nashif
540327ee4f twister: generate and verify test run id
Set run id (md5 of instance and a random number) for each test and match
what was set during build with the output on the screen. This will
verify that we are evaluating the same test we have uploaded and not
some previous output on the screen.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-12 08:54:41 -07:00
Andrzej Głąbek
cd00a3a3c9 scripts: kconfigfunctions: Redefine dt_nodelabel_has_compat()
The function in its current form is confusing because unlike other
similarly named functions (dt_nodelabel_has_prop(), dt_node_has_prop())
or devicetree macros (DT_NODE_HAS_COMPAT(), DT_NODE_HAS_PROP()), this
function takes into account the status of the checked node and returns
"y" only when the node is enabled.
This commit redefines dt_nodelabel_has_compat() so that it no longer
checks the node status, and for cases where the previous functionality
is needed, a new function named dt_nodelabel_enabled_with_compat()
is introduced as a replacement.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-02 15:14:38 +02:00
Andrzej Głąbek
9f2a27b3e0 scripts: kconfigfunctions: Add dt_has_compat()
Add a function for checking if any node with a given compatible exists,
no matter if its status is "okay" or not.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-02 15:14:38 +02:00
Anas Nashif
6e8cb0d155 MAINTAINERS: do not use orphaned terminology
an area without maintainer is still considered active, calling it orphan
is a bit extreme. We have some areas that can be considered "orphaned",
those now will be covered with 'odd fixes' status, meaning that they
might have one or more collaborator and getting some changes from time
to time, but nothing beyond fixes and nobody driving the area beyond
where it is right now.

Even an area with a dedicated maintainer can be have the status of 'odd
fixes', i.e. there is a maintainer but the area is stale and no further
development is happening.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-01 17:16:41 -04:00
Anas Nashif
43d3dfb7c5 boards: add maintainer to the platform yaml file
Each board needs to have a maintainer to allow automatic assignment and
adding reviewers when pull requests concerning the platform are being
submitted.

This is now a placeholder so we can start adding maintainers early, the
data is not being used anywhere yet.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-01 17:16:41 -04:00
Daniel Leung
0c600d7bff scripts: logging/dictionary: generate MIPI Sys-T collateral
This adds the ability to the dictionary logging database
generation script to output MIPI Sys-T collateral in XML.
This will allow usage of catalog logging under Sys-T, which
is similar to dictionary logging.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
1c9e89cd5e scripts: logging/dictionary: can specify output format
This changes the script to allow output format to be specified.
Currently, only JSON is support. This will allow supporting
other formats in the future.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
caca548cf9 scripts: logging/dictionary: extract actual strings for db
This changes the database generation to actually extracting
individual strings instead of stuffing the whole binary sections
into the database. This allows the generation script to be
extended to accommodate more output formats.

Note that if CONFIG_LOG2_FMT_SECTION is enabled, the format
strings are in log_strings_sections, and also have associated
debug symbols in DWARF. So there is no need to manually
extract them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
dc6b51a52d scripts: logging/dictionary: fixes pylint warnings
Fixes some easy pylint warnings.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Daniel Leung
bdf778b196 logging: dictionary: update package processing
With the new structure of the cbpprintf packages, the Python
parser needs to be updated to skip extra bytes before reaching
the string table.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-01 13:29:45 +02:00
Piotr Golyzniak
806cc70f7c twister: harness: fix ztest detection
Decision about whether test should be considered as ztest should be made
after detection ztest testcase - not after detection ztest test suite.

Fixes: #44397

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-31 22:31:08 -04:00
Gerard Marull-Paretas
e9d2cea2a3 doc: enable sphinx-copybutton extension
The sphinx-copybutton extension adds a button to every code snippet
that, when clicked, copies the code to the clipboard.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-25 15:05:13 -07:00
Anas Nashif
8c0b82d0b8 ci: remove buildkite/daily.yml from ignore list
This file does not exist anymore

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-24 09:44:11 -05:00
Andrzej Głąbek
23994335c8 scripts: kconfig: Add missing check in _dt_node_bool_prop_generic
This is a follow up to commit a1ab8da862.

Handle the case when a node with the specified label does not exist.
Unlike edt.get_node(), edt.label2node.get() retuns None then, it does
not raise edtlib.EDTError.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-24 15:13:32 +01:00
Steve Winslow
c2ae5b3bbf west: spdx: Exclude files not present after build
The list of files which are included in the `build.spdx` SPDX SBOM document
is based on the files recorded as build artifacts based on the CMake
file-based API metadata response.

In some situations, such as the case indicated in #42072, a build artifact
may be reported by CMake but no such file is present on the system
following the build. This results in the `build.spdx` SPDX SBOM being
invalid, as a result of trying to provide metadata for a non-existent
file (and specifically being unable to provide its checksum).

This commit fixes this bug by omitting files from `build.spdx` if they
do not exist on disk after the build is complete, even if the CMake
metadata claims that they should. The resulting SPDX document should
then be valid.

Fixes #42072

Signed-off-by: Steve Winslow <steve@swinslow.net>
2022-03-24 14:54:20 +01:00
Piotr Golyzniak
c459b752f5 twister: add search ZTEST_SUITE, ZTEST and ZTEST_F
New ztest API is available in those places:
subsys/testsuite/ztest/src/ztest_new.c
subsys/testsuite/ztest/include/ztest_test_new.h

This requires also changes in Twister code during parsing c files to
find properly test suites and testcases.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:59:10 -04:00
Piotr Golyzniak
e2d903fe31 twister: extend searching src directory
Extend scope of searching src directory with defined test source code.
In some cases for optimization reason src direcotry is placed in parent
directory (in relation to testcase.yaml file placement). This changes
allow to detect such situations.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:59:10 -04:00
Piotr Golyzniak
340da2ecf3 twister: verify ztest suite name in output
Test wirtten in ztest framework should print in output information about
test suite name defined in test's source code (as a first argument of
ztest_test_suite() function). This changes make it possible to find such
test names in c files. Next they are used during test execution to
verify if performed test was performed properly (verification can base
not only on existance of "PROJECT EXECUTION SUCCESSFUL" info).

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:59:10 -04:00
Piotr Golyzniak
cdfa230131 twister: change serial option existence verification
Modify serial and serial_pty option availability verification in DTU
object in device_is_available method to avoid situation when empty string
passed as serial in hardware_map.yaml cause hang up Twister in this
place.

Fixes: #41169

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:54:22 -04:00
Martí Bolívar
50f9b3c2ca gen_defines: add _CHILD_IDX macros for nodes with parents
These expose every node's index in its parent's list of children to C.
The root node has no parent, so no _CHILD_IDX macro is generated for
it.

Keep macros.bnf up to date with the new generated macros.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-03-24 10:48:40 +01:00
Martí Bolívar
355cc01a36 scripts: gen_defines: rearrange some internals
Consolidate child helper macros into a single function. No functional
changes expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-03-24 10:48:40 +01:00
Martí Bolívar
7c3b445323 edtlib: add Node.child_index()
It can be useful to know what the index of a particular child is in
the list of nodes. Add a a helper for computing that and some test
cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-03-24 10:48:40 +01:00
Yuriy Vynnychek
1c78447428 scripts: runners: spi_burn: replaced delay by wait for response
Replaced hard-coded delay by wait for response during ICEman
connection.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
Signed-off-by: Alex Kolosov <rikorsev@gmail.com>
2022-03-23 18:33:24 +01:00
Mikkel Jakobsen
646499c36e twister: fix valgrind failure handling
falures found during valgrind execution were treated as normal test
failures, so the logger would display a link to handler.log and not to
valgrind.log, leading to some confusion.

the return code is now handled in a correct sequence.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-23 09:21:50 -04:00
Mikkel Jakobsen
78aa424f69 twister: error if valgrind executable not found
if --enable-valgrind is selected but no valgrind executable can be
found in PATH, exit with an error

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-23 09:21:50 -04:00
Mikkel Jakobsen
9314f6e527 twister: add --track-origin to valgrind execution
generate full information when looking for uninitialized variables

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-23 09:21:50 -04:00
Michał Barnaś
a1ab8da862 kconfig: fix dt_node_has_prop and add nodelabel functions
The Kconfig function "dt_node_has_prop" was using label as its
parameter, where other functions use either chosen or path.
The documentation says that the parameter is path, so this patch
makes the function as documentation says and as other functions
in the file.
The additional nodelabel functions were added as counterparts that
are using nodes labels instead of paths.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-03-23 13:25:21 +01:00
Anas Nashif
ab9de7c6d7 twister: support retrying on build errors
Allow retries on build errors, this is now done using
--retry-build-errors. This option is useful when for example build
failures are caused by licensing issues or intermittent network issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-22 12:09:14 -04:00
Anas Nashif
becef8c83b twister: Improve counting and count at runtime
Do not wait till the end to update counters, do the counting at
realitime and reuse data for on-screen reporting.

Add a counter summary function for debugging.

This patch changes how we count and report skipped tests and the total
now has the skipped tests included.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-22 12:09:14 -04:00
Anas Nashif
cdc84dc8cf twister: remove commented logger call
Remove old commented logger call.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-22 12:09:14 -04:00
David Leach
c243da02ed code_relocation: Move NOCOPY flag to avoid OS drive colon
COPY/NOCOPY flag was added to the end of the string with ':'
as separators. The python script then split the line on ':'
which breaks on Windows build because the string was

[MEM]:[FILE]:[COPY]

In windows you will have 'c:\' in the file path so the
line.split() in script will split on the 'c:'.

Move the COPY/NOCOPY to:

[MEM]:[COPY/NOCOPY]:[FILE]

Note that the comments at top of gen_relocate_app.py also
indicates this format.

Fixes #43950

Signed-off-by: David Leach <david.leach@nxp.com>
2022-03-22 12:33:40 +01:00
Gerard Marull-Paretas
8b91cb0cd4 scripts: utils: pinctrl_nrf_migrate: support more peripherals
Add support for more peripherals:

- I2C
- SPI (master mode assumed)
- PDM
- QDEC
- QSPI
- PWM
- I2S

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-21 15:09:28 +01:00
Erwan Gouriou
3b4544005c scripts/checkpatch: typdefsfile: Derogate on STM32Cube CMSIS *_TypeDef
Add a derogation to checkpatch's 'SPACING' rule, which randomly returns
the following type of issue when STM32Cube HAL *_TypeDef are used:

-:10: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#10: FILE: drivers/adc/adc_stm32.c:806:
+	ADC_TypeDef *adc = config->base;

This derogation applies to all _TypDef structures defined in STM32Cube
CMSIS descriptions:
FMC_Bank1E_6_TypeDef
DMA_Channel_TypeDef
ADC_TypeDef

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-03-21 10:11:54 +01:00
Carlo Caione
bc72fb67b1 linker: Create sections from zephyr,memory-region nodes
Currently when a node has a 'zephyr,memory-region' compatible and a
'zephyr,memory-region' string property, a new memory region is created
in the linker script.

Having a memory region without a section to place variables in could be
not that useful. With this patch we extend the memory-region mechanism
to also create sections.

The user can then place variables in the sections as usual by using for
example the GCC attributes.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-19 14:32:17 -04:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Maciej Perkowski
62c7774014 twister: footprints: Move footprint calculation
Adds operation "gather_footprint" after the build stage
with minor refactoring. Before footprints were collected
only at the very end of the twister workflow
and there were situations were elf files were not available any more
(for qemu and --runtime-artifact-cleanup used).

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-03-17 18:23:59 -04:00
Daniel Leung
a5b33f89b7 scripts: gen_kobject_list: fix pylint complain on using keys()
This fixes a pylint complain on using .keys() while looping through
dictionary.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-03-15 17:34:15 -04:00
Daniel Leung
7f8dba9d04 scripts: gen_kobject_list: linker section for _thread_idx_map
In some circumstances, _thread_idx_map[] is all zero and the linker
decides to put it into BSS instead of DATA section. This results in
kernel objects being pushed away so the hash table is no longer
valid. This forces _thread_idx_map to be in the data section inside
the intermediate object file so it will be placed in the data
section in final binary.

Fixes #43618

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-03-15 17:34:15 -04:00
Andreas Pettersson
d356280b54 twister: make git describe work without tags present
Git describe should work in eg. shallow clones when there are no tags.
Has been fixed in cmake previously, but not in twister.

Signed-off-by: Andreas Pettersson <andreaspettersson95@gmail.com>
2022-03-14 14:54:40 -04:00
Chen Peng1
1246404923 twister: fix skipped count issue in xml result with --only-failed.
When running twister with --only-failed option, based on last xml
result, the new skipped count should be the last skipped count
plus current skipped count.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-03-14 14:39:42 -04:00
enjia mai
be7dabed19 Revert "twister: passing the build dir to device serial pty"
This reverts commit 919b014509.
2022-03-11 17:57:04 -05:00
Marc Herbert
29fd1826cb sign.py: pass west -v flag(s) to rimage
Give rimage the same number of -v that were given to west.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-03-11 11:52:38 -08:00
Enjia Mai
919b014509 twister: passing the build dir to device serial pty
Passing the zephyr build directory to the script run by
--device-serial-pty, it makes the feature of the device serial
pty more flexible.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-03-10 13:29:06 -05:00
Damian Krolik
a505148d2f scripts: enforce module name uniqueness
Although CMake scripts already support duplicated module
names, if two modules with the same name provide different
Kconfig files, then both files will be loaded leading to
potential conflicts.

Modify zephyr_module.py to enforce that all modules are
uniquely named so that it is possbile to override some of
the built-in modules using ZEPHYR_EXTRA_MODULES variable.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-03-10 09:47:58 -05:00
Henrik Brix Andersen
e9c9caa80d net: remove unmaintained 6LoCAN implementation
Remove the unmaintained, experimental 6LoCAN (IPv6 over CAN bus)
implementation.

Fixes: #42559

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-09 18:07:31 +01:00
Gerard Marull-Paretas
6b2391d000 scripts: ci: check_compliance: add check for boolean prompt text
Add a new check that enforces boolean's prompt to not start with
"Enable...".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Gerard Marull-Paretas
6a273838e4 scripts: checkpatch: allow parentheses around operators
Some macros, e.g., FOR_EACH_FIXED_ARG, require a separator argument that
needs to be in parentheses, e.g., (||). This should not trigger a
checkpatch warning.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 12:05:22 +01:00
Nicolas Pitre
1db5c8b948 scripts: gen_syscalls: fix argument marshalling with 64-bit debug builds
Let's consider this (simplified) compilation result of a debug build
using -O0 for riscv64:

|__pinned_func
|static inline int k_sem_init(struct k_sem * sem,
|                             unsigned int initial_count,
|                             unsigned int limit)
|{
|    80000ad0:   6105                    addi    sp,sp,32
|    80000ad2:   ec06                    sd      ra,24(sp)
|    80000ad4:   e42a                    sd      a0,8(sp)
|    80000ad6:   c22e                    sw      a1,4(sp)
|    80000ad8:   c032                    sw      a2,0(sp)
|        ret = arch_is_user_context();
|    80000ada:   b39ff0ef                jal     ra,80000612
|        if (z_syscall_trap()) {
|    80000ade:   c911                    beqz    a0,80000af2
|                return (int) arch_syscall_invoke3(*(uintptr_t *)&sem,
|                                    *(uintptr_t *)&initial_count,
|                                    *(uintptr_t *)&limit,
|                                    K_SYSCALL_K_SEM_INIT);
|    80000ae0:   6522                    ld      a0,8(sp)
|    80000ae2:   00413583                ld      a1,4(sp)
|    80000ae6:   6602                    ld      a2,0(sp)
|    80000ae8:   0b700693                li      a3,183
|    [...]

We clearly see the 32-bit values `initial_count` (a1) and `limit` (a2)
being stored in memory with the `sw` (store word) instruction. Then,
according to the source code, the address of those values is casted
as a pointer to uintptr_t values, and that pointer is dereferenced to
get back those values with the `ld` (load double) instruction this time.

In other words, the assembly does exactly what the C code indicates.
This is wrong for 2 reasons:

- The top half of a1 and a2 will contain garbage due to the `ld` used
  to retrieve them. Whether or not the top bits will be cleared
  eventually depends on the architecture and compiler.
- Regardless of the above, a1 and a2 would be plain wrong on a big
  endian system.
- The load of a1 will cause a misaligned trap as it is 4-byte aligned
  while `ld` expects a 8-byte alignment.

The above code happens to work properly when compiling with
optimizations enabled as the compiler simplifies the cast and
dereference away, and register content is used as is in that case.
That doesn't make the code any more "correct" though.

The reason for taking the address of an argument and dereference it as an
uintptr_t pointer is most likely done to work around the fact that the
compiler refuses to cast an aggregate value to an integer, even if that
aggregate value is in fact a simple structure wrapping an integer.

So let's fix this code by:

- Removing the pointer dereference roundtrip and associated casts. This
  gets rid of all the issues listed above.
- Using a union to perform the type transition which deals with
  aggregates perfectly well. The compiler does optimize things to the
  same assembly output in the end.

This also makes the compiler happier as those pragmas to shut up warnings
are no longer needed. It should be the same about coverity.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-03-08 11:26:58 +01:00
Nicolas Pitre
df80c77ed8 scripts: gen_syscalls: fix access validation size on extra params array
It was one below the entire array size.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-03-08 11:26:58 +01:00
Otavio Salvador
e2edb3e405 scripts: Allow use of bash outside of /bin
Even though bash is commonly available as /bin/bash there are
exceptions (e.g NixOS). This commit allow the use of the scripts in my
environment and is generic.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2022-03-08 11:11:10 +01:00
Anas Nashif
dd651c0323 twister: add option to ignore skipped tests in reports
With --no-skipped-report, twister will skip over all tests marked as
skipped (filtered) in the junit report.

This is useful for CI where have 1000s of filtered tests that appear in
the report and in some cases cause tools parsing the output to fail or
provide incomplete results.

Fixes #38179

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-03 12:12:03 -05:00
Gerard Marull-Paretas
036b780c89 scripts: kconfig: update symbol info hint URL
Kconfig options are now in
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_XXX.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-03 08:30:25 -05:00
Maciej Perkowski
02f949401e twister: footprints: Fix missing memory footprints
Commit 28b2e55321 introduced a regression
into twister workflow, breaking memory footprint calculation.
The commit changed name of produced .elf files.
There is no more zephyr_prebuilt.elf and instead we have
zephyr_pre0.elf and zephyr_pre1.elf. This commit fixes a filter
telling which files to exclude when calculating memory footprints,
to match the current status.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-03-02 10:02:40 -08:00
Markus Swarowsky
9510f96179 west: runners: Fix verify warning from nrfjprog
nrfjprog prints out a warning if a device is programed without the
--verify option, which can be confusing.
So added the option when programming with nrfjprog.
Then west flash can be used without getting a warning.
Also changed the tests to only accept programming with --verify
option.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2022-03-01 08:41:40 -08:00
Henrik Brix Andersen
7249dab0c8 scripts: twister: harness: pytest: add support for custom cmd line args
Add support for passing custom command line arguments to a pytest
harness in twister.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-28 12:18:48 -05:00
Henrik Brix Andersen
57a9f0431b scripts: ci: test_plan: use common code for finding matching boards
Use the common code in scripts/list_boards.py for finding matching
boards in scripts/ci/test_plan.py. This has the benefit of not trying to
use board revisions files as board names.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-28 07:31:19 -08:00
Gregers Gram Rygg
4680180944 scripts: add board revision help text for west build
west build supports specifying the board revision using @revision, but
it's not mentioned in the help text. This commit updates the help text
to describe how to specify the board revision.

Signed-off-by: Gregers Gram Rygg <gregers.gram.rygg@nordicsemi.no>
2022-02-24 13:44:01 -08:00
Jingru Wang
eb614e268c scripts: twister: output error message
Sometimes custom script fails, but we can't see the
error information in twister log, because the twister
uses _ to ignore the stderr.

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2022-02-22 18:52:39 -05:00
Marc Herbert
2fdc551acc sign.py: stop ignoring the -- -c foo.toml option passed to rimage
The -c option points rimage at its main and mandatory configuration
file ("signing schema"). The -c option passed by sign.py to rimage comes
from _two_ different places:

A. From the command line, example:

   west sign -t rimage -- OTHER_ARGS_FOR_RIMAGE -c foo.toml

However passing -- -c signing_schema.toml on the west sign command line
has always been optional because:

B. west sign systematically adds another `-c bar.toml` option. The name
   'bar' is found in the CMakeCache. Right now 'bar' comes from
   a product specific `board.cmake` file.

There were two problems fixed by this commit:

1. The -c option from the command line was passed _first_ but the last
   -c wins with rimage. The command line should have precedence.

2. The "last -c wins" behavior is not documented/official, it's an
   rimage implementation deteail.

To fix both, simply scan the command line for a '-c' option. If any is
found then it takes precedence over the CMakeCache-based value which is
dropped.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-02-22 11:55:09 -08:00
Torsten Rasmussen
61453e4a58 cmake: Zephyr CMake package and CMake modules
Create a cmake/modules folder containing all Zephyr CMake modules.
All Zephyr cmake files that are included from boilerplate are now
converted into CMake modules which can be individually loaded.

The Zephyr CMake package is updated to support loading of individual
CMake modules using the COMPONENTS argument to `find_package(Zephyr)`.
If the COMPONENTS argument is not specified, the default Zephyr build
system will load.
If COMPONENTS is specified then, only those components and the
dependencies will be loaded.

If a Zephyr CMake module depends on another CMake module which has not
been loaded, it will automatically be loaded.

This allows us to modularize and reuse individual parts of the Zephyr
CMake build system in a more flexible way in future.

Such usage could be:
- Higher livel multi image build system
- Invocation of individual components, for example dts processing by
  twister without loading all build code
- Doc build
- Unittesting

With this new CMake package and CMake module scheme then direct
sourcing of boilerplate.cmake has been deprecated.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Carles Cufi
e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Anas Nashif
c50966ac17 twister: support xt-sim as a runnable target
Use xt-sim to run Xtensa simulator in twister.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-21 22:10:42 -05:00
Carlo Caione
d3203dc70d code_relocation: Add NOCOPY feature
* Use case of interest:

Some platforms are shipping in parallel to the internal FLASH some other
storage / external FLASH (usually a QSPI FLASH) that can be used to
execute (XIP) code from.

The content of this external FLASH can usually be written at flash time
using proper tools (see for example the case of the external FLASH on
the nRF5340DK that can be written at flash time using nrfjprog).

The external FLASH is a nice addition that is extremely useful when a
large application code doesn't entirely fit on the internal FLASH so
that we could want to move part of it in the auxiliary FLASH to XIP the
code from there.

* The problem:

Right now Zephyr doesn't have a formal and generic way to move at build
time part of the code to a different memory region.

* The current status:

Zephyr is indeed shipping a code_relocation feature but that doesn't
entirely match our needs.

When XIP is enabled, the code_relocation feature is used in Zephyr to
move the selected code (that is to copy text section, to initialize data
and zero bss) from FLASH to SRAM at run time and execute code from SRAM.

The relocation is done by a generated snippet of code that is
memcpy()-ing the right content to the destination region also using some
build-time generated portions of linker script to retrieve start and
destination addresses and regions.

* This patch:

This patch is leveraging the code_relocation code and adding a NOCOPY
feature. This feature is using the code_relocation feature to
dynamically build the linker script snippets but entirely skipping the
run-time code relocation so that the code can be XIP-ed from the
destination region.

* Example:

Let's say that we have a big file called `huge_file.c` that we want to
XIP from the external FLASH that is mapped in an EXTFLASH region.

In this case we should enable `CONFIG_XIP` and
`CONFIG_CODE_DATA_RELOCATION` and instruct cmake as follows:

  zephyr_code_relocate(src/huge_file.c EXTFLASH_TEXT NOCOPY)
  zephyr_code_relocate(src/huge_file.c SRAM_DATA)

this means that:

- The .text section of the `huge_file.c` must reside in the EXTFLASH
  memory region and we do not need to copy the section there because we
  are going to XIP it (and we assume that the file is going to be placed
  in the external FLASH at flash time).
- The .data section of the `huge_file.c` must still reside in the SRAM
  memory region.

* TODOs:

It's desirable to have the possibility to relocate libraries and
pre-build files instead of source code files.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:09:46 -05:00
Carlo Caione
3c0c03b9eb cmake: dts: Add dt_comp_path() cmake function
Add a new cmake extension function:

  dt_comp_path(<var> COMPATIBLE <compatible> [INDEX <idx>])

to get a list of paths for the nodes with the given <compatible>. This
is useful when we have to cycle through several nodes with the same
compatible.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:02:04 -05:00
Chen Peng1
c0319cffa2 twister: add fixtures given by --fixture option to each devices.
fixtures could also be given by twister command with --fixture option
explicitly, not only hardware map file. In this case, we should
assign those fixtures to each devices too.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-02-21 21:59:50 -05:00
Nicolas Pitre
678b76e4b0 kernel/init.c: allow for memset/memcpy alternatives during early boot
Zeroing the BSS and copying data to RAM with regular memset/memcpy may
cause problems when those functions are assuming a fully initialized
system for their optimizations to work e.g. some instructions require
an active MMU, but turning the MMU on needs the .bss section to be
cleared first, etc.

Commit c5b898743a ("aarch64: Fix alignment fault on z_bss_zero()")
provides a detailed explanation of such a case.

Replacing z_bss_zero() with an architecture specific one is problematic
as the former may see new sections added to it that would be missed by
the later. The same reasoning goes for z_data_copy().

Let's make maintenance much easier by providing weak versions of
memset/memcpy that can be overridden by architecture-specific safe
versions when needed.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-21 21:00:12 -05:00
Piotr Golyzniak
b618f4bf8e twister: add option to create shorter build paths
Add possibility to create shorter build paths when --short-build-path
option is enabled. This can help during run Twister on Windows OS and
building programs by CMake which has a problem when paths with building
files are too long. The solution based on symbolic links which help to
connect "traditional" long paths with shorter one like:
"twister_links/test_0".

Fixes #41929

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-02-21 19:39:32 -05:00
Gerard Marull-Paretas
724b042108 scripts: ci: check_compliance: check for (re)defined Kconfig symbols
Kconfig symbols must not be defined in Kconfig.defconfig.* files. Such
files are meant to change the default value of certain options.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-21 19:35:21 -05:00
Carlo Caione
ccf51e3cd3 gen_relocate_app: Create files from scratch, do not append
The problem with append is that when doing incremental (non-clean)
build, the content of these files are appended each time to the previous
leftover content.

Example:

 # west build -p -b qemu_cortex_m3 \
 	samples/application_development/code_relocation/

 #   // disable for example CONFIG_XIP

 # west build -b qemu_cortex_m3 \
        samples/application_development/code_relocation/

at this point the content of the generated files (i.e.
linker_relocate.ld) is wrong.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-15 16:17:54 -05:00
Gerard Marull-Paretas
10da718fd7 doc: requirements: stick to breathe < 4.33
Looks like the 4.33 release has some more issues, so let's wait until
everything gets fixed before allowing future versions.

Ref. https://github.com/michaeljones/breathe/issues/805

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-15 11:26:13 +01:00
Gerard Marull-Paretas
8889114e3c doc: requirements: disallow breathe 4.33.0
Sphinx 4.33.0 introduces Graphviz support, but the Graphviz
configuration value names clash with the Sphinx built-in Graphviz
extension.

Issue: https://github.com/michaeljones/breathe/issues/803

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-14 10:00:41 +01:00
Anas Nashif
8e70d04193 actions: twister: build/run module tests and samples
This step was dropped when we moved to to GH actions, add it back.

Fixes #41305

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-09 19:47:36 -05:00
Piotr Golyzniak
c8862db1d9 twister: add setting skip reason
When testcase written in ztest is skipped by ztest_test_skip() function,
then "SKIP" information is printed in output data. This "SKIP" result is
set as result of performed testcase, but the information about reason is
still "Unknown". This patch fix this problem and if all test scenario
has state "passed" (so testcases have result "PASS" or "SKIP"), reason
is still set as "Unknown" and if any of testcase has result "SKIP" then
set reason as "ztest skip".

Fixes #42414

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-02-09 19:44:33 -05:00
Flavio Ceolin
32c4bd3b68 scripts: twister: Fix -W help message
This option is used to disable warnings as errors and not the other
way around.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-09 16:06:53 -05:00
Torsten Rasmussen
91709778a4 cmake: version.h generation performed at build time
Fixes: #39503
Fixes: #40167

This commit moves `BUILD_VERSION` CMake variable from a compile
definition to be a define inside version.h.

Besides the benefit of having related settings grouped in a common
header, it also means that an updated `BUILD_VERSION` value does not
need to trigger re-compilation of all source files.

When using compile definitions, CMake cannot tell whether a given source
files uses the definition or not, and hence all sources must be
recompiled to be sure they are up-to-date.

Placing `BUILD_VERSION` in version.h, the source dependencies ensures
that only source files including `version.h` gets recompiled.

As part of this, version.h generation is moved so that it is now done
at build time.
This means that re-generation of version.h is no longer depending on a
CMake re-run but can have it's own dependency in `.git/index` when git
described is used to obtain `BUILD_VERSION` information.

Generation of logging dictionary database has been updated to support
BUILD_VERSION from header file instead of CMake configure time variable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-08 07:50:24 -05:00
Yonatan Schachter
a2aa02dbc8 drivers: gpio: Added support for raspberry pi
Added GPIO support for the RP2040 SoC. Only one
core is supported.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2022-02-02 16:23:35 +01:00
Anas Nashif
f7cdea8510 ci: disable cbprintf tag filtering
Need a better way or tagging for this area, we have been introducing
regressions that were undetected due to those filters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-27 10:32:02 -05:00
Steve Winslow
e12d9385c6 west: spdx: Fix missing field in build results
When using the west spdx functionality to create an SPDX SBOM
during a build, several SPDX Documents are created. In some
instances, the SPDX metadata field PackageLicenseInfoFromFiles
is required to be present according to the SPDX 2.2 spec, but is
being omitted from the build.spdx Document if no licenses were
detected.

This commit fixes this bug so that a NOASSERTION value is written
for this field for Packages that do not contain any detected
licenses.

Additionally, this ensures that Packages with a FilesAnalyzed
value of false do not have this field written, also in accordance
with the spec.

Fixes #42070

Signed-off-by: Steve Winslow <steve@swinslow.net>
2022-01-26 18:15:33 +01:00
Chen Peng1
5b102040c2 twister: ignore unencodable unicode of west flash command.
sometimes there are some unencodable unicode chars from output
of west flash command, need to ignore them rather than reporting
an error.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-01-25 08:15:17 -05:00
Maureen Helm
1a7bc06086 debug: Remove deprecated CONFIG_OPENOCD_SUPPORT
CONFIG_OPENOCD_SUPPORT was deprecated in favor of
CONFIG_DEBUG_THREAD_INFO in Zephyr v2.6.0 and can now be removed.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-24 10:23:20 -05:00
Torsten Rasmussen
d51a67b7c0 cmake: support ELF image adjustment
This commit adds support for adjust the addresses of the final image.
This is useful when the image is to be flashed at a location different
from the LMA address encoded in the ELF file by the linker.

An example use-case is multicore systems where core A might load image
from a flash partition into RAM in order for core B to execute and load,
but where the image itself is build with the RAM addresses as LMA.

It updates the zephyr_image_info.h header with information of adjustment
value.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-22 16:57:31 -05:00
Torsten Rasmussen
c8ddc34bb8 scripts: generate image info header file
This commit adds the `gen_image_info.py` script which supports creation
of a header file with image information from the EFL file.

This version populates the header file with:
- Number of segments in the image
- LMA address of each segment
- VMA address of each segment
- Size of each segment

The header file can be used by a secondary build system which needs this
information.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-22 16:57:31 -05:00
Antony Pavlov
0369998e61 arch: add MIPS architecture support
MIPS (Microprocessor without Interlocked Pipelined Stages) is a
instruction set architecture (ISA) developed by MIPS Computer
Systems, now MIPS Technologies.

This commit provides MIPS architecture support to Zephyr. It is
compatible with the MIPS32 Release 1 specification.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
2022-01-19 13:48:21 -05:00
Daniel Leung
0c32256b00 scripts: logging: include pinned rodata in database
This adds "pinned.rodata" into the string database so
this will work with pinned rodata section.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-18 10:39:21 -05:00
Daniel Leung
9b9001956f logging: dictionary: workaround non-existing strings
When strings are not in the dictionary, the parser would crash.
This works around the issue by indcating an unknown string
as "string@<addr>".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-18 10:39:21 -05:00
Marc Herbert
8a603da6cd twister: add -Werror to CMAKE_AFLAGS
This reports the warning fixed in commit 61fe69dded ("sys:
device_mmio.h replace <toolchain/common.h> with <toolchain.h>")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-11 12:32:27 -05:00
Marc Herbert
19e4e12c03 twister: remove spurious quoting of EXTRA_xFLAGS=-Werror
Testing shows cmake is invoked directly, not through a shell.

Fixes commit 5092541e2b ("sanitycheck: disable erroring on warnings").
Note EXTRA_AFLAGS was quoted only on the left side!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-11 12:32:27 -05:00
Piotr Golyzniak
483101fe36 twister: raise error for non-existing platform call
Changes will raise error and break program in following three situations:

1. Platform name pass in --platform option does not exist.
2. During using --all option, platform from platform_allow list does not
exist.
3. During using --integration option, platform from
integration_platforms list does not exist.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-01-11 09:53:40 -05:00
Piotr Golyzniak
16dbc115c7 twister: fix skip marked as pass in json report
When some testcase is skip in their source code by ztest_test_skip()
function in final json report it is marked as pass what is wrong. Due to
the changes in this commit those skips can be marked properly.

Fixes: #41440

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-01-06 07:55:16 -05:00
Anas Nashif
ce60a91fb0 actions: twister: scale nodes up for large test coverage
If we determine we need more nodes than the default, do not override the
calculated number.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-06 07:32:20 -05:00
Marcin Niestroj
c9a3dae651 scripts: runners: esp32: remove print() call
This print() call was introduced as part of commit 16571db029 ("soc:
esp32: add support to mcuboot build") probably as a leftover from
debugging stage. Remove that, so flash command is not printed by
default. Those commmands can be easily printed by passing -v flag to
`west -v flash ...` command.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-01-05 19:48:18 -05:00
Anas Nashif
b8e9b04384 footprint: track audio features on xtensa
Track footprint of ther SOF application on both intel and nxp xtensa
platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-05 14:59:01 -05:00
Gerard Marull-Paretas
37566221ba doc: update requirements
breathe: for simplicity, require versions > 4.30 (lower versions have
known issues, so do not take risks).
Sphinx: start requiring versions >=4.x. Keep with compatible versions,
since Sphinx major updrages can easily break extensions, themes, etc.
sphinx_rtd_theme: upgrade to >=1.x. Again, keep with compatible versions
since we have style customizations that can likely break on major
upgrades.
pygments: Allow any version >=2.9 (version that introduced DT support).
We do not have strong compatibility requirements here.
sphinx-notfound-page: Remove any requirements, we do not have strong
requirements for this one.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-05 14:38:24 +01:00
Carles Cufi
fef2e30b7f runners: openocd: Default to an actual executable when not configured
Whenever build/zephyr/runners.yaml does not specify the location of the
openocd executable we seemd to be leaving the executable variable as
None. Instead, use its executable name.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-18 18:19:34 +01:00
Sylvio Alves
16571db029 soc: esp32: add support to mcuboot build
Select configuration when mcuboot is enabled.
At this moment, only UNSIGNED image is supported as per
Espressif's mcuboot porting.

This also updates esp32 runner to use proper bin_file name
and updates default bootloader check.

Move CMakeLists.txt content from board to soc directory
as this support is for esp32 architecture and not board
specific.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-12-18 07:20:38 -05:00
Shubham Kulkarni
5f11ac7c2a runners: esp32.py: Support flashing for MCUboot and IDF bootloader
IDF bootloader requires partition table which is not a requirement for
MCUboot. Hence, esp32.py is updated to flash partition table only if it
exists.

Current implementation only allows flashing zephyr.bin. This commit adds
capability to flash binaries with other names as well
(e.g. - zephyr.signed.bin)

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-12-18 07:20:38 -05:00
Anas Nashif
526ee4c74f twister: do not use deprecated arguments to nrfprog
--snr is deprecated, so use --dev-id instead.

Fixes #40449

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-15 14:09:49 -05:00
Anas Nashif
018ccd6210 twister: fix baud setting for detected devices
When generating new map we store serial_baud, but the schema has 'baud'
only, so call this baud in the class and resolve the issue of creating
new maps.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-15 14:09:49 -05:00
Anas Nashif
d1991e9952 twister: remove lock from generated hardware map
remove lock before storing yaml file.

Fixes #39179

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-15 14:09:49 -05:00
Piotr Golyzniak
3194f75098 twister: log error for non-existing platform call
Changes will log error message in following three situations:

1. Platform name pass in --platform option does not exist.
2. During using --all option, platform from platform_allow list does not
exist.
3. During using --integration option, platform from
integration_platforms list does not exist.

Fixes #31868

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-12-15 09:38:55 -05:00
Andy Ross
2906d1aa51 soc/intel_adsp: Build bootloader with Zephyr
The presence of a separate build for the bootloader code has always
been a wart with this platform.  Sharing of code between the two has
required great care. We've had bugs with mismatched include paths,
macro definitions and compiler flags, etc...  And of course it's not
possible for one to see the other; in theory we'd like the ability to
call back into IMR code after startup, to use the space for temporary
storage, etc...

So let's finally do it.  This really isn't that complicated when you
see it in isolation:

+ Move the module manifest metadata into an "rimage_modules.c", and
  put them in their own NOLOAD section where we can grab them later
  with objcopy.

+ Make a new "imr" memory region in the main linker and just paste the
  bootloader linkage (which is now using its own specific sections) in
  there.

+ After zephyr.elf is built and cache-remapped, we can extract the imr
  sections and the appropriate manifest for the bootloader rimage
  module, and then do the converse by excluding them for the main
  image module.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-12-14 18:43:05 -06:00
Lauren Murphy
ddfb3a193c debug: coredump: dummy window registers, assign an to arn
GDB server dummies WINDOWBASE to 0 and WINDOWSTART to 1
for both arches and sends An as corresponding ARn for ESP32
to get around packet size limitation. Fixes backtrace and
other issues causing GDB client to crash.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2021-12-14 07:40:55 -05:00
Lauren Murphy
80927cac87 debug: coredump: add xtensa coredump gdbserver
Adds support for Xtensa to coredump custom GDB server for
the sample_controller and ESP32 SOCs.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2021-12-14 07:40:55 -05:00
Torsten Rasmussen
1a51993192 scripts: support propagating workspace status to zephyr revision
The PR #39382 raised a discussion on build reproducibility and knowledge
of west projects being out of sync with the west manifest.

Similar to how `git submodules` will report the working tree dirty if
any of the submodules HEAD points to a SHA different than the one
recorded in the super project.

Based on this discussion this commit extends the Zephyr and manifest
repo (when `west` is used) revisions to include the concatenated states
of the workspace.

The workspace states are:
>  dirty: false / true
>  extra: false / true
>  off:   false / true

the final revision will become: <SHA>-<state1>-<state2>-<state3>

For example:
> zephyr:
>  path: /.../zephyr
>  revision: <SHA>-dirty-extra-off

or
> zephyr:
>  path: /.../zephyr
>  revision: <SHA>-extra

The `BUILD_OUTPUT_META_STATE_PROPAGATE` Kconfig setting is introduced
to provide user control of this behavior.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-14 12:32:10 +01:00
Torsten Rasmussen
64ec6ee3a3 scripts: build meta file workspace status extension
The PR #39382 raised a discussion on build reproducibility and knowledge
of west projects being out of sync with the west manifest.

Similar to how `git submodules` will report the working tree dirty if
any of the submodules HEAD points to a SHA different than the one
recorded in the super project.

Based on this discussion this commit extends the Zephyr build meta file
with overall workspace status included in the meta file.

It adds the following meta info to the build meta file:
> workspace:
>  dirty: false / true
>  extra: false / true
>  off:   false / true

A project using west and having an extra Zephyr module loaded not
controlled using git and a west project at a SHA different than the
SHA referenced by the manifest can look like:
zephyr:
  path: /.../zephyr
  revision: 863600cd0e
modules:
- name: mcuboot
  path: /.../bootloader/mcuboot
  revision: c61538748ead773ea75a551a7beee299228bdcaf
- name: local_module
  path: /.../local_module
  revision: null
west:
  manifest: /.../zephyr/west.yml
  projects:
  - path: /.../zephyr
    revision: 863600cd0e
  - path: /.../bootloader/mcuboot
    revision: c61538748ead773ea75a551a7beee299228bdcaf-off
  - path: /.../tools/net-tools
    revision: f49bd1354616fae4093bf36e5eaee43c51a55127
workspace:
  dirty: false
  extra: true
  'off': true

And without west:
zephyr:
  path: /.../zephyr
  revision: 863600cd0e
modules:
- name: hal_nordic
  path: /.../modules/hal/nordic
  revision: a6e5299041f152da5ae0ab17b2e44e088bb96d6d
- name: local_module
  path: /.../local_module
  revision: null
workspace:
  dirty: false
  extra: true

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-14 12:32:10 +01:00
Erwan Gouriou
82b290ef48 scripts/pylib/twister: Add sn option to stm32cubeprogrgammer runner
In order to enable use of stm32cubeprogrammer runner with twister,
add "sn" tool specific option which allows to provide target serial
number and hence select the target to flash when multiple ones are
connected to the host.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-12-13 17:20:17 -05:00
Hake Huang
2f3b8b01aa twister: remove redundant required for generate-hardware-map
remove a redundate required for --generate-hardware-map

this fixing: #41066

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-12-13 08:46:15 -05:00
Anas Nashif
9cb2bc2c01 actions: clang: do not test all boards when --platform is given
If we are invoking testplan for only one board, do not bother with other
board related changes, just generate plan for the specified platform.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-09 16:23:22 +01:00
Jordan Yates
9c98d4f2b7 scripts: gen_defines: zephyr,linker-region unique
Add checks to ensure that `zephyr,linker-region` property values are
always globally unique.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-12-09 16:23:03 +01:00
Mark Holden
1a697ccf59 coredump: add support for RISC-V
This adds the necessary bits in arch code, and Python scripts
to enable coredump support for RISC-V

Signed-off-by: Mark Holden <mholden@fb.com>
2021-12-08 08:54:32 -05:00
Hake Huang
5c2bdfbbad twister: reorder ungroupped args
reorder ungroupped args in alpha-beta order

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-12-08 08:25:45 -05:00
Hake Huang
fd914d7fc1 twister: reorder group args
reorder group args at parser function beginning

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-12-08 08:25:45 -05:00
Hake Huang
dfe5514afc twister: refactor for pylint checking
refact to code sgement for better coding style

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-12-08 08:25:45 -05:00
Hake Huang
9ab4e364d0 twister: argparse group refactor
add more groups in twister opts

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-12-08 08:25:45 -05:00
Martí Bolívar
6c65b15ce6 edtlib: wrap DTError
Don't let a malformed devicetree escape as a DTError. Wrap it in an
EDTError instead, so callers can just rely on the edtlib APIs as is
generally expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-07 13:39:37 -05:00
Martí Bolívar
7738977af4 dtlib: handle GCC linemarkers
A GCC linemarker of the form:

  # 1 "filename" 2 3 4

or so is not currently being handled, because the current regular
expression assumes the "flags" values (the numbers after "filename")
are limited to a single value. Tweak the regular expression to allow
for up to 4 flags, which is what GCC documents it may emit:

https://gcc.gnu.org/onlinedocs/gcc-10.2.0/cpp/Preprocessor-Output.html

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-07 13:39:37 -05:00
Martí Bolívar
4e783a363a dtlib: add _Token __repr__
Convert numeric IDs to symbolic token ID names for ease of debugging.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-07 13:39:37 -05:00
Martí Bolívar
17ae4fe05a scripts: gen_dts_cmake: emit properties for /aliases
This enables cmake extensions that can look up the path for any
devicetree alias, or check if the alias is missing, etc.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Martí Bolívar
b65b49bef6 scripts: gen_dts_cmake: a small optimization
Using edt.chosen_nodes looks like a simple attribute lookup, but it's
actually calling a property that will create a new list of chosen
nodes every time. Apply a small optimization by only creating the list
once.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Alex Kolosov
f374d6b1f1 scripts: runners: Add west flash command for B91 platform
This commit implements west flash command for Telink B91 platform.
west flash command uses ICEman and SPI burn from AndeSight for flashing.

Signed-off-by: Alex Kolosov <rikorsev@gmail.com>
2021-12-06 07:28:38 -05:00
Anas Nashif
77a7df31e5 ci: fix test plan for smaller sets
We were missing smaller sets and skipping tests when the set is smaller
than the allowed number of tests per node.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-05 10:53:50 -05:00
Tom Burdick
e29d9e1e2f checkpatch: Add UTIL_CAT support to checkpatch
Checkpatch was checking for macro concats (##), however
we often use UTIL_CAT to allow for multiple macro expansion passes
to succeed.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2021-12-04 07:22:56 -05:00
Trond Einar Snekvik
6a8326ff1e modules: Use posix paths in Kconfig module prompts
kconfiglib doesn't render backslashes in menu strings, and the prompts
in the module menu will be unintelligible on Windows. Print these
menus as posix paths on Windows as well, so they don't look broken in
menuconfig.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-12-03 16:50:31 -06:00
Gerard Marull-Paretas
92b9aff9b3 scripts: checkpatch: typedefsfile: add pinctrl_soc_pin_t
The pinctrl_soc_pin_t is used as an opaque type in pinctrl to store pin
configurations which are SoC dependent.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-03 13:21:40 +01:00
Anas Nashif
8d40928b2a actions: twister: determine nodes in python script
Improve calculation of matrix and move calculations from workflow to the
testplan script. We now generate a file that can be parsed by the action
with the data needed to start twister with the right number of nodes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-29 20:06:24 -05:00
Anas Nashif
d52212b09a actions: fix filtering for clang action
Do not invoke --integration when dealing with one platform only and
generate testplan only for the needed platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-29 20:06:24 -05:00
Yasushi SHOJI
b652fe2a7b scripts: west_commands: runners: openocd: Add --verify-only
Add yet another option, --verify-only, to west flash.  This option
runs openocd with verify_image but without load_image.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-11-29 09:35:57 -05:00
Yasushi SHOJI
da8a41d42a scripts: west_commands: runners: openocd: Add flash --verify
OpenOCD has verify_image command.  Add `--verify` option to west flash
so that openocd can do vierfy_image right after load_image.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-11-29 09:35:57 -05:00
Anas Nashif
8b55275d48 ci: test_plan: fix pylint warnings
Fix some of the warnings reported by pylint.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-28 20:35:40 -05:00
Anas Nashif
053cc9fe62 actions: twister: run tests on all platforms when changed
When tests are changes, run them on all supported platformed, not only
integration platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-28 20:35:40 -05:00
Gerard Marull-Paretas
d47700177a scripts: utils: add pinctrl migration script for nRF boards
This script can be used to automatically migrate the Devicetree files of
nRF-based boards using the old <signal>-pin properties to select
peripheral pins. The script will parse a board Devicetree file and will
first adjust that file by removing old pin-related properties replacing
them with pinctrl states.  A board-pinctrl.dtsi file will be generated
containing the configuration for all pinctrl states. Note that script
will also work on files that have been partially ported.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-26 14:20:51 +01:00
Torsten Rasmussen
41c25a2de4 twister: remove CMAKE_EXPORT_COMPILE_COMMANDS=1
The -DCMAKE_EXPORT_COMPILE_COMMANDS=1 is removed from twisterlib.py as
it is now always set by the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-25 10:41:28 -05:00
Torsten Rasmussen
f643b8b369 scripts: support compile_commands.json in gen_app_partitions.py
Fixes: #40590

This commit updates gen_app_partitions.py to include only files present
in the current build by extracting the information from the CMake
generated `compile_commands.json` file.

This ensures that object files in sub-projects, such as `empty_cpu0`,
will not be considered by the script.

Using the compile_commands.json instead of walking the whole build tree
for finding object files also improves performance:

Time of executing `gen_app_partitions.py` (Old):
__________________________
Executed in  480.06 millis
   usr time  425.83 millis
   sys time   49.55 millis

Time of executing `gen_app_partitions.py` (New):
________________________________________________________
Executed in   76.22 millis
   usr time   49.00 millis
   sys time   24.59 millis

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-25 10:41:28 -05:00
Anas Nashif
0b2df8f41c actions: twister/clang: cleanup test plan generation
Merged 3 files used to generate the test plan per PR based on the
changes. 2 python scripts and a shell script are now all merged into 1
python script that generates the input file for twister based on a list
of changed files by the PR.

This remove lots of old and obsolete code and simplifies things a bit,
no need anymore for an intermediate script to call twister, we call it
directly in the workflow and use the new test_plan script to generate
the test plan.

This also reenables the recently disabled tag based filtering which had
a bug, bug is resolved in this new implementation.

On push events, we now run twister without the --integration option to
catch any issues in the main branch that were not caught in PRs. PRs
continue to run with --integration enabled. This event (push) is now run
on 15 builders due to the increased size.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-24 22:54:25 -05:00
Johann Fischer
73199f2c91 scripts/Kconfig: add dt_node_str_prop_equals Kconfig function
Add function to check if a property of a node
is equal to a passed string.

The motivation is that in current USB device support
the sizes of bulk endpoints are configured in Kconfig.
The information if a USB device controller supports
high-speed comes from devicetree. This information must be
mapped in controller driver Kconfig and corresponding options
in USB device stack configured must be adjusted.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-24 12:28:02 +01:00
Anas Nashif
5c24fcb4ae actions: run twister using github action
This action replaces current buildkite workflow and uses github actions
to build and run tests in the zephyr tree using twister. The main
differences to current builtkite workflow:

- the action handles all 3 events: pull requests, push and schedule

- the action determines size of matrix (number of build hosts) based on
  the change with a minimum of 1 builder. If more tests are built/run
  due to changes to boards or tests/samples, the matrix size is
  increased. This will avoid timeouts when running over capacity due to
  board/test changes.

- We use ccache and store cache files on amazon S3 for more flexibility

- Results are collected per build host and merged in the final step and
  failures are posted into github action check runs.

- It runs on more powerful instances that can handle more load.
  Currently we have 10 build hosts per run (that can increase depending
  on number of tests run) and can deliver results within 1 hour.

- the action can deal with non code changes and will not allocate more
  than required to deal with changes to documentation and other files
  that do not require running twister

The goal long-term is better integrate this workflow with other actions
and not run unncessarily if other workflows have failed, for example, if
commit message is bogus, we should stop at that check, to avoid wasting
resources given that the commit message will have to be fixed anyways
which would later trigger another run on the same code.

Currently there is 1 open issue with this action related to a github
workflow bug where the final results are not posted to the same workflow
and might appear under other workflows. Github is working on this bug.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-23 06:42:23 -05:00
Anas Nashif
2c5a37cb74 scripts: gen_app_partitions: do not load empty files
Do not load empty files through the ELF parser and raise exception when
magic number of ELF is not matched.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-23 06:42:23 -05:00
Jordan Yates
106f710c7d device: iterable supported devices
Add supported device information to the device `handles` array. This
enables API's to iterate over supported devices for power management
purposes.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-23 12:17:14 +01:00
Fabio Baltieri
d0377d30e3 scripts: runners: add connect_srst support for blackmagicprobe
Black Magic Probe supports a "monitor connect_srst" command [1] to
configure whether to assert reset when connecting to the target. This is
useful to reprogram a target that may be idling in a low power state,
with an otherwise unresponsive debug core.

Adding a --connect-srst runner option for enabling this for "flash" and
"debug" operations to ensure that programming works in that case, but
also explicitly disabling it for "attach", to allow attaching to a
running target without changing its state.

Not turning this on by default since apparently some MCUs disable the
SWD interface while in reset.

[1] https://github.com/blacksphere/blackmagic/wiki/Useful-GDB-commands

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-11-22 22:20:02 -05:00
Olof Johansson
16003b1e58 twister: Fix trivial typo
Plarforms -> Platforms

Signed-off-by: Olof Johansson <olof@lixom.net>
2021-11-22 08:32:12 -05:00
Julien Massot
c727a9a4ca scripts: gen_kobject_placeholders: iterating the dictionary directly
Fix:
************* Module gen_kobject_placeholders
scripts/gen_kobject_placeholders.py:88:19: C0201:
Consider iterating the dictionary directly
instead of calling .keys() (consider-iterating-dictionary)

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-11-19 19:16:11 -05:00
Julien Massot
36f116b47f scripts/arch: remove usage of deprecated LooseVersion
replace with version.parse from packaging module.

prevent this warning message:
DeprecationWarning: The distutils package is deprecated
and slated for removal in Python 3.12. Use setuptools or
check PEP 632 for potential alternatives

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-11-19 19:16:11 -05:00
Shao Ming
4315140702 twister: fix the testcase-schema.yaml
Change the "yes/no" value to "true/false".
Otherwise pykwalify 1.8.0 will report below errors:
- Value: 'no' for required keyword must be a boolean:
  Path: '/mapping/common'>
- Value: 'yes' for required keyword must be a boolean:
  Path: '/mapping/sample/mapping/name'>

Signed-off-by: Shao Ming <ming.shao@intel.com>
2021-11-19 11:46:38 -05:00
David Leach
1e5a830233 scripts: kconfig: Add unit divisor to dt_node_int_prop_int/hex functions
Added a unit divisor option to the dt_node_int_prop_int and
dt_node_int_prop_hex functions to allow retrieval of DTS items as
a size value of K, M, or G divisor similar to the dt_node_reg_size_int
function.

Signed-off-by: David Leach <david.leach@nxp.com>
2021-11-18 14:29:53 +01:00
Maureen Helm
525fa76f4d boards: xtensa: Use a CMake variable to set the rimage target name
Removes hardcoded logic in the west signing script that translates
Zephyr board names to rimage target names. Instead, use a cached CMake
variable set at the board level to define its respective rimage target
name. This eliminates the need to modify the west signing script when
new SOF-supported boards are introduced to Zephyr.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-11-17 19:44:35 -05:00
Jordan Yates
44b8a0d199 scripts: gen_handles.py: remove size restrictions
With `gen_handles.py` now running on the first pre-built image,
`zephyr_pre0.elf` there is no requirement for the device handle arrays
to remain the same size after processing.

Remove the padding generated in `gen_handles.py`, as well as the
temporary option `CONFIG_DEVICE_HANDLE_PADDING` which was added to work
around this issue.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-16 10:41:59 +01:00
Anas Nashif
a5c2a6169b actions: footprint: fix csv formatting
Fix formatting of plan.txt CSV file and make it parseable by script.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-15 11:12:05 -05:00
Torsten Rasmussen
fffaf05e5d scripts: support for build meta file creation
This commit is motivated by the west discussion in:
https://github.com/zephyrproject-rtos/west/issues/548

The commit provides the ability to generate a build meta info file
containing lists of:
- Zephyr:         path and revision
- Zephyr modules: name, path, and revision
- West:           manifest path
                  path and revision for each project

For Zephyr or Zephyr modules the revision will be `null` if it is not
under git version control.

If Zephyr, a modules, or a project has uncommitted changes, the revision
will be marked dirty.

If west is not installed or used for the build process, the
west-projects list will be empty.

If a project is both a Zephyr module and a west project it will show up
in both lists.

Similar to Zephyr, which is independently referred as the Zephyr in use
but also listed as west project when west is used.
This is important in case ZEPHYR_BASE was manually set and pointing to
a different Zephyr repository.

The build meta file is not created per default but can be enabled with
the BUILD_OUTPUT_META Kconfig setting.

A project using west and having an extra Zephyr module loaded not
controlled using git can look like:
zephyr:
  path: /.../zephyr
  revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
modules:
- name: mcuboot
  path: /.../bootloader/mcuboot
  revision: c61538748ead773ea75a551a7beee299228bdcaf
- name: local_module
  path: /.../local_module
  revision: null
west:
  manifest: /.../zephyr/west.yml
  projects:
  - path: /.../zephyr
    revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
  - path: /.../bootloader/mcuboot
    revision: c61538748ead773ea75a551a7beee299228bdcaf
  - path: /.../tools/net-tools
    revision: f49bd1354616fae4093bf36e5eaee43c51a55127

And without west:
zephyr:
  path: /.../zephyr
  revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
modules:
- name: hal_nordic
  path: /.../modules/hal/nordic
  revision: a6e5299041f152da5ae0ab17b2e44e088bb96d6d
west: null

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-11 06:06:07 -05:00
Anas Nashif
46e3318dbd ci: hotfix: disable test exclusion by tags
Many tests and CI activties are being missed by excluding tests
mistakingly when running twister.
This is visibile when you change one or more tests in kernel/ for
example, twister does not run those tests that have changed at all and
marking the PR as tested and ready to be merged.

Temporary fix for #40235.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-10 22:37:21 -05:00
Anas Nashif
23ab949975 ci: inclusive language, use nodes instead of slaves
Fix the usage of the word slaves and replace with nodes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-10 08:04:26 -06:00
Marc Herbert
c2524a07a6 west: build.py: resolve symlinks in cached source directory check
Fixes the following error:

ERROR: Build directory "<whatever>" is for application "<symbolic source
  dir in CMakeCache.txt>", but source directory "<resolved source dir>"
  was specified; please clean it, use --pristine, or use --build-dir to
  set another build directory
FATAL ERROR: refusing to proceed without --force due to above error

Fixes initial commit ab82264ace ("scripts: add west build, flash, and
debug commands")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-11-10 08:27:16 -05:00
Neil Armstrong
1e8f0f3bd1 gen_defines: generate ranges defines for PCIe I/O and memory regions
As described in IEEE Std 1275-1994, the PCIe bindings uses the ranges
property to describe the PCI I/O and memory regions.

Write _RANGES_ defines that will be used to determines the I/O and
memory regions from PCIe Controller drivers.

Also exclude "ranges" & "dma-ranges" property's length generation
alogn "reg" and "interrupt".

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-11-10 08:23:00 -05:00
Neil Armstrong
2f4a6646cf edtlib: add tests to check Range property
This adds some tests in test_edtlib.py and test.dts to check all
common possible combination of ranges property usage and handling
by edtlib.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-11-10 08:23:00 -05:00
Neil Armstrong
cd6a5648d7 edtlib: add Range property on Node, used for PCIe I/O and memory regions
As described in IEEE Std 1275-1994, the PCIe bindings uses the ranges
property to describe the PCI I/O and memory regions.

Add parsing of this property in edtlib.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-11-10 08:23:00 -05:00
Carles Cufi
5ba301d449 footprint: Add Bluetooth samples to footprint tracking
Add a few Bluetooth samples to track their footprint as part of the
effort to contain firmware bloat.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-11-10 08:05:21 -05:00
Gerson Fernando Budke
0de934b2a7 scripts: runner: Introduce gd32isp flash runner
Add GigaDevice ISP console flash runner.  This tool enable uses ROM
bootloader to flash devices using serial port.

The GD32_ISP_Console tool can be found at
  http://www.gd32mcu.com/download/down/document_id/175/path_type/1

Signed-off-by: Gerson Fernando Budke <gerson.budke@atl-electronics.com>
2021-11-07 05:20:50 -05:00
Piotr Golyzniak
8b773481e9 twister: reenable build samples on Windows OS
Fix few limitation which do not allow to run Twister on Windows OS.
Especially turn off "import pty" module, due to the fact, that this
module can be used only on POSIX OS.

Fixes #40007

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-11-04 07:33:39 -04:00
Bartosz Bilas
d85465fb11 scripts: gen_relocate_app: check if argument matches
Check each line whether contains the correct pattern
${location}:${file} before splitting because it
turns out that script passes also compile
definitions added in project CMakeLists.txt such as:

add_compile_definitions(ABCD="XYZ")

which results in the build failure.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-11-02 22:26:41 -04:00
Bartosz Bilas
50ec0461af scripts: gen_relocate_app: fix C0201 pylint warning
As pylint says "Consider iterating the dictionary directly
instead of calling .keys()" don't use .keys() method.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-02 13:26:09 +01:00
Anas Nashif
910e86af68 ci: do not run twister on footprint script changes
No need to run twister on changes to changes to scripts/footprint/*

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-10-29 12:26:36 -04:00
Anas Nashif
82ebf78f95 footprint: add power management application
Add the footprint application with PM enabled for tracking.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-10-29 12:26:36 -04:00
Yuval Peress
27f6a5e07d ztest: add a weak implementation of test_main()
Introduce a weak implementation of test_main() which calls:
* ztest_run_registered_test_suites(NULL);
* ztest_verify_all_registered_test_suites_ran();

This will attempt to run all registered test suites and verify that
they each ran.

Signed-off-by: Yuval Peress <peress@chromium.org>
2021-10-28 16:57:51 -04:00
Yuval Peress
dee79d2b66 ztest: Add register functionality
Add new functionality to ztest to improve test modularity. The two
primary new entry points are:
* ztest_register_test_suite
* ztest_run_registered_test_suites

When registering a new test suite, users provide the name as well as
an optional predicate used to filter the tests for each run. Using NULL
as the predicate ensures that the test is run exactly once (after which
it is automatically filtered from future runs).

Calls to ztest_run_registered_test_suites take a state pointer as an
argument. This allows the the pragma functions to decide whether the
test should be run.

The biggest benefit of this system (other than the ability to filter
tests and maintain a larger test state) is the ability to better
modularize the test source code. Instead of all the various tests
having to coordinate and the main function having to know which tests
to run, each source file manages registering its own test
suite and handling the conditions for running the suite.

Signed-off-by: Yuval Peress <peress@chromium.org>
2021-10-28 16:57:51 -04:00
Bartosz Bilas
1502c6631d runners: jlink: exit with error in case of a failure
Add "ExitOnError 1" argument that treats any command-error
as fatal thus in the case of a programming error the "west flash"
command will return the correct error code instead of the default 0. It
fixes the false positive return codes when e.g we call west flash
command without a connected programmer or with the disconnected board.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-10-28 10:57:28 +02:00
Torbjörn Leksell
95ad27fe1f Tracing: TRACING_SYSCALL status ignored fix
Added check to respect the TRACING_SYSCALL tracing option
when generating syscall tracing overrides in
gen_syscalls.py.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
2021-10-26 15:13:08 -04:00
Jim Shu
46eb3e5fce gen_app_partitions: add .sdata/.sbss section into app_smem
Some architectures (e.g. RISC-V) has .sdata/.sbss section for small
data/bss. Memory partition should also manage the permission of these
sections in library so they should be put into app_smem.
(For example, newlib _impure_ptr is in .sdata section and
__malloc_top_pad is in .sbss section in RISC-V.)

Signed-off-by: Jim Shu <cwshu@andestech.com>
2021-10-25 19:16:37 -04:00
Tom Burdick
97dc88bb6d tracing: Automatic syscall tracing
When generating syscall wrappers, call a tracing macro with the id,
name, and all parameters of the syscall as params when entering and
leaving the syscall. This can be disabled in certain call sites
by defining DISABLE_SYSCALL_TRACING which is useful for certain
tracing implementations which require syscalls themselves to work.

Notably some syscalls *cannot* be automatically traced this way and
headers where exclusions are set are in the gen_syscall.py as notracing.

Includes a systemview and test format implementation.

Tested with systemview, usb, and uart backends with the string
formatter using the tracing sample app.

Debugging the trace wrapper can be aided by setting the TRACE_DIAGNOSTIC
env var and rebuilding from scratch, a warning is issued for every
instance a syscall is traced.

Automatically generating a name mapping for SYSVIEW_Zephyr.txt is a
future item as is documenting how to capture and use the tracing data
generated.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2021-10-23 20:45:17 -04:00
Torsten Rasmussen
1c911290e9 kconfig: add support for warnings when using experimental features
This adds two new Kconfig settings.

The first setting `EXPERIMENTAL` which is a promptless symbol.
This symbol must be selected by any setting which is used to enable
an experimental feature.

The second setting is `WARN_EXPERIMENTAL` which is a user controlled
setting that configures the build system to print a warning when
experimental features are enabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-10-22 13:59:21 +02:00
Maciej Perkowski
2253c6efd8 twister: Fix skipping unskippable tests when --subset is used
Fixes a bug causing tests with error status get silently skipped
when --subset is used.

Fixes: #39619

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-10-21 21:45:53 -04:00
Iuliana Prodan
602e675418 west: sign: add support for NXP i.MX8MP
Add support for signing i.MX8MP SOF with
Zephyr images with rimage.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-10-20 19:08:50 -04:00
Henrik Brix Andersen
5d34a45697 runners: openocd: always search the board support directory if found
Always add the boards/<arch>/<board>/support directory to the OpenOCD
runner search path if the directory exists.

This simplifies using custom --config <partial-board.cfg> runner
arguments without having to use the full path to the cfg file.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-10-19 17:38:54 +02:00
Steve Winslow
878ee1493e west: spdx: Fix --init for Windows builds
Currently, west spdx --init uses os.mknod to create an empty file
to enable the Cmake file-based API system. As reported in #39311,
Python on Windows does not implement os.mknod.

This commit switches to using open()/close() instead of os.mknod()
to address this issue.

Signed-off-by: Steve Winslow <steve@swinslow.net>
2021-10-18 09:47:30 -04:00
Christopher Friedt
8b55eb8052 scripts: get_maintainer: add count function
For looking at statistics over time, it is helpful to be able to
quickly query the number of unique maintainers, collaborators,
areas, and the number of orphaned areas (without a maintainer).

This change adds the `count` subcommand to
`scripts/get_maintainer.py`.

```
% python3 ./scripts/get_maintainer.py count -h
usage: get_maintainer.py count [-h] [-a] [-c] [-n] [-o]

optional arguments:
  -h, --help            show this help message and exit
  -a, --count-areas     Count the number of areas
  -c, --count-collaborators
                        Count the number of unique collaborators
  -n, --count-maintainers
                        Count the number of unique maintainers
  -o, --count-orphaned  Count the number of orphaned areas

% python3 ./scripts/get_maintainer.py count
areas:          113
maintainers:    49
collaborators:  81
orphaned:       21

% python3 ./scripts/get_maintainer.py count -o
orphaned:       21
```

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-10-18 08:36:21 -04:00
Julien Massot
a35e046fb2 runners: openocd: prefer extended-remote for gdb connection
Instead of deprecated 'target remote'.
Fix:
Warn : Prefer GDB command "target extended-remote :3333"
instead of "target remote :3333"

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-10-17 11:47:36 -04:00
Julien Massot
e4fac0e261 runners: openocd: gives configuration file before initialization
#38557 Reordered the argument for openocd, but we should not try
to call the init command before giving the board configuration
file stored in 'self.cfg_cmd'.

Move back this variable to it's original position.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-10-17 11:47:36 -04:00
Julien Massot
1cac55cf3a runners: openocd do not try to iterate over gdb_init if None
Commits 49bcc08033 introduced
a possible None object 'gdb_init', do not try to iterate over
this variable if it is a None object.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-10-17 11:47:36 -04:00
Peter Mitsis
ae394bff7c kernel: add support for event objects
Threads may wait on an event object such that any events posted to
that event object may wake a waiting thread if the posting satisfies
the waiting threads' event conditions.

The configuration option CONFIG_EVENTS is used to control the inclusion
of events in a system as their use increases the size of
'struct k_thread'.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2021-10-16 06:27:10 -04:00
Peter Mitsis
fc12f69cd0 scripts: Resolve python check warnings
Resolves two pylist check warnings that recommend using 'in'.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2021-10-16 06:27:10 -04:00
Dennis Ruffer
c714c78743 twister: Allow baud rates other than 115200
Fixes #38046
Document the changes in twister.rst
Add baud rate to debug message in twister
Add baud parameter to twister's add_device function
Set the twister baud rate from input parameters
Use 115200 as the default baud rate if not specified
Add baud to the hwmap-schema.yaml file
Add --device-serial-baud to twister arguments
Fix compliance issues
Fix mistake in parameter name from device-baud to device-serial-baud
Refactoring of the code in orded to simplify the logic
   and clear multiple definitions of the default baud rate.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Signed-off-by: Dennis Ruffer <daruffer@gmail.com>
2021-10-14 16:35:48 -04:00
Henrik Brix Andersen
10fb5c203b runners: canopen: poll for flash ready
Poll the flash status instead of just reading the flash status once. Add
support for controlling the number of SDO retries and the SDO timeouts.

These changes allows for greater control of the CANopen program
download, which is especially useful on noisy or congested CAN networks
and on devices with slower flash access.

Fixes: #39409

Signed-off-by: Klaus H. Sorensen <khso@vestas.com>
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-10-14 10:44:21 +02:00
Carlo Caione
42105ed882 dts: Add support for specifier-space property.
Currently all the *-names and *-cells properties are derived from the
name of the base <name>s property. This is a limitation because:

- It forces the base property name to be plural ending in -s
- It doesn't allow the english exception of plural words ending in -es

With this patch we add one additional property 'specifier-space' that
can be used to explicitly specify the base property name.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Suggested-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-10-13 09:56:46 -05:00
Carles Cufi
6a3593f4af west: runners: Add a deprecation action to the core code
In order to allow for further options to be deprecated with minimal
impact, add a deprecation argparse Action and a callable instantiator
that can be used to deprecate options in favor of new ones.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi
2ccfd22594 runners: pyocd: Convert to -i/--dev-id
Remove the previous pyocd-specific --board-id option and switch to
the common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi
285c2cabf1 runners: dfu-util: Convert to -i/--dev-id
Remove the previous dfu-util-specific --pid option and switch to the
common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi
e3e23a51bb runners: canopen: Convert to -i/--dev-id
Remove the previous canopen-specific --node-id option and switch to the
common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi
5ee719ee9d runners: nrfjprog: Convert to -i/--dev-id
Remove the previous nrfjprog-specific --id option and switch to the
common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi
f6b13ddb6f runners: jlink: Convert to -i/--dev-id
Remove the previous jlink-specific --id option and switch to the common
-i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi
898f65f53c runners: Add new common -i/--dev-id command-line option
In an effort to standardize the way that a particular debugger or device
instance is identified when there are multiple present, introduce a new
-i/--dev-id option common to all runners that allows the user to specify
which device to interact with when there are multiple connected.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Sylvio Alves
49bcc08033 openocd: add hardcoded configs as input parameters
Debugging ESP32 SoCs is not possible if the commands
halt, target and load are enabled by default.
This MR allows this configs to be used as input parameters.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-10-08 12:59:55 +02:00
Daniel Leung
da9c40a7b8 scripts: footprint: fix print alignment and color
The size percentage was doing "xx.xx%" so 100% would not be
aligned correctly when printed. So add a space for percentage
printing.

Also change the coloring of "(hidden)" node so it would not
have the same color as files or symbols.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-10-07 16:56:20 -04:00
Daniel Leung
10eab23f08 west: sign/rimage: fix rimage argument if --no-manifest
If --no-manifest is specified, '-e' is still being passed
to rimage to build the extended manifest. Fix this so
that when --no-manifest is specified, '-e' is no longer
passed to rimage.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-10-06 19:43:30 -04:00
Martí Bolívar
a627666e06 device: add fudge factor for handle padding
When CONFIG_USERSPACE is enabled, the ELF file from linker pass 1 is
used to create a hash table that identifies kernel objects by address.
We therefore can't allow the size of any object in the pass 2 ELF to
change in a way that would change those addresses, or we would create
a garbage hash table.

Simultaneously (and regardless of CONFIG_USERSPACE's value),
gen_handles.py must transform arrays of handles from their pass 1
values to their pass 2 values; see the file's docstring for more
details on that transformation.

The way this works is that gen_handles.py just pads out each pass 2
array so its length is the same as its pass 1 value. The padding value
is a repeated run of DEVICE_HANDLE_ENDS values. This value is the
terminator which we look for at runtime in places like
device_required_handles_get(), so there must be at least one, and we
error out in gen_handles.py if there's no room in the pass 2 array for
at least one such value. (If there is extra room, we just keep
inserting extra DEVICE_HANDLE_ENDS values to pad the array to its
original length.)

However, it is possible that a device has more direct dependencies in
the pass 2 handles array than its corresponding devicetree node had in
the pass 1 array. When this happens, users have no recourse, so that's
a potential showstopper.

To work around this possibility for now, add a new config option,
CONFIG_DEVICE_HANDLE_PADDING, whose value defaults to 0.

When nonzero, it is a count of padding handles that are inserted into
each device handles array. When gen_handles.py errors out due to lack
of room, its error message now tells the user how much to increase
CONFIG_DEVICE_HANDLE_PADDING by to work around the problem.

It looks like a real fix for this is to allocate kernel objects whose
addresses are required for hash tables in CONFIG_USERSPACE=y
configurations *before* the handle arrays. The handle arrays could
then be resized as needed in pass 2, which saves ROM by avoiding
unnecessary padding, and would avoid the need for
CONFIG_DEVICE_HANDLE_PADDING altogether.

However, this 'real fix' is not available and we are facing a deadline
to get a temporary solution in for Zephyr v2.7.0, so this is a good
enough workaround for now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-09-30 21:37:59 -04:00
Martí Bolívar
2c99173d64 Revert "device: simplify structure of handles array"
This reverts commit ec331c6fe2.

Although it's a valid simplification under the assumption that we're
going to be padding the array out anyway, it would use extra ROM if we
fix the build system issues that are currently forcing gen_handles.py
to introduce extra padding in the handles arrays for linker pass 2.

On the (perhaps optimistic) assumption that we're going to fix the
build system, let's get rid of a commit that would get in the way. The
extra "complexity" in device_required_handles_get() is trivial.

This gets rid of a comment describing the linker passes, but the
structure of the comment is a bit misleading (and it contains
incorrect information for the results of pass 2: the terminator at the
end is DEVICE_HANDLE_ENDS, not DEVICE_HANDLE_NULL).

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-09-30 21:37:59 -04:00
Martí Bolívar
288bcb90da Revert "device: iterable supported devices"
This reverts commit 0c6588ff47.

It's not clear that the supported devices are being properly computed,
so let's revert this for v2.7.0 until we've had more time to think
it through.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-09-30 21:37:59 -04:00
Piotr Golyzniak
0e1ecb373a twister: Fix missing testcases with error status
If timeout error was occured during performing testsuite on QEMU or
other simulator (e.g. Renode), information about this error will be not
placed in final report. It can be fixed, by set status of testcases,
which were not performed due to this error as "BLOCK".

Simmilar solution is alredy used in DeviceHandler when Twister works
with real platform. So I think that it is resonable to use the same
approach, when tests are performed on simulators.

I move loop which iterate through all testcases and set their tests
status as BLOCK into the parent Handler class, because the same
activity is performed in each children class (BinaryHandler,
DeviceHandler and QEMUHandler).

Fixes #38756

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-09-28 21:34:10 -04:00
Jaxson Han
f079e6638f scripts: Add align for empty _app_smem region
When _app_smem region is empty, alignment is also needed. If there
is no alignment, the _app_smem_start used by arm mpu can be lower
than __rodata_region_end, and this two regions can overlap.

The Armv8-R aarch64 MPU does not allow overlapped regions.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2021-09-28 20:06:06 -04:00
Alex Sergeev
e7778b8584 net: ptp: extract PTP interfaces outside gPTP subsys under NET_L2_PTP
As per #38352, we would like to start building out PTP (IEEE 1588)
support for superset of gPTP functionality in Zephyr. This is the first
step to abstract away some key interfaces from NET_GPTP umbrella to
NET_L2_PTP.

Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
2021-09-28 20:01:16 -04:00
Torsten Rasmussen
af87599e11 scripts: twister: print message from CMake verify toolchain on failures
Fixes: #38924

When the `verify-toolchain.cmake` script fails, then twister will print
a standard message to the user regardless of the reason.
> E: Variable ZEPHYR_TOOLCHAIN_VARIANT is not defined

The `verify-toolchain.cmake` already prints detailed information
regarding the cause of the failure, so twister should just pass that
message as-is.

For example, the message that is provided by verify-toolchain.cmake
when Zephyr SDK 0.13.0 is installed but 0.13.1 is required looks like:
> CMake Error at cmake/verify-toolchain.cmake:75 (find_package):
>  Could not find a configuration file for package "Zephyr-sdk" that is
>  compatible with requested version "0.13.1".
>
>  The following configuration files were considered but not accepted:
>
> /opt/zephyr-sdk-0.13.0/cmake/Zephyr-sdkConfig.cmake, version: 0.13.0

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-28 14:10:37 -04:00
Iuliana Prodan
3ec07c5f47 west: sign: add support for NXP i.MX8QXP board
Add support for signing i.MX8QXP SOF with Zephyr images with rimage.

i.MX8QXP and i.MX8QM have the same board-level definitions,
so we use the generic imx8.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-09-27 21:52:31 -04:00
Henrik Brix Andersen
9aa4a70e5c twister: ignore ROM region overflows
Add ROM region to list of regions to optionally ignore overflows on.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-09-27 17:53:09 -04:00
Torsten Rasmussen
e2427ff671 scripts: check_compliance should not generate soc/shield Kconfig files
Fixes: #38463

With 6be1b2af9b then Zephyr shields and
soc Kconfig are always sourced from Kconfig directly.

However, check_compliance.py generates Kconfig files for sourcing the
same files thus sourcing the same files twice.
The end result is a lot of Kconfig warnings as described in #38463.

Removing the generated Kconfig files as this is no longer needed after
6be1b2af9b has been introduced.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-23 11:27:41 -04:00
Anas Nashif
55c3dde322 twister: fix json reporting of build only tests
Tests are reported as skipped if they are only being built. Fix this by
checking for the correct status.

Fixes #37475

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-09-17 08:11:01 -04:00
Maciej Perkowski
edb23d7bd8 twister: native_posix: Ignor filtering by toolchain for native_posix
In the case of native_posix (and other "host" toolchain based
platforms) Twister shouldn't filter tests by ZEPHYR_TOOLCHAIN_VARIANT.
The PR replaces `- zephyr` with `- host` in native_posix(_64).yaml
and modify the filter in twisterlib.py to not block building
if "host" is under the platform supported toolchains.

Fixes: #38418

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-09-10 11:24:58 -04:00
Gerson Fernando Budke
7bf00c935a scripts: runners: openocd: Fix empty search path
When enable thread awareness feature for OpenOCD the search path was
converted to a list.  In some environments OPENOCD_DEFAULT_PATH may
not be defined.  That create an empty search path list system fails.
This add a test to skips fill search_args with openocd_search values
when list is empty.

Fixes #38272.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-09-09 19:44:22 -04:00
Jingru Wang
b78d6740ec twister: when simulatio is mdb-nsim, call make run
For twister, when simulation is mdb-nsim, the platform is
nsim_hs_smp. Before the twister will call west falsh
when platform is nsim_hs_smp, because twister can't kill
cld process, now this problem has been fixed

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-09-06 22:20:51 -04:00
Andy Ross
507e1154e3 scripts/check_compliance.py: Add kconfig false positives
New docs for cavs_v25 describe building a Linux kernel for a
Chromebook and need to talk about these kconfigs.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-03 07:19:34 -04:00
Christopher Friedt
6c37258f5b scripts: add script to extract top-ten bug-bashers
This script allows us to programmatically query bug-bashers within
a user-supplied time-window.

For example, we held a "Bug Bash Week" August 1-7, 2021 (it was
announced a week early though). The output of the script prints
the "top ten" bug bashers in tab-separated columns in descending
order. The first column is the number of bugs squashed and the
second column is the github user id.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-09-01 17:06:50 -04:00
Benedikt Schmidt
b83681d156 twister: Fix execution of twister in makefile environment
When run by a makefile twister might fail to decode the text results of
commands, based upon the environment settings of the system. With this
change escape characters are removed before the string is passed to the
json decoder.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2021-09-01 09:09:57 -04:00
Martí Bolívar
ffa1515978 dtlib: fix issue which allowed invalid node names
Node names are subject to the rules in table 2.1 of the devicetree
specification v0.3, while properties are subject to rules in table
2.2. These rules mean that some property names are invalid node names.

However, the same regular expression is being used to validate the
names of nodes and properties in dtlib. This leads to invalid node
names being allowed to pass. Fix this issue by moving the node name
handling code to the Node constructor and checking against the
characters in table 2.1.

The test cases claim that the existing behavior matches dtc. I can't
reproduce that. I get errors when I use invalid characters (like "?")
in a node name. For example:

foo.dts:3.8-11: ERROR (node_name_chars): /node?: Bad character '?' in
node name

Try to make the dtlib error message reminiscent of that.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-31 19:36:31 -04:00
Martí Bolívar
fff818bbe6 dtlib: remove unused variable
This is unused since the very beginning of the module's introduction.
It looks like it was abandoned in favor of the approach where each
token can have only one capturing group.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-31 19:36:31 -04:00
Torsten Rasmussen
36bb00d1f5 armclang: ARM Compiler C library support
Support for ARM Compiler C library.

This commit add support for the ARM Compiler C libary in:
- Kconfig
- libc/armstdc

A new Kconfig symbol is added to allow a toolchain to specify if they
support linking with the minimal C library.
Also the CMake variable `TOOLCHAIN_HAS_NEWLIB` is exported to Kconfig
so that CONFIG_NEWLIB_LIBS can only be enabled if the toolchain has
newlib.

The armclang toolchain selects the CMake scatter file generator and
disables support for the LD linker template which is not supported by
armlink.

For the ARM Compiler C library, a corresponding lib/libc/armstc/ folder
with a minimal implementation to work with the ARM Compiler C library
is added.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen
c9804d24fe scripts: gen_handles.py: take device start symbol as argument.
The current gen_handles.py script uses linker defined symbols.
As preparation for support of more linkers the gen_tables.py now takes
the device start symbol as argument.

For example, armlink and ld uses different symbols.
With ld those can be named explicitly, but for armlink the linker
decides the names.

For ld, Zephyr defines: __device_start
For armlink, the symbol is defined as: Image$$<section name>$$Base

Therefore knowledge of the linker symbol to be used must be passed to
gen_handles.py so that the correct symbol can be used for locating
devices.

To support this change, the creation of the asm, compiler, compiler-cpp,
linker targets has been moved from target_toolchain_flags.cmake to
target_toolchain.cmake.

All linkers has been updated to support the use of the
device_start_symbol on the linker target.

List of linkers updated:
- ld
- lld
- arcmwdt

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Iuliana Prodan
82304213c3 west: sign: add support for NXP i.MX
Add support for signing i.MX SOF with Zephyr images with rimage.

Note that, for i.MX, we don't need a bootloader nor the .elf.mod files
since there is no need to change the VMA/LMA of each uncached section
to the equivalent address in the cached area of memory.
For the above reasons, I've updated the arguments given to "west sign"
command.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-08-28 23:27:02 -04:00
Henrik Brix Andersen
7d94b0ccfd runners: openocd: add support for custom reset halt command
Add support for specifying a custom OpenOCD command to be used for
resetting and halting a target.

As noted in the OpenOCD documentation, not all targets support the
"reset halt" command for halt-on-reset.

Some targets support a software emulation via the "soft_reset_halt"
command. Other targets may require a custom command (e.g. a command
defined in the target configuration file).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-08-27 13:08:17 -04:00
Gerson Fernando Budke
c3db83ba58 scripts: runners: openocd: Enable thread awareness
Zephyr thread awareness is available for openocd but boards don't
have debuggers configuration.  This configure OpenOCD runner
automatically to complete configuration.

User still require enable CONFIG_DEBUG_THREAD_INFO=y to visualize
thread debug information.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-08-27 06:44:45 -04:00
Daniel Leung
7ad00b9e47 kernel: syscall: pin generated inline functions
Although they are marked as an inline functions, the compiler
may decide not to inline them which would result in them being
outside the pinned text section. Since these functions are
required for userspace to work correctly, pin them in physical
memory. This also applies to k_is_user_context().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung
2117a2a44b kernel: app_smem: allowing pinning memory partitions
This allows memory partitions to be put into the pinned
section so they are available during boot. For example,
the stack guard (in libc partition) is needed during boot
but before the paging mechanism is initialized. Without
pinning it in physical memory, it would fault in early
boot process.

A new cmake property app_smem,pinned_partitions is
introduced so that additional partitions can be pinned
if needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Erwan Gouriou
5c24a6813d scripts/west_commands/runners: openocd: Add no-halt debug option
Some targets require no 'halt' to be issued i the gdb server command.
Add a --no-halt option to make it possible.
Keep use of halt as the default case.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-08-26 17:57:09 -04:00
Torsten Rasmussen
fcf720941f cmake: dts: import devicetree symbols into CMake
This commit introduces devicetree API in CMake so that devicetree
properties and register block can be used in the CMake build system.

The script scripts/dts/gen_dts_cmake.py processes the edt.pickle and
generates a corresponding devicetree property map in a devicetree_target
that is then used in CMake.

The following devicetree API has been made available in Zephyr CMake:
- dt_nodelabel(<var> NODELABEL <label>)
- dt_node_exists(<var> PATH <path>)
- dt_node_has_status(<var> PATH <path> STATUS <status>)
- dt_prop(<var> PATH <path> PROPERTY <prop>)
- dt_prop(<var> PATH <path> INDEX <idx> PROPERTY <prop>)
- dt_num_regs(<var> PATH <path>)
- dt_reg_addr(<var> PATH <path> [INDEX <idx>])
- dt_reg_size(<var> PATH <path> [INDEX <idx>])
- dt_has_chosen(<var> PROPERTY <prop>)
- dt_chosen(<var> PROPERTY <prop>)

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-25 20:28:26 -04:00
Jordan Yates
0c6588ff47 device: iterable supported devices
Add supported device information to the device `handles` array. This
enables API's to iterate over supported devices for power management
purposes.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-25 19:43:54 -04:00
Jordan Yates
ec331c6fe2 device: simplify structure of handles array
Force the inclusion of a `DEVICE_HANDLE_SEP` at the end of the
devicetree dependency section of the array. This lets us simplify the
implementation of `device_required_handles_get`, as there is only one
symbol the section ends with.

This does not use any extra ROM as the array is padded out to the
original size with `DEVICE_HANDLE_ENDS` anyway.

Also adds a description of the array format where the array is
instantiated.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-25 19:43:54 -04:00
Jordan Yates
b5c4140afb device: optimize handles array
Optimize the handles array by making the following observations:
 * The devicetree ordinal at index 0 in pass1 is discarded by
   gen_handles.py, and therefore does not appear in the pass2 array.
 * gen_handles.py does not need `DEVICE_HANDLE_ENDS` to determine the
   end of the handle array, as that information is present in the .elf.

Therefore, instead of replacing the devicetree ordinal with an
additional `DEVICE_HANDLE_ENDS` at the end (to preserve lengths), we
can simply move the ordinal to the end and have it be the original
`DEVICE_HANDLE_ENDS` symbol. This reduces the size of the array by
one handle per device (2 bytes).

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-25 19:43:54 -04:00
Martí Bolívar
9df0493dc3 scripts: gen_defines: emit pinctrl helper macros
We need to be able to access pinctrl-<index> property contents by
name, convert names to indexes, convert indexes to names, and perform
existence checks by name and by index.

This is currently not possible because we don't track these properties
the same way we do other named properties. That in turn is because
they are different then the usual named properties.

The usual case looks like this, picking DMAs just for the sake of
example:

  dmas = <&dma0 ...>, <&dma1 ...>;
  dma-names = "tx", "rx";

So "tx" is the name for the <&dma0 ...> element, and "rx" is the name
for the <&dma1 ...> element, all in a single "dmas" property.

By contrast, pinctrl properties look like this:

  pinctrl-0 = <&foo &bar ...>;
  pinctrl-1 = <&baz &blub ...>;
  pinctrl-names = "default", "sleep";

Here, "default" is the name for the entire pinctrl-0 property.
Similarly, "sleep" is the name of the pinctrl-1 property. It's a
strange situation where the node itself is kind of a container for an
array of pin control properties, which Zephyr's bindings language
can't really capture and has some special case handling in edtlib.

This is easiest to handle with ad-hoc code. Add special case macros
for pinctrls.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Martí Bolívar
7f69a03f72 scripts: gen_defines: refactor write_special_props
Move the partition handling code into its own function and rework the
comment. This is prep work for adding additional generated macros to
this function.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Martí Bolívar
3252821b4c scripts: gen_defines: fix typo
Missing 's'.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Martí Bolívar
fa2e82becd edtlib: emit pinctrl names as tokens
This will be necessary to going back and forth between indexes and
names in C.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Martí Bolívar
6e9e984e60 dtlib: remove pylint suppression
This became useless when _init_tokens() was refactored not to use
global variables (in "dtlib: use IntEnum for token IDs"), and the
linter is complaining about it now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:03:17 -04:00
Martí Bolívar
227ce89c41 edtlib: use f-strings where it makes sense
Similarly to what was done for dtlib, use f-strings in places where it
improves readability. Some places, e.g. __repr__ methods that
construct a string using something like

    "<SomeType, {}>".format(", ".join(...))

are better left off as-is.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:03:17 -04:00
Martí Bolívar
66ee3d291c dtlib: use f-strings where it makes sense
The library was originally developed before Python 3.6 was the minimum
supported version. Use f-strings now that we can do that, as they tend
to be easier to read.

There are a few places where str.format() makes sense to preserve,
specifically where the same argument is used multiple times; leave
those alone.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:03:17 -04:00
Andreas Vibeto
32fbf8e414 twister: Fix bug re-running all tests when using test-only
When using both test-only and retry-failed flags, all tests would be
added to the test queue regardless if they failed or not. This commit
updates the logic to process test-only runs similar as other runs,
by adding tests to the queue with the 'run' operation directly.

Signed-off-by: Andreas Vibeto <andreas.vibeto@nordicsemi.no>
2021-08-20 18:58:47 -04:00
Martí Bolívar
85837e1c54 scripts: gen_defines: allow multiple --vendor-prefixes
Allowing multiple such files will let higher layers take inputs from
multiple DTS_ROOT directories. This in turn will allow out of tree
bindings to manage their own sets of prefixes without patching
upstream Zephyr's file or doing other similar hacks.

Parse each file into a dict, and merge those dicts into a single
dictionary for the EDT constructor.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-20 18:57:30 -04:00
Martí Bolívar
2533246610 edtlib: tweak vendor prefixes implementation details
If the user passes None, set the internal attribute to an empty dict
instead. This lets us avoid some None checking and simplifies things
without changing semantics -- if the user *does* pass an empty dict,
the results are the same.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-20 18:57:30 -04:00
Martí Bolívar
d14835812c edtlib: allow .yml files too
This is a common extension for YAML files. We don't have to allow it
in upstream zephyr, but we should allow downstream DTS_ROOTs to have
this ability.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-20 18:57:30 -04:00
Henrik Brix Andersen
0f958bd3ac runners: openocd: add support for multiple configuration files
Add support for passing the --config argument to the openocd west runner
multiple times.

This allows for using modular openocd configuration files (e.g. CPU core
configuration in one file, independent of the selected JTAG interface
type).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-08-20 06:31:42 -04:00
Martí Bolívar
9e8da8953c scripts: edtlib: fix werror for unknown vendor
Commit c4079e4be2
("scripts: rework edtlib warnings-turned-errors") was trying to abort
on unknown vendor prefix, but the error log is not fatal.

Fix it by using the same error handling function we use when aborting
due to deprecated property usage.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-17 17:51:57 -04:00
Martí Bolívar
e9229f1f2b scripts: edtlib: relax vendor check for root node
There are way too many one-off vendor prefixes set up for individual
boards to bother tracking them in vendor-prefixes.txt. As a practical
matter, the compatible for the root node doesn't matter anyway. So
just relax our check for that node.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-17 17:51:57 -04:00
Kumar Gala
7b9fbcd3b7 devicetree: Fix DT_PROP/DT_PROP_BY_IDX for phandle(s)
DT_PROP for a phandle property should return the node that phandle
points to (similar for DT_PROP_BY_IDX for phandles)  and this wasn't
working as the define generator didn't create the proper defines for
phandle(s).

Fix the generator and add some tests to make sure this continues to
work correctly.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-08-12 19:01:38 -05:00
Martí Bolívar
361956b669 cmake: add a comment header to zephyr_settings.txt
I saw a user wondering what this is for and and where it comes from.
Provide a comment header with some explanation and a pointer to where
to find out more.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-10 07:37:19 -04:00
Martí Bolívar
e7d42ff879 dts: gen_defines: emit more for-each helpers
Add some helper macros that work similarly to the
'DT_FOREACH_OKAY_INST_<compat>(fn)' macros, except they give 'fn'
node identifiers in their expansion instead of instance numbers.

This makes it possible to add for-each APIs to devicetree.h that work
on an arbitrary compatible, not just DT_DRV_COMPAT.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-06 12:24:57 -05:00
Martí Bolívar
6fe3c30af7 scripts: check_compliance: fix filter_py edge case
The filter_py() function is handed a bunch of file names and is
expected to give back just the python files.

Its input is the output from a 'git diff' command which normally when
used in the vanilla zephyr repository just prints regular files.

In situations where we're checking compliance on a repository with
submodules, however, filter_py() can be given directories in the
'fnames' list from the git output.

In the interests of being defensive and sharing infrastructure, just
handle this case in filter_py().

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-05 16:14:12 +02:00
Martí Bolívar
c4079e4be2 scripts: rework edtlib warnings-turned-errors
Create a "global" gen_defines.py option and edtlib.EDT constructor
kwarg that turns edtlib-specific warnings into errors. This applies to
edtlib-specific warnings only. Warnings that are just dupes of dtc
warnings are not affected.

Use it from twister to increase DT testing coverage in upstream zephyr.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Martí Bolívar
f261d77c75 cmake: dts: warn on unrecognized vendor prefixes
This uses the list of vendor prefixes provided by the user by default.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Martí Bolívar
6719fae101 edtlib: warn on unrecognized vendors
An unknown vendor prefix is now a warning. We augment the list of
vendor prefixes passed by the user with a grandfathered-in bunch from
Linux.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Martí Bolívar
7b60fa3a15 edtlib: move vendor-prefixes.txt parsing in here
Take this helper from the doc tooling and expose it as API.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Martí Bolívar
4a313129b2 edtlib: only do compatible checks once
Remember the compatibles we've validated, and don't check them again.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Carles Cufi
2a173c2213 runners: jlink: Add support for specifying a serial number
Handle serial numbers provided from the command-line instead of forcing
the user to provide 'tool-opt' manually.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-08-03 17:39:51 +02:00
Sylvio Alves
b3bf6d854e esp32: auto detect serial port
Current default serial port used for flashing is
/dev/ttyUSB0. This changes that to automatically detect the device
serial port or uses the one exported to the environment.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-08-03 13:59:04 +02:00
Maureen Helm
e433993890 scripts: Track memory footprint for networking samples on frdm_k64f
Extends memory footprint tracking to include echo_client and echo_server
networking samples on the frdm_k64f board.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-08-03 07:10:09 -04:00
Kentaro Sugimoto
e8ab98712c refactor: correct spells to that probably intended
Make correction on the terms "intput" appearing
in sciripts/pylib/twister/twisterlib.py to "input" for all.

This type of misspellings may cause another unnoticeable misspellings,
when propagated by code completions.

(assuming that the "intput" was intended
to have the opposite meaning of "output",
which also appear on the same areas)

Signed-off-by: Kentaro Sugimoto <tarotene@gmail.com>
2021-08-02 12:13:23 -04:00
Andrzej Głąbek
cfaee96e92 twister: Add dt_nodelabel_enabled devicetree filter function
This function takes a node label (not a label property) and returns
true if a node with such label exists and the node is enabled.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-07-28 18:41:26 -04:00
Maciej Perkowski
d87160391f twister: No error when skipping quarantined tests in integration mode
When integration mode is on, any skips on integration_platforms are
treated as errors. This patch adds an exemption for quarantined tests.
They will stay as skipped.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-07-27 17:43:12 -04:00
Piotr Golyzniak
35a052066c twister: Fix wrong error counter in report
If "Cmake build failure" is detected test instance get status "error".
Despite this in final report this error is counted as failure. It can
be fix, by set proper results of each testcase in instance from None
to "BLOCK" after found Cmake error. After this fix, error is counted
properly in final report.

Fixes #37140

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-07-23 18:33:18 +03:00
Daniel Leung
cca65a986e scripts: gen_syscalls: skip GCC pragma on -Warray-bound for XCC
XCC doesn't recognize GCC pragma to ignore -Warray-bounds. So #if
it out, or else XCC would complain about unknown option for all
syscall generated header files.

Fixes #36661

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 15:41:11 +03:00
Anas Nashif
dfc259d13c action: footprint tracking
Add action and scripts for footprint tracking.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-21 14:54:30 +03:00
Anas Nashif
302ac4995b size_report: report total and root size correctly
Fix reporting totals.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-21 14:54:30 +03:00
Anas Nashif
e230e00677 size_report: generate multiple reports
Generate both ram/rom reports in one call.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-21 14:54:30 +03:00
Anas Nashif
eaed951e96 size_report: add --quiet argument
Add a new argument to allow generating json files without printing the
complete diff on the screen.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-21 14:54:30 +03:00
Anas Nashif
f026b470d8 scripts: introduce footprint diffing
Very simple script to diff between two ram or rom reports generated by
size_report. When you call call the ram_report or rom_report targets you
end up with a json file in the build directory that can be used as input
for this script.

The output shows which symbols insreased and which decreased in size and
also tracked added/remove symbols as well.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-21 14:54:30 +03:00
Elliot Revell-Nash
c2897c6b18 scripts: coredump: rename parser to avoid conflict with builtin module
The parser module name collides with builtin parser module in python.
This seems to break the import in windows.

Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
2021-07-19 21:14:16 +03:00
Elliot Revell-Nash
78498933f1 scripts: colorize parsed dictionary logging
Print parsed dictionary based logging with color

Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
2021-07-16 21:34:06 -04:00
Marcin Niestroj
54b26ca7e8 scripts: west: boards: support listing out-of-tree boards
So far only upstream boards were listed. Use just introduced
zephyr_module.parse_modules() function to get information about
out-of-tree board roots. Append them to user provided args.board_roots,
so out-of-tree boards from west modules are listed as well.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-16 07:17:35 -04:00
Marcin Niestroj
248d25dc6f scripts: zephyr_module: split function for parsing modules
Add parse_modules() function, which will offload most of the work in
main() and additionally allow external Python code to use that function.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-16 07:17:35 -04:00
Carlo Caione
f4db14f349 dts: Introduce DT_STRING_TOKEN and DT_STRING_UPPER_TOKEN
To be able to get a tokenize DT string without the quotes. Deprecate
also DT_ENUM_TOKEN and DT_ENUM_UPPER_TOKEN.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-07-15 18:12:51 -05:00
Martí Bolívar
15db98a400 dtlib: allow dangling aliases with DT(..., force=True)
As a first step towards being more forgiving on invalid inputs, allow
string-valued aliases properties that do not point to valid nodes when
the user requests permissiveness.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-07-14 19:51:46 -04:00
Martí Bolívar
176225db58 dtlib: add force DT kwarg
Modeled after dtc's --force option, the idea is this will try harder
and harder over time to produce an object despite malformed input.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-07-14 19:51:46 -04:00
Arvin Farahmand
d0b9c03154 devicetree: Add _VARGS variants to _FOREACH_ marcos
`_FOREACH_` macros do not allow the caller to pass additional arguments
to the `fn`. A series of `_VARGS` variants have been added that allow
the caller to pass arbitrary number of arguments to the `fn`:

```
DT_FOREACH_CHILD_VARGS
DT_FOREACH_CHILD_STATUS_OKAY_VARGS
DT_FOREACH_PROP_ELEM_VARGS
DT_INST_FOREACH_CHILD_VARGS
DT_INST_FOREACH_STATUS_OKAY_VARGS
DT_INST_FOREACH_PROP_ELEM_VARGS
```

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-14 19:50:39 -04:00
Felipe Neves
132ab922a8 drivers: timer: esp32c3: add esp32c3 systimer driver to CODEOWNERS
Also added maintainer to the entry

Signed-off-by: Felipe Neves <ryukokki.felipe@gmail.com>
Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
2021-07-07 20:58:50 -04:00
Felipe Neves
5d736766ed soc: esp32c3: added initial soc support files for esp32c3
by adding the soc specific files such: soc initialization code,
linker scripts and support for esp32c3 devkitm

Signed-off-by: Felipe Neves <ryukokki.felipe@gmail.com>
Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
2021-07-07 20:58:50 -04:00
Watson Zeng
91aedd964e arc: west: mdb: reverse the launch order for multi cores
The ARConnect Inter-core Debug Unit (ICD) provides
additional debug assist features in multi-core scenarios.
In master core(core 0) initial stage, we will program ICD to halt
all other cores based on a halt occurring in one ore more core.
And all cores are in halt mode on reset, so we need to make
sure other slave cores have launched and in running mode
before we enable ICD in master core.

Currently we launch master first, Let's reverse the launch
order, launch master last, to make sure slave cores have
launched before we program and enable ICD.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-07-01 13:33:34 -04:00
Armando Visconti
351b28e122 drivers/sensor: lis2dw12: move int-pin in DTS binding
Take the int-pin information (i.e. what pin between INT1
and INT2 the drdy is attached to) directly from DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Kumar Gala
3641de91e0 ci/tags.yaml: Add entries for a few different tags
Add entries for bluetooth, cmsis_dsp, posix, and cbprintf.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-24 12:38:57 -05:00
Kumar Gala
0f7dde8ec1 ci/tags.yaml: Remove includes
Remove includes from the tag file.  If we have a change to an include
that implies some API change which may show up somewhere else so we
want to build as many tests/samples as possible in that case.

Also added a comment about keeing entries sorted alphabetically.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-24 12:38:57 -05:00
Erwan Gouriou
e5bf24b325 scripts: twister: Fix error in dt_label_with_parent_compat_enabled
In dt_label_with_parent_compat_enabled, it maybe that there is
no node matching expected label.
In this case don't generate error, but return False.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-24 10:24:58 -04:00
David Leach
f5b0f92bb7 scripts: dictionary: rename parser module to avoid name collision
The parser module collides with a module in python called parser.
Doesn't seem to be a problem in Linux but for some reason the
search/include order in Windows causes python to import the wrong
parser. The change is to rename the module to dictionary_parser
to avoid the name space collision.

fixes: #36339

Signed-off-by: David Leach <david.leach@nxp.com>
2021-06-24 04:22:33 -05:00
Jingru Wang
fed1c54cf2 twister: try to clean ninja zombie
sometimes ninja fails to launch qemu, the sub-thread
can't read anything from qemu pipeline, then the
corresponding testcase will timeout. Then the
sub-thread will get blocked if it call join()

set terminate as the Handler's method, then
Handler's children class can call it

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-06-23 06:10:32 -04:00
Erwan Gouriou
3e1443ccf9 scripts/pylib: expr_parser.py: Review dt_compat_enabled_with_label
Function used for filtering "dt_compat_enabled_with_label" was not
working as expected as it was not taking into account that we're
looking for a children/parent combination:
Provided "compat" with enabled status should be the one of the parent
of the node matching given label.

Function is then reworked to take this into account.
And to make it's usage clear:
- function name is changed to be clearer on the intention
- args order is reversed to be more logical wrt the intention

Users of the function are also updated to take the change into
account.

Fixes #36093

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-21 20:31:49 -04:00
Kumar Gala
1bf5b70771 run_ci.sh: Fix setting of twister_exclude_tag_opt
We were testing modified_tags.args before we called get_twister_opt.py
so it would never have been created and thus twister_exclude_tag_opt
would never get set correctly.  Move the check to after we call
get_twister_opt.py

Also we need to remove modified_tags.args once we are done with it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-16 16:00:06 -05:00
Marc Herbert
e21ffe6baa requirements-doc: add PyYAML which removes dependency on -base
This means a light requirements-doc.txt is enough for doc writers. See
previous discussions in PR #31199 and PR #31239

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-06-16 10:39:08 +02:00
Marc Herbert
88600d69e9 scripts: runners: add specific ImportError to warning message
So when for instance adding some `import wrong_module` line to a sample
runner like bossac.py this adds the text between parentheses ( ) below:

  The module for runner "bossac" could not be imported (No module named
  'wrong_module'). This most likely means it is not handling its
  dependencies properly. Please report this to the zephyr developers.

Test tip: changes to bossac.py do not trigger a fast, incremental doc
build. touch doc/guides/west/build-flash-debug.rst does it instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-06-16 10:39:08 +02:00
Kumar Gala
d736899504 run_ci.sh: add support for tag exclusion
Plumb modified_tags.args into run_ci.sh

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-15 11:39:23 -04:00
Kumar Gala
d7773fba06 ci: Add twister tag support to get_twister_opt
Add the ability to map file/dir paths of a PR to twister TAG.  We
introduce scripts/ci/tags.yaml to conveys which files are associated
with which tag.

Since not all file/tags will be specified in tags.yaml we use the
combination of the files modified list and the tags.yaml information to
determine which tags can be excluded (ie if the file list doesn't match
any file in tags.yaml for a given tag listed there, we can that exclude
it).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-15 11:39:23 -04:00
Casper Meijn
d25e5c20a0 scripts: dts: Produce error for invalid yaml
I made an alignment error in a dts binding, but the build was
successful. After some debugging I found the following warning
explaining the problem:

  '/home/casper/src/zephyrproject/zephyr/dts/bindings/gpio/
       gpio-keys.yaml' appears in binding directories but isn't valid
       YAML: while parsing a block mapping
    in "<unicode string>", line 11, column 8
  did not find expected key
    in "<unicode string>", line 18, column 9

I think this should be an error as there shouldn't be any invalid yaml.

Signed-off-by: Casper Meijn <casper@meijn.net>
2021-06-14 10:36:27 -05:00
Anas Nashif
070cf6a7fc west: parse options from testcase.yaml/sample.yaml during build
Allow the use of build configurations from testcase/sample yaml files.
This addition makes it easy to build a sample or a test with the options
provided in the test file by pointing to the test section to be built on
the command line of `west build`.

Fixes #31993

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-11 20:56:10 -04:00
Marcin Niestroj
35c882d18f scripts: list_boards: handle boards dirs with subset of architectures
Out-of-tree boards directory is likely to have boards within subset of
architectures (e.g. only 'arm' boards) that are supported by Zephyr.
Currently script iterates over all architectures and tries to list
contents of boards/<arch>/, which might not be existing. This results in
'FileNotFoundError' exception:

  Traceback (most recent call last):
    File "/project/zephyr/scripts/list_boards.py", line 113, in <module>
      dump_boards(find_arch2boards(parse_args()))
    File "/project/zephyr/scripts/list_boards.py", line 32, in \
                                              find_arch2boards
      arch2board_set = find_arch2board_set(args)
    File "/project/zephyr/scripts/list_boards.py", line 45, in \
                                              find_arch2board_set
      for arch, boards in find_arch2board_set_in(root, arches).items():
    File "/project/zephyr/scripts/list_boards.py", line 78, in \
                                              find_arch2board_set_in
      for maybe_board in (boards / arch).iterdir():
    File "/usr/lib/python3.9/pathlib.py", line 1149, in iterdir
      for name in self._accessor.listdir(self):
  FileNotFoundError: [Errno 2] No such file or directory: \
                                              '/project/app/boards/arc'

Simply ignore missing boards/<arch>/ directories and skip to the next
arch.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-06-11 16:26:30 +02:00
Anas Nashif
08aa12a14e twister: remove toolchain test
We now get toolchain from cmake and can operate even if the toolchain
variant is not set in the envrionment, this test was verifying the old
behavior, so remove. There is not much twister related here to test and
the environment is not setup correctly to run all of this cmake code. We
are testing twister after all.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-11 08:16:41 -04:00
Kumar Gala
168bdaadc5 run_ci.sh: Move creation of test_file.txt into a function
Make a single function that handles creation of test_file.txt and fold
get_tests_to_run into it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-10 07:53:58 -05:00
Kumar Gala
5e46a6453c run_ci.sh: Rename test_file_main to test_file_full
Rename test_file_main to test_file_full to be more consistent with the
usage of "full" elsewhere.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-10 07:53:58 -05:00
Kumar Gala
4e7a444131 run_ci.sh: rework logic to be a bit more consistent
Treat all test_file_* files the same and just explicitly set the header
in the final test_file.txt.  This makes the logic the same regardless of
what paths tests are coming from.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-10 07:53:58 -05:00
Kumar Gala
fd8dabcb95 run_ci.sh: Fix what tests run with -l
If the local option (-l) was specified we were ignoring the results
of what_changed.py and always setting a "FULL" build.  Only explicitly
set a FULL run if we are building for a commit to the tree (local and
PR builds should respect the output of what_changed.py).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-10 07:53:58 -05:00
Kumar Gala
88cf35cb24 run_ci.sh: Rename master to main branch in example comment
Since we use 'main' now, rename the example comment usage to use
that branch name instead of 'master'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-10 07:53:58 -05:00
Martí Bolívar
8875340db4 python-devicetree: tox: fix mypy
Recent versions of mypy have learned that the yaml module has type
stubs and the tool is now erroring out when it discovers we import
yaml since the stubs are not involved.

This is breaking CI on unrelated patches; fix it following the
instructions here:

https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-06-09 21:01:55 -04:00
Daniel Leung
82ec1c0e88 kernel: ignore array bound warnings for generated syscall funcs
Compilers and static code analyzers do not understand Zephyr's
syscall mechanism so they always complain about out of bound
array access inside the generated syscall header functions.
So add a flag for GCC to ignore this type of warning for these
functions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-06-04 16:22:03 -05:00
Anas Nashif
39354d92bb size_report: give root node a unique identifier
Call the root node 'root', otherwise we end up with two nodes with the
same identifier ':'.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-03 20:46:55 -05:00
Martí Bolívar
91f0212399 doc: add docs for west spdx
These are based on the commit log in
fd31b9b4ac.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-06-01 07:26:33 -05:00
Daniel Leung
4725db8722 scripts: gen_syscall: ignore Coverity overrun check
Coverity does not understand syscall mechanism and will already
complain when any function argument is not of exact size as
uintptr_t. So tell Coverity to ignore this particular rule here.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 07:31:40 -04:00
Erwan Gouriou
2448cfa505 scripts: series-push-hook: Use main as base comparison branch
Following master branch renaming to "main", update this script
to use $remote/main as base comparison branch

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-05-27 15:55:43 -05:00
Daniel Leung
d475f9865b scripts: size_report: add tree node for WORKSPACE
Add a tree node to group files under WORKSPACE so that
they won't be shown with full path. The WORKSPACE is
usually the same as WEST_TOPDIR unless ZEPHYR_WORKSPACE
is defined during build.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Daniel Leung
c3e8c4e6dc scripts: size_report: add tree node for hidden symbols
The list of symbols only contain visible symbols that can be
obtained through ELF file. There are code and data where
the toolchain never emits symbols for them and thus are not
visible in the list. So add a "(hidden)" node to the tree
to show they are there.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Daniel Leung
e87c82df51 scripts: size_report: alter how nodes are grouped together
This changes how the tree is generated. Symbols with no paths
are now grouped together instead of scattering throughout
the tree. If paths in ELF file are not all under ZEPHYR_BASE,
it will create additional node groups as 2nd level. This is
useful when not all source files are under ZEPHYR_BASE, and
provides a better indications of where they are.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Daniel Leung
3e695ccef9 scripts: size_report: keep full path until inserting into tree
This changes how paths are stored in intermediate structures
so that full paths are stored. This makes it more consistent
with those structures to avoid an issue where some paths are
full paths, some are relateive to ZEPHYR_BASE.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Daniel Leung
1e8f6be1fd scripts: size_report: recognize C++ file extensions
This adds some common C++ file extensions so the script
can recognize those as source file, and display them in
different color.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Daniel Leung
86cff1a857 scripts: size_report: fix pylint docstrings and import issues
This fixes the issues on import statements identified by pylint.
Also add docstrings for method and classes. Most of them are
already there as comments, so simply move them as docstrings.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Gerson Fernando Budke
f3a7f041bf scripts: runners: bossac: Add legacy mode
Add compatibility mode with old sam-ba flash bootloaders that don't have
offset capabilities.  These bootloaders flash to a pre-defined flash
region.  At end, bossac will suppress --offset parameter.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-05-21 21:20:58 +02:00
Martí Bolívar
bd122e5ea2 edtlib: validate compatible properties
Error out on compatible properties with invalid values. The regular
expression used to validate them matches what's used in dt-schema.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-19 22:18:25 -05:00
Gerard Marull-Paretas
95d8d2cc58 doc: fix 404 page
Sphinx handling of 404 page is not that easy when using theme
customizations. Enabled the `sphinx-notfound-page` extension (maintained
by readthedocs) to fix its displaying.

Also adjusted Zephyr logo (was causing some Sphinx processing errors
when trying to scale it).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-19 16:48:39 -04:00
Martí Bolívar
cc1e64be93 runners: openocd: fix 'debug'
The 'debug' command isn't reloading the binary. Fix it, keeping
'attach' support as-is.

Fixes: #33745

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-19 17:33:33 +02:00
Martí Bolívar
2a47142b0a requirements: bump west to >=0.10.1
We are in the process of changing the HEAD branch in the zephyr
repository from 'master' to 'main'. Users will need west version at
least 0.10.1 for the plain 'west init' line in the getting started
guide to still work after that change.

To avoid problems:

- add -U to the macOS and Windows lines for installing west (this
  option is already there for Ubuntu). Upgrading west will make
  the guide 'just work' for users who have an old version.

- bump the minimum version in the relevant requirements file,
  in case anybody is doing something like basing a CI setup
  on those versions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-18 09:52:12 -05:00
Anas Nashif
0e64b877da twister: fix hardware map generation
when generating a new map, set the status of the device and whether it
is connected or now. The available key is runtime only and is not part
of the map anymore.
Adapt documentation and remove available as a key in the generated map.

Fixes #35341

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 11:47:50 -04:00
Carles Cufi
2189c08e4e ci: Add an errno.h check to CI
Add a very simple check that verifies that new error numbers are added
according to the errno.h file in newlib, in order to maintain
compatibility with it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-05-17 09:11:15 -04:00
George White
f54e1eddbe runners: bossac: Arduino bootloader reset on macOS
Fixes compatibility with the Arduino bootloader reset mechanism when
using `west flash` on Darwin hosts.

stty is used to set the serial port in the bossac runner to 1200 baud on
Arduino ATSAMD21 bootloaders. The `-F` argument to stty is a GNU
coreutils addition, and thus it is missing from Darwin's BSD stty, so
change the flag to `-f` when we're not running on Linux.

On Darwin, set DEFAULT_BOSSAC_PORT to None and ask the user to select
one from a list of IOCalloutDevices reported by ioreg, modelled on the
get_board_snr from the nrfjprog runner. This is because serial port TTYs
are generated by the device driver, and therefore there is no safe
default.

Tested with an Arduino Nano 33 IoT board.

Signed-off-by: George White <me@galexite.uk>
2021-05-13 22:05:17 -04:00
Kumar Gala
92275cfa60 twister: Add ICCM/DCCM to list of overflow regions
On ARC some platforms utilize ICCM/DCCM for their "flash" and "ram"
storage.  So we might get errors about overflowing one of these regions.
So treat them similar to how we treat FLASH and SRAM.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-05-10 13:16:05 -05:00
Anas Nashif
4d994af032 kernel: remove object tracing
Remove this intrusive tracing feature in favor of the new object tracing
using the main tracing feature in zephyr. See #33603 for the new tracing
coverage for all objects.

This will allow for support in more tools and less reliance on GDB for
tracing objects.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Arvin Farahmand
2de6bf91d5 west: sign.py: fix logic bug
Fix bug where if `CONFIG_BOOTLOADER_MCUBOOT` is set sign.py incorrectly
shows warning `CONFIG_BOOTLOADER_MCUBOOT is not set to y...`.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-05-06 19:49:52 -05:00
Anas Nashif
01c1bcf724 ci: disable identifier_length scripts for now
This rules is not working as expected, so remove it for now.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-06 14:45:03 -04:00
Krzysztof Chruscinski
d3b246464c scripts: ci: check_compliance: Extend UNDEF_KCONFIG_WHITELIST
Added SAMPLE_MODULE_LOG_LEVEL_DBG as an exception. Define is used
in the log_api test suite.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-06 15:40:05 +02:00
Shubham Kulkarni
2caaacc191 scripts: esp32.py: Do not convert ELF to bin
ELF to binary generation is handled by build system

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-05-05 19:49:38 -04:00
Anas Nashif
d4e03991a0 ci: have twister cleanup artifacts as it goes
Avoid running out of space by cleaning up passing tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-05 18:48:45 -05:00
Martí Bolívar
2e0d95f3cd devicetree: add mypy-based type checking
Extend the steps taken in tox.ini by type checking the 'devicetree'
package. This will make it easier for callers to type-check code that
uses the low level DT module's public APIs, since they can rely on
the type checker a bit more.

It will also help avoid bugs by adding some type checking for future
changes to this module.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
a8f7bfbbd4 edtlib: silence type checker issue
Mypy is complaining about this line for some reason I didn't have time
to figure out. Just shut it up for now; I'll look into this when I get
around to type annotating edtlib.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
8e30289b84 dtlib: type annotate DT fields and public methods
Now that all the other code it depends on is annotated, we can finish
up the type annotation of this module in the main DT class.

It's not worth it to try to annotate the private methods (the ones
that begin with '_'). Most of these are low level lexing helpers that
aren't particularly amenable to static type checking, because the type
of a token's value is often dependent on the token ID in ways that
static type annotations are not well equipped to capture.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
c6bb336bc1 dtlib: add type checking for DT.root
We'd like users of this API to know that DT.root is always a Node,
and not an Optional[Node].

However, although DT.__init__ throws an exception if the resulting DT
object would have no root node, static analysis can't tell that since
the root instance attribute starts out as None during initialization,
so checkers like mypy are convinced it's Optional[Node].

Since this is really OK, we'll quiet the type checker down by stashing
the instance attribute in self._root instead, and providing a root
property accessor that is annotated to return Node instead of
Optional[Node]. We can tell mypy to ignore what looks like a potential
None here to allow callers to treat the result as a Node.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
b13b5b8b3a dtlib: fix include_path edge case
The documentation says DT.__init__ takes any iterable for the
include_path, but this leads to bad results when you pass it something
other than a 'real' sequence (list/tuple/etc), like a generator:

>>> dt = DT('/tmp/foo.dts', (x for x in ['a', 'b', 'c']))
>>> repr(dt)
"DT(filename='/tmp/foo.dts', include_path=<generator object ...>)"

Make a copy in list form just to avoid things like this.

Add a test for this and relax the regular expression in the existing
test case related to this.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
628fb90412 dtlib: type annotate public functions
Some of these are also tripping up a python 2 / python 3 warning
in mypy in the way that '{}'.format(b'foo') works, which we silence by
explicitly requesting the python 3 behavior.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
9d4ccf23ec dtlib: use IntEnum for token IDs
The way that _init_tokens() is manipulating globals() defeats static
analyses of the file that are trying to infer a type for the 'tok_id'
variable in assignment expressions like 'tok_id = _T_INCLUDE'.

To make it easier on the analyser, define the token types as an
enum.IntEnum named _T. This means we can write e.g. '_T.INCLUDE'
instead of '_T_INCLUDE', avoiding line length increases in the lexing
code.

While we're here, use '==' and '!=' instead of 'is' and 'is not'
when comparing a tok_id that is obtained from an re.Match.lastindex
with a _T.FOO value.

This is now necessary since an int object and a _T object definitely
don't point to the same memory. It worked previously because CPython
interns all integer instances from -5 to 256, but that's an
implementation detail and not a language feature. Since we're getting
the ints from an re.Match.lastindex instead of putting the exact
_T_FOO values into some list, this code probably should not strictly
speaking have been using 'is'.

Explicitly initialize the global _token_re also, to make it more
visible for static analysis.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
8427259ca2 dtlib: type annotate Property class
Continue annotating the module. In some cases mypy will miss that
_err() calls means the function will not return, so we return an
unnecessary local variable to appease it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
a7e7964b14 dtlib: use IntEnum for marker types
Add a _MarkerType enum. A subsequent commit will use it for type
annotations in the Property class.

Fix an incorrect type in a comment while we're here.

We continue to use 'marker_type is _MarkerType.FOO' instead of
'marker_type == _MarkerType.FOO' because we are adding those actual
_MarkerType.FOO objects to each property, so 'is' comparison
is legitimate.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
f663521e4a dtlib: type annotate Node class
A step along the way towards typing the whole module.

Fix an incorrect (or at best misleading) comment while we're here,
which was noticed by the type checker when I originally annotated
'props' as a Dict[str, bytes].

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
a6ed7b262e dtlib: type annotate _err()
Marking this NoReturn helps the type checker figure out that functions
which call it are only returning valid values or failing to
return. (It unfortunately doesn't always work as mypy's control flow
analysis seems to treat a direct 'raise DTError(...)' differently than
calling _err() in some situations, but it helps.)

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
587b3248dc dtlib: code order and whitespace refactoring
Move the DTError, Node, Type, and Property definitions to the top.

This way, class definitions occur before methods which use those
classes. This will be useful to avoid string literals in type
annotations that will be added later. Some can't be avoided due to
circular dependencies, but this will help.

Adjust whitespace.

No functional changes expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Martí Bolívar
22fd259ce1 devicetree: fix stale comments
Update stale script comments from the package reorganization.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-05 13:13:12 -05:00
Steve Winslow
fd31b9b4ac west: spdx: Generate SPDX 2.2 tag-value documents
This adds support to generate SPDX 2.2 tag-value documents via the
new west spdx command. The CMake file-based APIs are leveraged to
create relationships from source files to the corresponding
generated build files. SPDX-License-Identifier comments in source
files are scanned and filled into the SPDX documents.

Before `west build` is run, a specific file must be created in the
build directory so that the CMake API reply will run. This can be
done by running:

    west spdx --init -d BUILD_DIR

After `west build` is run, SPDX generation is then activated by
calling `west spdx`; currently this requires passing the build
directory as a parameter again:

    west spdx -d BUILD_DIR

This will generate three SPDX documents in `BUILD_DIR/spdx/`:

1) `app.spdx`: This contains the bill-of-materials for the
application source files used for the build.

2) `zephyr.spdx`: This contains the bill-of-materials for the
specific Zephyr source code files that are used for the build.

3) `build.spdx`: This contains the bill-of-materials for the built
output files.

Each file in the bill-of-materials is scanned, so that its hashes
(SHA256 and SHA1) can be recorded, along with any detected licenses
if an `SPDX-License-Identifier` appears in the file.

SPDX Relationships are created to indicate dependencies between
CMake build targets; build targets that are linked together; and
source files that are compiled to generate the built library files.

`west spdx` can be called with optional parameters for further
configuration:

* `-n PREFIX`: specifies a prefix for the Document Namespaces that
will be included in the generated SPDX documents. See SPDX spec 2.2
section 2.5 at
https://spdx.github.io/spdx-spec/2-document-creation-information/.
If -n is omitted, a default namespace will be generated according
to the default format described in section 2.5 using a random UUID.

* `-s SPDX_DIR`: specifies an alternate directory where the SPDX
documents should be written. If not specified, they will be saved
in `BUILD_DIR/spdx/`.

* `--analyze-includes`: in addition to recording the compiled
source code files (e.g. `.c`, `.S`) in the bills-of-materials, if
this flag is specified, `west spdx` will attempt to determine the
specific header files that are included for each `.c` file. This
will take longer, as it performs a dry run using the C compiler
for each `.c` file (using the same arguments that were passed to it
for the actual build).

* `--include-sdk`: if `--analyze-includes` is used, then adding
`--include-sdk` will create a fourth SPDX document, `sdk.spdx`,
which will list any header files included from the SDK.

Signed-off-by: Steve Winslow <steve@swinslow.net>
2021-05-05 11:14:06 -04:00
Gerard Marull-Paretas
aa0b02bf75 doc: use pygments devicetree language support
Since Pygments 2.7.0 devicetree syntax is supported, so there is no need
to use a custom lexer. Version 2.9.0 introduces a fix that is required
for some devicetree snippets.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-04 22:42:15 -04:00
YouhuaX Zhu
965c8b9888 sanitycheck: Add a feature which can handle pytest script.
1. Add a class of Pytest(Harness) which can handle pytest script
in harness.py
2. Use running_dir to store current test directory which be
used in pytest scrpt.
3. Add usage of this feature into zephyr doc.

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2021-05-04 19:08:18 -04:00
Kumar Gala
010cf3986a scripts: Remove sanitycheck wrapper
We planned on removing this wrapper post 2.5.  People should be using
twister by now.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-05-04 13:37:06 -04:00
Mahesh Mahadevan
3035b3ac5d scripts: Set align size for code relocated
Code relocated to SRAM need MPU setup.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2021-05-04 15:46:52 +02:00
Martí Bolívar
376e9cfdff requirements-base.txt: fix pylink package name
This should be pylink-square.

Reported-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 16:24:09 -05:00
Anas Nashif
bc4b4c5988 actions: cocci: remove boolean.cocci as it take too long
This script is taking too long on large files and is delaying the
action. Remove it for now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-03 17:11:12 -04:00
Anas Nashif
8ebc67ee0d action: timeout on scripts taking too long
Some scripts might take very long to execute, kill those after 10s and
let the action continue.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-03 17:11:12 -04:00
Martí Bolívar
55e8807b08 runners: jlink: support thread_info_enabled
Automatically enable per-thread info in GDB if the binary and J-Link
support it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
61996a35ac runners: jlink: extend 'nogui' support
Support this when debugging also.

Tweak the style for brevity also while we're here by propertizing the
supports_nogui method, etc.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
b733ddb48d runners: core: add thread_info_enabled property
This makes it easier for runners to check if the binary has thread
info support turned on, allowing automatic configuration of the
underlying tool to support threads, if possible.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
250b2133ee scripts: re-work BuildConfiguration boolean handling
Set options that are definitely true or false to True or False in the
options dict. Add a 'getboolean' method that also allows a fallback to
False in case the option is not mentioned in .config due to unmet
dependencies. This allows calling code to just ask about the option
they are interested in, even if the .config file doesn't mention the
option at all.

Propagate this to users within the runners package and 'west sign',
taking advantage of the new build_conf property.

Rename the 'bcfg' internal variable in sign.py to 'build_conf' to
match other source files that use BuildConfiguration instances, to
make it easier to grep for users.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
778a18cb1a runners: tests: don't patch BuildConfiguration
Instead of mocking out the BuildConfiguration class, just create its
input file and let the real class do the work.

This in turn exposes a bug in the way the board name is being pulled
out of the BuildConfiguration, which we fix to keep the tests passing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
f31a8f67a9 runners: jlink: silence commander output by default
This is really verbose, and I doubt anyone cares unless there is a
problem. Keep it around when run as 'west -v flash' to allow for
debugging, though.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
6357770eef runners: jlink: rework --dt-flash handling
Defer loading .config until we really need it, when we are flashing a
binary. Pre-emptively loading it is wasted effort if we're flashing a
.hex, which has been the default behavior when possible since
dcaabb860f ("west: runners: jlink: prefer .hex over .bin").

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
7640c39505 runners: jlink: clean up commander script logging
Put it all in one log message rather than splitting it up.

This makes it look cleaner now that each log message is prefixed with
'runners.link:'.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
2d43f660d9 runners: jlink: fix --commander help
The default commander path is platform specific.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
069c18d3ad runners: jlink: replace version parsing code
JLink versions like 'V7.0a' do not conform to PEP 440 version
conventions; the 'a' part is used by PEP 440 compliant versions for
alphas. It gets parsed to a legacy type by the packaging library,
which always is treated as a lower value when compared with a
conforming version string.

To fix, get the version from the shared library distributed with the
JLink tools. This has the side benefit of making the code work on
Windows. That's merely a nice to have for -nogui 1 detection for now,
but will be essential in the next commit.

Reported-by: Jake Mercer <jake.mercer@civica.co.uk>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
2fb7e9dc63 requirements-base.txt: add pylink
This will be used to deal with the Segger shared library in a portable
way in the jlink runner.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
aded635dfa runners: core: add build_conf property
Make it easier to get a BuildConfiguration from runner code.
Stash the result so it only has to be computed once.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
e1e1bdc20f runners: core: add **kwargs to other subprocess wrappers
Just to make these match check_output().

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
bbb17df9a2 runners: core: refactor helper for getting flash address
Separate the logic that gets the right address from .config
into its own helper.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
c2c8e8824e runners: core: try to improve --dt-flash option help
This option has existed since the beginning of the runners package,
which greatly predates the way DT is used in zephyr right now. It
never really worked the way I wanted it to but it's too much work to
fix it now. Try to improve the help a bit at least while I'm looking
at it again.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
47007338af runners: core: return shutil.which() value from require()
Make it easy to get the full path to a required binary.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar
09f55767b1 runners: tests: fix os.path.isfile patch
Copy a fix from test_nrfjprog.py to the other runner test suites. The
current code will enter an infinite recursion if you hit the path
where os.path.isfile is called, since it's been patched to
os_path_isfile_patch in the calling context. The fix is to cache the
'real' version in the parent scope and call it directly as a fallback.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Anas Nashif
b669f0c017 ci: fix regex in guideline_check.py
Also match _ in file names.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-03 08:08:25 -05:00
Anas Nashif
184b786fe2 coccinelle: check reserved symbols based on a file
Use a file with reserved symbols instead of checking against a fixed
list of strings.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-30 22:09:43 -04:00
Jordan Yates
371a83b9d9 scripts: gen_handles.py: initialize handle.device
Initialize `handle.device` to `None` so that the assert after the
matching has a chance to catch errors. Without this, a failed match will
raise an exception on the line above as it attempts to get a property
that doesn't exist.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-30 15:16:02 +02:00
Daniel Leung
a5ab1a7518 logging: add support for dictionary based logging
This adds dictionary based logging support. Dictionary based
logging is binary based where one big difference is that
static strings are stored as pointers instead of the whole
string. This results in reduced space requirements for
storing log messages in certain scenairos.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-28 22:25:42 +02:00
Gerard Marull-Paretas
dfcc5fd7cc doc: make Sphinx version specifier more flexible
Allow all compatible versions starting from 3.3, that is >=3.3.0,<4.0.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-27 21:38:39 -04:00
Gerard Marull-Paretas
57dc1eb9c4 doc: make breathe version specifier more flexible
Breathe project has released version 4.29.1, a fix release for the
issues found in 4.29.0. Relax version requirements by just skipping the
buggy version and staying to compatible releases.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-27 21:38:39 -04:00
Hou Zhiqiang
0700a24276 devicetree: Add DT_FOREACH_CHILD_STATUS_OKAY macro
The macro only iterates the enabled child nodes and invokes
provided macro for each node.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
2021-04-27 13:32:55 -04:00
Daniel Leung
1117169980 kernel: generate placeholders for kobj tables before final build
Due to the use of gperf to generate hash table for kobjects,
the addresses of these kobjects cannot change during the last
few phases of linking (especially between zephyr_prebuilt.elf
and zephyr.elf). Because of this, the gperf generated data
needs to be placed at the end of memory to avoid pushing symbols
around in memory. This prevents moving these generated blocks
to earlier sections, for example, pinned data section needed
for demand paging. So create placeholders for use in
intermediate linking to reserve space for these generated blocks.
Due to uncertainty on the size of these blocks, more space is
being reserved which could result in wasted space. Though, this
retains the use of hash table for faster lookup.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-27 13:32:00 -04:00
Daniel Leung
317dcd908f scripts: gen_kobject_list: no need to specify linker section
There is no need to specify linker section for variables in
the output. The compiled object file from the produced
source file will be further processed to have them renamed
anyway.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-27 13:32:00 -04:00
Daniel Leung
c3711b3446 kernel: change metadata for priv_stacks to const
The metadata array for priv_stacks doesn't change and
can be marked const so this can put in ROM.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-27 13:32:00 -04:00
Jingru Wang
a3469a0497 script: add ram and rom total size to json file
It's easier and safer to parse json file rather than extract
total size from stdout

Now the .json file has two keys:
{
    "symbols": {
       "children": [
           ...
	],
       "identifier": ":",
       "name": "root",
       "size": 2220
    },
    "total_size": 34272
}

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-04-26 14:23:13 -04:00
Anas Nashif
e366d7948a ci: remove bsim from buildkit execution
We now have a dedicated action for this.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-23 21:40:10 -04:00