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 <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
Grzegorz Swiderski 2023-10-09 10:48:50 +02:00 committed by Johan Hedberg
parent de85a208a0
commit 5cf5282e60

View file

@ -4049,8 +4049,8 @@ function(zephyr_linker_dts_section)
)
endif()
dt_node_exists(exists PATH ${DTS_SECTION_PATH})
if(NOT ${exists})
dt_node_has_status(okay PATH ${DTS_SECTION_PATH} STATUS okay)
if(NOT ${okay})
return()
endif()
@ -4122,14 +4122,19 @@ function(zephyr_linker_dts_memory)
return()
endif()
dt_node_exists(exists PATH ${DTS_MEMORY_PATH})
if(NOT ${exists})
dt_node_has_status(okay PATH ${DTS_MEMORY_PATH} STATUS okay)
if(NOT ${okay})
return()
endif()
dt_reg_addr(addr PATH ${DTS_MEMORY_PATH})
dt_reg_size(size PATH ${DTS_MEMORY_PATH})
dt_prop(name PATH ${DTS_MEMORY_PATH} PROPERTY "zephyr,memory-region")
if(NOT DEFINED name)
message(FATAL_ERROR "zephyr_linker_dts_memory(${ARGV0} ...) missing "
"\"zephyr,memory-region\" property"
)
endif()
zephyr_string(SANITIZE name ${name})
zephyr_linker_memory(