Skip to content

Commit

Permalink
scripts: extract_dts_includes: Generate defines for chosen props
Browse files Browse the repository at this point in the history
Generate a set of defines that convey if a given chosen property is used
or not.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak authored and carlescufi committed Dec 17, 2018
1 parent 07eb5d1 commit 2cc957e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/devices/dts/device_tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ The full set of Zephyr-specific ``chosen`` nodes follows:
* - ``zephyr,uart-mcumgr``
- :option:`CONFIG_UART_MCUMGR_ON_DEV_NAME`

As chosen properties tend to be related to software configuration, it can be
useful for the build system to know if a chosen property was defined. We
generate a define for each chosen property, for example:

``zephyr,flash`` will generate: ``#define DT_CHOSEN_ZEPHYR_FLASH 1``

Adding support for device tree in drivers
*****************************************
Expand Down
8 changes: 8 additions & 0 deletions scripts/dts/extract_dts_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@ def main():

defs = generate_node_definitions()

# Add DT_CHOSEN_<X> defines to generated files
for c in sorted(chosen.keys()):
chosen_def = 'DT_CHOSEN_' + convert_string_to_label(c)
load_defs = {
chosen_def: "1",
}
insert_defs('chosen', load_defs, {})

# generate config and include file
generate_keyvalue_file(args.keyvalue[0])

Expand Down

0 comments on commit 2cc957e

Please sign in to comment.