Commit graph

88 commits

Author SHA1 Message Date
Martí Bolívar b6425b913a doc: dts: adjust CONFIG_COMPILER_TRACK_MACRO_EXPANSION text
Rework to address some grammar issues and typos in the original.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-05-05 12:19:36 -07:00
Gerard Marull-Paretas d45946c65d doc: build: dts: add CONFIG_COMPILER_TRACK_MACRO_EXPANSION
When debugging devicetree related issues, it may be useful to turn macro
expansion tracking off. Let's document this in the troubleshooting
section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-05 12:08:48 +02:00
Jamie McCrae 2b9370597d doc: sysbuild: Improve documentation for targets
Adds information on targets that can be used from sysbuild.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-03 14:26:04 +02:00
Martí Bolívar c625a0e7a8 doc: dts: add help for undefined reference to __device_dts_ord_N
This is an FAQ and we don't have a satisfactory page that describes
the current state of the world for how to troubleshoot. This leads
to frustrated users and duplicated support efforts. Try to improve
this by at least writing down what people have to do today.

If we ever improve the situation by adding a machine-readable map
between drivers, Kconfig options, and DT compatibles, we can hopefully
do better than this, but at least it's a start.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-26 12:53:48 +02:00
Daniel Mangum 63e7f106ea docs(build): fix typo of in CONFIG_GEN_ISR_TABLES description
Fixes misspelling of `scans` in the description of `CONFIG_GEN_ISR_TABLES`
in the build system documentation.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-04-24 13:36:28 +02:00
Jamie McCrae a8164b705a doc: kconfig: setting: Add "fragment" to text
Adds "fragment" to the Kconfig text, this is because these files
are known as Kconfig fragments, and when searching the
documentation for this, all you get are irrelevant results instead
of this page - which is by far the most important one.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-04 11:50:46 +02:00
Fabio Baltieri 08d1b33d07 doc: troubleshooting: update the save-temps instructions
Update the save-temps instruction to mention the new kconfig option
instead of setting EXTRA_CFLAGS directly.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-04-02 22:07:22 -04:00
Marti Bolivar ee4b134dd6 doc: add snippets documentation
Document this new build system feature.

Since its purpose is customizing application builds, the logical place
for the main body of documentation is in a new snippets/ directory in
doc/build/. Create that directory and add its initial documentation.

Like boards and samples, however, we expect people to write
documentation for each snippet within the directory that defines the
snippet itself. Therefore, add a new top-level snippets/ directory and
stub out the documentation needed to document individual snippets as
well.

Add documentation and cross-references in other required places as
well.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Jamie McCrae 4b5bbb2902 docs: build system: Update note that prj.conf file is needed
Adds a note that this file is mandatory.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-17 11:49:27 +01:00
Jamie McCrae 388b3c237a doc: sysbuild: Add details on external modules
Adds details on how to use the new sysbuild external module
feature.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-09 09:25:00 +01:00
Adrien Leravat 534b7ec78d doc: build: dts: fix small doc typo
`using west build` was repeated, and supposed to be `west build`.

Signed-off-by: Adrien Leravat <adrien.leravat@gmail.com>
2023-03-06 16:44:16 +01:00
Martí Bolívar 04386be57e doc: dt: fix links to script files
These have been moved into a subpackage.

Fixes: #55198
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-28 11:51:24 -08:00
Henrik Brix Andersen fba6c7f210 scripts: kconfig: add function to determine if GPIO hogs are enabled
Existence of enabled GPIO hog nodes cannot be determined using any of the
existing kconfig functions. Add custom kconfig helper function to determine
whether any GPIO hogs nodes are enabled.

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

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

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-27 14:38:52 -08:00
Marti Bolivar c4b10874eb doc: dts: add missing entry to dts/bindings search path
Since SHIELD_DIRS gets added to DTS_ROOT in dts.cmake, any shield
directories are also places where we look for bindings by default.
This feature is not used in upstream Zephyr, but it is supported,
so document it.

Suggested-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 196df5c9b4 doc: dts: clarify reg format
These are in hex.

