From 5cf5282e60ba0a9df91690a4a08a5900bca7b818 Mon Sep 17 00:00:00 2001 From: Grzegorz Swiderski Date: Mon, 9 Oct 2023 10:48:50 +0200 Subject: [PATCH] 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 --- cmake/modules/extensions.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 0c79947cd37982..061ed7747c1eaf 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -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(