From edfe5a653e63a26d2fc946dc762c5f376467d190 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 29 Jan 2020 06:33:41 +0100 Subject: [PATCH] dts: gen_defines.py: Save final devicetree to zephyr/zephyr.dts Add a '--dts-out ' flag to gen_defines.py that saves the final devicetree to , in DTS format, using the new EDT.dts_source attribute. Handy to have available as a debugging aid. Unused otherwise. Also write a dummy .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 .dts_compiled"). Fixes: #22272 Signed-off-by: Ulf Magnusson --- cmake/dts.cmake | 6 ++++++ scripts/dts/gen_defines.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cmake/dts.cmake b/cmake/dts.cmake index eb7382207b0..459f82fc7bb 100644 --- a/cmake/dts.cmake +++ b/cmake/dts.cmake @@ -198,6 +198,7 @@ if(SUPPORTS_DTS) --bindings-dirs ${DTS_ROOT_BINDINGS} --conf-out ${DEVICETREE_CONF} --header-out ${DEVICETREE_UNFIXED_H} + --dts-out ${PROJECT_BINARY_DIR}/zephyr.dts # As a debugging aid ) execute_process( @@ -209,6 +210,11 @@ if(SUPPORTS_DTS) message(FATAL_ERROR "new extractor failed with return code: ${ret}") 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() file(WRITE ${DEVICETREE_UNFIXED_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */") endif(SUPPORTS_DTS) diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index 049dd6c032c..cc15ca88b80 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -37,6 +37,10 @@ def main(): except edtlib.EDTError as 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") header_file = open(args.header_out, "w", encoding="utf-8") @@ -87,6 +91,9 @@ def parse_args(): help="path to write header to") parser.add_argument("--conf-out", required=True, 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()