Suggested-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 7812bedb09 doc: dts: touch up api
Just a few minor things from a periodic review.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar c35d83f95d doc: dts: touch up api-usage
Just a few minor things from a periodic review.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 1ab3a6f53d doc: dts: document zephyr, prefix for props/compats
We have established a convention that the zephyr, prefix in property
names indicates some sort of zephyr-specific extension to a common
binding, or a zephyr-specific driver configuration knob. We also have
established a convention that compatibles which begin with "zephyr,"
are specific to our operating system. Document these facts.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 0d827a8f50 doc: dts: improve bindings-upstream
Splitting up the 'general rules' section into subsections makes it
possible to link directly to a particular rule. This is useful when
pointing out an issue during code review, sharing with another
colleague, etc. Adding a local table of contents makes the page
skimmable (it's buried too deeply in the toctree to have sections
listed in the HTML sidebar).

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar cd3008a9ac doc: dts: improve zephyr-user-node.rst
Now that this information is in a separate page instead of buried at
the bottom of the DT bindings documentation, it's more convenient to
split it up into subsections for readability.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 67b0cd382e doc: dts: clarify a design requirement
There's been some confusion about what we mean by hardware
description. We're really talking about the user-facing inputs that
need to be configured per SoC, application, etc. It's fine to do
things like use ifdeffery on a CMSIS header in an aarch32 support file
to decide if the current target has some feature, for instance -- that
sort of thing doesn't *have* to come from DT.

At the same time, we don't want to encourage vendor-specific hardware
configuration languages from creeping into upstream zephyr, so keep
the language strong in an effort to avoid that misinterpretation.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar b141c72a2a doc: dts: add guide to phandles
Phandles, specifier spaces, and cell names are simultaneously
extremely common and woefully underdocumented. Address that by:

- reworking our existing documentation on these subjects in
  bindings-syntax.rst, fixing missing information in the
  property syntax template as well

- adding a standalone guide which describes how all the pieces
  fit together, providing a bridge for the gap between
  DTS/bindings and C APIs

My goal is not to eventually make this a comprehensive place
where *all* specifier spaces are documented. It would be better (more
scalable, more discoverable) to improve the individual API pages to
cover the devicetree-related conventions that apply in each case.
That's a problem for someone else and another day, but we do need a
few concrete references in the DTS guides to keep the motivation
clear.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar 6780ed4a82 doc: dts: split up intro
The devicetree introduction page is too big. Split it up to improve
readability and restore maintainability. Add more section headers and
do some other rearranging now that it's more convenient to do so.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar aeabe31c60 doc: dts: bindings-syntax improvements
Generic improvements:

- clean up some language that needs adjusting
- rename some section headers and reorder some content to
  improve readability
- add a table of contents to ease search

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Marti Bolivar eb21bd36eb doc: dts: split up bindings docs
The bindings.rst page has gotten too big. Split it up into
sub-documents to improve readability and restore maintainability.

As part of this effort, move the /zephyr,user node documentation into
its own page in the guide. This page has proven extremely difficult
for users to spot in my experience, and it's meant as a convenience,
so let's make the documentation more convenient as well.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-23 07:16:04 -08:00
Stephen Stauts d4b8db792d scripts: kconfig: Add functions for array/chosen props
Expands kconfigfunctions to include checks for value existence in
an array property by nodelabel, or a chosen's boolean prop value.

Signed-off-by: Stephen Stauts <stephen.stauts@nordicsemi.no>
2023-01-10 07:10:07 -08:00
Torsten Rasmussen 7ea6031430 doc: clarify where relative devicetree files are found
Add description of how relative devicetree overlay files are picked up
from the application configuration directory.

Also add a link to detailed description of application configuration
directory.

This aligns the devicetree overlays with the description found for
Kconfig configuration files.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-11-24 15:22:21 +01:00
Torsten Rasmussen c8942afe6d doc: add commas in macro arguments to Kconfig tips
Kconfig uses commas to separate macro arguments.

Improve Kconfig documentation by describing to users how this can be
handled when using devicetree Kconfig macros when using devicetree names
which may have commas in them.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-11-22 14:55:10 -08:00
Daniel DeGrasse 6aa7194d48 scripts: kconfig: add dt_node_has_compat kconfig function
Add dt_node_has_compat kconfig function, to check if a node path has a
given compatible string while parsing kconfig files

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

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-11-21 13:03:26 +01:00
Chris Friedt bf0612cae3 doc: build: dts: bindings: discourage use of redundant: false
Aside from base properties (maybe for documentation purposes),
`required: false` should not be encouraged.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-20 13:12:44 -05:00
Gerard Marull-Paretas a76c1cf41b doc: build: dts: mention it is allowed to include at any level
This feature was not mentioned, even though it is supported.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-17 06:57:46 -06:00
Gerard Marull-Paretas 8d0eb6ce10 devicetree: remove deprecated DT_CHOSEN_*_LABEL macros
DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL and
DT_CHOSEN_ZEPHYR_ENTROPY_LABEL were deprecated a couple of releases ago,
so it is time to remove them. Note that the zephyr/devicetree/zephyr.h
is also removed, since both macros were its last content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Torsten Rasmussen f4d372bf7d doc: clarify where application can use ExternalZephyrProject_Add
The sysbuild documentation refers to CMakeLists.txt which can lead the
user to believe this call can be added to the <sample>/CMakeLists.txt
file.

