Skip to content

Commit 5cf5282

Browse files
57300jhedberg
authored andcommitted
cmake: extensions: Check status of "zephyr,memory-region" DT nodes
Functions `zephyr_linker_dts_memory()` and `zephyr_linker_dts_section()` are described as defining a memory region or section based on a DT node, as long as it "exists and has status okay". However, only the existence of the node is actually checked, using `dt_node_exists()`. To fix that, employ `dt_node_has_status()` instead, which can check both conditions. The status check is important, because both functions require the given DT node to contain a `zephyr,memory-region` property (not to be confused with the compatible string). This property is required by the associated binding as well, but required properties can be omitted from nodes which don't have status "okay". In those cases, edtlib won't raise an error, and neither should CMake, because those nodes should be ignored. Speaking of that property, add a missing error check for it as a bonus (tucked behind the status check, of course). Signed-off-by: Grzegorz Swiderski <[email protected]>
1 parent de85a20 commit 5cf5282

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cmake/modules/extensions.cmake

+9-4
Original file line numberDiff line numberDiff line change
@@ -4049,8 +4049,8 @@ function(zephyr_linker_dts_section)
40494049
)
40504050
endif()
40514051

4052-
dt_node_exists(exists PATH ${DTS_SECTION_PATH})
4053-
if(NOT ${exists})
4052+
dt_node_has_status(okay PATH ${DTS_SECTION_PATH} STATUS okay)
4053+
if(NOT ${okay})
40544054
return()
40554055
endif()
40564056

@@ -4122,14 +4122,19 @@ function(zephyr_linker_dts_memory)
41224122
return()
41234123
endif()
41244124

4125-
dt_node_exists(exists PATH ${DTS_MEMORY_PATH})
4126-
if(NOT ${exists})
4125+
dt_node_has_status(okay PATH ${DTS_MEMORY_PATH} STATUS okay)
4126+
if(NOT ${okay})
41274127
return()
41284128
endif()
41294129

41304130
dt_reg_addr(addr PATH ${DTS_MEMORY_PATH})
41314131
dt_reg_size(size PATH ${DTS_MEMORY_PATH})
41324132
dt_prop(name PATH ${DTS_MEMORY_PATH} PROPERTY "zephyr,memory-region")
4133+
if(NOT DEFINED name)
4134+
message(FATAL_ERROR "zephyr_linker_dts_memory(${ARGV0} ...) missing "
4135+
"\"zephyr,memory-region\" property"
4136+
)
4137+
endif()
41334138
zephyr_string(SANITIZE name ${name})
41344139

41354140
zephyr_linker_memory(

0 commit comments

Comments
 (0)