From 882855d5df2f7c64ebb88bd4b8b24726105b3188 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 23 Jun 2023 20:16:53 +0000 Subject: [PATCH] soc: adsp: cmake: fix sign.py when CONFIG_KERNEL_BIN_NAME is used This fixes the build error below reported in #59603 when CONFIG_KERNEL_BIN_NAME is used. ``` zephyr/zephyr.elf', needed by 'zephyr/zephyr.ri', missing and no known rule to make it ``` Note `rimage` is _still_ optional. As before, to avoid using rimage: - make sure it's not in your PATH - west config -d rimage.path Signed-off-by: Marc Herbert --- soc/xtensa/intel_adsp/common/CMakeLists.txt | 22 +++++++++++++++++++++ soc/xtensa/nxp_adsp/CMakeLists.txt | 13 ++++++++++++ 2 files changed, 35 insertions(+) diff --git a/soc/xtensa/intel_adsp/common/CMakeLists.txt b/soc/xtensa/intel_adsp/common/CMakeLists.txt index ff09b1e4ea8092..c903d1838d785d 100644 --- a/soc/xtensa/intel_adsp/common/CMakeLists.txt +++ b/soc/xtensa/intel_adsp/common/CMakeLists.txt @@ -117,10 +117,30 @@ endif() # west sign + +# Warning: most of this code is for now duplicated in +# soc/xtensa/nxp_adsp/CMakeLists.txt + add_custom_target(zephyr.ri ALL DEPENDS ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri ) +# Copy/normalize any weird ${CONFIG_KERNEL_BIN_NAME}.elf to zephyr.elf +# if different. +# +# zephyr.elf is not used by sign.py when a boot.mod bootloader is used +# BUT others do expect a zephyr.elf file: smex, debuggers, CI and other +# automation, etc. (Ab)using Kconfig to merely rename a file seems like +# a bad idea because it breaks build directory expectations. +if(NOT CONFIG_KERNEL_BIN_NAME STREQUAL "zephyr") + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf + DEPENDS ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} + ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf +) +endif() + # If some of your board(s) need to override default rimage parameters # then you can define WEST_SIGN_OPTS in boards/my/board/board.cmake. # Example: @@ -146,4 +166,6 @@ add_custom_command( COMMAND west sign --if-tool-available --tool rimage --build-dir ${CMAKE_BINARY_DIR} ${WEST_SIGN_OPTS} DEPENDS gen_modules ${CMAKE_BINARY_DIR}/zephyr/boot.mod ${CMAKE_BINARY_DIR}/zephyr/main.mod + # Not necessary but see above + ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf ) diff --git a/soc/xtensa/nxp_adsp/CMakeLists.txt b/soc/xtensa/nxp_adsp/CMakeLists.txt index 2ca5d100db3fb7..9099fec88cd905 100644 --- a/soc/xtensa/nxp_adsp/CMakeLists.txt +++ b/soc/xtensa/nxp_adsp/CMakeLists.txt @@ -8,10 +8,23 @@ add_subdirectory(common) # west sign # See detailed comments in soc/xtensa/intel_adsp/common/CMakeLists.txt +# where most of this code is for now duplicated. + add_custom_target(zephyr.ri ALL DEPENDS ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri ) +# sign.py supports `zephyr.elf` only. Copy/normalize any weird +# ${CONFIG_KERNEL_BIN_NAME}.elf to zephyr.elf if different. +if(NOT CONFIG_KERNEL_BIN_NAME STREQUAL "zephyr") + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf + DEPENDS ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} + ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf +) +endif() + add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri COMMENT "west sign --if-tool-available --tool rimage ..."