Commit graph

2587 commits

Author SHA1 Message Date
Anas Nashif f16ed8e0b8 sanitycheck: move global info() into Testsuite class
This function is not used anywhere else now that we use logging module,
so push this into the class where it is being used.

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

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

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

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

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

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

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

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

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

sanitycheck --generate-hardware-map

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

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

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

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

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

the module.yaml file now accepts the following:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

See the documentation changes for details.

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

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

For more details, refer to the issue #19860.

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

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

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

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

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

Before:

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

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

After:

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

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

Piggyback some minor comment-related simplifications.

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

Relates to #17626.

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

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

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

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

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

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

make/ninja hardenconfig

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

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

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

Maybe the error could be selectively re-enabled later.

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

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

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

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

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

Fixes #21162

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

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

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

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

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

Fixes: #21139

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

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

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

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

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

sanitycheck --list-test-duplicates

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

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

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

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

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

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

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

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

Partially addresses #2664

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

Fixes #20804

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

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

Import edtlib and use that instead.

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

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

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

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

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

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

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

For more details, refer to the PR #20573.

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

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

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

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

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

Fixes: #20571

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

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

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

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

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

Also fixes #20449.

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

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

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

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

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

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

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

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

    Have Symbol/Choice.name_and_loc return strings like

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

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

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

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

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

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

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

Checks so far:

 - Symbols that can never be anything but n/empty

 - Symbols that look unused

 - menuconfig symbols with empty menus

 - Symbols only defined in Kconfig.defconfig files

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

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

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

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

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

into

    node.required_by
    node.depends_on

which might be a bit more readable.

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

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

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

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

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

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

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

This commit introduces the following major changes:

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

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

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

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

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

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

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

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

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

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

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

3. Refactor kernel and the existing architecture implementations.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes: #20371

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

  DT_ST_STM32_I2S_40015000_RX_DMAS_CONTROLLER_1

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

  DT_ST_STM32_I2S_40015000_RX_DMAS_CONTROLLER
  DT_ST_STM32_I2S_40015000_DMAS_CONTROLLER_1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes this pylint warning:

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

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

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

Could also make it a class method.

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

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

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

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

Fixes: #14683

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

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

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

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

Before:

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

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

    Some extra lines
    for testing  */
    #define DT_INST_0_RISCV_CPU_INTC                    1

After:

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

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

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

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

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

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

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

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

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

    delays = <30000 20 45000>;

and the driver can use:

    static u32_t delays[] = DT_INST_0_COMPAT_DELAYS;

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

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

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

with:
  dt_chosen_reg_addr_int
  dt_chosen_reg_size_int
  dt_chosen_reg_addr_hex
  dt_chosen_reg_size_hex
  dt_node_reg_addr_int
  dt_node_reg_size_int
  dt_node_reg_addr_hex
  dt_node_reg_size_hex

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

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

This fixes the following problem:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes: #19536

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

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

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

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

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

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

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

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

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

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

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

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

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

And many other cleanups and improvements...

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

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

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

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

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

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

Add missed k_mbox_data_block_get.

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

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

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

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

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

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

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

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

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

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

Example output for header:

Before:

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

After:

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

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

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

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

This change allows us to address a device directly:

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

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

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

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

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

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

    interrupt-cells:
        - irq
        - priority
        - flags

    gpio-cells:
        - pin
        - flags

    pwm-cells:
        - channel
        - period

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

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

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

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

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

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

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

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

    Fix handling of parentheses in macro argument values

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #19098

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

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

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

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

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

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

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

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

Piggyback some documentation clarifications.

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

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

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

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

Fixes: #17337.

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

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

Change noweak to a basic list.

Reproducibility regression introduced by commit 6564974bae

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

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

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

This lets nodes give bindings to grandchildren.

For example, take this devicetree fragment:

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

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

    compatible: "foo"

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

        ...

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

            properties:
                ...

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

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

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

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

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

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

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

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

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

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

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

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

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

    child:
        bus: foo

    parent:
        bus: bar

, have

    child-bus: foo

    parent-bus: bar

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 - Use a raw string to fix this warning:

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

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

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

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

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

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

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

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

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

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

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

    DT_GPIO_KEYS_BUTTON_1_GPIOS={"GPIO_0", 14, 256}

so keep them from being added there.

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

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

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

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

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

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

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

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

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

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

    include: [bar.yaml, foo.yaml]

(with that particular order due to implementation details).

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

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

Piggyback two fixes/cleanups:

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

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

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

Discovered via this pylint warning:

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

Improve naming a bit to fix it.

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

Fixes this pylint warning:

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

Fixing pylint warnings for a CI check.

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

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

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

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

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

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

Suggested by Peter A. Bigot.

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

The encoding scheme is documented here:

doc/reference/kernel/other/interrupts.rst

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

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

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

    Allow preprocessor user functions to access the parsing location

    Just requires making Kconfig.filename/linenr public.

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

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

Some minor optimizations are included too.

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

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

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

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

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

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

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

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

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

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

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

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

Getting rid of pylint warnings for a CI check.

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

Fixes this pylint warning:

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

Fixing warnings for a CI check.

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

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

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

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

    properties:
        compatible:
            constraint: "foo"

, just have

    compatible: "foo"

at the top level of the binding.

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

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

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

Better to keep it simple.

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

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

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

Fixes this pylint warning:

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

Fixing pylint warnings for a CI check.

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

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

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

Fixing pylint warnings for a CI check.

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

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

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

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

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

Also add some more comments to clarify _init_tokens().

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

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

Fixes this pylint warning:

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

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

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

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 88c5079a87 scripts: dts: Fix misc. pylint warnings in old scripts
Fix pylint warnings for bad indent, redundant len()s in conditionals,
tests that could be improved with 'in', methods that don't use 'self',
and type()s where isinstance() is more common.

Preparation for adding a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson d834b69bd9 scripts: dts: Improve syntax and code for including binding files
Have

    include: foo.dts
    include: [foo.dts, bar.dts]

instead of

    inherits:
        !include foo.dts

    inherits:
        !include [foo.dts, bar.dts]

This is a nicer and shorter and less cryptic syntax, and will make it
possible to get rid of the custom PyYAML constructor for '!include'
later.

'inherits: !include ...' is still supported for backwards compatibility
for now. Later on, I'm planning to mass-replace it, add a deprecation
warning if it's used, and document 'include:'. Then the '!include'
implementation can be removed a bit later.

'!include' has caused issues in the past (see the comment above the
add_constructor() call), gets iffy with multiple EDT instances, and
makes the code harder to follow.

I'm guessing '!include' might've been intended to be useful outside of
'inherits:' originally, but that's the only place where it's used. It's
undocumented that it's possible to put it elsewhere.

To implement the backwards compatibility, the code just transforms

    inherits:
        !include foo.dts

into

    inherits:
        - foo.dts

and treats 'inherits:' similarly to 'include:'. Previously, !include
inserted the contents of the included file instead.

Some more sanity checks for 'include:'/'inherits:' are included as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson fcd665a26c dts: bindings: Have 'required: true/false' instead of 'category: ...'
The 'category: required/optional' setting for properties is just a
yes/no thing. Using a boolean makes it clearer, so have
'required: true/false' instead.

Print a clear error when 'category:' is used:

    edtlib.EDTError: please put 'required: true' instead of 'category:
    required' in 'properties: foo: ...' in
    test-bindings/sub-node-parent.yaml - 'category' has been removed

The old scripts in scripts/dts/ ignore this setting, and only print a
warning if 'category: required' in an inherited binding is changed to
'category: optional'. Remove that code, since the new scripts already
have the same check.

The replacement was done with

    git ls-files 'dts/bindings/*.yaml' | xargs sed -i \
        -e 's/category:\s*required/required: true/' \
        -e 's/category:\s*optional/required: false/'

dts/binding-template.yaml is updated as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 929837a35f scripts: dtlib: Add test for untested /memreserve/ error
Also simplify the /memreserve/ code a biny bit and convert spaces to
tabs in a testcase.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 247ae982ed dts: gen_defines: Remove lots of code duplication for phandle/val lists
Add a write_phandle_val_list() function for handling GPIOs, PWMs, and IO
channels. The logic is the same in all cases.

This also indirectly makes pwm-names and io-channel-names work the same
as gpio-names. Previously, they were ignored.

Also add a long explanation with example output.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 14138c3b9b dts: edtlib: Improve how we get the compatible string from bindings
Use Galak's idea from
https://github.com/zephyrproject-rtos/zephyr/pull/18313 to read the
'properties: compatible: constraint: "foo"' string from bindings in a
more robust way.

First, check if any of the compatible strings are in the file (needed as
an optimization). If any of them are, do a more careful check for the
'properties: compatible: constraint: ...' value matching a compatible,
to filter out false positives from comments and the like.

This commit a no-op in itself besides making things a bit more robust,
but it'll make later work easier (supporting multiple compatibles for a
binding, in a dt-schema-like way).

Co-authored-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 1480ad9ce7 dts: edtlib: Sanity-check the final merged binding only
Sanity-checking each !included file separately was inherited from the
old scripts. It makes it messy to check that combinations of fields make
sense, e.g. to check 'const:' or 'default:' against 'type:', since those
fields might come from different files (this is handy, since it makes
sense to just add/change a 'const:' value, for example).

Drop the requirement that each !included file is a complete binding in
itself, and treat them as binding fragments instead. Only check the
final merged binding.

This also means that !included files no longer need to have a
'description:' or 'title:' (those have always been unused for !included
files), so remove those, and add comments that explain what the
fragments are for instead. That should demystify bindings a bit.

Also fix the descriptions of i2c.yaml, i2s.yaml, spi.yaml, and
uart.yaml. They're for controllers, not devices. These are copy-paste
error from the corresponding device .yaml files.

Piggyback some indentation consistency nits in binding-template.yaml.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 73df9dea34 dts: dtlib: Add an _err() helper for error reporting
Similar to edtlib._err(). Just saves a bunch of 'raise DTError'.

Also add tests for some errors from the global to_num() and to_nums()
functions that were untested.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 2282777ad1 dts: dtlib: Refactor to get rid of _is_parsing flag
The public DT.get_node() function was used during parsing to look up
paths in references like &{/foo/bar}, along with an ugly
'DT._is_parsing' flag to adapt its behavior (to not mention aliases in
error messages).

Split out common node lookup code needed during parsing and by
get_node() instead, and stop using get_node() during parsing. This
allows '_is_parsing' to be removed and untangles things a bit.

Piggyback some other small reference-related cleanups, and fix an issue
with the filename/linenr being given twice in some error messages.

This commit also removes the index of path components from error
messages, but just the string is probably good enough.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson a9e8f1a96c dts: dtlib: Remove unused Property._err_with_context() function
Leftover.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 378254ad13 dts: edtlib: Sanity-check 'ranges' assignment syntax
Require either type TYPE_EMPTY ('ranges;') or TYPE_NUMS
('ranges = < 1 2 ... >;').

