Custom MCUboot DFU bootloader nrf Connect

Hi,

We want to modify the bootloader process on MCUboot. To avoid someone having to press and hold a button the entire time on our custom boards we want as a minimum to set a pin high to ensure it doesn't turn off.

I was successfully able to try this using SYS_INIT and a custom board.c file by following this ticket  Modify the MCUboot's booting process however, the problem I've found with this method is it sets the pin high regardless of whether the unit goes through the bootloader or not - which makes sense. In some instances we want to indicate the bootloader is running by switching on an LED just as user feedback something's going on. So a potential flicker of the LED (e.g. switching it off ASAP in the main app) would be inappropriate for our devices. 

It looks therefore that the best way to achieve what we want is by modifying the bootloader and I've gone down a ticket rabbit hole through here  How to create custom MCUBOOT for DFU which ends up leading to this blog archive:  nRF Connect SDK Tutorial - Part 2 | NCS v1.3.0 

is there a more up to date and recommended way of customising the mcuboot? Our aim would be to have a file within the main project directory that handles the main functions of the boot but adds in our own "switch on this pin" code.

Thanks.

BR,
Richard

Parents
  • Hi,

    To avoid someone having to press and hold a button the entire time on our custom boards

    Could you explain this some more? Why does a use need to press and hold a button?

  • Hi Sigurd,

    On most of our boards we have a soft power on that maintains the power after being physically switched on via a button. The board is therefore either on by pressing and holding the button, or on if a pin is held high.

    BR,
    Richard

  • That looks promising. Where does the handler for mcuboot_status_change need to be placed?

    I've added it in the main project directory at the moment (which I suspected would be wrong), I'm getting this in the build log:

    c:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(loader.c.obj): in function `context_boot_go':
    C:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\src\loader.c:2112: undefined reference to `mcuboot_status_change'
    collect2.exe: error: ld returned 1 exit status

    I added 

    CONFIG_MCUBOOT_ACTION_HOOKS=y into my mcuboot.conf file which is within a child_image folder.
  • Hi,

    I haven't tested it, but I'm thinking that you in CMakeLists.txt in boards/arm/your_board , can add something like this:

    if(CONFIG_MCUBOOT)
    zephyr_library()
    zephyr_library_sources(my_mcuboot_hook.c)
    endif()

    Then place a my_mcuboot_hook.c in boards/arm/your_board

    Might need to include these:

    #include "bootutil/boot_hooks.h"
    #include "bootutil/mcuboot_status.h"

  • Thank you, I've got that running. Unfortunately, not exactly how I was expecting.

    I realise I didn't mention we're doing the upgrade via bluetooth and nrf Connect google play store app. The lack of MCUBOOT_STATUS references to BLE types seem to indicate those status updates aren't supported?

    In which case, it's basically back to the initial query on the best process for this?

    I've added this:

    void mcuboot_status_change(mcuboot_status_type_t status)
    {
    	printk("mcuboot status: %d \n", status);
    }

    and my terminal output is below (emphasis mine). Perhaps my misunderstanding, but I wouldn't expect the 'normal' startup process to hit the status of 1 (MCUBOOT_STATUS_UPGRADING)?

    *** Booting Zephyr OS build v3.1.99-ncs1-1 ***
    I: Starting bootloader
    mcuboot status: 0
    I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    mcuboot status: 1
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot
    *** Booting Zephyr OS build v3.1.99-ncs1-1 ***
    Bluetooth initialized
    Advertising successfully started
    build time: Nov 30 2022 12:23:46


    uart:~$ Connected
    [00:00:26.260,498] <inf> mcuboot_util: Swap type: none
    [00:00:26.260,772] <inf> mcuboot_util: Swap type: none
    [00:00:26.412,780] <inf> mcuboot_util: Swap type: none
    [00:00:26.412,872] <inf> mcuboot_util: Swap type: none
    [00:00:34.729,522] <inf> mcumgr_img_mgmt: Erased 0x39000 bytes of image slot
    [00:00:34.875,823] <inf> mcumgr_img_mgmt: Erased 0x1000 bytes of image slot trailer
    uart:~$ *** Booting Zephyr OS build v3.1.99-ncs1-1 ***
    I: Starting bootloader
    mcuboot status: 0
    I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
    I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    mcuboot status: 1
    I: Starting swap using move algorithm.
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot
    *** Booting Zephyr OS build v3.1.99-ncs1-1 ***
    Bluetooth initialized
    Advertising successfully started
    build time: Nov 30 2022 12:01:21


    uart:~$ Connected
    [00:00:01.227,844] <inf> mcuboot_util: Swap type: revert
    [00:00:01.227,905] <inf> mcuboot_util: Swap type: revert
    [00:00:01.228,546] <inf> mcuboot_util: Swap type: none
    [00:00:01.228,820] <inf> mcuboot_util: Swap type: none
    uart:~$

  • Hi,

    I checked this with the developer, MCUBOOT_STATUS_UPGRADING does not necessarily mean that it is upgrading the image, just that it is at the point of mcuboot where upgrades take place... https://github.com/zephyrproject-rtos/mcuboot/blob/main/boot/bootutil/src/loader.c#L2059

    to make it only run if an upgrade is present, it could be placed in an if()

    PS: It might be getting cut off due to booting the application but the status does change prior to the application booting: mcuboot_status_change(MCUBOOT_STATUS_BOOTABLE_IMAGE_FOUND);

  • to make it only run if an upgrade is present, it could be placed in an if()

    Excuse my ignorance, but which part exactly would be placed in an if, and what's being checked?

    I'm already doing this:

    if(CONFIG_MCUBOOT)
    zephyr_library()
    zephyr_library_sources(my_mcuboot_hook.c)
    endif()

    BR,
    Richard

