Partition manager and FOTA

Hi,

I have a nrf52833 with MCUBoot and BLE, I am using NCS v3.0.1. 

I need also a custom NVS partition to store user data, so i create a data_partition for this purpose.

Now to the fun part, i am having trouble with the partition manager when i'm using FOTA. My project works fine but when i wanted to add FOTA, i got an flash error everytime i try an update. After digging a bit, i understand that is a write error in the smcuboot_secondary partition. 

The mcuboot_secondary partition start at address 0x41800 and don't respect the 0x1000 page size of the nrf52833 which explain why i couldn't update (cf pm_static.yml.working)

app:
  address: 0x7200
  end_address: 0x41800
  region: flash_primary
  size: 0x3a600
data_storage:
  address: 0x7c000
  end_address: 0x7e000
  placement:
    align:
      start: 0x1000
  region: flash_primary
  size: 0x2000
mcuboot:
  address: 0x0
  end_address: 0x7000
  placement:
    align:
      end: 0x1000
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x7000
mcuboot_pad:
  address: 0x7000
  end_address: 0x7200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x7000
  end_address: 0x41800
  orig_span: &id001
  - app
  - mcuboot_pad
  region: flash_primary
  sharers: 0x1
  size: 0x3a800
  span: *id001
mcuboot_primary_app:
  address: 0x7200
  end_address: 0x41800
  orig_span: &id002
  - app
  region: flash_primary
  size: 0x3a600
  span: *id002
mcuboot_secondary:
  address: 0x41800
  end_address: 0x7c000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x1000
  region: flash_primary
  share_size:
  - mcuboot_primary
  size: 0x3a800
settings_storage:
  address: 0x7e000
  end_address: 0x80000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x2000
sram_primary:
  address: 0x20000000
  end_address: 0x20020000
  region: sram_primary
  size: 0x20000

I edit the file to place it at 0x41000 and decrease the image size (cf pm_static.yml.not_working)

EMPTY_0:
  address: 0x7b000
  end_address: 0x7c000
  region: flash_primary
  size: 0x1000
app:
  address: 0x7200
  end_address: 0x41000
  region: flash_primary
  size: 0x39e00
data_storage:
  address: 0x7c000
  end_address: 0x7e000
  region: flash_primary
  size: 0x2000
mcuboot:
  address: 0x0
  end_address: 0x7000
  region: flash_primary
  size: 0x7000
mcuboot_pad:
  address: 0x7000
  end_address: 0x7200
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x7000
  end_address: 0x41000
  orig_span: &id001
  - app
  - mcuboot_pad
  region: flash_primary
  size: 0x3a000
  span: *id001
mcuboot_primary_app:
  address: 0x7200
  end_address: 0x41000
  orig_span: &id002
  - app
  region: flash_primary
  size: 0x39e00
  span: *id002
mcuboot_secondary:
  address: 0x41000
  end_address: 0x7b000
  region: flash_primary
  size: 0x3a000
settings_storage:
  address: 0x7e000
  end_address: 0x80000
  region: flash_primary
  size: 0x2000
sram_primary:
  address: 0x20000000
  end_address: 0x20020000
  region: sram_primary
  size: 0x20000

But it don't boot anymore, i can't get anything on RTT or serial or anything that make me believe the bootloader successfully start the image.

Do you know what is happening ? 

Best regards,

Nathan

