From 0ab31abca654b4d3f3618c9f408cb20432b04df8 Mon Sep 17 00:00:00 2001 From: Andrey Borisovich Date: Thu, 4 May 2023 15:02:17 +0200 Subject: [PATCH] LMDK: fixed rimage and key paths and discovery Path to rimage and private key had been failing to be used while provided in form of relative path using dots. Changed how rimage is discovered in the scripts: * rimage is searched for using find_program with paths and hints provided * changed RIMAGE_COMMAND to RIMAGE_INSTALL_DIR so end-user may specify directory where rimage executable is placed. It will be used by find_program. * If RIMAGE_INSTALL_DIR is not provided, find_program will try to search for rimage in the directory where SOF project installs it (west_dir/build-rimage). * Updated README.md with instructions on how to build: - simplified configure and build commands - updated explanations on how to use RIMAGE_INSTALL_DIR - added information on how to use toolchain file * private key path was parsed incorrectly when provided windows path style using backslashes. It was passed to rimage as is resulting in the invalid path as the last slash was made by rimage as forward slash. Added path normalization what fixed the problem. Signed-off-by: Andrey Borisovich --- lmdk/README.md | 18 ++++++++++-------- lmdk/cmake/build.cmake | 14 ++++++++++++++ lmdk/cmake/config.cmake | 7 ------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lmdk/README.md b/lmdk/README.md index 5d8b4b3037c2..874171826189 100644 --- a/lmdk/README.md +++ b/lmdk/README.md @@ -5,11 +5,13 @@ To build dummy loadable library execute: cd libraries/dummy - mkdir build - cd build - - cmake -DRIMAGE_COMMAND="/path/to/rimage" -DSIGNING_KEY="/path/to/signing/key.pem" .. - cmake --build . - -Here RIMAGE_COMMAND is path to rimage executable binary, SIGNING_KEY is path to -signing key for rimage. + cmake -B build -G -DRIMAGE_INSTALL_DIR="path/where/rimage/executable/is" -DSNIGNING_KEY="path/to/key" + cd --build build + + +Here RIMAGE_INSTALL_DIR is a path to directory where rimage executable is, SIGNING_KEY is a path to +signing key for rimage. If RIMAGE_INSTALL_DIR is not provided, rimage will be searched for in the directory +where SOF project installs it. Dummy module sets up toolchain file in the project file. +However, in your library you can select toolchain file in the configure step command: + + cmake -B build -G --toolchain "../../cmake/xtensa-toolchain.cmake" -DSNIGNING_KEY="path/to/key" diff --git a/lmdk/cmake/build.cmake b/lmdk/cmake/build.cmake index f7a26a754498..e3182f596b06 100644 --- a/lmdk/cmake/build.cmake +++ b/lmdk/cmake/build.cmake @@ -46,6 +46,20 @@ endforeach() set(RIMAGE_OUTPUT_FILE ${PROJECT_NAME}_noextmft) set(OUTPUT_FILE ${PROJECT_NAME}.bin) +if(RIMAGE_INSTALL_DIR) + cmake_path(ABSOLUTE_PATH RIMAGE_INSTALL_DIR BASE_DIRECTORY ${CMAKE_SOURCE_DIR} NORMALIZE) +endif() + +# Create a hint - rimage may be installed to directory where SOF project installs it +cmake_path(APPEND SOF_BASE "../build-rimage" OUTPUT_VARIABLE RIMAGE_SOF_INSTALL_DIR) +cmake_path(NORMAL_PATH RIMAGE_SOF_INSTALL_DIR) +cmake_path(ABSOLUTE_PATH SIGNING_KEY BASE_DIRECTORY ${CMAKE_SOURCE_DIR} NORMALIZE) + +find_program(RIMAGE_COMMAND NAMES rimage + PATHS "${RIMAGE_INSTALL_DIR}" + HINTS "${RIMAGE_SOF_INSTALL_DIR}" + REQUIRED) + add_custom_target(${PROJECT_NAME}_target ALL DEPENDS ${MODULES_LIST} COMMAND ${RIMAGE_COMMAND} -k ${SIGNING_KEY} -f 2.0.0 -b 1 -o ${RIMAGE_OUTPUT_FILE} -c ${TOML} -e ${MODULES_LIST} diff --git a/lmdk/cmake/config.cmake b/lmdk/cmake/config.cmake index 2137aad44408..5c7305c05133 100644 --- a/lmdk/cmake/config.cmake +++ b/lmdk/cmake/config.cmake @@ -1,11 +1,4 @@ -if(NOT DEFINED RIMAGE_COMMAND) - message(FATAL_ERROR - " Please define RIMAGE_COMMAND: path to rimage executable.\n" - " E.g. using cmake -DRIMAGE_COMMAND=/path/rimage command line parameter." - ) -endif() - if(NOT DEFINED SIGNING_KEY) message(FATAL_ERROR " Please define SIGNING_KEY: path to signing key for rimage.\n"