Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/arm/lpcxpresso54114/pre_dt_board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2019, NXP
# SPDX-License-Identifier: Apache-2.0

# Suppress "simple_bus_reg" on LPC boards as all GPIO ports use the same register.
list(APPEND EXTRA_DTC_FLAGS "-Wno-simple_bus_reg")
5 changes: 5 additions & 0 deletions boards/arm/lpcxpresso55s69/pre_dt_board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2019, NXP
# SPDX-License-Identifier: Apache-2.0

# Suppress "simple_bus_reg" on LPC boards as all GPIO ports use the same register.
list(APPEND EXTRA_DTC_FLAGS "-Wno-simple_bus_reg")
3 changes: 3 additions & 0 deletions cmake/app/boilerplate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ set(CMAKE_CXX_COMPILER_FORCED 1)

include(${ZEPHYR_BASE}/cmake/host-tools.cmake)

# Include board specific device-tree flags before parsing.
include(${BOARD_DIR}/pre_dt_board.cmake OPTIONAL)

# DTS should be close to kconfig because CONFIG_ variables from
# kconfig and dts should be available at the same time.
#
Expand Down
1 change: 1 addition & 0 deletions cmake/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ if(SUPPORTS_DTS)

set(CMD_NEW_EXTRACT ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/dts/gen_defines.py
--dts ${BOARD}.dts.pre.tmp
--dtc-flags '${EXTRA_DTC_FLAGS}'
--bindings-dirs ${DTS_ROOT_BINDINGS}
--conf-out ${DEVICETREE_CONF}
--header-out ${DEVICETREE_UNFIXED_H}
Expand Down
8 changes: 8 additions & 0 deletions doc/guides/dts/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ file. It includes the generated :file:`include/devicetree_unfixed.h` and
Do not include the generated C headers from the build directory directly.
Include :file:`devicetree.h` instead.

Since some boards may need special instructions for the device tree compiler
(e.g. warning suppression), create a file named ``pre_dt_board.cmake`` inside
the board's folder and add the extra flags inside.

.. code-block:: cmake
list(APPEND EXTRA_DTC_FLAGS "-Wno-simple_bus_reg")
Generated macros
================

Expand Down
14 changes: 11 additions & 3 deletions scripts/dts/edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
TYPE_PHANDLE, TYPE_PHANDLES_AND_NUMS
from grutils import Graph


dtc_flags = ""

#
# Public classes
#
Expand Down Expand Up @@ -776,6 +779,8 @@ class Node:
The flash controller for the node. Only meaningful for nodes representing
flash partitions.
"""
global dtc_flags

@property
def name(self):
"See the class docstring"
Expand All @@ -797,9 +802,12 @@ def unit_addr(self):

addr = _translate(addr, self._node)

if self.regs and self.regs[0].addr != addr:
self.edt._warn("unit-address and first reg (0x{:x}) don't match "
"for {}".format(self.regs[0].addr, self.name))
# This code is redundant, it checks the same thing as simple_bus_reg in
# dtc, we disable it in python if it's suppressed in dtc.
if "-Wno-simple_bus_reg" not in dtc_flags:
if self.regs and self.regs[0].addr != addr:
self.edt._warn("unit-address and first reg (0x{:x}) don't match "
"for {}".format(self.regs[0].addr, self.name))

return addr

Expand Down
2 changes: 2 additions & 0 deletions scripts/dts/gen_defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def main():
conf_file = open(args.conf_out, "w", encoding="utf-8")
header_file = open(args.header_out, "w", encoding="utf-8")
flash_area_num = 0
edtlib.dtc_flags = args.dtc_flags

write_top_comment(edt)

Expand Down Expand Up @@ -89,6 +90,7 @@ def parse_args():

parser = argparse.ArgumentParser()
parser.add_argument("--dts", required=True, help="DTS file")
parser.add_argument("--dtc-flags", help="extra device tree parameters")
parser.add_argument("--bindings-dirs", nargs='+', required=True,
help="directory with bindings in YAML format, "
"we allow multiple")
Expand Down