Putting the check in _check_dt() means it will run for all nodes,
including nodes without bindings, which is handy.

The _split() function already gives a decent error message if 'ranges'
has unexpected length, so skip checking the length.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 165dde0df4 dts: edtlib: Add a Property.type field
Deriving the type from looking at Property.val gets awkward e.g. when
there are many types that make Property.val a list. Instead, save the
type as given in the binding in Property.type.

Let Property.type just be a string. This has typo potential, but is nice
and flexible (and easy to print), and errors will probably be pretty
obvious.

Show the type in Property.__repr__() as well. This automatically gives
some test coverage.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson c42873fbe7 dts: dtlib/edtlib: Add phandle and phandle+nums array types
Add two new type-checked property types 'phandles' and 'phandle-array'
to edtlib.

'phandles' is for pure lists of phandles, with no other data, like

    foo = < &bar &baz ... >

'phandle-array' is for lists of phandles and (possibly) numbers, like

    foo = < &bar 1 2 &baz 3 4 ... >

dt-schema also has the 'phandle-array' type.

Property.val (in edtlib) is set to an array of Device objects for the
'phandles' type.

For the 'phandle-array' type, no Property object is created. This type
is only used for type checking.

Also refactor how types that do not create a Property object
('phandle-array' and 'compound') are handled. Have _prop_val() return
None for them.

The new types are implemented with two new TYPE_PHANDLES and
TYPE_PHANDLES_AND_NUMS types at the dtlib level. There is also a new
Property.to_nodes() functions for fetching the Nodes for an array of
phandles, with type checking.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson 11019549bf dts: dtlib: Ignore manually specified phandles in type checking
Previously, Property.to_node() would allow assignments like

    x = < 1 >;

as long as 1 happened to be a valid phandle. This was deliberate, but
might hide errors, and would make the planned 'phandles' (list of
phandles) and 'phandle-array' (list of phandles and numbers) types a bit
too similar to 'type: array'.

Change Property.to_node() to only accept

    x = < &foo >;

This is probably all we need, and if you really need to accept manually
specified phandles, it can be worked around in other ways.

Piggyback some consistency nits in error messages from the
Property.to_*() functions.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Ulf Magnusson e703b4954a dts: edtlib: Sanity-check contents of 'sub-node:'
The contents of 'sub-node:' was assigned as-is as the binding, bypassing
_check_binding(). This also hid an error in
test-bindings/sub-node-parent.yaml.

Require 'sub-node:' to just have 'properties:' in it, and sanity-check
the properties like for regular bindings.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Kumar Gala f80332543e scripts/dts/gen_defines.py: Ignore varions base properties
We don't want any defines generated for 'status', 'interrupt-parent',
and 'interrupts-extended' properties.  So skip them in write_props if
we see them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-07 10:25:02 -05:00
Kumar Gala 3d14374c5e scripts/dts/edtlib.py: add 'const' support to bindings
Add a 'const' property to bindings for any properties that are expected
to have a specifi known value.  For example, #address-cells for an I2C
bus should always be '1'.  So we can do something like the following in
the I2C bus binding:

    "#address-cells":
      type: int
      category: required
      const: 1

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Kumar Gala cd72ce122b scripts/dts/edtlib.py: error check enum
Make sure 'enum' is a list in the binding.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-07 10:25:02 -05:00
Kumar Gala 62bf267bb2 scripts/dts/edtlib.py: Hoist enum checking before early out
Move the enum checking before we early out for '#' and '-map' properties
so they can benefit from it.  Also make the error messages for failed
'enum' check more informative by including the paths to the .dts file
and the binding for the node.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 10:25:02 -05:00
Carles Cufi 4a504446d7 west: flash: Fix exception on build folder guessing
When guessing the build folder, the current path might not exist at all,
leading to an uncaught exception when trying to list its folders. Fix
this by making sure the path exists at all first.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-09-07 10:24:17 -04:00
Marti Bolivar 146580e555 scripts: west_commands: verify minimum cmake version
A recent developer experience study has pointed out that it's very
common for people to miss that the minimum cmake version required by
zephyr is higher than that which is commonly packaged by Linux
distributions.

Since this is a serious usability issue, it's worth adding extra
checking from zcmake.py to make sure that west commands which run
cmake always print a sensible error message if the cmake version used
is too old. Make that happen.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-09-07 10:08:23 -04:00
Charles E. Youse 6767563f94 arch/x86: remove support for IAMCU ABI
This ABI is no longer required by any targets and is deprecated.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-07 10:07:42 -04:00
Anas Nashif 4132ee3a05 ci: do not export BSIM env vars if bsim is not available
When running run_ci.sh locally with:

 ./scripts/ci/run_ci.sh -l -b master -R upstream/master..

we export BSIM_OUT_PATH unconditionally which causes sanitycheck to fail
on nrf52_bsim (it depends on BSIM_OUT_PATH variable).

Check if the path defined in BSIM_OUT_PATH is available and unset env.
variable if it is not.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-07 09:04:40 -04:00
Ulf Magnusson ea4d1d6ff0 sanitycheck: harness.py: Fix bad indentation
Getting rid of pylint warnings for a CI check. No functional change.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:14:29 -04:00
Ulf Magnusson d4c851ca57 scripts: gen_kobject_list.py: Remove redundant parentheses
No need to put () around 'if' conditions in Python.

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:12:44 -04:00
Ulf Magnusson 16041cda0c west: zcmake.py: Simplify test with 'in'
Getting slightly subjective, but fixes this pylint warning:

    scripts/west_commands/zcmake.py:186:13: R1714: Consider merging
    these comparisons with "in" to "type_ in ('STRING', 'INTERNAL')"
    (consider-using-in)

Use a set literal instead of a tuple literal, as recent Python 3
versions optimize set literals with constant keys nicely.

