Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCUBoot image signing will fail in a docker container without west being installed #86438

Open
ckhardin opened this issue Feb 27, 2025 · 1 comment · May be fixed by #86439
Open

MCUBoot image signing will fail in a docker container without west being installed #86438

ckhardin opened this issue Feb 27, 2025 · 1 comment · May be fixed by #86439
Assignees
Labels
area: Build System area: MCUBoot bug The issue is a bug, or the PR is fixing a bug

Comments

@ckhardin
Copy link

ckhardin commented Feb 27, 2025

Describe the bug

For a project we are dockerizing the build for a zephyr chip using an out-of-tree application and board, but this bug was really found thru code inspection. We had west installed on the host but we didn't install it in docker build as we weren't using it and just calling cmake directly.

To Reproduce

Ensure west is not installed

pip3 uninstall west

Then we configured our build with an out-of-tree board and application this should be broken in-tree as well - note, this wants to use a sys build because mcuboot is included and just signed.

cmake -GNinja -B build -DAPP_DIR=myapplications/app -DBOARD=myboard -DSB_CONFIG_BOOTLOADER_MCUBOOT=y share/sysbuild
cmake --build build

Expected behavior
Build should complete

Logs and console output

   *************************
   * Running CMake for app *
   *************************

Loading Zephyr default modules (Zephyr base).
-- Application: /Volumes/Workspace/mcu-canopener/firmware/applications/app
-- CMake version: 3.28.3

… snip snip …

-- Including signing script: /Volumes/Workspace/mcu-canopener/firmware/zephyr/cmake/mcuboot.cmake
CMake Error at /Volumes/Workspace/mcu-canopener/firmware/zephyr/cmake/mcuboot.cmake:37 (message):
  Can't sign images for MCUboot: west not found.  To fix, install west and
  ensure it's on PATH.
Call Stack (most recent call first):
  /Volumes/Workspace/mcu-canopener/firmware/zephyr/cmake/mcuboot.cmake:248 (zephyr_mcuboot_tasks)
  /Volumes/Workspace/mcu-canopener/firmware/zephyr/CMakeLists.txt:1999 (include)


-- Configuring incomplete, errors occurred!
CMake Error at cmake/modules/sysbuild_extensions.cmake:514 (message):
  CMake configure failed for Zephyr project: app

  Location: /Volumes/Workspace/mcu-canopener/firmware/applications/app
Call Stack (most recent call first):
  cmake/modules/sysbuild_images.cmake:20 (ExternalZephyrProject_Cmake)
  cmake/modules/sysbuild_default.cmake:20 (include)
  /Volumes/Workspace/mcu-canopener/firmware/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
  /Volumes/Workspace/mcu-canopener/firmware/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  /Volumes/Workspace/mcu-canopener/firmware/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
  template/CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!
FAILED: sysbuild-app-prefix/src/sysbuild-app-stamp/sysbuild-app-configure /Volumes/Workspace/mcu-canopener/build/firmware/sysbuild-app-prefix/src/sysbuild-app-stamp/sysbuild-app-configure 
cd /Volumes/Workspace/mcu-canopener/build/firmware/sysbuild-app && /usr/bin/cmake -E env ZEPHYR_BASE=/Volumes/Workspace/mcu-canopener/firmware/zephyr /usr/bin/cmake "-DZEPHYR_MODULES:STRING=/Volumes/Workspace/mcu-canopener/firmware/bootloader/mcuboot;/Volumes/Workspace/mcu-canopener/firmware/modules/hal/cmsis;/Volumes/Workspace/mcu-canopener/firmware/modules/hal/stm32;/Volumes/Workspace/mcu-canopener/firmware/modules/crypto/mbedtls" -DAPP_DIR:PATH=/Volumes/Workspace/mcu-canopener/firmware/applications/app -DBOARD_ROOT:PATH=/Volumes/Workspace/mcu-canopener/firmware -DBOARD:STRING=identifier_f413zh -B /Volumes/Workspace/mcu-canopener/build/firmware/sysbuild-app -S /Volumes/Workspace/mcu-canopener/firmware/zephyr/share/sysbuild && /usr/bin/cmake -E touch /Volumes/Workspace/mcu-canopener/build/firmware/sysbuild-app-prefix/src/sysbuild-app-stamp/sysbuild-app-configure
ninja: build stopped: subcommand failed.

Environment (please complete the following information):

  • OS: MacOS
  • Toolchain: Zephyr SDK in a Docker Container
  • Version: 4.0.0

Additional context

After code inspection - this commit stood out

commit c952f09a797e0b77a131b776daac25316a06051f
Author: Jamie McCrae <[email protected]>
Date:   Wed Sep 25 11:06:45 2024 +0100

    cmake: mcuboot: Use imgtool instead of west for signing
    
    Uses imgtool directly to sign images instead of calling west sign,
    this also removes the MCUBOOT_CMAKE_WEST_SIGN_PARAMS Kconfig option
    as this has no effect
    
    Signed-off-by: Jamie McCrae <[email protected]>

Because reading up the mcuboot.cmake there is nothing using WEST now and so when it is removed the build succeeds as expected.

diff --git a/cmake/mcuboot.cmake b/cmake/mcuboot.cmake
index 2767af807c1..8626dd1c259 100644
--- a/cmake/mcuboot.cmake
+++ b/cmake/mcuboot.cmake
@@ -32,11 +32,6 @@ function(zephyr_mcuboot_tasks)
     endif()
   endif()
 
-  if(NOT WEST)
-    # This feature requires west.
-    message(FATAL_ERROR "Can't sign images for MCUboot: west not found. To fix, install west and ensure it's on PATH.")
-  endif()
-
   foreach(file keyfile keyfile_enc)
     if(NOT "${${file}}" STREQUAL "")
       if(NOT IS_ABSOLUTE "${${file}}")
@ckhardin ckhardin added the bug The issue is a bug, or the PR is fixing a bug label Feb 27, 2025
Copy link

Hi @ckhardin! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

ckhardin added a commit to ckhardin/zephyr that referenced this issue Feb 27, 2025
As of c952f09 the calls to west
sign were replaced with imgtool and this check is not relevant. As
it stands since west is optional - it is possible to complete a
signed build without west being installed if this check is removed.

Fixes: zephyrproject-rtos#86438
Signed-off-by: Charles Hardin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System area: MCUBoot bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants