From 3a97f30688a44710524eaade6c3e80e607ac8819 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 17 Dec 2025 07:52:10 +0000 Subject: [PATCH] [nrf fromlist] scripts: dts: gen_dts_cmake: Output compatibles for partitions Seemingly partitions (fixed-partitions and fixed-subpartitions) have no properties when the edt file is loaded, work around this issue by outputting compatibles for nodes that have them but have no properties Upstream PR #: 101171 Signed-off-by: Jamie McCrae --- scripts/dts/gen_dts_cmake.py | 40 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/scripts/dts/gen_dts_cmake.py b/scripts/dts/gen_dts_cmake.py index a8a2c3df611f..4ba2c1009dea 100755 --- a/scripts/dts/gen_dts_cmake.py +++ b/scripts/dts/gen_dts_cmake.py @@ -118,21 +118,31 @@ def main(): for label in node.labels: cmake_props.append(f'"DT_NODELABEL|{label}" "{node.path}"') - for item in node.props: - # We currently do not support phandles for edt -> cmake conversion. - if "phandle" not in node.props[item].type: - if "array" in node.props[item].type: - # Convert array to CMake list - cmake_value = '' - for val in node.props[item].val: - cmake_value = f'{cmake_value}{val};' - else: - cmake_value = node.props[item].val - - # Encode node's property 'item' as a CMake target property - # with a name like 'DT_PROP||'. - cmake_prop = f'DT_PROP|{node.path}|{item}' - cmake_props.append(f'"{cmake_prop}" "{escape(cmake_value)}"') + if node.props: + for item in node.props: + # We currently do not support phandles for edt -> cmake conversion. + if "phandle" not in node.props[item].type: + if "array" in node.props[item].type: + # Convert array to CMake list + cmake_value = '' + for val in node.props[item].val: + cmake_value = f'{cmake_value}{val};' + else: + cmake_value = node.props[item].val + + # Encode node's property 'item' as a CMake target property + # with a name like 'DT_PROP||'. + cmake_prop = f'DT_PROP|{node.path}|{item}' + cmake_props.append(f'"{cmake_prop}" "{escape(cmake_value)}"') + elif node.compats and ('fixed-partitions' in node.compats or \ + 'fixed-subpartitions' in node.compats): + # Manually output compatibles for fixed partition/subpartition nodes as they have no + # properties + cmake_value = '' + for val in node.compats: + cmake_value = f'{cmake_value}{val};' + cmake_prop = f'DT_PROP|{node.path}|compatible' + cmake_props.append(f'"{cmake_prop}" "{escape(cmake_value)}"') for comp in node.compats: compatible2paths[comp].append(node.path)