dts: gen_defines.py: Save final devicetree to zephyr/zephyr.dts

Add a '--dts-out <file>' flag to gen_defines.py that saves the final
devicetree to <file>, in DTS format, using the new EDT.dts_source
attribute.

Handy to have available as a debugging aid. Unused otherwise.

Also write a dummy <BOARD>.dts_compiled file that tells people to look
at zephyr.dts, for people that might be used to that file. It was
removed in commit 8d8b06978c ("dts: Remove generation of
<BOARD>.dts_compiled").

Fixes: #22272

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
Ulf Magnusson 2020-01-29 06:33:41 +01:00 committed by Kumar Gala
commit edfe5a653e
2 changed files with 13 additions and 0 deletions

View file

@ -198,6 +198,7 @@ if(SUPPORTS_DTS)
--bindings-dirs ${DTS_ROOT_BINDINGS} --bindings-dirs ${DTS_ROOT_BINDINGS}
--conf-out ${DEVICETREE_CONF} --conf-out ${DEVICETREE_CONF}
--header-out ${DEVICETREE_UNFIXED_H} --header-out ${DEVICETREE_UNFIXED_H}
--dts-out ${PROJECT_BINARY_DIR}/zephyr.dts # As a debugging aid
) )
execute_process( execute_process(
@ -209,6 +210,11 @@ if(SUPPORTS_DTS)
message(FATAL_ERROR "new extractor failed with return code: ${ret}") message(FATAL_ERROR "new extractor failed with return code: ${ret}")
endif() endif()
# A file that used to be generated by 'dtc'. zephyr.dts is the new
# equivalent. Will be removed in Zephyr 2.3.
file(WRITE ${PROJECT_BINARY_DIR}/${BOARD}.dts_compiled
"See zephyr.dts for the final merged devicetree.")
else() else()
file(WRITE ${DEVICETREE_UNFIXED_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */") file(WRITE ${DEVICETREE_UNFIXED_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */")
endif(SUPPORTS_DTS) endif(SUPPORTS_DTS)

View file

@ -37,6 +37,10 @@ def main():
except edtlib.EDTError as e: except edtlib.EDTError as e:
sys.exit(f"devicetree error: {e}") sys.exit(f"devicetree error: {e}")
# Save merged DTS source, as a debugging aid
with open(args.dts_out, "w", encoding="utf-8") as f:
print(edt.dts_source, file=f)
conf_file = open(args.conf_out, "w", encoding="utf-8") conf_file = open(args.conf_out, "w", encoding="utf-8")
header_file = open(args.header_out, "w", encoding="utf-8") header_file = open(args.header_out, "w", encoding="utf-8")
@ -87,6 +91,9 @@ def parse_args():
help="path to write header to") help="path to write header to")
parser.add_argument("--conf-out", required=True, parser.add_argument("--conf-out", required=True,
help="path to write configuration file to") help="path to write configuration file to")
parser.add_argument("--dts-out", required=True,
help="path to write merged DTS source code to (e.g. "
"as a debugging aid)")
return parser.parse_args() return parser.parse_args()