Getting rid of pylint warnings for a CI check. I could disable any
controversial ones (it's already a list of warnings to enable anyway).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:12:09 -04:00
Ulf Magnusson f5d8ece3b7 west: nrfjprog.py: Remove len() from conditional to fix pylint warning
Empty sequences are falsy in Python, so len() can be skipped.

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:11:44 -04:00
Ulf Magnusson 5d307c98fe west: build.py: Remove len() from conditional to fix pylint warning
Non-empty sequences are truthy in Python, so len() can be skipped.

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:11:02 -04:00
Ulf Magnusson 1f0a8e5a3f west: completion.py: Fix bad indentation and blank lines at end of file
Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:09:56 -04:00
Ulf Magnusson 22274696a9 west: boards: Remove accidental comma to fix pylint warning
Remove a trailing comma that generated a single-element tuple and made
pylint warn:

    scripts/west_commands/boards.py:50:8: W0106: Expression
    "(parser.add_argument(...), )" is assigned to nothing
    (expression-not-assigned)

No functional change.

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:08:48 -04:00
Ulf Magnusson 3206e42935 scripts: gen_kobject_list.py: Simplify test with chained comparison
'a < b and b < c' can be simplified to 'a < b < c' in Python.

Fixes this pylint warning:

    scripts/gen_kobject_list.py:198:22: R1716: Simplify chained
    comparison between the operands (chained-comparison)

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:07:36 -04:00
Ulf Magnusson d2d5fae838 west: runners: core.py: Remove no-op try-excepts
Removing these doesn't change behavior, since the
subprocess.CalledProcessError is just immediately re-raised when caught.

Fixes this pylint warning:

    W0706: The except handler raises immediately (try-except-raise)

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:06:51 -04:00
Ulf Magnusson 4094ee686e west: runners: Remove unnecessary constructors
These just pass their arguments through to the base class constructor.
Removing them means the base class constructor gets called directly
instead.

Fixes this pylint warning:

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

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:06:51 -04:00
Ulf Magnusson bf128d09b3 west: runners: Fix typo'd log.wrn() call
Should be wrn() instead of warn(). Reported by pylint.

Also remove a {} from the message. It's not being formatted.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:05:57 -04:00
Ulf Magnusson 11d98ae9de scripts: gen_relocate_app.py: Simplify test with 'in'
Getting slightly subjective, but fixes this pylint warning:

    scripts/gen_relocate_app.py:228:38: R1714: Consider merging these
    comparisons with "in" to "region in ('data', 'bss')"
    (consider-using-in)

Use a set literal instead of a tuple literal, as recent Python 3
versions optimize set literals with constant keys nicely.

Getting rid of pylint warnings for a CI check. I could disable any
controversial ones (it's already a list of warnings to enable anyway).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:05:22 -04:00
Ulf Magnusson bb634167ae west: commands: Make functions that don't use 'self' static
Fixes this pylint warning:

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

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

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:04:58 -04:00
Ulf Magnusson 4cac371d43 scripts: Suppress/fix undefined variable pylint warnings
dtlib.py and guiconfig.py do some hackery to build token and image
variable names, which triggers spurious pylint warnings like

    scripts/dts/dtlib.py:243:28: E0602: Undefined variable '_T_LABEL'
    (undefined-variable)

Suppress the warning for those files. The generated names get used in
lots of places.

Also suppress some warnings in doc/conf.py ('tags' is from Sphinx), and
fix a legitimate issue in scripts/dts/testdtlib.py.

This pylint check is useful enough to want enabled in the upcoming CI
check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:03:04 -04:00
Ulf Magnusson 3feb8f96f6 scripts: gen_kobject_list.py: Simplify test with 'in'
Getting slightly subjective, but fixes this pylint warning:

    scripts/gen_kobject_list.py:308:11: R1714: Consider merging these
    comparisons with "in" to "kobj in ('device',
    '_k_thread_stack_element')" (consider-using-in)

Use a set literal instead of a tuple literal, as recent Python 3
versions optimize set literals with constant keys nicely.

Getting rid of pylint warnings for a CI check. I could disable any
controversial ones (it's already a list of warnings to enable anyway).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:01:31 -04:00
Ulf Magnusson 89efaeda74 west: build.py: Rename unused variable from unpacking to _
This is a common Python idiom, and it's easy to look up what the unused
value is in this case if you need to. Fixes this pylint warning:

    scripts/west_commands/build.py:227:15: W0612: Unused variable
    'origin' (unused-variable)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:00:57 -04:00
Ulf Magnusson 883b53101c menuconfig: Suppress spurious pylint tuple unpacking warning
pylint might be afraid that there'd be less than three elements in
'args', but there never is. Fixes this warning:

    scripts/kconfig/menuconfig.py:3184:8: W0632: Possible unbalanced
    tuple unpacking with sequence: left side has 3 label(s), right side
    has 0 value(s) (unbalanced-tuple-unpacking)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 08:00:30 -04:00
Ulf Magnusson 47ef9ba6c2 scripts: sanitycheck: Remove redundant ifs
Fixes these pylint warnings:

    scripts/sanity_chk/ini2yaml.py:25:22: R1719: The if expression can
    be replaced with 'test' (simplifiable-if-expression)

    scripts/sanity_chk/expr_parser.py:208:15: R1719: The if expression
    can be replaced with 'bool(test)' (simplifiable-if-expression)

    scripts/sanity_chk/expr_parser.py:210:15: R1719: The if expression
    can be replaced with 'bool(test)' (simplifiable-if-expression)

Also replace a redundant re.compile().match() with re.match(). compile()
doesn't help when re-compiling the regular expression each time through.

(compile() often doesn't help much in general, because the 're' module
caches compiled regexes.)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 07:59:53 -04:00
Ulf Magnusson 16b548fcc7 gen_gcov_files.py: Replace bare 'except' with 'except Exception'
A bare 'except:' can do some annoying stuff like eat Ctrl-C (because it
catches KeyboardInterrupt). Better to use 'except Exception:' as a
catch-all.

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

Fixes this pylint warning:

    scripts/gen_gcov_files.py:54:12: W0702: No exception type(s)
    specified (bare-except)

Piggyback a formatting nit.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 07:58:16 -04:00
Ulf Magnusson 4699375162 west: run_common.py: Remove redundant 'if'
Fixes this pylint warning:

    scripts/west_commands/run_common.py:175:12: R1719: The if expression
    can be replaced with 'test' (simplifiable-if-expression)

Fixing pylint warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 07:57:46 -04:00
Ulf Magnusson 0d39a10fbb scripts: Fix random typo'd whitespace
Reported by pylint's 'bad-whitespace' warning.

Not gonna enable this warning in the CI check, because it flags stuff
like deliberately aligning assignments and gets too cultish. Just a
cleanup pass.

For whatever reason, the common convention in Python is to skip spaces
around '=' when passing keyword arguments and giving default arguments:

    f(x=3, y=4)
    def f(x, y=8):
        ...

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-07 07:54:17 -04:00
David B. Kinder 02ee3754c6 west: update requirements.txt to avoid west 0.6.1
Update scripts/requirements.txt to use 0.6.2 or later (avoiding 0.6.1
that has an known issue)

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-09-06 19:12:33 +02:00
Anas Nashif 053ab4ac41 release: update sanitycheck release file
Update release file used by sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-06 13:31:04 +02:00
Wentong Wu ed6ce291ba scripts: elf_helper.py: fix stack declared K_THREAD_STACK_EXTERN
If a stack is declared with K_THREAD_STACK_EXTERN first, analyze array
in elf_helper.py will ignore this declaration which will be referenced
by the actual instances via the tag DW_AT_specification, so that this
stack can't be detected by the kernel object detection mechanism, and
this will cause userspace not work.

Fixes: #16760.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-29 08:18:54 -04:00
Wentong Wu 9ca0d5e18b scripts: elf_helper.py: add analyze for DW_TAG_typedef
add analyze for DW_TAG_typedef in order to catch all the
kernel objects.

Fixes: #16760.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-08-29 08:18:54 -04:00
David B. Kinder 2c93d1f1f2 doc: add sphinx-tabs extension
The sphinx-tabs extension provides a tabbed interface within documents
that will let us dynamically display information based on a user
selection, for example, for instruction variations based on the user's
development OS (Linux, macOS, Windows).

I'm adding this early so it can get integrated into the CI doc build
before subsequent PRs using this extension are submitted.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-08-23 19:38:44 -04:00
Anas Nashif 35d4177a0b requirements: add west>-0.6.0
west is yet another python package, so lets add it here. This will
provide us with one single file with all python requirements that can be
used during setup and for example for docker images.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-08-23 13:50:16 -04:00
Anas Nashif dd3776cfa5 requirements: sort alphabetically
Sort packages alphabetically.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-08-23 13:50:16 -04:00
Kumar Gala a0a576d384 scripts/dts/gen_defines.py: Fix generation for multiple IO Channels
If there is more than one IO Channel than generate a define with a
trailing index for the IO Channel.  This matches what we do for GPIOs
and PWMs.

So something like:
  DT_FOOBAR_IO_CHANNELS_CONTROLLER_0
  DT_FOOBAR_IO_CHANNELS_CONTROLLER_1
  ...
  DT_FOOBAR_IO_CHANNELS_CONTROLLER_<N>

Fixes #18352

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-19 14:48:44 -05:00
Håkon Øye Amundsen 208c4ecacb scripts: kconfig: normalize paths to avoid duplicate
There is a bug where non-normalized paths can introduce multiple entries
for the same file. E.g. '/1/2/../2.file' and '/1/2/3/../../2.file' would
both be listed, and end in a ninja error because multiple targets
generate the same file.

This commit fixes this issue by normalizing the paths.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-08-19 16:26:31 +02:00
Marti Bolivar f7a4275328 scripts: west flash: fix --board-id for pyocd
Newer pyocd versions (specifically the 0.21.0 we have in our
requirements.txt) no longer support -b and have moved the same option
to -u. Keep up.

Fixes: #17554
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-19 11:03:03 +02:00
Marti Bolivar 08e0d1ff46 scripts: runners: improve hex file detection and output
This is a band-aid to make it more obvious to potential users of 'west
sign' and 'west flash' which hex file they are flashing, when they are
falling back on a binary file, and erroring out when a hex file does
not exist.

Fixes: #18201
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-16 18:42:41 +02:00
Kumar Gala c484935fe5 scripts: openocd: Add error if hex file is missing when flashing
Add a check to make sure the hex file exists as that is what we utilize
in openocd to flash.  If its missing we report that its likely due to
not having CONFIG_BUILD_OUTPUT_HEX set.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-14 07:55:10 -05:00
Ulf Magnusson c2d702b961 dts: dtlib: Fix parsing of character literals
This was allowed due to a misunderstanding:

    foo = 'x';

In reality, 'x' works like an integer literal, and is used like this:

    foo = < 'x' >;

Fix character literal parsing to match the C tools.

Also fix backslash escape parsing to match the C tools exactly
(get_escape_char() in util.c): \<char> should be turned into <char> if
<char> isn't recognized as a special escape character, instead of being
left alone. This fixes parsing of e.g. '\'' (a character literal with a
single quote in it).

Piggyback some more tests for weird property/node names.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-13 07:41:45 -05:00
Ulf Magnusson 7168118290 dts: edtlib: Fix outdated doc comment for _init_devices()
No longer takes the DT instance as a parameter.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-13 07:41:45 -05:00
Ulf Magnusson 06b746cc58 dts: dtlib/edtlib: Add a syntax-based type-checking system
Property type-checking has been pretty rudimentary until now, only
checking things like the length being divisible by 4 for 'type: array',
and strings being null-terminated. In particular, no checking was done
for 'type: uint8-array', letting

  jedec-id = < 0xc8 0x28 0x17 >;

slip through when

  jedec-id = [ 0xc8 0x28 0x17 ];

was intended.

Fix it by adding a syntax-based type checker:

  1. Add Property.type, which gives a high-level type for the property,
     derived from the markers added in the previous commit.

     This includes types like TYPE_EMPTY ('foo;'),
     TYPE_NUM ('foo = < 3 >;'), TYPE_BYTES ('foo = [ 01 02 ];'),
     TYPE_STRINGS ('foo = "bar", "baz"'),
     TYPE_PHANDLE ('foo = < &bar >;'), and TYPE_COMPOUND (everything not
     recognized).

     See the Property.type docstring in dtlib for more info.

  2. Use the high-level type in
     Property.to_num()/to_string()/to_node()/etc. to verify that the
     property was assigned in an expected way for the type.

     If the assignment looks bad, give a helpful error:

       expected property 'nums' on /foo/bar in some.dts to be assigned
       with 'nums = < (number) (number) ... >', not 'nums = "oops";'

Some other related changes are included as well:

  - There's a new Property.to_bytes() function that works like accessing
    Property.bytes, except with an added check for the value being
    assigned like 'foo = [ ... ]'.

    This function solves problems like the jedec-id one.

  - There's a new Property.to_path() function for fetching the
    referenced node for assignments like 'foo = &node;', with type
    checking. (Strings are accepted too, as long as they give the path
    to an existing node.)

    This function is used for /chosen and /aliases.

  - A new 'type: phandle' type can now be given in bindings, for
    properties that are assigned like 'foo = < &node >;'.

  - Property.__str__() now displays phandles and path references as they
    were written (e.g. '< &foo >' instead of '< 0x1 >', if the
    allocated phandle happened to be 1).

  - Property.to_num() and Property.to_nums() no longer take a 'length'
    parameter, because it makes no sense with the type checking.

  - The global dtlib.to_string() and dtlib.to_strings() functions were
    removed, because they're not that useful.

  - More tests were added, along with misc. minor cleanup in various
    places.

  - Probably other stuff I forgot.

The more strict type checking in dtlib indirectly makes some parts of
edtlib more strict as well (wherever Property.to_*() is used).

Fixes: #18131

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-13 07:41:45 -05:00
Ulf Magnusson c9ac5e60e3 dts: dtlib: Remember the format of assignments
Previously, dtlib just stored the raw 'bytes' value for each property,
along with some markers in Property._markers for phandle and path
references.

Extend Property._markers to also remember where different data blocks
start, so that e.g.

    foo = <1 2 3>, "bar", [00 01];

can be reproduced as written.

Use the new information to reproduce properties as written in
Property.__str__(). This gives good test coverage as well, since the
test suite checks literal __str__() output.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-13 07:41:45 -05:00
Kumar Gala b2ba44c1d7 scripts/dts/gen_defines.py: Fix generation for multiple PWMs
If there is more than one PWM than generate a define with a trailing
index for the PWM.  This matches what we do for GPIOs.

So something like:
  DT_PWM_LEDS_RED_PWM_LED_PWMS_CONTROLLER_0
  DT_PWM_LEDS_RED_PWM_LED_PWMS_CONTROLLER_1
  ...
  DT_PWM_LEDS_RED_PWM_LED_PWMS_CONTROLLER_<N>

Fixes #18171

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-12 17:42:15 +02:00
Marcin Sloniewski b78bf8d6c1 requirements.txt: change package name "hub" to "git-spindle"
Package "hub" has been renamed some time ago to "git-spindle".
Recently package with the same name "hub" has been released on PyPi
page, which causes installing pip requirements.txt to fail since
it is trying to install different package.

Signed-off-by: Marcin Sloniewski <marcin.sloniewski@gmail.com>
2019-08-12 11:53:10 +02:00
Kumar Gala 480dcc1634 scripts/dts/gen_defines.py: Ignore 'gpio-controller' prop
We don't want any defines generated for the boolean
'gpio-controller'.  So skip it in write_props if we see it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-09 14:10:40 -05:00
Kumar Gala b0a6b3c0be scripts/dts/gen_defines.py: Ignore 'interrupt-controller' prop
We don't want any defines generated for the boolean
'interrupt-controller'.  So skip it in write_props if we see it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-09 14:10:40 -05:00
Jim Paris 998d7a01dd scripts/dts: add basic test for IO channel property
Test the new io-channel support

Signed-off-by: Jim Paris <jim@jtan.com>
2019-08-09 13:16:09 -05:00
Jim Paris 67f53ba18f scripts/dts: Support 'io-channels' property just like 'pwms'
This is a direct search-and-replace copy of the PWM code.
The name is chosen to match Linux's iio-bindings.txt.

Signed-off-by: Jim Paris <jim@jtan.com>
2019-08-09 13:16:09 -05:00
Kumar Gala 5dd715b9c1 scripts/dts/edtlib.py: error check # and -map properties
Move when we early out for properties that start with # like
"#address-cells" or end with -map like "interrupt-map" to after we do
some error checking.  This allows us to check those properties at least
exist if they are required.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-09 11:49:16 -05:00
Ulf Magnusson 75391c4f2c dts: edtlib: Shorten some license headers
One line instead of three.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-09 00:03:19 -05:00
Ulf Magnusson 4985c214ef dts: edtlib: Shorten _init_{interrupts,gpios}() a bit
Also makes them consistent with _simple_phandle_val_list().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-09 00:03:19 -05:00
Ulf Magnusson f7f0e0adf9 dts: edtlib: Simplify 'category: optional' code in Device._prop_val()
Reuse Device.enabled().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-09 00:03:19 -05:00
Ulf Magnusson c0c8dd1b85 dts: edtlib: Improve naming in _check_binding()
'keys' is really a dictionary of options (like {"type": "int", ...}) for
a property. Calling it 'options' makes it clearer.

Also s/prop/prop_name/.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-09 00:03:19 -05:00
Kumar Gala e328e56b30 dts/gen_defines.py: Use err() instead of _err()
_err comes from edtlib and we should be using err() inside of
gen_defines.py.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-08 23:53:22 -05:00
Marcin Niestroj b08adcdd7e scripts: openocd: use hex file for flash command
Use hex file for flash command, instead of elf file. This allows to
flash signed firmware, which is not available in elf format, by
specifying --hex-file command line argument.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-08-08 22:16:50 +02:00
Marcin Niestroj 6778468c73 scripts: openocd: allow to overwrite elf file used to flash device
So far zephyr.elf file was hardcoded in cmake files. Remove it from
there and use cfg.elf_file from python, which can be overwritten by
specifying --elf-file command line option.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-08-08 22:16:50 +02:00
Ulf Magnusson acf276f1df edtlib: Check that 'status' has one of the values from the DT spec.
dtlib is meant to be general and anything-goes re. property values, but
edtlib can be pickier. Check that all 'status' properties have one of
the values listed in the devicetree specification
(https://www.devicetree.org/specifications/), and error out otherwise.

This will get rid of the 'status = "ok"'s (should be "okay") that keep
cropping up.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-08 14:03:25 -05:00
Kumar Gala 8622c3415d scripts/dts: Fix detection of a GPIO specifier
We should only assume a GPIO specifier is either named <FOO>-gpios or
gpios.  Any other form like ngpios should not be considered a GPIO
specifier.  especially since 'ngpios' is the standard property name for
the number of gpio's that are implemented.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-07 13:15:51 -04:00
Kumar Gala 99769990ed scripts/dts/gen_defines: Cleanup write_prop for which props we process
We don't create props for compound types so we dont need to check for
'pwms', 'gpios', 'clocks'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-07 13:15:51 -04:00
Ulf Magnusson 95deec1d24 scripts: edtlib: Reduce code duplication in phandle/value list parsing
Most of the logic for initializing 'clocks' and 'pwms' is the same and
can be shared. Add an EDT._simple_phandle_val_list() helper function for
initializing 'clocks', 'pwms', and any other properties on the form

    <foo>s = <phandle value phandle value ...>

where the nodes pointed at by the phandles are expected to have a
'#<foo>-cells' property.

This should make it easier to add similar properties.

There's still some code duplication in the classes (PWM, Clock, etc.),
but also some differences, so I'm wondering if requiring a class for
each might be okay. Maybe some more class-related stuff could be
factored out later.

Piggyback some related cleanup:

 - Have _phandle_val_list() take the name of the #foo-cells property
   instead of a function for fetching the value. The pattern is always
   the same.

 - Have _add_names() just take the "foo" part of "foo-names". Same
   pattern everywhere.

 - Clean up some redundant comments for stuff that's already documented
   in docstrings

 - Fix error messages printed by _named_cells() ("GPIOS controller" ->
   "GPIO controller", etc.)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-07 11:48:53 -04:00
Piotr Zierhoffer a3ddc09abf build: west: Update the error message when not in west dir
Zephyr verifies if it is built from a west-initialized directory.
The message changed in west@c08061cef1c7b0e19a58a82db731098e2f4bba4a.

Closes #18034.

Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-08-06 19:13:24 +02:00
Paul Sokolovsky 04da7eaf07 scripts: dts: Consistently open text files with utf-8.
Zephyr codebase standardizes in UTF-8 as file encoding. To
accommodate this, we explicitly pass encoding="utf-8" to Python's
open() function, to be independent of any locale setting of a
particular system (e.g., CI/build systems oftentimes have "C",
i.e. ASCII-only, locale). In a few places, we lacked this parameter,
so add it consistently.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-08-05 17:47:57 -04:00
Marti Bolivar 7118d084c9 scripts: un-break test_nrfjprog.py
The pytest.raises context manager is now returning an ExceptionInfo
whose str() doesn't contain the str() of the underlying exception
object. Take str(e.value) directly to make sure we're looking at the
exception string.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-05 15:17:45 +02:00
Marti Bolivar 2b3d9df1d7 west: require v0.6.0 or higher
The main change is the elimination of the bootstrapper, a design flaw
/ misfeature.

Update the documentation to be compatible with the 0.6.x releases as
well. This has to be done atomically, as there were incompatible
changes.  Make use of the versionchanged and versionadded directives
to begin keeping track of how these APIs are evolving.

(Note that west 0.6.0 will remain compatible with the extension
commands in Zephyr v1.14 LTS as long as that is still alive. This
change is targeted towards Zephyr 2.0 users.)

This requires a bump in the shippable container and allows us to
simplify the west_commands test procedure.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-05 15:17:45 +02:00
Ulf Magnusson fe2d858b5f scripts: dts: Add test for multiple binding directories
Add two bindings

    test-bindings/multidir.yaml
    test-bindings-2/multidir.yaml

and a new test-multidir.dts with two nodes that use them.

Verify that the two bindings were found by checking the
Device.binding_path attribute for the two device nodes.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-03 14:17:49 -04:00
Michael Scott b8909439bf scripts: dts: support multiple binding dirs in new scripts
gen_defines.py and edtlib.py were recently added in
commit 62d5741476 ("dts: Add new DTS/binding parser").

The old extract_dts_includes.py script allowed for multiple
dts bindings dirs.  Let's add that functionality to the new
scripts as well.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-03 14:17:49 -04:00
Ulf Magnusson 5d0db517b9 dts: riscv: Add sifive,plic-1.0.0 binding and fix riscv,ndev values
Add a new sifive,plic-1.0.0 binding that inherits from the riscv,plic0
binding. The new binding adds a required riscv,ndev property, which
gives the number of external interrupts supported.

Use the new binding for microsemi-miv.dtsi (with a value of 31 for
riscv,ndev, from http://www.actel.com/ipdocs/MiV_RV32IMAF_L1_AHB_HB.pdf)
and riscv32-fe310.dtsi (which already assigns riscv,ndev).

Also remove a spurious riscv,ndev assignment from
riscv32-litex-vexriscv.dtsi.

Also make edtlib and the old scripts/dts/ scripts replace '.' in
compatible strings with '_' when generating identifiers.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-02 11:44:09 +02:00
Kumar Gala 11e91a83c1 scripts/sanitycheck: optimize disk usage for --save-tests
If we are doing a nightly build we can utilize a large (over 50G) of
disk space just to generate the list of tests to build.  We need to
optimize this so as we finish building the initial pass we clean up
as we go and only keep around the files we need (like .config,
generated_dts_board.conf, CMakeCache.txt, etc).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-31 18:46:32 -04:00
Peter A. Bigot 9a0d9e3af0 scripts: gen_cfb_font_header: modify to replicate cfb fonts
The content of subsys/fb/cfb_fonts cannot be replicated by the existing
script due to lack of positioning options and use of a full-color frame
buffer, which affects the generated bitmap.  Switch to the solution used
in the original script, add the required options, and document the
process of regenerating the fonts.

This commit also determines the required bounding box for the glyphs to
be sure that the user-provided value is sufficient to avoid partial
characters.  Ideally the calculated width and height would be used for
font characters, but this would require significant restructuring of the
script to make calculated values available at the point where the
arguments are used to produce output.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-31 05:43:50 -04:00
Peter A. Bigot f14b19b00a scripts: gen_cfb_font_header: remove guard and make font data private
The output of this script is intended to be put into an implementation
file, where the font data is accessed by index to an array maintained by
the linker script.  There is no need for protection against multiple
includes, and the font data array should not be a global symbol.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-31 05:43:50 -04:00
Kumar Gala 9d9b108dab scripts/dts: Sort output of DT_COMPAT_ defines
Sort the DT_COMPAT_ defines so comparing them from different builds is
easier.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-31 05:33:41 -04:00
Kumar Gala 4e7863dc41 dts: Make instance defines consistent
We generated a define for each instance to convey its existance of the
form:
	#define DT_<COMPAT>_<INSTANCE> 1

However we renamed all other instance defines to be of the form
DT_INST_<INSTANCE>_<FOO>.  To make things consistent we now generate a
define of the form:

	#define DT_INST_<INSTANCE>_<COMPAT> 1

We also now deprecate the DT_<COMPAT>_<INSTANCE> form and fixup all uses
to use the new form.

Fixes: #17650

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-30 17:10:31 -05:00
Anas Nashif 578ae40761 boards: remove quarl_se_c1000
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Ulf Magnusson 7de2f4da14 scripts/dts: Add deprecation comments to old scripts
Makes it easier to understand what's going on.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-07-29 16:22:17 -04:00
Ulf Magnusson 62d5741476 dts: Add new DTS/binding parser
Add a new DTS/binding parser to scripts/dts/ for generating
generated_dts_board.conf and generated_dts_board_unfixed.h.

The old code is kept to generate some deprecated defines, using the
--deprecated-only flag. It will be removed later.

The new parser is implemented in three files in scripts/dts/:

dtlib.py:
  A low-level .dts parsing library. This is similar to devicetree.py in
  the old code, but is a general robust DTS parser that doesn't rely on
  preprocessing.

edtlib.py (e for extended):
  A library built on top of dtlib.py that brings together data from DTS
  files and bindings and creates Device instances with all the data for
  a device.

gen_defines.py:
  A script that uses edtlib.py to generate generated_dts_board.conf and
  generated_dts_board_unfixed.h. Corresponds to extract_dts_includes.py
  and the files in extract/ in the old code.

testdtlib.py:
  Test suite for dtlib.py. Can be run directly as a script.

testedtlib.py (uses test.dts and test-bindings/):
  Test suite for edtlib.py. Can be run directly as a script.

The test suites will be run automatically in CI.

The new code turns some things that were warnings (or not checked) in
the old code into errors, like missing properties that are specified
with 'category: required' in the binding for the node.

The code includes lots of documentation and tries to give helpful error
messages instead of Python errors.

Co-authored-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-07-29 16:22:17 -04:00
Ulf Magnusson a72e451624 scripts/dts: Rename --deprecate-only to --deprecated-only
--deprecate-only sounded like a command to "only deprecate (something)"
to me at first. --deprecated-only might make it clearer that it's about
only generating deprecated stuff.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-07-29 16:22:17 -04:00
Jukka Rissanen f95938da0f net: ppp: Initial support for point-to-point protocol
This implements ppp L2 component, LCP and IPCP modules.

Fixes #14034

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-29 10:24:46 +03:00
Andrew Boie 81ef42d2bc sanitycheck: simplify fault detection
Any fatal error will print "ZEPHYR FATAL ERROR" now, so
we don't have to maintain a set of strings in the
sanitycheck harness.py

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-25 15:06:58 -07:00
Andrew Boie 96571a8c40 kernel: rename NANO_ESF
This is now called z_arch_esf_t, conforming to our naming
convention.

This needs to remain a typedef due to how our offset generation
header mechanism works.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-25 15:06:58 -07:00
Andrew Boie 7875707a98 userspace: add kobject flag for drivers
This new flag will indicate that the kernel object represents
an instance of a device driver object.

Fixes: #14037

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-24 12:33:34 +02:00
Ulf Magnusson 0ec0c84808 dts: bindings: Remove unused 'version' field
No binding has anything but 'version: 0.1', and the code in scripts/dts/
never does anything with it except print a warning if it isn't there.
It's undocumented what it means.

I suspect it's overkill if it's meant to be the binding format version.
If we'd need to tell different versions from each other, we could change
some other minor thing in the format, and it probably won't be needed.

Remove the 'version' fields from the bindings and the warning from the
scripts/dts/ scripts.

The new device tree script will give an error when unknown fields appear
in bindings.

The deletion was done with

    git ls-files 'dts/bindings/*.yaml' | xargs sed -i '/^\s*version: /d'

Some blank lines at the beginning of bindings were removed as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-07-22 09:28:07 -04:00
Alexander Wachter b4c5f4b32b linker: Add dtcm section for Cortex M7 MCUs
This commit adds a DTCM (Device Tightly Coupled Memory) section for
Cortex F7 MCUs. The Address and length is defined in the corresponding
device tree file.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-07-19 10:05:46 +02:00
Wentong Wu fa7ce3ff70 scripts: make mpu align in sections for code reloation
make mpu align inside sections instead of outside to avoid
overlap for code relocation feature.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-07-18 11:09:48 -04:00
Carles Cufi 9754201e04 west: Load CMakeCache.txt as a UTF-8 encoded file
CMake has been using UTF-8 as an encoding for CMakeCache.txt since 3.2.

Fixes #17635

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-07-18 16:50:08 +02:00
Carles Cufi 3ad1f27efc cmake: Encode and decode in UTF-8 in build system
In order to make sure that the build works in folders that require a UTF
encoding, make sure that both CMake and the various Python scripts that
interact with each other on files use the same encoding, in this case
UTF-8.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-07-18 16:50:08 +02:00
Kumar Gala 1c6952c4f6 dts/extract: Mark DT_FLASH_AREA_*_LABEL defines as deprecated
We don't use the DT_FLASH_AREA_*_LABEL defines today so lets mark them
deprecated until we actually need something.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-15 13:40:33 -04:00
Kumar Gala 4d2625cd79 scripts/dts: Add option to generate only deprecated defines
Add a --deprecate-only flag to only generate the deprecated defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-15 13:40:07 -04:00
Andy Ross 50b78f08ea cmake: Remove check_link_map.py
This script is looking for a hyperspecific error (mismatched padding
when linking into two simultaneous output sections) that bit us once,
in an era where the linker scripts were less unified.  We haven't seen
it crop up since, and multiple platforms have changed the way they do
this anyway.

It's needless complexity.  Junk it.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-07-14 04:54:29 -07:00
Alberto Escolar Piedras f8908cd0d8 sanitycheck: Add missing section to whitelist
In a3bea8872b (PR #16352)
_bt_br_channels_area was added to the code but not the
sanitycheck sections whitelist => Add it

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-12 17:08:25 -07:00
Alberto Escolar Piedras 010c609bba sanitycheck: update sections whitelist
In c20ff1150f
and 5f19c8160a
(PR #16897)
_bt_settings_area was replaced with _settings_handlers_area

Update sanitycheck sections whitelist accordingly

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-12 13:36:13 +02:00
Peter A. Bigot 98a8e293cb scripts: gen_cfb_font_header: correct command sanitization
The code to sanitize the generated font path by removing bindir
improperly stripped the first character of every argument when --bindir
was not provided, corrupting the command documentation when fonts are
generated manually.  Only sanitize if --bindir was provided with
non-empty content.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-11 20:20:59 -07:00
Peter A. Bigot 8b4d529706 scripts: gen_cfb_font_header: correct last character
DELETE is not a printable character.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-11 20:20:59 -07:00
Kumar Gala 31052837ed scripts/dts: cleanup 'generation' usage
* Remove dead code that referenced 'generation' but didn't do anything
  with it
* Replace looking at 'generation' with a simple check for property
  starting with # (for things like #address-cells, etc)  or ending in
  -map (for things like gpio-map) to skip

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-11 06:51:17 -04:00
Peter A. Bigot 79765b8ad7 scripts/dts: fix support for uint8-array property values
uint8-array is the name for what the devicetree specification calls a
bytestring.

The original parsing code treated square brackets as equivalent to
quotes or angle brackets, failing to interpret elements as hex-encoded.
This was a bug, corrected in this patch by processing content as a
sequence of hex-encoded bytes with arbitrary whitespace.

The original generating code emitted the property as individual
elements.  Replace that with generation of a single structure
initializer, which is more useful in cases where the length of a
property value may vary between nodes.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-11 06:50:27 -04:00
Manivannan Sadhasivam 7ac767b880 scripts: dts: Match alpha numeric property values
For using alpha numeric property values in a devicetree node, we
need to match the values starts with a number. Current scenario will
return the value as a numeric literal if it starts with a number. This
will not work for a compatible like, "96b-ls-con" which is proposed in
issue #15598.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2019-07-11 06:15:22 -04:00
Michael Scott 4ca54390f4 sanitycheck: handle west-flash dependency for device-testing
sanitycheck --help mentions that west-flash requires device-testing
to be enabled (and indeed it does because DeviceHandler will never
be called where west_flash option is used.  Let's generate an error
if west-flash is used w/o specifying device-testing.

Also cleanup help text which looks odd in both sanitycheck --help
and in the file itself.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-07-10 08:13:57 -07:00
Michael Scott 421ce46f4b sanitycheck: add west-runner parameter
Several boards have multiple runners setup.  We need a way to specify
which runner to use with sanitycheck.  Introduce --west-runner option.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-07-10 08:13:57 -07:00
Kumar Gala 8083f8a6b0 scripts/dts: deprecate DT_<COMPAT>_<INSTANCE ID>_BUS_<BUS>
We don't have any uses of this form of define so deprecate it for now.
If needed this should be DT_INST_<INSTANCE ID>_<COMPAT>_BUS_<BUS>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-10 06:24:39 -05:00
Kumar Gala 81072b53a6 dts/scripts: mark all non DT_ prefix deprecated
Now that we've converted LED and SW to use DT_ prefix we can mark the
non-DT_ prefixed versions as deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-10 05:23:24 -05:00
Kumar Gala 5c78b93c6b scripts/dts: Mark 'non-S' forms of cell and controllers as deprecated
Now that we've converted all _GPIO_ to _GPIOS_ we can mark the _GPIO_
form as deprecated (same for _PWM_ / _PWMS_).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-10 05:23:24 -05:00
Kumar Gala e5d838081c dts: Fix handling of fixed-clock
A number of minor issues with the 'fixed-clock' support:
* Fix the #clock-cells to be 0
* Fix nxp_ke1xf.dtsi to set #clock-cells 0 and the clock reference to
  only be a phandle.
* Fix the generation script to only generate what it should for a
  'fixed-clock'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-07-10 05:23:07 -05:00
Marc Herbert c7633de038 sanitycheck: fix priority of --extra-args=CONFIG_ over testcase.yaml
sanitycheck takes any "extra_config" list found in the testcase.yaml
file and generates an "overlay" file from it. This file is placed in
the per-test build directory and passed to cmake/kconfig.cmake through a
-DOVERLAY_CONF= option set in the (also) generated sanity-out/Makefile.

This commit moves this generated config overlay to a subdirectory one
level down from the build directory, otherwise kconfig.cmake picks it
up *twice*: once from the -DOVERLAY_CONF= option already mentioned above
and a second time because kconfig.cmake scans the build directory and
blindly picks up ALL files ending with .conf[*]. The second pickup is
problematic because kconfig.cmake currently gives it the top precedence,
even higher than anything the user espressed with --extra-args=CONFIG_*

Here's a quick and simple demonstration of the issue fixed by this
commit:

  cd $ZEPHYR_BASE/samples/net/sockets/net_mgmt/
  sanitycheck -T. -p qemu_x86 -b -v # --extra-args=CONFIG_USERSPACE=y|n
  grep CONFIG_USERSPACE $(find sanity-out/ -name .config)

  .net_mgmt.kernelmode/zephyr/.config: # CONFIG_USERSPACE is not set
    .net_mgmt.usermode/zephyr/.config: CONFIG_USERSPACE=y

  grep 'Merged configuration' $(find sanity-out/ -name build.log)

Without this commit, attemps to override anything with
--extra-args=CONFIG_ are silently dropped on the floor.

For more background this issue was found while using the recipe in
commit message 4afcc0f8af

[*] picking up all .conf files is debatable but a much bigger debate
with backward compatibility implications. This small fix makes
absolutely zero difference to anyone or anything not using sanitycheck.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-09 19:16:30 -07:00
Andrew Boie 49cf4867c7 sanitycheck: select gcov tool based on target
Use PATH gcov if no SDK in use, or native-posix derived
targets are in use.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-09 10:20:31 +02:00
Wentong Wu 859ca42006 scripts: elf_helper: correct kernel object address check range
kernel object should not located in app_smem area.

Fixes: #17338.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-07-08 13:28:13 -07:00
Marc Herbert e5cedcae43 sanitycheck help: how to spot tests that were not run and just built
There are a few reasons why sanitycheck will only build a test and not
run it: list them in the developer guide. Also lists the --options that
provide that information and update their --help message.

A couple other --help fixes.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-08 08:07:57 -04:00
Marc Herbert d7ca903b72 sanitycheck: replace cmake -H "not meant for public use" with -S
https://www.mail-archive.com/cmake-developers@cmake.org/msg16769.html

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-08 08:04:39 -04:00
Sebastian Bøe b8d4a77ecd size_report: Don't crash when observing stripped symbols
When stripped symbols are present in the build size_report has crashed
due to it not being aware of this case.

This patch causes stripped symbols to be ignored instead, allowing
analysis of the non-stripped symbols.

It is left as future work to somehow display how much space stripped
symbols are taking up.

Stripped symbols can be present when third-party binaries are linked
into the build.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-07-05 14:18:49 -04:00
Marc Herbert 9e57338efd sanitycheck: fix --jobs help message + other cosmetic fixes
The --jobs default was recently changed in commit 9f4f57eed3, update
its help message.

Add the hopefully last missing verbose("Spawning...") statement.

Fix comment updated in commit 095b82a301.

Replace two tags with whitespace.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-07-03 23:04:16 -07:00
Andrew Boie 1578ef71b1 sanitycheck: workaround file limits
sanitycheck is opening an insane number of file descriptors
simultaneously as it opens up communication pipes with
every test that supports emulation, on every emulated
board target.

Increase the resource limit on open files until this code
can be properly refactored.

Workaround for: #17239

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-03 16:49:21 -04:00
Andrew Boie 8047a6f4d0 sanitycheck: make coverage reports easier to do
- The --gcov-tool argument now has a reasonable default
  if the Zephyr SDK is in use.
- --coverage-platform, if unspecified, defaults to what
  was passed to --platform
- --coverage implies --enable-slow, so that tests with
  the 'slow' tag are built and run.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 22:56:14 -04:00
Andrew Boie 095b82a301 sanitycheck: correct timeout extension comment
This wasn't discussing why there is extra time for when
code coverage is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 22:54:24 -04:00
Andrew Boie 9f4f57eed3 sanitycheck: don't multiply CPU count
We have a number of timing sensitive tests which run
correctly on a much more frequent basis if the system
is not so heavily loaded. Instead of squeezing a few
more crumbs of performance by doubling the CPU count,
just use the number of CPUs reported by the system.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 22:51:24 -04:00
Andrew Boie d62e229680 sanitycheck: extend coverage timeout
If GCOV coverage is enabled, the coverage dump happens after
"PROJECT EXECUTION SUCCESSFUL" is printed. In some cases,
the additional time added was not enough to capture all the
GCOV output on a heavily loaded system before the emulator
gets killed.

Ideally, the decision to kill the emulator needs to be smarter
and less race-prone, but that can wait for a future
enhancement.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-02 20:30:41 -04:00
Alberto Escolar Piedras b91f37494b sanitycheck: Minor optimization in BinaryHandler
Do not search for the valgrind binary (which) if valgrind
was not selected to be used.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-02 18:49:44 -04:00
Alberto Escolar Piedras 649368c018 sanitycheck: Record time used in BinaryHandler
So the time used to run boards which use the BinaryHandler can be
reported, record the time used from spawning the process until
it finnishes or is killed.
The BinaryHandler is used by the "native" boards, unit tests,
nsim and Renode.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-07-02 18:49:44 -04:00
Andrzej Głąbek bb8dddfa99 scripts: dts: Add extraction of clock frequency for fixed clock
This patch adds generation of `*_FIXED_CLOCK_FREQUENCY` macros for
clock consuming nodes that are provided with a fixed rate clock.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-28 09:45:35 -05:00
Andrzej Głąbek c782ba82ae scripts: dts: Add special handling of '+' in 'str_to_label' function
This patch is needed in order to get compilable macros for compatibles
like "arm,cortex-m0+".

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-28 07:32:01 -05:00
Marc Herbert eefea9da9c gen_app_partitions: deterministic _and_ decreasing app_smem_*.ld
Commit 212ec9a29a / feature #14121 already ordered partitions by
decreasing size, however it was common in samples/userspace/shared_mem/
/sample.kernel.memory_protection.shared_mem for two partitions to have
the same size and be randomly ordered between them. This adds the
partition name as a second sort key.

Unlike previous attempt in commit 725abdf430 this doesn't use the
partition name as the first (and only) key and doesn't break the
decreasing size order.  Huge thanks to Sigvart Hovland for spotting this
in a post-merge but prompt code review.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-27 18:06:30 -07:00
Marc Herbert 85bc0d2fe5 Revert "gen_app_partitions.py: make generated/app_smem_*.ld files deterministic"
This reverts commit 725abdf430 which did get rid of randomness in the
order of the partition _names_ as claimed but regressed commit
212ec9a29a / feature #14121 and broke the previous size order which I
missed. Huge thanks to Sigvart Hovland for spotting this in a post-merge
but prompt code review. Proper fix in the next commit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-27 18:06:30 -07:00
Marc Herbert 725abdf430 gen_app_partitions.py: make generated/app_smem_*.ld files deterministic
Dictionaries are not ordered in Python 3.5 and before, so building twice
in a row could lead to a different partition order, different
build/zephyr/include/generated/app_smem_*.ld files and different
binaries.

Fix with a minor change to the "for" loop in the output function:
make it iterate on sorted(partitions.items()) instead of the raw and
randomly ordered partitions dictionary.

It is easy to reproduce the issue even without downgrading to an
obsolete Python version; pick a test like samples/userspace/shared_mem/
and simply change the code to this:

--- a/scripts/gen_app_partitions.py
+++ b/scripts/gen_app_partitions.py
@@ -159,10 +159,12 @@ def parse_elf_file(partitions):
                     partitions[partition_name][SZ] += size

+import random
 def generate_final_linker(linker_file, partitions):
     string = linker_start_seq
     size_string = ''
-    for partition, item in sorted(partitions.items()):
+    for partition, item in sorted(partitions.items(),
+                                  key=lambda x: random.random()):
         string += data_template.format(partition)
         if LIB in item:
             for lib in item[LIB]:

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-27 07:18:09 -04:00
Marc Herbert 6ccd026f7c gen_relocate_app.py: make generated/linker_relocate.ld deterministic
Dictionaries are not ordered in Python 3.5 and before, so building twice
${ZEPHYR_BASE}/samples/application_development/code_relocation/
in a row could lead to a different sections order, different
build/zephyr/include/generated/linker_relocate.d and code_relocation.c
and different binaries.

Fix with a minor change to three "for" loops in the output functions:
make them iterate on sorted(list of sections) instead of the raw and
randomly ordered dictionaries of sections.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-27 07:18:09 -04:00
Carles Cufi 41f1f648f6 west: runners: Guess build folder
When using a build folder format with build.dir-fmt that includes any
parameters that need resolving, the west runners cannot find the folder
since the required information (board, source dir or app) is not
available.
Add a very simple heuristic to support the case where a build folder
starts with a hardcoded prefix (for example 'build/') and a single build
is present under that prefix.
The heuristic is gated behind a new configuration option:
build.guess-dir

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-06-26 11:50:26 -04:00
Carles Cufi 3b3bbc1ee0 Bluetooth: hci_uart: Use DT for the hci_uart UART
Use Device Tree,and in particular a new 'bt-c2h-uart' to select which
UART is being used to communicate with an external BLE Host when acting
as a Controller.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-06-26 12:37:04 +02:00
Marti Bolivar 814bc7ba8e scripts: remove runner related cruft
There's some old cache variables that don't matter anymore in here.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar f08935fa73 scripts: west_commands: improve run_common error handling
Print a friendlier error message on ValueError, but don't throw away
the stack trace.

Move another call to log.die().

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar e6873b8d7e scripts: tweak west build output
Follow along with changes made in west flash/debug/etc to make it
easier to see the output steps visually.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar ec8dbf34dc scripts: tweak runner-related command output
Having common log handlers now lets us improve our logging output so
that info messages are prefixed with the runner they came from, and
doing something similar with the high level steps as we go, like this:

   -- west <command>: using runners
   -- runners.RUNNER_NAME: doing something
   <output from RUNNER_NAME subprocesses go here>
   -- runners.RUNNER_NAME: all done, bye

We can also colorize the west output to make it stand out better from
subprocesses, using the same output formatting style that west
commands like west list do.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar ddce583ca2 scripts: west_commands: decouple runners pkg from west
I've had some requests to be able to use code in the runners package
without having west installed.

It turns out to be pretty easy to make this happen, as west is
currently only used for west.log and some trivial helper methods:

- To replace west log, use the standard logging module
- Add an appropriate handler for each runner's logger in
  run_common.py which delegates to west.log, to keep
  output working as expected.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar d176cc36ad scripts: runners: update ZephyrBinaryRunner docstring
Fix some things that are incorrect and try to make it more clear.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar 6440514bec scripts: west_commands: fix help string
The option name is wrong.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar 725e98e300 scripts: fix pyocd runner --flash-opt help
This doesn't work. Fix the example.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-25 22:33:02 +02:00
Kumar Gala 95f28eb764 scripts/dts: Remove DT_CHOSEN generation
We never used DT_CHOSEN so lets remove this and add it back if/when
there's an actual need for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-25 08:43:58 -05:00
Kumar Gala 08a5f9f8eb scripts/dts: Add ability to mark cell/ctrl defines as deprecated
Add support so that we can flag any "defines" associated with a call to
either extract_cells or extract_controller as deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-25 08:43:35 -05:00
Kumar Gala 79b59e8205 scripts/dts: Remove 'use-prop-name' from clock generation
We never set 'use-prop-name' on clock bindings so lets just always
use CLOCK_CONTROLLER as the define name we generate.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-25 08:42:31 -05:00
Kumar Gala 593d628e32 dts/extract: Remove 'use-prop-name' from cell and controller handling
We have 'use-prop-name' flag in the bindings which is specifically used
for GPIO properties to control if we get "GPIO" or "GPIOS" as the
generated define name.

Lets remove the inconsistancy and use "GPIOS" as the preferred name as
this matches the DTS property name.  Towards that we will generate both
forms and remove support for 'use-prop-name'.

This also impacts "PWM" generation.  So we'll have "PWM" and "PWMS"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-25 08:40:33 -05:00
Jukka Rissanen c9aaab74db net: ptp: clock: Add usermode support to ptp_clock_get()
It is useful that the ptp_clock_get() function can be called from
the userspace. Create also unit test for calling that function
from userspace.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Wentong Wu 5611e92347 kernel: add futex support
A k_futex is a lightweight mutual exclusion primitive designed
to minimize kernel involvement. Uncontended operation relies
only on atomic access to shared memory. k_futex structure lives
in application memory. And when using futexes, the majority of
the synchronization operations are performed in user mode. A
user-mode thread employs the futex wait system call only when
it is likely that the program has to block for a longer time
until the condition becomes true. When the condition comes true,
futex wake operation will be used to wake up one or more threads
waiting on that futex.

This patch implements two futex operations: k_futex_wait and
k_futex_wake. For k_futex_wait, the comparison with the expected
value, and starting to sleep are performed atomically to prevent
lost wake-ups. If different context changed futex's value after
the calling use-mode thread decided to block himself based on
the old value, the comparison will help observing the value
change and will not start to sleep. And for k_futex_wake, it
will wake at most num_waiters of the waiters that are sleeping
on that futex. But no guarantees are made on which threads are
woken, that means scheduling priority is not taken into
consideration.

Fixes: #14493.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-06-24 15:38:21 -07:00
Ulf Magnusson a570b40252 genrest: De-spam docs by skipping direct deps. in more places
Similar deal to commit cc14c40a2d ("kconfiglib: Unclutter symbol
strings, avoid redundant writes, misc.").

Hide the direct dependencies in the defaults, selects, and implies
sections. Do the same in menuconfig/guiconfig as well.

This uses a new Kconfiglib API, so update Kconfiglib to upstream
revision 164ef007a8. This also includes some minor optimizations and
cleanups.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-24 12:14:06 -07:00
Ioannis Glaropoulos 88959e75dd scripts: gen_priv_stacks.py: use the right alignment for priv stacks
The privilege stacks are not sandboxed inside an MPU region,
so they do not have to be aligned with the stack buffer size.
We fix this by using the PRIVILEGE_STACK_ALIGN macro, which
is defined in arch.h and reflects the minimum alignment
requirement for privilege stack buffers.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-24 10:16:57 -07:00
Kumar Gala 74818bcb49 scripts/dts: Treat array always as a list
If the type of property is a 'array' we should generate defines as
if its a list even if theres only a single element in the list.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-24 07:16:59 -04:00
Kumar Gala 344737d759 scripts/dts: Treat string-list always as a list
If the type of property is a 'string-list' we should generate defines as
if its a list even if theres only a single element in the list.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-22 10:03:17 -05:00
Marc Herbert 35dc96399c sanitycheck: show handler_time in -v output (qemu 2.032s)
We already have the info so let's show it. This helps spots intermittent
issues[*], gives an indication of the time --build-only saves, can help
spot an overloaded test system, highlights the most time-consuming tests
which may need a longer timeout in their config, shows the effective
timeout value when one occurs... all this for a dirt cheap screen estate
price and two extra lines of code.

Sample -v output:

32/81 board123  tests/testme              PASSED (qemu 2.049s)
33/81 board456  samples/hello             PASSED (build)
34/81 qemu_x3   tests/kernel.stack.usage  FAILED: timeout (qemu 60.029s)
     see: sanity-out/qemu_x3/tests/kernel.stack.usage/handler.log
35/81 board456  tests/testme              PASSED (build)
36/81 qemu_x5   tests/kernel.queue        FAILED: failed (qemu 2.191s)
     see: sanity-out/qemu_x5/tests/kernel.queue/handler.log

[*] running qemu in heavily packed cloud virtual machines comes to mind,
    also see #12553, #14173 etc.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-21 13:47:32 -04:00
Kumar Gala bf0f6d911d dts: Add concept of sub-nodes to YAML and generator
Several bindings have an expectation of sub-nodes that describe the
actual infomation.  The sub-nodes don't have any compatiable so we can't
key on that.

So we can add the concept of a sub-node to the YAML to handle cases like
'gpio-keys', 'gpio-leds', 'pwm-leds', etc..

The sub-node in the YAML is effective the "binding" params that describe
what properties should exist in the sub-node.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 15:34:28 +02:00
Kumar Gala fe2062b38b dts/extract: deprecate old IRQ alias define generation
Make the old IRQ aliases that where missing the _0, _1, etc. part as
deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Kumar Gala 7b638bf3f6 dts/extract: Fix IRQ alias define generation
The alias generation wasn't doing the right thing with regards to
keeping the names consistent.  We would drop the index from the define
name for aliases.

So we'd get
	DT_NXP_KINETIS_GPIO_GPIO_D_IRQ
which should be
	DT_NXP_KINETIS_GPIO_GPIO_D_IRQ_0

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Kumar Gala 6a79bf2571 dts/extract: Add ability to mark aliases as deprecated
Add a deprecate flag to add_prop_aliases so we can make the aliases it
generates as deprecated if needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Anas Nashif cbfba62182 ci: increase sleep time between sanitycheck runs
Give the system more time to settle before we try to re-run the tests
again.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-20 22:15:27 +02:00
Ulf Magnusson e1f0b61d23 scripts/dts: Clarify extract/flash.py some more
Think I understand it now, and that was the goal.

 - _extract_partition() adds index-based entries. extract_partition()
   adds label-based entries.

   Rename them to _add_partition_index_entries() and
   _add_partition_label_entries(), and call them from a top-level
   extract_partition() function.

   This makes the logic clearer. It took me a long time to spot it.

 - Generate indicies with a simple counter and remove the _flash_area
   logic. This would break if partitions were extracted more than once,
   but they aren't, and now you know that they can't be.

 - Rename _create_legacy_label() to add_legacy_alias() and make it
   global. It doesn't use 'self'.

 - Break the logic for finding the flash controller into a separate
   helper function

 - Add doc-comments for the new functions

 - Misc. other small clean-ups

generated_dts_board.conf and generated_dts_board_unfixed.h were verified
to be identical for disco_l475_iot1 and frdm_kw41z before and after the
cleanup.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-20 11:35:05 +02:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Andy Ross 5efdd6a525 sanitycheck harness: Correct ordered regex handling
The way sanitycheck did its ordered regexes is that it would test
every regex against every line, and store the matching lines and their
regexes in an OrderedDict and check that they happened in the right
order.

That's wrong, because it disallows matching against a line that
previously appeared (and should have been ignored) in the input
stream.  The watchdog sample is the best illustration: the first boot
will (by definition) contain all the output already, but the regex has
to match against a line from the SECOND boot and not the same one it
saw earlier.

Do this the simple way: keep a counter of which regex we're trying to
apply next and increment it on a match.  This is faster too as we only
need to check one pattern per line.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-06-19 14:37:20 -04:00
Tyler Hall bb359257bf scripts/sanitycheck: fix ZEPHYR_BASE subdir check edge case
There is a case where using startswith to determine if a path is a
subdirectory of another path can erroneously match. When using a
testcase root outside of ZEPHYR_BASE, an erroneous match will cause the
relative path containing ".." to get prepended to the test output
directory.

Example:

$HOME/zephyr/zephyr # ZEPHYR_BASE
$HOME/zephyr/zephyr-rust/tests # testcase root

The relative path prepended to the testcase name is ../zephyr-rust/tests
and an example test output dir is
./sanity-out/qemu_x86/../zephyr-rust/tests/rust/rust.main

In this case, the build directory escapes the board directory and is no
longer unique. Parallel tests then clobber each other.

Use pathlib instead of string matching to cover this case.

Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
2019-06-19 13:56:26 -04:00
Marc Herbert 6f98db61f1 generated/cfb_font_dice.h: don't leak absolute paths in comment
The start of generated/cfb_font_dice.h looked like this:

/*
 * This file was automatically generated using the following command:
 * /home/john/zephyrproject/zephyr/scripts/gen_cfb_font_header.py
 * --input fonts/dice.png --output
 * /home/john/tmp/build/zephyr/include/generated//cfb_font_dice.h
 * --width 32 --height 32 --first 49 --last 54
 */

For build reproduction and "privacy" reasons, change it to this:

/*
 * This file was automatically generated using the following command:
 * ${ZEPHYR_BASE}/scripts/gen_cfb_font_header.py
 * --input fonts/dice.png --output
 * zephyr/include/generated//cfb_font_dice.h
 * --width 32 --height 32 --first 49 --last 54
 */

Test with:
  sanitycheck  -p reel_board \
  -T $ZEPHYR_BASE/samples/display/cfb_custom_font/

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-19 08:40:59 -04:00
Erwan Gouriou 8a9ca0d864 scripts: Upgrade pyocd for pack support
pyocd 0.21.0 provides pack support 'pack support' functionality,
as opposed to current 'buitlin support'.
This new feature enables the possibility to add pyocd support
for any chip that is documented in Keil database. Then one doesn't
need anymore to wait pyocd is updated with a new target to use
pyocd with his target, as long as it is populated in Keil database.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-06-18 23:03:35 -04:00
Kumar Gala 84cf9dc671 scripts/sanitycheck: Add --cmake-only option
Add an option that only invokes the cmake phase of sanitycheck.  This
can be useful for any testing that only needs to initial generation
phase of cmake, for example device tree.  Also useful if we want to
just generate compile_commands.json files from cmake via:

./sanitycheck -xCMAKE_EXPORT_COMPILE_COMMANDS=1 --cmake-only

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-18 12:02:03 -04:00
Ioannis Glaropoulos a4afe8c0fa scripts: gen_priv_stacks: remove unused variable
Variable priv_stack_decl_size is not used by the script,
so we can remove it.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-06-17 12:33:58 -04:00
Marti Bolivar c24e044c6e scripts: runners: check for required programs
Add self.require() checks before running commands. Increase test
coverage, including for this feature, while we are here.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-17 15:06:21 +02:00
Marti Bolivar c07267a26a scripts: runners: abstract jlink's missing program support
The runners/jlink.py script has a mechanism for erroring out if a host
tool is not installed. Abstract it into runners/core.py and handle it
from run_common.py. This will let it be used in more places.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-17 15:06:21 +02:00
Anas Nashif 49b22d4fc3 sanitycheck: report tests that never build/run
Add new option --report-excluded to list all those tests with bad
filtering that never build or run. This option produces accurate results
with --all but can be used with default sanitycheck options to see what
does not run/build in CI for example. (limited coverage).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-16 14:13:25 -04:00
Marti Bolivar d371c54f51 scripts: west sign: test for input file existence
Check the CONFIG_BUILD_OUTPUT_HEX and CONFIG_BUILD_OUTPUT_BIN options
are enabled before attempting to build signed versions of these formats.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-16 10:16:15 -04:00
Marti Bolivar 2f839da163 scripts: west sign: improve user friendliness
Add more error handling and warnings. Doing this nicely requires a bit
of re-work to the control flow.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-16 10:16:15 -04:00
Marti Bolivar 33cbba3457 scripts: west sign: move hex and bin default locations
When signing binaries from multiple build directories, it is
inconvenient to have to specify the output file locations by hand each
time. It's also a little weird that they're not next to zephyr.bin and
zephyr.hex.

Move them to the build directory, next to their unsigned variants.

Suggested by Piotr Mienkowski.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-16 10:16:15 -04:00
Marti Bolivar 06c9f8e9e6 scripts: west sign: code style refactor
Let's leave self.args as the actual parsed argument namespace.
Pass the final computed build directory separately.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-16 10:16:15 -04:00
Marti Bolivar 3bd07a244a scripts: west sign: make it work again
This got broken in the patches which added the build.dir-fmt config
option when BUiLD_DIR_DESCRIPTION was renamed.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-16 10:16:15 -04:00
Marti Bolivar fe91e48418 scripts: runners: add __contains__ to BuildConfiguration
Implement the in operator for this class.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-16 10:16:15 -04:00
Ulf Magnusson 045c809561 scripts/dts: Make extract/flash.py easier to read
Clean up the code a bit:

 - Simplify the loops over the flash 'reg' properties by using range()

 - Build identifier names with a plain .format() where possible. This
   makes them stand out better in the code.

 - Remove redundant variables

 - Move variables close to where they're used

 - Misc. other minor improvements

generated_dts_board.conf and generated_dts_board_unfixed.h were verified
to be identical for disco_l475_iot1 and frdm_kw41z before and after the
cleanup.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-16 10:10:06 -04:00
Piotr Mienkowski 9ac4dc6631 scripts/dts: generate DT_ALIAS_<ALIAS>_<PROP> defines
DT_ALIAS_<ALIAS>_<PROP> defines are a convenient and portable way to get
the device instance name despite different naming conventions used by
the device drivers.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-06-15 11:15:26 -05:00
Anas Nashif b58aa20e13 ci: skip handling coverage data
We not analysing coverage data at all in CI right now. Disable this
while we figure out a better solution for reporting data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-14 09:26:40 -04:00
Kumar Gala 01e54a5472 scripts/dts: Change DT_<COMPAT>_<INSTANCE>_<PROP> define
Its possible that the <INSTANCE> number could conflict with the register
number.  This is shown to happen for a device like soc-nv-flash at
address 0.

So change naming convention to DT_INST_<INSTANCE>_<COMPAT>_<PROP> and
make DT_<COMPAT>_<INSTANCE>_<PROP> as deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-14 08:02:15 -05:00
Kumar Gala 062bd0656a scripts/dts: Sort instance IDs by reg addr
Because of how generate defines for instances its possible that we have
a name conflict if the instance ID and reg addr space clash.

For example on qemu_x86 there are current two 'soc-nv-flash' nodes and
one is at reg addr 0, but instance id 1, the other is reg addr 0x1000
and instance id 0.  We'd possibly get this conflict:

For the 'soc-nv-flash' at 0x1000 (instance 0):
	(instance define)
	#define DT_SOC_NV_FLASH_0_BASE_ADDRESS          0x1000

For the 'soc-nv-flash' at 0x0 (instance 1):
	(address define)
	#define DT_SOC_NV_FLASH_0_BASE_ADDRESS          0x0

To deal with this we make sure that the lower reg address is instance 0,
than things work out ok.  To handle this case, if we sort the instance
IDs based on reg addr than if we have something at reg addr 0, it will
also than be an instand ID 0.

The longer term solution will be to deprecated the old defines and
remove the conflict between instance ID defines and normal DT defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-13 14:11:13 -05:00
Marti Bolivar 8718d5c84b scripts: west: improve error message on missing cache
In the west flash/debug commands, if the user gives an invalid build
directory, they'll get a stack trace instead of a helpful error
message when the cache can't be built.

Fix that.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-10 17:46:27 -05:00
Carles Cufi 98980c6b7c west: build: Configurable build folder format
Add the possibility of configuring the build folder format in west's
configuration system.
The build.dir-fmt configuration option controls how west will create
build folders when not specified, the following parameters are currently
accepted:

- board: The board name
- source_dir: The relative path from CWD to the source directory
- app: The name of the source directory

If CWD is below source_dir in the directory hierarchy then source_dir is
set to an empty string.

This means that if one sets:

[build]
dir-fmt = build/{board}/{source_dir}

Then when building samples/hello_world from zephyr's root for the
reel_board the build folder will be:

./build/reel_board/samples/hello_world

but when building it from inside the samples/hello_world folder it will
instead be:

./build/reel_board

Fixes https://github.com/zephyrproject-rtos/west/issues/124

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-11 00:00:34 +02:00
Carles Cufi 49c4b1c303 west: Use find_build_dir in run_common
In preparation for upcoming changes to the way the default build folder
is defined, switch to using the common find_build_dir() function in the
runners.
This actually changes the behavior for the west build command slightly,
since the current working directory (cwd) will now be checked after the
default build folder ('build'). This brings it in line with what is
used for the runners.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-06-11 00:00:34 +02:00
Andrew Boie a42313d488 requirements.txt: add gcovr
This tool is cited in our documentation for producing coverage
reports, add it to the list of packages pulled in by pip during
workstation setup.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-07 14:15:16 -07:00
Kumar Gala 1c55882ae3 dts/extract: Remove bogus pinctrl generation
The pinctrl generation has never done anything useful so lets remove it
as its just dead code.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-07 10:35:58 -06:00
Ulf Magnusson f46ebc3c97 kconfig.py: Use messages returned by load_config() and write_config()
load_config() and write_config() now return a message to print. This
message also says whether the configuration was loaded (replace=True) or
merged (replace=False), and whether the new .config is different from
the old (for write_config()).

Print the returned messages and remove some old print()s.

Also switch to an improved warning control API (the old one is still
supported, but might as well).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-07 18:20:22 +02:00
Ulf Magnusson cc14c40a2d kconfiglib: Unclutter symbol strings, avoid redundant writes, misc.
Update kconfiglib, menuconfig, and guiconfig to upstream revision
5c904f4549 to get various improvements and fixes in:

 - Marc Herbert found an issue involving symlinks, absolute paths,
   and rsource that could lead to files not being found. The root cause
   was relpath() assuming that symlink/../bar is the same as bar/, which
   isn't guaranteed.

   Fix it by handling paths in a simpler, more textual way.

 - Propagated dependencies from 'depends on' are now stripped from
   properties when symbols are printed (e.g. in information dialogs and
   generated documentation).

   The printed representation now also uses shorthands.

   Before:

     config A
             bool
             prompt "foo" if C && D
             default A if B && C && D
             depends on C && D

   After:

     config A
             bool "foo"
             default A if B
             depends on C && D

 - Before writing a configuration file or header, Kconfiglib now
   compares the previous contents of the file against the new contents,
   and skips the write if there's no change. This avoids updating the
   modification time, and can save work.

   A message like "No change to '.config'" is shown when there's no
   change.

 - .config now has '# end of <menu>' comments to make it easier to see
   where a menu ends. This was taken from a change to the C tools.

 - load_config() and write_(min_)config() now return a message that can
   be printed with print(kconf.load_config()). This allows messages to
   be reused in e.g. the configuration interfaces (nice now that there's
   also a "No change to..." string).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-06-07 18:20:22 +02:00
Alexey Brodkin bceaed67b3 simulation: ARC EM in nSIM to use nsim_em.props
This matches a naming scheme used for other flavour of ARC EM
SoC flavors.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2019-06-06 14:20:42 -04:00
Kumar Gala 442df97366 scripts/dts: Remove alias defines for labels
We added generation of aliases for "alt-label" (which was the outer
label of a node) for use with shields and connectors.  However we've
never used these defines and the generation is a bit inconsistent.

This removes generation of defines like for label 'arduino_spi':
	#define ARDUINO_SPI_BASE_ADDRESS ... (already deprecated)
	#define DT_ST_STM32_SPI_FIFO_ARDUINO_SPI_BASE_ADDRESS ...

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-06 09:08:16 -06:00
Nathaniel Graff bd2919dcf1 runners/jlink: Add --tool-opt option for more args
Adds the --tool-opt option to allow additional arguments to be
passed to JLink Commander

Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
2019-05-30 16:54:02 -04:00
Ulf Magnusson a1c3cc6660 guiconfig: Add a graphical configuration interface
This is a graphical configuration interface written in Tkinter. Like
menuconfig.py, it supports showing all symbols (with invisible symbols
in red) and jumping directly to symbols. Symbol values can also be
changed directly from the jump-to dialog.

This interface should feel a lot smoother than menuconfig.py on Windows.

When single-menu mode is enabled, a single menu is shown at a time, like
in the terminal menuconfig. Only this mode distinguishes between symbols
defined with 'config' and symbols defined with 'menuconfig'.

Compatible with both Python 2 and Python 3. Has been tested on X11,
Windows, and macOS.

To avoid having to carry around a bunch of GIFs, the image data is
embedded in guiconfig.py. To use separate GIF files instead, change
_USE_EMBEDDED_IMAGES to False. The image files can be found in
https://github.com/ulfalizer/Kconfiglib/tree/screenshots/guiconfig.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-05-30 09:54:06 -04:00
Ulf Magnusson 6cfc13522c menuconfig: Small Space/Enter improvement + fix for obscure bug
Update menuconfig (and Kconfiglib, just to sync) to upstream revision
7e0b9f7ae1, to get these commits in:

  menuconfig: Improve space/enter behavior slightly

  Space toggles value is possible, and enters menus otherwise. Enter
  works the other way around.

  Make this explicit in the code, which also fixes some corner cases,
  like space doing nothing on a y-selected menuconfig symbol.

  -------------------------------------------------------------------

  menuconfig: Fix display issue for unsatisfied-deps selected symbol
  with children

  A symbol with unsatisfied direct dependencies can end up with visible
  children in an implicit submenu if it is selected (though that
  generates a warning), so the optimization in _shown_nodes() isn't
  safe, and causes the child nodes to not be shown outside show-all
  mode.

  Just remove the optimization. Trying things out some more,
  everything's plenty fast enough anyway.

  Checking the direct dependencies of the parent instead would be safe.

The menu path now says "(Top)" instead of "(top menu)" too, which is a
bit more compact. Make the same change in genrest.py.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-05-30 09:54:06 -04:00
Luiz Augusto von Dentz a3bea8872b Bluetooth: L2CAP: Move fixed channels to its own section in ROM
This changes the declaration of fixed channels to be statically defined
with use of BT_L2CAP_CHANNEL_DEFINE since fixed channels are never
unregistered.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00