Parents
  • Hello Nathan,

    he mcuboot_secondary partition start at address 0x41800 and don't respect the 0x1000 page size of the nrf52833 which explain why i couldn't update (cf pm_static.yml.working)

    Just to confirm, this start address was set automatically in your build, and not by you? I'm also surprised it didn't adhere to the flash page aligment requirement.

    Please try the following: 

    - delete the build folder

    - make a backup of your pm static file, then create a new one that only defines the settings_storage and data_storage partition. This allows the PM to dynamically create the rest.

    - Try DFU again.

    Best regards,

    Vidar 

  • Hi Vidar,

    I did let the partition manager do it's job and then copy the content of partitions.yml to my pm_static.yml

    Following your instructions, i only define settings_storage and data_storage in my pm_static.yml like this : 

    settings_storage:
      placement:
        before: 
        - end
      region: flash_primary
      size: 0x2000
    data_storage:
      placement:
        before: 
        - settings_storage
      region: flash_primary
      size: 0x2000

    And i got this build error : 

    (.venv) C:\Workspace\001_CAPTAIN_BLINK\blinker\blinker.git>west build -p -b board_blinker app --sysbuild
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: C:/Workspace/.venv/Scripts/python.exe (found suitable version "3.13.7", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/.cache
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: board_blinker, qualifiers: nrf52833
    Parsing C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/sysbuild/Kconfig
    Loaded configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/_sysbuild/empty.conf'
    Merged configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/sysbuild.conf'
    Configuration saved to 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/zephyr/.config'
    Kconfig header saved to 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/_sysbuild/autoconf.h'
    -- 
       *****************************
       * Running CMake for mcuboot *
       *****************************
    
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Workspace/001_CAPTAIN_BLINK/blinker/bootloader/mcuboot/boot/zephyr
    -- CMake version: 4.1.0
    -- Found Python3: C:/Workspace/.venv/Scripts/python.exe (found suitable version "3.13.7", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/.cache
    -- Zephyr version: 4.0.99 (C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: board_blinker, qualifiers: nrf52833
    -- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
    -- Found host-tools: zephyr 0.17.0 (C:/Users/natha/zephyr-sdk-0.17.0)
    -- Found toolchain: zephyr 0.17.0 (C:/Users/natha/zephyr-sdk-0.17.0)
    -- Found Dtc: C:/Users/natha/AppData/Local/Microsoft/WinGet/Packages/oss-winget.dtc_Microsoft.Winget.Source_8wekyb3d8bbwe/usr/bin/dtc.exe (found suitable version "1.6.1", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/boards/captain/board_blinker_nrf52833.dts
    -- Found devicetree overlay: C:/Workspace/001_CAPTAIN_BLINK/blinker/bootloader/mcuboot/boot/zephyr/app.overlay
    -- Generated zephyr.dts: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/zephyr.dts
    -- Generated pickled edt: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/edt.pickle
    -- Generated zephyr.dts: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/include/generated/zephyr/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/dts.cmake
    CMake Warning at C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/cmake/modules/dts.cmake:428 (message):
      dtc raised one or more warnings:
    
    
      C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/zephyr.dts:56.25-61.5:
      Warning (unique_unit_address_if_enabled): /soc/clock@40000000: duplicate
      unit-address (also used in node /soc/power@40000000)
    
    
      C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/zephyr.dts:361.21-365.5:
      Warning (unique_unit_address_if_enabled): /soc/acl@4001e000: duplicate
      unit-address (also used in node /soc/flash-controller@4001e000)
    
    Call Stack (most recent call first):
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:18 (find_package)
    
    
    
    warning: Deprecated symbol DEPRECATED_UART_NRFX_UARTE_LEGACY_SHIM is enabled.
    
    Parsing C:/Workspace/001_CAPTAIN_BLINK/blinker/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/boards/captain/board_blinker_nrf52833_defconfig'
    Merged configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/sysbuild/mcuboot.conf'
    Merged configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/.config.sysbuild'
    Configuration saved to 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/.config'
    Kconfig header saved to 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/include/generated/zephyr/autoconf.h'
    -- Found GnuLd: c:/users/natha/zephyr-sdk-0.17.0/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd.exe (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: C:/Users/natha/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at C:/Workspace/001_CAPTAIN_BLINK/blinker/nrf/lib/flash_patch/CMakeLists.txt:8 (message):
    
    
            ----------------------------------------------------------
            --- WARNING: To maintain the integrity of secure boot, ---
            --- enable CONFIG_DISABLE_FLASH_PATCH in production.   ---
            ----------------------------------------------------------
    
    
    MCUBoot bootloader key file: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/../keys/private_key.pem
    -- Configuring done (9.2s)
    -- Generating done (0.6s)
    -- Build files have been written to: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot
    -- 
       *************************
       * Running CMake for app *
       *************************
    
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app
    -- CMake version: 4.1.0
    -- Found Python3: C:/Workspace/.venv/Scripts/python.exe (found suitable version "3.13.7", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/.cache
    -- Zephyr version: 4.0.99 (C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: board_blinker, qualifiers: nrf52833
    -- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
    -- Found host-tools: zephyr 0.17.0 (C:/Users/natha/zephyr-sdk-0.17.0)
    -- Found toolchain: zephyr 0.17.0 (C:/Users/natha/zephyr-sdk-0.17.0)
    -- Found Dtc: C:/Users/natha/AppData/Local/Microsoft/WinGet/Packages/oss-winget.dtc_Microsoft.Winget.Source_8wekyb3d8bbwe/usr/bin/dtc.exe (found suitable version "1.6.1", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/boards/captain/board_blinker_nrf52833.dts
    -- Generated zephyr.dts: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/zephyr.dts
    -- Generated pickled edt: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/edt.pickle
    -- Generated zephyr.dts: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/include/generated/zephyr/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/dts.cmake
    CMake Warning at C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/cmake/modules/dts.cmake:428 (message):
      dtc raised one or more warnings:
    
    
      C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/zephyr.dts:55.25-60.5:
      Warning (unique_unit_address_if_enabled): /soc/clock@40000000: duplicate
      unit-address (also used in node /soc/power@40000000)
    
    
      C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/zephyr.dts:360.21-364.5:
      Warning (unique_unit_address_if_enabled): /soc/acl@4001e000: duplicate
      unit-address (also used in node /soc/flash-controller@4001e000)
    
    Call Stack (most recent call first):
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:8 (find_package)
    
    
    
    warning: Experimental symbol UART_BT is enabled.
    
    Parsing C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/Kconfig
    Loaded configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/boards/captain/board_blinker_nrf52833_defconfig'
    Merged configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/prj.conf'
    Merged configuration 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/.config.sysbuild'
    Configuration saved to 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/.config'
    Kconfig header saved to 'C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/include/generated/zephyr/autoconf.h'
    -- Found GnuLd: c:/users/natha/zephyr-sdk-0.17.0/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd.exe (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: C:/Users/natha/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    =========== Generating psa_crypto_config ===============
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Backup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
    Backup: CONFIG_MBEDTLS_THREADING: False
    Backup: CONFIG_MBEDTLS_THREADING_ALT: True
    =========== Checkpoint: backup ===============
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Restore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
    Restore: CONFIG_MBEDTLS_THREADING: False
    Restore: CONFIG_MBEDTLS_THREADING_ALT: True
    =========== End psa_crypto_config ===============
    =========== Generating psa_crypto_library_config ===============
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Backup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: True
    Backup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
    Backup: CONFIG_MBEDTLS_THREADING: False
    Backup: CONFIG_MBEDTLS_THREADING_ALT: True
    =========== Checkpoint: backup ===============
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Restore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: True
    Restore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
    Restore: CONFIG_MBEDTLS_THREADING: False
    Restore: CONFIG_MBEDTLS_THREADING_ALT: True
    =========== End psa_crypto_library_config ===============
    -- Including signing script: C:/Workspace/001_CAPTAIN_BLINK/blinker/nrf/cmake/sysbuild/image_signing.cmake
    -- Configuring done (9.8s)
    -- Generating done (0.9s)
    -- Build files have been written to: C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app
    -- Found partition manager static configuration : C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/pm_static.yml
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    Traceback (most recent call last):
      File "C:\Workspace\001_CAPTAIN_BLINK\blinker\nrf\scripts\partition_manager.py", line 1054, in <module>
        main()
        ~~~~^^
      File "C:\Workspace\001_CAPTAIN_BLINK\blinker\nrf\scripts\partition_manager.py", line 1034, in main
        solution.update(solve_region(pm_config, region, region_config,
                        ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                     static_config, regions))
                                     ^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Workspace\001_CAPTAIN_BLINK\blinker\nrf\scripts\partition_manager.py", line 977, in solve_region
        get_region_config(partitions, region_config, static_partitions, system_reqs=pm_config)
        ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Workspace\001_CAPTAIN_BLINK\blinker\nrf\scripts\partition_manager.py", line 764, in get_region_config
        solve_complex_region(pm_config, start, size, placement_strategy, region_name, device, static_conf, dp, system_reqs)
        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Workspace\001_CAPTAIN_BLINK\blinker\nrf\scripts\partition_manager.py", line 861, in solve_complex_region
        get_dynamic_area_start_and_size(static_conf, start, size, dp)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Workspace\001_CAPTAIN_BLINK\blinker\nrf\scripts\partition_manager.py", line 708, in get_dynamic_area_start_and_size
        starts = {last_address} | {config['address']
                                   ~~~~~~^^^^^^^^^^^
    KeyError: 'address'
    CMake Error at C:/Workspace/001_CAPTAIN_BLINK/blinker/nrf/cmake/sysbuild/partition_manager.cmake:181 (message):
      Partition Manager failed, aborting.  Command:
      C:/Workspace/.venv/Scripts/python.exe;C:/Workspace/001_CAPTAIN_BLINK/blinker/nrf/scripts/partition_manager.py;--input-files;C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/modules/nrf/subsys/partition_manager/pm.yml.settings;C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/mcuboot/zephyr/include/generated/pm.yml;C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/app/zephyr/include/generated/pm.yml;--regions;sram_primary;flash_primary;--output-partitions;C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/partitions.yml;--output-regions;C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/build/regions.yml;--static-config;C:/Workspace/001_CAPTAIN_BLINK/blinker/blinker.git/app/pm_static.yml;--sram_primary-size;0x20000;--sram_primary-base-address;0x20000000;--sram_primary-placement-strategy;complex;--sram_primary-dynamic-partition;sram_primary;--flash_primary-size;0x80000;--flash_primary-base-address;0x0;--flash_primary-placement-strategy;complex;--flash_primary-device;flash_controller;--flash_primary-default-driver-kconfig;CONFIG_SOC_FLASH_NRF
    Call Stack (most recent call first):
      C:/Workspace/001_CAPTAIN_BLINK/blinker/nrf/cmake/sysbuild/partition_manager.cmake:620 (partition_manager)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/nrf/sysbuild/CMakeLists.txt:779 (include)
      cmake/modules/sysbuild_extensions.cmake:583 (nrf_POST_CMAKE)
      cmake/modules/sysbuild_extensions.cmake:583 (cmake_language)
      cmake/modules/sysbuild_images.cmake:46 (sysbuild_module_call)
      cmake/modules/sysbuild_default.cmake:21 (include)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      C:/Workspace/001_CAPTAIN_BLINK/blinker/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
      template/CMakeLists.txt:10 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' -DWEST_PYTHON=C:/Workspace/.venv/Scripts/python.exe '-BC:\Workspace\001_CAPTAIN_BLINK\blinker\blinker.git\build' -GNinja -DBOARD=board_blinker '-SC:\Workspace\001_CAPTAIN_BLINK\blinker\zephyr\share\sysbuild' '-DAPP_DIR:PATH=C:\Workspace\001_CAPTAIN_BLINK\blinker\blinker.git\app'

  • pm_static.yml 

    data_storage:
      address: 0x7c000
      region: flash_primary
      size: 0x2000
    settings_storage:
      address: 0x7e000
      region: flash_primary
      size: 0x2000

    partitions.yml from build

    EMPTY_0:
      address: 0x7b000
      end_address: 0x7c000
      placement:
        after:
        - mcuboot_secondary
      region: flash_primary
      size: 0x1000
    app:
      address: 0x7200
      end_address: 0x41000
      region: flash_primary
      size: 0x39e00
    data_storage:
      address: 0x7c000
      end_address: 0x7e000
      region: flash_primary
      size: 0x2000
    mcuboot:
      address: 0x0
      end_address: 0x7000
      placement:
        align:
          end: 0x1000
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x7000
    mcuboot_pad:
      address: 0x7000
      end_address: 0x7200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x7000
      end_address: 0x41000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x3a000
      span: *id001
    mcuboot_primary_app:
      address: 0x7200
      end_address: 0x41000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x39e00
      span: *id002
    mcuboot_secondary:
      address: 0x41000
      end_address: 0x7b000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
        align_next: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x3a000
    settings_storage:
      address: 0x7e000
      end_address: 0x80000
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20020000
      region: sram_primary
      size: 0x20000

    Look correct but same issue the firmware don't seem to start.

  • I don't see anything wrong with the memory layout now. Do you have logging over UART available on this board? If not, can you try to attach the debugger to see where it the bootloader it hangs?

  • I managed to launch a debug session with J-Link GDB server v8.18, you will find the log below : 

    JLinkGDBServerCL: SEGGER J-Link GDB Server V8.18 Command Line Version
    JLinkGDBServerCL: 
    JLinkGDBServerCL: JLinkARM.dll V8.18 (DLL compiled Mar  5 2025 14:42:43)
    JLinkGDBServerCL: 
    JLinkGDBServerCL: -----GDB Server start settings-----
    JLinkGDBServerCL: GDBInit file:                  none
    JLinkGDBServerCL: GDB Server Listening port:     57790
    JLinkGDBServerCL: SWO raw output listening port: 2332
    JLinkGDBServerCL: Terminal I/O port:             2333
    JLinkGDBServerCL: Accept remote connection:      localhost only
    JLinkGDBServerCL: Generate logfile:              off
    JLinkGDBServerCL: Verify download:               off
    JLinkGDBServerCL: Init regs on start:            off
    JLinkGDBServerCL: Silent mode:                   on
    JLinkGDBServerCL: Single run mode:               on
    JLinkGDBServerCL: Target connection timeout:     0 ms
    JLinkGDBServerCL: ------J-Link related settings------
    JLinkGDBServerCL: J-Link Host interface:         USB
    JLinkGDBServerCL: J-Link script:                 none
    JLinkGDBServerCL: J-Link settings file:          none
    JLinkGDBServerCL: ------Target related settings------
    JLinkGDBServerCL: Target device:                 nRF52833_xxAA
    JLinkGDBServerCL: Target device parameters:      none
    JLinkGDBServerCL: Target interface:              SWD
    JLinkGDBServerCL: Target interface speed:        4000kHz
    JLinkGDBServerCL: Target endian:                 little
    JLinkGDBServerCL: 
    =thread-group-added,id="i1"
    =cmd-param-changed,param="pagination",value="off"
    main () at C:/Workspace/001_CAPTAIN_BLINK/blinker/bootloader/mcuboot/boot/zephyr/main.c:611
    611	        FIH_PANIC;
    Execute debugger commands using "-exec <command>" or "`<command>", for example "-exec info registers" or "`info registers" will list registers in use (when GDB is the debugger)
    
    

    It appears to be stuck in the FIH_PANIC but i don't know why


    int main(void)
    {
        struct boot_rsp rsp;
        int rc;
        FIH_DECLARE(fih_rc, FIH_FAILURE);
    
        MCUBOOT_WATCHDOG_SETUP();
        MCUBOOT_WATCHDOG_FEED();
    
    #if !defined(MCUBOOT_DIRECT_XIP)
        BOOT_LOG_INF("Starting bootloader");
    #else
        BOOT_LOG_INF("Starting Direct-XIP bootloader");
    #endif
    
    #ifdef CONFIG_MCUBOOT_INDICATION_LED
        /* LED init */
        io_led_init();
    #endif
    
        os_heap_init();
    
        ZEPHYR_BOOT_LOG_START();
    
        (void)rc;
    
        mcuboot_status_change(MCUBOOT_STATUS_STARTUP);
    
    #ifdef CONFIG_BOOT_SERIAL_ENTRANCE_GPIO
        if (io_detect_pin() &&
                !io_boot_skip_serial_recovery()) {
            boot_serial_enter();
        }
    #endif
    
    #ifdef CONFIG_BOOT_SERIAL_PIN_RESET
        if (io_detect_pin_reset()) {
            boot_serial_enter();
        }
    #endif
    
    #if defined(CONFIG_BOOT_USB_DFU_GPIO)
        if (io_detect_pin()) {
    #ifdef CONFIG_MCUBOOT_INDICATION_LED
            io_led_set(1);
    #endif
    
            mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_ENTERED);
    
            rc = usb_enable(NULL);
            if (rc) {
                BOOT_LOG_ERR("Cannot enable USB");
            } else {
                BOOT_LOG_INF("Waiting for USB DFU");
                wait_for_usb_dfu(K_FOREVER);
                BOOT_LOG_INF("USB DFU wait time elapsed");
            }
        }
    #elif defined(CONFIG_BOOT_USB_DFU_WAIT)
        rc = usb_enable(NULL);
        if (rc) {
            BOOT_LOG_ERR("Cannot enable USB");
        } else {
            BOOT_LOG_INF("Waiting for USB DFU");
    
            mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_WAITING);
    
            wait_for_usb_dfu(K_MSEC(CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS));
            BOOT_LOG_INF("USB DFU wait time elapsed");
    
            mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_TIMED_OUT);
        }
    #endif
    
    #ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU
        /* Initialize the boot console, so we can already fill up our buffers while
         * waiting for the boot image check to finish. This image check, can take
         * some time, so it's better to reuse thistime to already receive the
         * initial mcumgr command(s) into our buffers
         */
        rc = boot_console_init();
        int timeout_in_ms = CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT;
        uint32_t start = k_uptime_get_32();
    
    #ifdef CONFIG_MCUBOOT_INDICATION_LED
        io_led_set(1);
    #endif
    #endif
    
        BOOT_HOOK_GO_CALL_FIH(boot_go_hook, FIH_BOOT_HOOK_REGULAR, fih_rc, &rsp);
        if (FIH_EQ(fih_rc, FIH_BOOT_HOOK_REGULAR)) {
            FIH_CALL(boot_go, fih_rc, &rsp);
        }
    
    #ifdef CONFIG_BOOT_SERIAL_BOOT_MODE
        if (io_detect_boot_mode()) {
            /* Boot mode to stay in bootloader, clear status and enter serial
             * recovery mode
             */
            boot_serial_enter();
        }
    #endif
    
    #ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU
        timeout_in_ms -= (k_uptime_get_32() - start);
        if( timeout_in_ms <= 0 ) {
            /* at least one check if time was expired */
            timeout_in_ms = 1;
        }
        boot_serial_check_start(&boot_funcs,timeout_in_ms);
    
    #ifdef CONFIG_MCUBOOT_INDICATION_LED
        io_led_set(0);
    #endif
    #endif
    
        if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
            BOOT_LOG_ERR("Unable to find bootable image");
    
            mcuboot_status_change(MCUBOOT_STATUS_NO_BOOTABLE_IMAGE_FOUND);
    
    #ifdef CONFIG_BOOT_SERIAL_NO_APPLICATION
            /* No bootable image and configuration set to remain in serial
             * recovery mode
             */
            boot_serial_enter();
    #elif defined(CONFIG_BOOT_USB_DFU_NO_APPLICATION)
            rc = usb_enable(NULL);
            if (rc && rc != -EALREADY) {
                BOOT_LOG_ERR("Cannot enable USB");
            } else {
                BOOT_LOG_INF("Waiting for USB DFU");
                wait_for_usb_dfu(K_FOREVER);
            }
    #endif
    
            FIH_PANIC;
        }
    
    #ifdef CONFIG_BOOT_RAM_LOAD
        BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
                     rsp.br_hdr->ih_load_addr);
    #else
        BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
                     rsp.br_image_off);
    #endif
    
        BOOT_LOG_INF("Image version: v%d.%d.%d", rsp.br_hdr->ih_ver.iv_major,
                                                        rsp.br_hdr->ih_ver.iv_minor,
                                                        rsp.br_hdr->ih_ver.iv_revision);
    
    #if defined(MCUBOOT_DIRECT_XIP)
        BOOT_LOG_INF("Jumping to the image slot");
    #else
        BOOT_LOG_INF("Jumping to the first image slot");
    #endif
    
        mcuboot_status_change(MCUBOOT_STATUS_BOOTABLE_IMAGE_FOUND);
    
    #if USE_PARTITION_MANAGER && CONFIG_FPROTECT
    
    #ifdef PM_S1_ADDRESS
    /* MCUBoot is stored in either S0 or S1, protect both */
    #define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_S0_ADDRESS)
    #define PROTECT_ADDR PM_S0_ADDRESS
    #else
    /* There is only one instance of MCUBoot */
    #define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_MCUBOOT_ADDRESS)
    #define PROTECT_ADDR PM_MCUBOOT_ADDRESS
    #endif
    
        rc = fprotect_area(PROTECT_ADDR, PROTECT_SIZE);
    
        if (rc != 0) {
            BOOT_LOG_ERR("Protect mcuboot flash failed, cancel startup.");
            while (1)
                ;
        }
    
    #if defined(CONFIG_SOC_NRF5340_CPUAPP) && defined(PM_CPUNET_B0N_ADDRESS) && defined(CONFIG_PCD_APP)
    #if defined(PM_TFM_SECURE_ADDRESS)
        pcd_lock_ram(false);
    #else
        pcd_lock_ram(true);
    #endif
    #endif
    #endif /* USE_PARTITION_MANAGER && CONFIG_FPROTECT */
    
        ZEPHYR_BOOT_LOG_STOP();
    
        do_boot(&rsp);
    
        mcuboot_status_change(MCUBOOT_STATUS_BOOT_FAILED);
    
        BOOT_LOG_ERR("Never should get here");
        while (1)
            ;
    }

  • Hello,

    This indicates that the bootloader did not find a bootable image. Did you program the merged.hex file generated by your build which contain both the application and bootloader?

  • Hi Vidar,

    Sorry for the late answer, i found and fix my problem.

    The issue was my image was more than 95% occupency and it is a know issue with mcuboot. As soon as i turn off log for saving memory, the program was booting as expected.

    I close this ticket.

Reply Children
Related