Skip to content

Commit

Permalink
soc: adsp: cmake: fix sign.py when CONFIG_KERNEL_BIN_NAME is used
Browse files Browse the repository at this point in the history
This fixes the build error below reported in zephyrproject-rtos#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 <marc.herbert@intel.com>
  • Loading branch information
marc-hb committed Jun 23, 2023
1 parent 4c45bd5 commit 882855d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions soc/xtensa/intel_adsp/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
)
13 changes: 13 additions & 0 deletions soc/xtensa/nxp_adsp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..."
Expand Down

0 comments on commit 882855d

Please sign in to comment.