OTA - Not working in Zephyr but works in SoftDevice

Hello,

I am using Celium device's BE33 (nRF52833 based) Click here for datasheet. there are crystal pins exposed in this controller but I dont want to use external crystal so I have added below to prj.conf

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

I am trying to implement https://getwavecake.com/blog/adding-ota-dfu-to-a-nordic-zephyr-project/ This example which is a reference of Nordic/Zephyr/samples/bluetooth/peripheral_hr example.

Here I am facing a boot problem. Once I set CONFIG_BOOTLOADER_MCUBOOT=y this problem begins. I need to touch to the crystal pins once to get started otherwise it won't start on its own. But when I am using softdevice DFU example it works well without the need to touch the crystal pins. why so ? Am I doing anything wrong?

Thanks in advance.

Regards,

Neeraj Dhekale

Parents Reply Children
  • Hello Amanda,

    Sorry for the delay in response.

    I have create folder named "child_image" in peripheral_hr project.

    in child_image folder I have created new folder named mcuboot and created prj.conf file in it.

    in peripheral_hr/prj.conf file I have added below line:

    CONFIG_BOOTLOADER_MCUBOOT=y

    added content of /child_image/mcuboot/prj.conf file:

    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Enable flash operations.
    CONFIG_FLASH=y
    
    # Required by the `taskstat` command.
    CONFIG_THREAD_MONITOR=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_STAT_MGMT=y
    
    # Allow for large Bluetooth data packets.
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_BUF_ACL_RX_SIZE=256
    
    # Enable the Bluetooth (unauthenticated) and shell mcumgr transports.
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    CONFIG_MCUMGR_SMP_SHELL=y
    CONFIG_CHILDAPP_BUILD_STRATEGY_FROM_SOURCE=y

    Next, I copied the boot folder and other content of mcuboot folder from mcuboot github.

    in peripheral_hr folder I have added below lines in CMakeLists.txt file:

    if (CONFIG_BOOTLOADER_MCUBOOT)
       add_child_image(
         NAME mcuboot
         SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/child_image/mcuboot/zephyr
         )
    endif()

    After the build I am getting the below error:

    *  Executing task: nRF Connect: Generate config nrf52833dk_nrf52833 for /home/neeraj/Applications/Nordic/peripheral_hr

    Building peripheral_hr
    /bin/sh -c west build --build-dir /home/neeraj/Applications/Nordic/peripheral_hr/build /home/neeraj/Applications/Nordic/peripheral_hr --pristine --board nrf52833dk_nrf52833 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="/home/neeraj/Applications/Nordic/peripheral_hr"

    -- west build: generating a build system
    Including boilerplate (Zephyr base): /home/neeraj/Applications/Nordic/zephyr/cmake/app/boilerplate.cmake
    -- Application: /home/neeraj/Applications/Nordic/peripheral_hr
    -- Zephyr version: 2.7.0 (/home/neeraj/Applications/Nordic/zephyr), build: v2.7.0-ncs1
    -- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.12") found components: Interpreter
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf52833dk_nrf52833
    -- Cache files will be written to: /home/neeraj/.cache/zephyr
    -- Found dtc: /usr/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
    -- Found toolchain: gnuarmemb (/home/neeraj/gnuarmemb)
    -- Found BOARD.dts: /home/neeraj/Applications/Nordic/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833.dts
    -- Found devicetree overlay: /home/neeraj/Applications/Nordic/peripheral_hr/nrf52833dk_nrf52833.overlay
    -- Generated zephyr.dts: /home/neeraj/Applications/Nordic/peripheral_hr/build/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: /home/neeraj/Applications/Nordic/peripheral_hr/build/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: /home/neeraj/Applications/Nordic/peripheral_hr/build/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: /home/neeraj/Applications/Nordic/peripheral_hr/build/zephyr/dts.cmake

    warning: BT_CTLR_ADVANCED_FEATURES (defined at subsys/bluetooth/controller/Kconfig.ll_sw_split:114)
    was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies:
    BT_LL_SW_SPLIT (=n). See
    docs.zephyrproject.org/.../CONFIG_BT_CTLR_ADVANCED_FEATURES.html and/or
    look up BT_CTLR_ADVANCED_FEATURES in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.


    warning: The choice symbol WDT_LOG_LEVEL_DBG (defined at
    subsys/logging/Kconfig.template.log_config:20) was selected (set =y), but no symbol ended up as the
    choice selection. See
    docs.zephyrproject.org/.../CONFIG_WDT_LOG_LEVEL_DBG.html and/or look up
    WDT_LOG_LEVEL_DBG in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.

    Parsing /home/neeraj/Applications/Nordic/zephyr/Kconfig
    Loaded configuration '/home/neeraj/Applications/Nordic/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833_defconfig'
    Merged configuration '/home/neeraj/Applications/Nordic/peripheral_hr/prj.conf'
    Configuration saved to '/home/neeraj/Applications/Nordic/peripheral_hr/build/zephyr/.config'
    Kconfig header saved to '/home/neeraj/Applications/Nordic/peripheral_hr/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 10.3.1
    -- The CXX compiler identification is GNU 10.3.1
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/neeraj/gnuarmemb/bin/arm-none-eabi-gcc

    === child image mcuboot -  begin ===
    Including boilerplate (Zephyr base): /home/neeraj/Applications/Nordic/zephyr/cmake/app/boilerplate.cmake
    -- Application: /home/neeraj/Applications/Nordic/bootloader/mcuboot/boot/zephyr
    -- Zephyr version: 2.7.0 (/home/neeraj/Applications/Nordic/zephyr), build: v2.7.0-ncs1
    -- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.12") found components: Interpreter
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf52833dk_nrf52833
    -- Cache files will be written to: /home/neeraj/.cache/zephyr
    -- Found dtc: /usr/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
    -- Found toolchain: gnuarmemb (/home/neeraj/gnuarmemb)
    -- Found BOARD.dts: /home/neeraj/Applications/Nordic/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833.dts
    -- Found devicetree overlay: /home/neeraj/Applications/Nordic/nrf/modules/mcuboot/usb.overlay
    -- Found devicetree overlay: /home/neeraj/Applications/Nordic/bootloader/mcuboot/boot/zephyr/dts.overlay
    -- Generated zephyr.dts: /home/neeraj/Applications/Nordic/peripheral_hr/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: /home/neeraj/Applications/Nordic/peripheral_hr/build/mcuboot/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: /home/neeraj/Applications/Nordic/peripheral_hr/build/mcuboot/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: /home/neeraj/Applications/Nordic/peripheral_hr/build/mcuboot/zephyr/dts.cmake

    warning: BOOTLOADER_MCUBOOT (defined at Kconfig.zephyr:561) was assigned the value 'y' but got the
    value 'n'. Check these unsatisfied dependencies: (!MCUBOOT) (=n). See
    docs.zephyrproject.org/.../CONFIG_BOOTLOADER_MCUBOOT.html and/or look up
    BOOTLOADER_MCUBOOT in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.


    /home/neeraj/Applications/Nordic/peripheral_hr/child_image/mcuboot/prj.conf:33: warning: attempt to assign the value 'y' to the undefined symbol CHILDAPP_BUILD_STRATEGY_FROM_SOURCE

    error: Aborting due to Kconfig warnings

    Parsing /home/neeraj/Applications/Nordic/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration '/home/neeraj/Applications/Nordic/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833_defconfig'
    Merged configuration '/home/neeraj/Applications/Nordic/peripheral_hr/child_image/mcuboot/prj.conf'
    Merged configuration '/home/neeraj/Applications/Nordic/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    CMake Error at /home/neeraj/Applications/Nordic/zephyr/cmake/kconfig.cmake:270 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      /home/neeraj/Applications/Nordic/zephyr/cmake/app/boilerplate.cmake:546 (include)
      /home/neeraj/Applications/Nordic/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      /home/neeraj/Applications/Nordic/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:44 (find_package)


    -- Configuring incomplete, errors occurred!
    CMake Error at /home/neeraj/Applications/Nordic/nrf/cmake/multi_image.cmake:306 (message):
      CMake generation for mcuboot failed, aborting.  Command: 1
    Call Stack (most recent call first):
      /home/neeraj/Applications/Nordic/nrf/cmake/multi_image.cmake:68 (add_child_image_from_source)
      /home/neeraj/Applications/Nordic/nrf/modules/mcuboot/CMakeLists.txt:216 (add_child_image)


    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/neeraj/Applications/Nordic/peripheral_hr/build -S/home/neeraj/Applications/Nordic/peripheral_hr -GNinja -DBOARD=nrf52833dk_nrf52833 -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DBOARD_ROOT:STRING=/home/neeraj/Applications/Nordic/peripheral_hr

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

  • Hi Amanda,

    I need to touch to the crystal pins once to get started otherwise it won't start on its own. But when I am using softdevice DFU example it works well without the need to touch the crystal pins

    I have followed all the steps the same way you have suggested  in the above link... I am able to build and flash successful.. but the above problem persist as I have mentioned in my 1st main thread.

    Why do I need to toch to crystal pins to make it start. once it is is started I don't need to touch and DFU works very well.

    Now I can see mcuboot under build. This means child_image has been considered to it. I hope so.

    Am I doing anything wrong?

    Thanks and regards,

    Neeraj Dhekale

  • Hi, 

    Try to add CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y and CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y in the child_image/mcuboot/prj.conf.

    -Amanda H.

  • Hi Amanda,

    I tried to add the above 2 lines.

    After adding the above 2 lines in mcubot/prj.conf It starts displaying an error below during build.

    [232/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/banner.c.obj
    [233/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/main_weak.c.obj
    [234/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/fatal.c.obj
    [235/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/kheap.c.obj
    [236/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mem_slab.c.obj
    [237/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/errno.c.obj
    [238/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/device.c.obj
    [239/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/init.c.obj
    [240/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/version.c.obj
    [241/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/xip.c.obj
    [242/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timeout.c.obj
    [243/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread.c.obj
    [244/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timer.c.obj
    [245/256] Linking C static library modules/segger/libmodules__segger.a
    [246/256] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mempool.c.obj
    [247/256] Linking C static library modules/mbedtls/libmodules__mbedtls.a
    [248/256] Linking C static library zephyr/kernel/libkernel.a
    [249/256] Linking C executable zephyr/zephyr_prebuilt.elf
    FAILED: zephyr/zephyr_prebuilt.elf zephyr/zephyr_prebuilt.map /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/zephyr_prebuilt.map
    : && ccache /home/neeraj/gnuarmemb/bin/arm-none-eabi-gcc   zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj -o zephyr/zephyr_prebuilt.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -Wl,-T  zephyr/linker_zephyr_prebuilt.cmd  -Wl,-Map=/home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/zephyr_prebuilt.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/posix/liblib__posix.a  zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/lib/fprotect/lib..__nrf__lib__fprotect.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/mbedtls/libmodules__mbedtls.a  modules/segger/libmodules__segger.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m/nofp"  -L/home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -no-pie  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn && cd /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr && /usr/bin/cmake -E echo
    /home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a(temp_nrf5.c.obj): in function `k_sem_give':
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:953: undefined reference to `z_impl_k_sem_give'
    /home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a(temp_nrf5.c.obj): in function `k_mutex_lock':
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:820: undefined reference to `z_impl_k_mutex_lock'
    /home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a(temp_nrf5.c.obj): in function `k_sem_take':
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:936: undefined reference to `z_impl_k_sem_take'
    /home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a(temp_nrf5.c.obj): in function `k_mutex_unlock':
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:836: undefined reference to `z_impl_k_mutex_unlock'
    /home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a(temp_nrf5.c.obj): in function `k_sem_init':
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:918: undefined reference to `z_impl_k_sem_init'
    /home/neeraj/gnuarmemb/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a(temp_nrf5.c.obj): in function `k_mutex_init':
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:802: undefined reference to `z_impl_k_mutex_init'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/zephyr.hex /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot/zephyr/zephyr.elf
    cd /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build/mcuboot && /usr/bin/cmake --build . --
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU_OTA/build

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

    What can be the issue?

    Thanks and regards,

    Neeraj Dhekale

Related