Reply Children
  • Richard said:
    Excuse my ignorance, but which part exactly would be placed in an if, and what's being checked?

    Something like this at https://github.com/zephyrproject-rtos/mcuboot/blob/main/boot/bootutil/src/loader.c#L2059

    if(has_upgrade) {
        mcuboot_status_change(MCUBOOT_STATUS_UPGRADING);
    
    }

    Some other alternatives that might work is to use boot_perform_update_hook() instead

    https://github.com/nrfconnect/sdk-mcuboot/blob/main/boot/zephyr/hooks_sample.c

  • Our preference is to avoid editing the files in the SDK, I've done it to test it out and it has worked in the sense that the state of the pin no longer persists into the main app, however the LED i'm using to test the pin change only comes on right at the end of the DFU process during validation and not during the actual update process, this is too late.

    boot_perform_update_hook doesn't seem to work in the same way as the status change?

    Lots of warnings when the boot_hooks.h is included:

    c:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\include\bootutil\boot_hooks.h:71:40: warning: 'struct image_header' declared inside parameter list will not be visible outside of this definition or declaration
    71 | struct image_header *img_head);
    | ^~~~~~~~~~~~
    c:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\include\bootutil\boot_hooks.h:101:43: warning: 'struct flash_area' declared inside parameter list will not be visible outside of this definition or declaration
    101 | const struct flash_area *area);
    | ^~~~~~~~~~
    c:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\include\bootutil\boot_hooks.h:100:52: warning: 'struct image_header' declared inside parameter list will not be visible outside of this definition or declaration
    100 | int boot_perform_update_hook(int img_index, struct image_header *img_head,
    | ^~~~~~~~~~~~
    c:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\include\bootutil\boot_hooks.h:119:60: warning: 'struct flash_area' declared inside parameter list will not be visible outside of this definition or declaration
    119 | int boot_copy_region_post_hook(int img_index, const struct flash_area *area,
    | ^~~~~~~~~~
    c:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\include\bootutil\boot_hooks.h:137:59: warning: 'struct flash_area' declared inside parameter list will not be visible outside of this definition or declaration
    137 | int boot_serial_uploaded_hook(int img_index, const struct flash_area *area,
    | ^~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\boards\arm\nrf52840dk_nrf52840\board.c:61:52: warning: 'struct image_header' declared inside parameter list will not be visible outside of this definition or declaration
    61 | int boot_perform_update_hook(int img_index, struct image_header *img_head,
    | ^~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\boards\arm\nrf52840dk_nrf52840\board.c:61:5: error: conflicting types for 'boot_perform_update_hook'
    61 | int boot_perform_update_hook(int img_index, struct image_header *img_head,
    | ^~~~~~~~~~~~~~~~~~~~~~~~
    In file included from C:\ncs\v2.1.2\zephyr\boards\arm\nrf52840dk_nrf52840\board.c:12:
    c:\ncs\v2.1.2\bootloader\mcuboot\boot\bootutil\include\bootutil\boot_hooks.h:100:5: note: previous declaration of 'boot_perform_update_hook' was here
    100 | int boot_perform_update_hook(int img_index, struct image_header *img_head,

  • Hi,

    1)

    You might need to add this to include

    #include "bootutil/bootutil.h"

    and maybe this to CMakeLists.txt

    add_subdirectory(${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/bootutil/zephyr
                     ${CMAKE_CURRENT_BINARY_DIR}/boot/bootutil/zephyr
    )

    2)

    Another alternative, that might be suitable, is to use CONFIG_OS_MGMT_RESET_HOOK

    https://github.com/nrfconnect/sdk-zephyr/commit/d67a364ace006f16019dc4fe0bc689df2dea55f8

    Register the callback with os_mgmt_register_reset_evt_cb(). Do this in the main application

    When mcumgr requests the application to reboot(typically after a new image has been sent), you can set a GPIO high in the reset callback.

  • Using the CONFIG_OS_MGMT_RESET_HOOK happens too late as well unfortunately. Seems to occur after the image has been sent, and when it's verifying.

    The comments in the boot perform update hook section looks like it'll happen at the right time - but it's not building successfully after I include "CONFIG_BOOT_IMAGE_ACCESS_HOOKS in my mcuboot.conf file.

    Whole build log here:

    * Executing task: nRF Connect: Build [pristine]: peripheral_hr_dfu2/build_dfu2_52840 (active)

    Building peripheral_hr_dfu2
    west build --build-dir d:\WorkSpacNCS_DFU\peripheral_hr_dfu2\build_dfu2_52840 d:\WorkSpacNCS_DFU\peripheral_hr_dfu2 --pristine --board nrf52840dk_nrf52840 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="d:/WorkSpacNCS_DFU/peripheral_uart;d:/WorkSpacNCS_DFU/peripheral_hr;d:/WorkSpacNCS_DFU/ble_dfu_peripheral_lbs;d:/WorkSpacNCS_DFU/peripheral_hr_dfu2" -DCONF_FILE:STRING="d:/WorkSpacNCS_DFU/peripheral_hr_dfu2/prj.conf"

    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2
    -- Found Python3: C:/ncs/toolchains/v2.1.2/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.1.2/zephyr/.cache
    -- Zephyr version: 3.1.99 (C:/ncs/v2.1.2/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.14.1 (C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk)
    -- Found dtc: C:/ncs/toolchains/v2.1.2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.1.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Generated zephyr.dts: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/zephyr/dts.cmake
    Parsing C:/ncs/v2.1.2/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v2.1.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'd:/WorkSpacNCS_DFU/peripheral_hr_dfu2/prj.conf'
    Configuration saved to 'D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/zephyr/.config'
    Kconfig header saved to 'D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 10.3.0
    -- The CXX compiler identification is GNU 10.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/ncs/toolchains/v2.1.2/opt/bin/python.exe (found version "3.8.2") found components: Interpreter

    === child image mcuboot - begin ===
    loading initial cache file D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/ncs/v2.1.2/bootloader/mcuboot/boot/zephyr
    -- Found Python3: C:/ncs/toolchains/v2.1.2/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.1.2/zephyr/.cache
    -- Zephyr version: 3.1.99 (C:/ncs/v2.1.2/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.14.1 (C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk)
    -- Found dtc: C:/ncs/toolchains/v2.1.2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.1.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: C:/ncs/v2.1.2/nrf/modules/mcuboot/usb.overlay
    -- Found devicetree overlay: C:/ncs/v2.1.2/bootloader/mcuboot/boot/zephyr/dts.overlay
    -- Generated zephyr.dts: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/dts.cmake
    Parsing C:/ncs/v2.1.2/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v2.1.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'C:/ncs/v2.1.2/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration 'C:/ncs/v2.1.2/bootloader/mcuboot/boot/zephyr/boards/nrf52840dk_nrf52840.conf'
    Merged configuration 'C:/ncs/v2.1.2/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration 'D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/child_image/mcuboot.conf'
    Merged configuration 'D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to 'D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/.config'
    Kconfig header saved to 'D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 10.3.0
    -- The CXX compiler identification is GNU 10.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at C:/ncs/v2.1.2/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: D:\\WorkSpacNCS_DFU\\peripheral_hr_dfu2\\child_image\\priv-ecdsa.pem
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot
    === child image mcuboot - end ===

    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840
    -- west build: building application
    [1/306] Generating include/generated/version.h
    -- Zephyr version: 3.1.99 (C:/ncs/v2.1.2/zephyr), build: v3.1.99-ncs1-1
    [2/306] Creating directories for 'mcuboot_subimage'
    [3/306] No download step for 'mcuboot_subimage'
    [4/306] No update step for 'mcuboot_subimage'
    [5/306] No patch step for 'mcuboot_subimage'
    [6/306] No configure step for 'mcuboot_subimage'
    [6/306] Performing build step for 'mcuboot_subimage'
    [1/196] Generating include/generated/version.h
    -- Zephyr version: 3.1.99 (C:/ncs/v2.1.2/zephyr), build: v3.1.99-ncs1-1
    [2/196] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
    [3/196] Generating include/generated/driver-validation.h
    [4/196] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h, include/generated/otype-to-size.h
    [5/196] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
    [6/196] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
    [7/196] Generating include/generated/offsets.h
    [8/196] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/validate_base_addresses.c.obj
    [9/196] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/validate_enabled_instances.c.obj
    [10/196] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_minimal.c.obj
    [11/196] Building ASM object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/common/soc_nrf_common.S.obj
    [12/196] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/storage/flash_map/flash_map.c.obj
    [13/196] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/storage/flash_map/flash_map_layout.c.obj
    [14/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
    [15/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/assert.c.obj
    [16/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/reboot.c.obj
    [17/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/multi_heap.c.obj
    [18/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_nano.c.obj
    [19/196] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
    [20/196] Building C object zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.1.2/nrfxlib/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_abort_zephyr.c.obj
    [21/196] Building C object zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.1.2/nrfxlib/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_no_mutex_zephyr.c.obj
    [22/196] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/tracing/tracing_none.c.obj
    [23/196] Building C object zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.1.2/nrf/subsys/partition_manager/flash_map_partition_manager.c.obj
    [24/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/cpu_idle.S.obj
    [25/196] Generating linker_zephyr_pre1.cmd
    [26/196] Building C object zephyr/arch/common/CMakeFiles/isr_tables.dir/isr_tables.c.obj
    [27/196] Generating linker_zephyr_pre0.cmd
    [28/196] Building C object zephyr/arch/common/CMakeFiles/arch__common.dir/sw_isr_common.c.obj
    [29/196] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi.c.obj
    [30/196] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/irq_manage.c.obj
    [31/196] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/fatal.c.obj
    [32/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi_on_reset.S.obj
    [33/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap_helper.S.obj
    [34/196] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap.c.obj
    [35/196] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/prep_c.c.obj
    [36/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/isr_wrapper.S.obj
    [37/196] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/thread.c.obj
    [38/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault_s.S.obj
    [39/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/exc_exit.S.obj
    [40/196] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault.c.obj
    [41/196] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/irq_init.c.obj
    [42/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/reset.S.obj
    [43/196] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fpu.c.obj
    [44/196] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/scb.c.obj
    [45/196] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/vector_table.S.obj
    [46/196] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/thread_abort.c.obj
    [47/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj
    [48/196] Linking C static library zephyr\arch\common\libisr_tables.a
    [49/196] Generating zephyr/autogen-pubkey.c
    [50/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
    [51/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
    [52/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc8_sw.c.obj
    [53/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc7_sw.c.obj
    [54/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32c_sw.c.obj
    [55/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
    [56/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
    [57/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
    [58/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
    [59/196] Linking C static library zephyr\arch\arch\arm\core\aarch32\libarch__arm__core__aarch32.a
    [60/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/bitarray.c.obj
    [61/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
    [62/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
    [63/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
    [64/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
    [65/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
    [66/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
    [67/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
    [68/196] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
    [69/196] Building C object zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/arm_mpu.c.obj
    [70/196] Linking C static library zephyr\arch\common\libarch__common.a
    [71/196] Building C object CMakeFiles/app.dir/main.c.obj
    [72/196] Building C object CMakeFiles/app.dir/keys.c.obj
    [73/196] Building C object CMakeFiles/app.dir/flash_map_extended.c.obj
    [74/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/encrypted.c.obj
    [75/196] Building C object CMakeFiles/app.dir/os.c.obj
    [76/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/image_validate.c.obj
    [77/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/tlv.c.obj
    [78/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/image_rsa.c.obj
    [79/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/image_ec256.c.obj
    [80/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/bootutil_misc.c.obj
    [81/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/image_ed25519.c.obj
    [82/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/fault_injection_hardening.c.obj
    [83/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/swap_scratch.c.obj
    [84/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/swap_misc.c.obj
    [85/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/swap_move.c.obj
    [86/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/loader.c.obj
    [87/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/caps.c.obj
    [88/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/ext/mbedtls-asn1/src/platform_util.c.obj
    [89/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/ext/nrf/cc310_glue.c.obj
    [90/196] Linking C static library zephyr\libzephyr.a
    [91/196] Building C object CMakeFiles/app.dir/zephyr/autogen-pubkey.c.obj
    [92/196] Building C object CMakeFiles/app.dir/C_/ncs/v2.1.2/bootloader/mcuboot/ext/mbedtls-asn1/src/asn1parse.c.obj
    [93/196] Building C object CMakeFiles/app.dir/nrf_cleanup.c.obj
    [94/196] Building C object zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/arm_core_mpu.c.obj
    [95/196] Linking C static library zephyr\arch\arch\arm\core\aarch32\cortex_m\libarch__arm__core__aarch32__cortex_m.a
    [96/196] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/perror.c.obj
    [97/196] Generating ../../../include/generated/libc/minimal/strerror_table.h
    [98/196] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj
    [99/196] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj
    [100/196] Building C object zephyr/soc/arm/common/cortex_m/CMakeFiles/soc__arm__common__cortex_m.dir/arm_mpu_regions.c.obj
    [101/196] Building C object zephyr/soc/arm/nordic_nrf/nrf52/CMakeFiles/soc__arm__nordic_nrf__nrf52.dir/soc.c.obj
    [102/196] Building C object modules/nrf/lib/fprotect/CMakeFiles/..__nrf__lib__fprotect.dir/fprotect_acl.c.obj
    [103/196] Building C object zephyr/drivers/console/CMakeFiles/drivers__console.dir/uart_console.c.obj
    [104/196] Building C object zephyr/drivers/clock_control/CMakeFiles/drivers__clock_control.dir/clock_control_nrf.c.obj
    [105/196] Building C object zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/gpio_nrfx.c.obj
    [106/196] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
    [107/196] Building C object zephyr/drivers/flash/CMakeFiles/drivers__flash.dir/soc_flash_nrf.c.obj
    [108/196] Building C object zephyr/drivers/flash/CMakeFiles/drivers__flash.dir/flash_page_layout.c.obj
    [109/196] Building C object zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/sys_clock_init.c.obj
    [110/196] Building C object zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/nrf_rtc_timer.c.obj
    [111/196] Building C object zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/pinctrl_nrf.c.obj
    [112/196] Building C object zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/common.c.obj
    [113/196] Building C object modules/nrf/lib/fatal_error/CMakeFiles/..__nrf__lib__fatal_error.dir/fatal_error.c.obj
    [114/196] Linking C static library app\libapp.a
    [115/196] Linking C static library zephyr\arch\arch\arm\core\aarch32\mpu\libarch__arm__core__aarch32__mpu.a
    [116/196] Building C object modules/nrf/drivers/hw_cc310/CMakeFiles/..__nrf__drivers__hw_cc310.dir/hw_cc310.c.obj
    [117/196] Building C object zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj
    [118/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtoul.c.obj
    [119/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtol.c.obj
    [120/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/abort.c.obj
    [121/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/atoi.c.obj
    [122/196] Building C object zephyr/boards/boards/arm/nrf52840dk_nrf52840/CMakeFiles/boards__arm__nrf52840dk_nrf52840.dir/board.c.obj
    C:\ncs\v2.1.2\zephyr\boards\arm\nrf52840dk_nrf52840\board.c:29:12: warning: 'board_init' defined but not used [-Wunused-function]
    29 | static int board_init(void)
    | ^~~~~~~~~~
    [123/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/exit.c.obj
    [124/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/malloc.c.obj
    [125/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtoll.c.obj
    [126/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtoull.c.obj
    [127/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/bsearch.c.obj
    [128/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/qsort.c.obj
    [129/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strerror.c.obj
    [130/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strncasecmp.c.obj
    [131/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strstr.c.obj
    [132/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/string.c.obj
    [133/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/sprintf.c.obj
    [134/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strspn.c.obj
    [135/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/stdout_console.c.obj
    [136/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/fprintf.c.obj
    [137/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/math/sqrt.c.obj
    [138/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/math/sqrtf.c.obj
    [139/196] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/time/gmtime.c.obj
    [140/196] Linking C static library zephyr\lib\posix\liblib__posix.a
    [141/196] Linking C static library zephyr\soc\arm\common\cortex_m\libsoc__arm__common__cortex_m.a
    [142/196] Linking C static library zephyr\soc\arm\nordic_nrf\nrf52\libsoc__arm__nordic_nrf__nrf52.a
    [143/196] Linking C static library zephyr\boards\boards\arm\nrf52840dk_nrf52840\libboards__arm__nrf52840dk_nrf52840.a
    [144/196] Linking C static library modules\nrf\lib\fprotect\lib..__nrf__lib__fprotect.a
    [145/196] Linking C static library zephyr\drivers\clock_control\libdrivers__clock_control.a
    [146/196] Linking C static library zephyr\drivers\gpio\libdrivers__gpio.a
    [147/196] Linking C static library zephyr\drivers\console\libdrivers__console.a
    [148/196] Linking C static library zephyr\drivers\flash\libdrivers__flash.a
    [149/196] Linking C static library zephyr\drivers\timer\libdrivers__timer.a
    [150/196] Linking C static library zephyr\drivers\serial\libdrivers__serial.a
    [151/196] Linking C static library zephyr\drivers\pinctrl\libdrivers__pinctrl.a
    [152/196] Linking C static library modules\nrf\lib\fatal_error\lib..__nrf__lib__fatal_error.a
    [153/196] Linking C static library modules\nrf\drivers\hw_cc310\lib..__nrf__drivers__hw_cc310.a
    [154/196] Building C object modules/mcuboot/boot/bootutil/zephyr/CMakeFiles/mcuboot_util.dir/C_/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/src/bootutil_public.c.obj
    [155/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/mdk/system_nrf52840.c.obj
    [156/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/src/nrfx_gpiote.c.obj
    [157/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/helpers/nrfx_flag32_allocator.c.obj
    [158/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/nrfx_glue.c.obj
    [159/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
    [160/196] Linking C static library zephyr\lib\libc\minimal\liblib__libc__minimal.a
    [161/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/src/nrfx_ppi.c.obj
    [162/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/src/nrfx_wdt.c.obj
    [163/196] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/src/nrfx_nvmc.c.obj
    [164/196] Building C object modules/segger/CMakeFiles/modules__segger.dir/SEGGER_RTT_zephyr.c.obj
    [165/196] Building C object modules/segger/CMakeFiles/modules__segger.dir/C_/ncs/v2.1.2/modules/debug/segger/SEGGER/SEGGER_RTT.c.obj
    [166/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/errno.c.obj
    [167/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/banner.c.obj
    [168/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/fatal.c.obj
    [169/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/main_weak.c.obj
    [170/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/device.c.obj
    [171/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/kheap.c.obj
    [172/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/init.c.obj
    [173/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/version.c.obj
    [174/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mem_slab.c.obj
    [175/196] Linking C static library modules\mcuboot\boot\bootutil\zephyr\libmcuboot_util.a
    [176/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/xip.c.obj
    [177/196] Building C object modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj
    FAILED: modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj
    C:\ncs\toolchains\v2.1.2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.1.2/zephyr/include/zephyr -IC:/ncs/v2.1.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.1.2/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/v2.1.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.1.2/nrf/include -IC:/ncs/v2.1.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.1.2/modules/hal/nordic/nrfx -IC:/ncs/v2.1.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.1.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.1.2/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.1.2/modules/debug/segger/SEGGER -IC:/ncs/v2.1.2/modules/debug/segger/Config -IC:/ncs/v2.1.2/zephyr/modules/segger/. -IC:/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/zephyr/.. -IC:/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/zephyr/../include -IC:/ncs/v2.1.2/bootloader/mcuboot/boot/bootutil/zephyr/../../zephyr/include -IC:/ncs/v2.1.2/nrfxlib/crypto/nrf_cc310_bl/include -isystem C:/ncs/v2.1.2/zephyr/lib/libc/minimal/include -isystem c:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/include -isystem c:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/include-fixed -isystem C:/ncs/v2.1.2/nrfxlib/crypto/nrf_cc310_platform/include -Os -imacros D:/WorkSpacNCS_DFU/peripheral_hr_dfu2/build_dfu2_52840/mcuboot/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee --sysroot=C:/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.1.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/ncs/v2.1.2/bootloader/mcuboot/boot/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.1.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.1.2=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj -MF modules\nrf\modules\mcuboot\hooks\CMakeFiles\..__nrf__modules__mcuboot__hooks.dir\nrf53_hooks.c.obj.d -o modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj -c C:/ncs/v2.1.2/nrf/modules/mcuboot/hooks/nrf53_hooks.c
    C:/ncs/v2.1.2/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'boot_read_image_header_hook':
    C:\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:28: error: 'PM_MCUBOOT_PRIMARY_1_ADDRESS' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ADDRESS'?
    28 | img_head->ih_load_addr = PM_MCUBOOT_PRIMARY_1_ADDRESS;
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | PM_MCUBOOT_PRIMARY_ADDRESS
    C:\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:28: note: each undeclared identifier is reported only once for each function it appears in
    C:\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:29:27: error: 'PM_CPUNET_APP_SIZE' undeclared (first use in this function)
    29 | img_head->ih_img_size = PM_CPUNET_APP_SIZE;
    | ^~~~~~~~~~~~~~~~~~
    In file included from C:\ncs\v2.1.2\zephyr\include\zephyr\toolchain\gcc.h:88,
    from C:\ncs\v2.1.2\zephyr\include\zephyr\toolchain.h:50,
    from C:\ncs\v2.1.2\zephyr\include\zephyr\sys\__assert.h:11,
    from C:\ncs\v2.1.2\zephyr\lib\libc\minimal\include\assert.h:11,
    from C:\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:7:
    C:/ncs/v2.1.2/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'network_core_update':
    C:\ncs\v2.1.2\zephyr\include\zephyr\device.h:96:39: error: '__device_dts_ord_DT_N_NODELABEL_PM_MCUBOOT_PRIMARY_1_DEV_ORD' undeclared (first use in this function)
    96 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
    | ^~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\device.h:276:37: note: in expansion of macro 'DEVICE_NAME_GET'
    276 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
    | ^~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\zephyr\include\zephyr\device.h:296:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    296 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    C:\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:85:19: note: in expansion of macro 'DEVICE_DT_GET'
    85 | mock_flash_dev = DEVICE_DT_GET(DT_NODELABEL(PM_MCUBOOT_PRIMARY_1_DEV));
    | ^~~~~~~~~~~~~
    C:\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:98:20: error: 'PM_CPUNET_B0N_ADDRESS' undeclared (first use in this function)
    98 | if (reset_addr > PM_CPUNET_B0N_ADDRESS) {
    | ^~~~~~~~~~~~~~~~~~~~~
    [178/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread.c.obj
    [179/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timeout.c.obj
    [180/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mempool.c.obj
    [181/196] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timer.c.obj
    [182/196] Linking C static library modules\segger\libmodules__segger.a
    [183/196] Linking C static library modules\hal_nordic\nrfx\libmodules__hal_nordic__nrfx.a
    ninja: build stopped: subcommand failed.
    [172/306] Building C object CMakeFiles/app.dir/src/main.c.obj
    In file included from C:\ncs\v2.1.2\zephyr\include\zephyr\kernel\sched_priq.h:9,
    from C:\ncs\v2.1.2\zephyr\include\zephyr\kernel_includes.h:23,
    from C:\ncs\v2.1.2\zephyr\include\zephyr\kernel.h:17,
    from C:\ncs\v2.1.2\zephyr\include\zephyr\zephyr.h:18,
    from d:\WorkSpacNCS_DFU\peripheral_hr_dfu2\src\main.c:18:
    C:\ncs\v2.1.2\zephyr\include\zephyr\sys\util.h:108: warning: "ARRAY_SIZE" redefined
    108 | #define ARRAY_SIZE(array) \
    |
    In file included from C:\ncs\v2.1.2\zephyr\include\zephyr\mgmt\mcumgr\buf.h:11,
    from C:\ncs\v2.1.2\zephyr\subsys\mgmt\mcumgr\lib\mgmt\include\mgmt\mgmt.h:11,
    from C:\ncs\v2.1.2\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt\include\img_mgmt\img_mgmt.h:13,
    from d:\WorkSpacNCS_DFU\peripheral_hr_dfu2\src\main.c:10:
    C:\ncs\v2.1.2\modules\lib\zcbor\include\zcbor_common.h:74: note: this is the location of the previous definition
    74 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
    |
    ../src/main.c: In function 'main':
    d:\WorkSpacNCS_DFU\peripheral_hr_dfu2\src\main.c:131:2: warning: implicit declaration of function 'stat_mgmt_register_group'; did you mean 'img_mgmt_register_group'? [-Wimplicit-function-declaration]
    131 | stat_mgmt_register_group();
    | ^~~~~~~~~~~~~~~~~~~~~~~~
    | img_mgmt_register_group
    [214/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/conn.c.obj
    FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf
    cmd.exe /C "cd /D D:\WorkSpacNCS_DFU\peripheral_hr_dfu2\build_dfu2_52840\mcuboot && C:\ncs\toolchains\v2.1.2\opt\bin\cmake.exe --build . --"
    [216/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/stat_mgmt/src/stat_mgmt.c.obj
    [217/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/img_mgmt/src/zephyr_img_mgmt_log.c.obj
    [218/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/smp_bt.c.obj
    [219/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/img_mgmt/src/img_mgmt_util.c.obj
    [220/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/buf.c.obj
    [221/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/smp.c.obj
    [222/306] Linking C static library zephyr\lib\libc\minimal\liblib__libc__minimal.a
    [223/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/mgmt/src/mgmt.c.obj
    [224/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/img_mgmt/src/img_mgmt_state.c.obj
    [225/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/img_mgmt/src/img_mgmt.c.obj
    [226/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/smp_shell.c.obj
    [227/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/os_mgmt/src/zephyr_os_mgmt.c.obj
    [228/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/keys.c.obj
    [229/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/os_mgmt/src/os_mgmt.c.obj
    [230/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/smp/src/smp.c.obj
    [231/306] Building C object zephyr/subsys/mgmt/mcumgr/CMakeFiles/subsys__mgmt__mcumgr.dir/lib/cmd/img_mgmt/src/zephyr_img_mgmt.c.obj
    [232/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/l2cap.c.obj
    [233/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/hci_core.c.obj
    [234/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/gatt.c.obj
    [235/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/att.c.obj
    [236/306] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/smp.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.1.2\opt\bin\cmake.EXE' --build 'd:\WorkSpacNCS_DFU\peripheral_hr_dfu2\build_dfu2_52840'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

  • Richard said:
    Using the CONFIG_OS_MGMT_RESET_HOOK happens too late as well unfortunately. Seems to occur after the image has been sent, and when it's verifying.

    Ah, okay. If you want a callback when the image is being transferred OTA, then you can do it like this:

    Snippet 1:

    #include <zephyr/mgmt/mcumgr/smp_bt.h>
    #include "os_mgmt/os_mgmt.h"
    #include "img_mgmt/img_mgmt.h"
    
    
    void dfu_started_cb(void)
    {
    
    		printk("Starting DFU image upload\n");
    
    }
    
    
    const struct img_mgmt_dfu_callbacks_t dfu_callbacks = {
    	.dfu_started_cb = dfu_started_cb,
    	.dfu_stopped_cb = NULL,
    	.dfu_pending_cb = NULL,
    	.dfu_confirmed_cb = NULL
    };

    Snippet 2:

    void main(void)
    {
    	int blink_status = 0;
    	int err;
    
    	printk("Starting Bluetooth Peripheral LBS example\n");
    
    	err = dk_leds_init();
    	if (err) {
    		printk("LEDs init failed (err %d)\n", err);
    		return;
    	}
    
    	err = init_button();
    	if (err) {
    		printk("Button init failed (err %d)\n", err);
    		return;
    	}
    
    	printk("build time: " __DATE__ " " __TIME__ "\n");
    	os_mgmt_register_group();
    	
    	img_mgmt_register_group();
    	img_mgmt_register_callbacks(&dfu_callbacks);
    	smp_bt_register();
    
    	if (IS_ENABLED(CONFIG_BT_LBS_SECURITY_ENABLED)) {
    		err = bt_conn_auth_cb_register(&conn_auth_callbacks);
    		if (err) {
    			printk("Failed to register authorization callbacks.\n");
    			return;
    		}
    
    		err = bt_conn_auth_info_cb_register(&conn_auth_info_callbacks);
    		if (err) {
    			printk("Failed to register authorization info callbacks.\n");
    			return;
    		}
    	}
    
    	err = bt_enable(NULL);
    	if (err) {
    		printk("Bluetooth init failed (err %d)\n", err);
    		return;
    	}
    
    	printk("Bluetooth initialized\n");
    
    	if (IS_ENABLED(CONFIG_SETTINGS)) {
    		settings_load();
    	}
    
    	err = bt_lbs_init(&lbs_callbacs);
    	if (err) {
    		printk("Failed to init LBS (err:%d)\n", err);
    		return;
    	}
    
    	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
    			      sd, ARRAY_SIZE(sd));
    	if (err) {
    		printk("Advertising failed to start (err %d)\n", err);
    		return;
    	}
    
    	printk("Advertising successfully started\n");
    
    	for (;;) {
    		dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
    		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
    	}
    }
    

Related