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

  • 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));
    	}
    }
    

  • Hi,

    I am also an engineer at the same company as Richard and am looking at this as well.

    Is the gap in asserting the pin due to the startup time of the nRFConnect SDK (or perhaps the RTOS part of it)? 

    In my tests the fastest I can get a pin set on the nrf52840 after a reset using nRFConnect is 250mS. Using SDK 3.2 for thread and zigbee it is instantaneous. I have tried using 

    SYS_INIT(_init_fn, PRE_KERNEL_2, 1);
    to set it as early as possible. This test did not involve a bootloader.
    So if during a DFU the 52840 resets then the pin will not get asserted for the 250ms because nothing can run? Could this be what is happening?
    kind regards
    Liam
  • Liam said:
    SYS_INIT(_init_fn, PRE_KERNEL_2, 1);
    to set it as early as possible.

    You are here waiting until all PRE_KERNEL_1 init is done. So use PRE_KERNEL_1 instead here if you want it to happen earlier. 

    Snippet:

    #include <hal/nrf_gpio.h>
    
    #define MY_PIN 3
    
    static int early_init(const struct device *dev)
    {
    nrf_gpio_cfg_output(MY_PIN);
    nrf_gpio_pin_set(MY_PIN);
    return 0;
    }
    
    SYS_INIT(early_init, PRE_KERNEL_1, 0);

  • I should have mentioned I could not get PRE_KERNEL_1 to work.

    void _init_fn( void )
    {
        int ret;

        if (!device_is_ready(led.port)) {
            return;
        }

        ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
        if (ret < 0) {
            return;
        }

        gpio_pin_set_dt(&led, 0);
    }
    SYS_INIT(_init_fn, PRE_KERNEL_1, 1);

    void main(void)
    {
        int ret;

    I found it would not ever set the pin.

    regards

Reply
  • I should have mentioned I could not get PRE_KERNEL_1 to work.

    void _init_fn( void )
    {
        int ret;

        if (!device_is_ready(led.port)) {
            return;
        }

        ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
        if (ret < 0) {
            return;
        }

        gpio_pin_set_dt(&led, 0);
    }
    SYS_INIT(_init_fn, PRE_KERNEL_1, 1);

    void main(void)
    {
        int ret;

    I found it would not ever set the pin.

    regards

Children
Related