@@ -23,11 +23,19 @@ project(uicr)
2323function (parse_kconfig_value config_file config_name output_var)
2424 file (STRINGS ${config_file} config_lines ENCODING "UTF-8" )
2525 foreach (line ${config_lines} )
26+ # Match quoted strings like CONFIG_FOO="value"
2627 if ("${line} " MATCHES "^${config_name} =\" (.*)\" $" )
2728 set (${output_var} "${CMAKE_MATCH_1} " PARENT_SCOPE)
2829 return ()
2930 endif ()
31+ # Match unquoted values like CONFIG_FOO=y or CONFIG_FOO=n
32+ if ("${line} " MATCHES "^${config_name} =(.*)$" )
33+ set (${output_var} "${CMAKE_MATCH_1} " PARENT_SCOPE)
34+ return ()
35+ endif ()
3036 endforeach ()
37+ # If not found, return empty (including "# CONFIG_FOO is not set" case)
38+ set (${output_var} "" PARENT_SCOPE)
3139endfunction ()
3240
3341# Function to compute partition absolute address and size from devicetree
@@ -131,8 +139,9 @@ if(CONFIG_GEN_UICR_GENERATE_PERIPHCONF)
131139 parse_kconfig_value(${_dir} /zephyr/.config CONFIG_KERNEL_BIN_NAME kernel_bin_name)
132140 set (kernel_elf_path ${_dir} /zephyr/${kernel_bin_name} .elf)
133141
134- # Check if this is secondary firmware by looking for the marker file
135- if (EXISTS ${_dir} /is_secondary_firmware.txt)
142+ # Check if this is secondary firmware by reading the Kconfig from .config
143+ parse_kconfig_value(${_dir} /zephyr/.config CONFIG_IS_IRONSIDE_SE_SECONDARY_IMAGE is_secondary)
144+ if (is_secondary STREQUAL "y" )
136145 list (APPEND secondary_periphconf_elfs ${kernel_elf_path} )
137146 else ()
138147 list (APPEND periphconf_elfs ${kernel_elf_path} )
0 commit comments