mcuboot, Image in the primary slot is not valid, Unable to find bootable image (2024)

I followed the course to enableMCUBOOT over BLE it is successful for the projectperipheral_lbs but not my application.

uart log;

*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Image index: 0, Swap type: none
E: Image in the primary slot is not valid!
E: Unable to find bootable image

build log:


Building peripheral
west build --build-dir /home/longqi/peripheral/build /home/longqi/peripheral --pristine --board nrf52833dk_nrf52833 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=/home/longqi/peripheral -Dmcuboot_OVERLAY_CONFIG=/home/longqi/ncs/v2.6.1/nrf/subsys/partition_manager/partition_manager_enabled.conf -Dmcuboot_secondary_app_OVERLAY_CONFIG=/home/longqi/ncs/v2.6.1/nrf/subsys/partition_manager/partition_manager_enabled.conf -DCONFIG_CORTEX_M_DEBUG_MONITOR_HOOK=y -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y -DCONFIG_SEGGER_DEBUGMON=y -DCACHED_CONF_FILE=/home/longqi/peripheral/prj.conf -DDTC_OVERLAY_FILE=/home/longqi/peripheral/nrf52833dk_nrf52833.overlay

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/longqi/peripheral
-- CMake version: 3.21.0
-- Found Python3: /home/longqi/ncs/toolchains/2be090971e/usr/local/bin/python3.9 (found suitable version "3.9.18", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/longqi/.cache/zephyr
-- Zephyr version: 3.5.99 (/home/longqi/ncs/v2.6.1/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52833dk_nrf52833
-- Found host-tools: zephyr 0.16.5 (/home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.5 (/home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk)
-- Found Dtc: /home/longqi/ncs/toolchains/2be090971e/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/longqi/ncs/v2.6.1/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833.dts
-- Found devicetree overlay: /home/longqi/peripheral/nrf52833dk_nrf52833.overlay
-- Generated zephyr.dts: /home/longqi/peripheral/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/longqi/peripheral/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/longqi/peripheral/build/zephyr/dts.cmake
Parsing /home/longqi/ncs/v2.6.1/zephyr/Kconfig
Loaded configuration '/home/longqi/ncs/v2.6.1/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833_defconfig'
Merged configuration '/home/longqi/peripheral/prj.conf'
Merged configuration '/home/longqi/peripheral/build/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to '/home/longqi/peripheral/build/zephyr/.config'
Kconfig header saved to '/home/longqi/peripheral/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/longqi/ncs/v2.6.1/zephyr/subsys/bluetooth/host/CMakeLists.txt:100 (message):
CONFIG_BT_FIXED_PASSKEY is enabled

A fixed passkey is easy to deduce during the pairing procedure, do not use in
production.


CMake Warning at /home/longqi/ncs/v2.6.1/nrf/samples/common/mcumgr_bt_ota_dfu/CMakeLists.txt:14 (message):
MCUmgr Bluetooth OTA DFU: suboptimal configuration of Bluetooth Controller
buffers. Consider using optimal values defined in the
/home/longqi/ncs/v2.6.1/nrf/samples/common/mcumgr_bt_ota_dfu/Kconfig file
for CONFIG_BT_BUF_ACL_TX_SIZE, CONFIG_BT_BUF_ACL_RX_SIZE and
CONFIG_BT_CTLR_DATA_LENGTH_MAX options


CMake Warning at /home/longqi/ncs/v2.6.1/nrf/samples/common/mcumgr_bt_ota_dfu/CMakeLists.txt:27 (message):
MCUmgr Bluetooth OTA DFU: suboptimal configuration of Bluetooth Host
buffers. Consider using optimal values defined in the
/home/longqi/ncs/v2.6.1/nrf/samples/common/mcumgr_bt_ota_dfu/Kconfig file
for CONFIG_BT_BUF_ACL_TX_SIZE, CONFIG_BT_BUF_ACL_RX_SIZE and
CONFIG_BT_L2CAP_TX_MTU options


-- Found Python3: /home/longqi/ncs/toolchains/2be090971e/usr/local/bin/python3.9 (found version "3.9.18") found components: Interpreter

=== child image mcuboot - begin ===
loading initial cache file /home/longqi/peripheral/build/mcuboot/child_image_preload.cmake
Loading Zephyr default modules (Zephyr base).
-- Application: /home/longqi/ncs/v2.6.1/bootloader/mcuboot/boot/zephyr
-- CMake version: 3.21.0
-- Found Python3: /home/longqi/ncs/toolchains/2be090971e/usr/local/bin/python3.9 (found suitable version "3.9.18", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/longqi/.cache/zephyr
-- Zephyr version: 3.5.99 (/home/longqi/ncs/v2.6.1/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52833dk_nrf52833
-- Found host-tools: zephyr 0.16.5 (/home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.5 (/home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk)
-- Found Dtc: /home/longqi/ncs/toolchains/2be090971e/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/longqi/ncs/v2.6.1/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833.dts
-- Found devicetree overlay: /home/longqi/ncs/v2.6.1/bootloader/mcuboot/boot/zephyr/app.overlay
-- Generated zephyr.dts: /home/longqi/peripheral/build/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/longqi/peripheral/build/mcuboot/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/longqi/peripheral/build/mcuboot/zephyr/dts.cmake
Parsing /home/longqi/ncs/v2.6.1/bootloader/mcuboot/boot/zephyr/Kconfig
Loaded configuration '/home/longqi/ncs/v2.6.1/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833_defconfig'
Merged configuration '/home/longqi/ncs/v2.6.1/bootloader/mcuboot/boot/zephyr/prj.conf'
Merged configuration '/home/longqi/ncs/v2.6.1/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Merged configuration '/home/longqi/peripheral/build/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to '/home/longqi/peripheral/build/mcuboot/zephyr/.config'
Kconfig header saved to '/home/longqi/peripheral/build/mcuboot/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/longqi/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/longqi/ncs/v2.6.1/nrf/lib/flash_patch/CMakeLists.txt:8 (message):

----------------------------------------------------------
--- WARNING: To maintain the integrity of secure boot, ---
--- enable CONFIG_DISABLE_FLASH_PATCH in production. ---
----------------------------------------------------------


-- Using ccache: /home/longqi/ncs/toolchains/2be090971e/usr/bin/ccache
MCUBoot bootloader key file: /home/longqi/ncs/v2.6.1/bootloader/mcuboot/root-rsa-2048.pem
-- Configuring done
-- Generating done
-- Build files have been written to: /home/longqi/peripheral/build/mcuboot
=== child image mcuboot - end ===

CMake Warning at /home/longqi/ncs/v2.6.1/nrf/modules/mcuboot/CMakeLists.txt:382 (message):

---------------------------------------------------------
--- WARNING: Using default MCUBoot key, it should not ---
--- be used for production. ---
---------------------------------------------------------

-- Using ccache: /home/longqi/ncs/toolchains/2be090971e/usr/bin/ccache
CMake Warning at /home/longqi/ncs/v2.6.1/nrf/cmake/partition_manager.cmake:79 (message):

---------------------------------------------------------------------
--- WARNING: Using a bootloader without pm_static.yml. ---
--- There are cases where a deployed product can consist of ---
--- multiple images, and only a subset of these images can be ---
--- upgraded through a firmware update mechanism. In such cases, ---
--- the upgradable images must have partitions that are static ---
--- and are matching the partition map used by the bootloader ---
--- programmed onto the device. ---
---------------------------------------------------------------------

Call Stack (most recent call first):
/home/longqi/ncs/v2.6.1/zephyr/cmake/modules/kernel.cmake:248 (include)
/home/longqi/ncs/v2.6.1/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
/home/longqi/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
/home/longqi/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:4 (find_package)


-- Configuring done
-- Generating done
-- Build files have been written to: /home/longqi/peripheral/build
-- west build: building application
[1/274] Preparing syscall dependency handling

[5/274] Generating include/generated/version.h
-- Zephyr version: 3.5.99 (/home/longqi/ncs/v2.6.1/zephyr), build: v3.5.99-ncs1-1
[1/271] Preparing syscall dependency handling

[4/271] Generating include/generated/version.h
-- Zephyr version: 3.5.99 (/home/longqi/ncs/v2.6.1/zephyr), build: v3.5.99-ncs1-1
[271/271] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 32670 B 48 KB 66.47%
RAM: 23808 B 128 KB 18.16%
IDT_LIST: 0 GB 32 KB 0.00%
[256/274] Building C object CMakeFiles/app.dir/src/main.c.obj
/home/longqi/peripheral/src/main.c:192:13: warning: 'device_name_set' defined but not used [-Wunused-function]
192 | static void device_name_set(uint8_t *name, uint8_t length)
| ^~~~~~~~~~~~~~~
[266/274] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 229048 B 232960 B 98.32%
RAM: 60564 B 128 KB 46.21%
IDT_LIST: 0 GB 32 KB 0.00%
[269/274] Generating ../../zephyr/app_update.bin
image.py: sign the payload
[271/274] Generating ../../zephyr/app_signed.hex
image.py: sign the payload
[272/274] Generating ../../zephyr/app_test_update.hex
image.py: sign the payload
[274/274] Generating zephyr/merged.hex
* Terminal will be reused by tasks, press any key to close it.

prj.conf

# Increased stack due to settings API usage

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048


CONFIG_BT=y


# Enable logging

CONFIG_LOG=y


CONFIG_BT_SMP=y

CONFIG_BT_SIGNING=y

CONFIG_BT_PERIPHERAL=y

CONFIG_BT_DIS=y

CONFIG_BT_ATT_PREPARE_COUNT=5

CONFIG_BT_PRIVACY=n

CONFIG_BT_DEVICE_NAME="p1"

CONFIG_BT_DEVICE_APPEARANCE=833

CONFIG_BT_DEVICE_NAME_DYNAMIC=y

CONFIG_BT_DEVICE_NAME_MAX=65


CONFIG_BT_DIS_MANUF="xnergy"

CONFIG_BT_DIS_MODEL="phoenix"


CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

CONFIG_BT_SETTINGS=y

CONFIG_FLASH=y

CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_FLASH_MAP=y

CONFIG_NVS=y

CONFIG_SETTINGS=y


CONFIG_BT_PERIPHERAL_PREF_MIN_INT=8

CONFIG_BT_PERIPHERAL_PREF_MAX_INT=8

CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=200

CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y


CONFIG_BT_BUF_ACL_RX_SIZE=251

CONFIG_BT_BUF_ACL_TX_SIZE=251

CONFIG_BT_BUF_CMD_TX_SIZE=255

CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255


CONFIG_BT_L2CAP_TX_MTU=247


CONFIG_BT_USER_DATA_LEN_UPDATE=y

CONFIG_BT_CTLR_DATA_LENGTH_MAX=251


CONFIG_BT_MAX_CONN=2


CONFIG_BT_FIXED_PASSKEY=y


CONFIG_UART_CONSOLE=n

CONFIG_RTT_CONSOLE=y


CONFIG_SERIAL=y

CONFIG_UART_ASYNC_API=y


CONFIG_MAIN_STACK_SIZE=2048


CONFIG_SENSOR=y


CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

mcuboot, Image in the primary slot is not valid, Unable to find bootable image (2024)
Top Articles
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 6193

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.