This file is sourced as part of the Zephyr CMake build and not sysbuild
CMake build.

Therefore change the description to sysbuild.cmake.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-19 11:07:03 +02:00
Torsten Rasmussen 303c1eb60c sysbuild: support sample configuration of extra images
This commit introduces the possibility of a sample to locate
configuration files for extra images that are used when building with
MCUboot.

This allows use-cases where a sample, A, want to include MCUboot but has
adjustments to the default MCUboot configuration.

By adding a Kconfig fragment `<sample>/sysbuild/mcuboot.conf`, then that
fragment will be used together with the default configuration for
MCUboot.

It is also possible to completely replace the MCUboot configuration.
This is done by creating `<sample>/sysbuild/mcuboot/` folder.
This folder will then be used as the `APPLICATION_CONFIG_DIR` when
building MCUboot.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-18 14:13:27 +02:00
Gregory Shue cfcf630184 build: Overlay build vars expand ${ZEPHYR_<module>_MODULE_DIR}
Support referencing module directories by name in CONF_FILE,
OVERLAY_CONFIG, and DTC_OVERLAY_FILE so that projects can reference
overlay files in arbitrary modules.

Verified by passing all the following tests:
  ./scripts/twister -T tests/cmake/overlays/

Fixes #41830

Signed-off-by: Gregory Shue <gregory.shue@legrand.us>
2022-10-13 12:04:38 +02:00
Maureen Helm e73c363346 scripts: edtlib: gen_defines: Add model name macros based on compat
Follow up to 5b5aa6ebba adding model name
and existence macros for all compatibles of a node that match an entry
in vendor prefixes.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-07 11:48:02 -07:00
Gerard Marull-Paretas fdea3c9a44 devicetree: add DT(_INST)_FOREACH_PROP_ELEM_SEP(_VARGS)
Add a new set of helpers for expanding property entries with a
separator. These macros complement DT(_INST)FOREACH_PROP_ELEM(_VARGS) by
adding the capability to expand with a custom separator between property
entries. This allows, in some cases, to re-use existing macros (e.g.
DT_PROP_BY_IDX) without creating an auxiliary macro that just appends a
separator. Example:

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

Before:

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

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

After:

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

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-03 10:11:18 +02:00
Gerard Marull-Paretas 1f98c24fc2 doc: dts: macros.bnf: add missing DT_FOREACH_PROP_ELEM entries
Entries for DT_FOREACH_PROP_ELEM_(VARGS) internal helpers were missing.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-03 10:11:18 +02:00
Stephanos Ioannidis 14d3c7338e doc: kconfig: Update outdated links to Kconfig documentation
This commit updates the outdated links to the Kconfig documentation in
the Linux kernel repository with those from the official documentation.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-29 12:20:14 +02:00
Stephanos Ioannidis 45a8ace1f3 doc: Use inline literals
Use inline literals where applicable -- especially for the words that
contain `@`; otherwise, Sphinx will think it is an email address.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-29 12:20:14 +02:00
Martí Bolívar 88ef844bd8 doc: dts: fix reference table of contents generation
Commit 6e9a43be79 ("doc: move DTS under Build/Configuration systems
section") made it so that the internal organization of the API
reference page is no longer visible to users. This means users have to
scroll around looking for macros they need, instead of being able to
look for a section that looks relevant and reading just that.

Fix it by restoring the independent toctree for DT reference material
with an appropriate maxdepth, and adding a local table of contents in
the reference page.

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

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Maureen Helm 5b5aa6ebba scripts: gen_defines: Add vendor name macros based on vendor prefixes
Adds vendor name and existence macros for all compatibles of a node that
match an entry in the vendor prefixes file.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-09-01 14:53:55 -07:00
Gerard Marull-Paretas fff9ecbc7f devicetree: add DT_(INST_)FOREACH_CHILD(_STATUS_OKAY)_SEP(_VARGS)
It is frequent to see in Devicetree code constructs like:

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

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

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

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

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

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

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Kumar Gala f1660f4d51 edtlib: allow const arrays
Allow for having array types (array, uint8-array, string-array) be const.
This would allow for something like:

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

To be supported.

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

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-25 18:11:27 -07:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Martí Bolívar 6ff802b336 doc: zephyr_cmake_package: fix obsolete text
Update the documentation on the files in the two zephyr cmake packages
we have in tree to remove references to obsolete files, and add
references to missing files.

Fixes: #48047

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-19 12:09:22 +02:00
Kevin Townsend 0e560bf8e9 doc: build: dts: Remove refs to label property
Removes references to the label property in devicetree, replacing
them with node label where appropriate.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
2022-08-18 19:50:39 -05:00