Commit graph

3563 commits

Author SHA1 Message Date
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