nRF5340 ESB OTA

Hello,

I have tested the smp_svr with hci_rpmsg Bluetooth OTA feature and I have successfully uploaded the firmware which worked with the old device manager Android app. I would like to use 2 nrf5340 with ESB protocol. What would be a good starting point do I use the hci_rpmsg existing code and enable ESB and configure it as such or is it better to use bootloader UART code? I am a bit stuck as the hci_rpmsg sample code is dependent on bluetooth defines and ESB and bluetooth give an error message when both are enabled. So if you could give me some guidance on the right decision and how I should handle the problem. Thank you

I am using:
2x NRF5340 DK 
nRF Connect for desktop v4.1.2
nRF Connect SDK v2.4.0

  • Hi

    DFU over ESB is not very straight forward, so I would recommend using ESB + BLE in the same application perhaps to do DFU OTA with BLE, and then have the application run with ESB. My colleague Torbjørn made an example that shows how to run BLE and ESB concurrently using the MPSL interface here. Alternatively the UART bootloader is an option as well if you don't need to do the DFU over the air.

    Best regards,

    Simon

  • Hello, I am trying to implement your colleagues ESB+BT example on the nrf5340 but I get undeclared config errors even though it is configured in the project. I am using the same sample code smp_svr with the overlay-bt.conf in the build configuration. I have modified the hci_rpmsg CMakeLists.txt in the SDK with the one used in the ESB+BT example of including the c file sources and library directories. When the source files and directory is included I get the error of:
    === child image b0n - CPUNET (inherited) end ===

    CMake Warning at C:/ncs/v2.4.2/nrf/subsys/bootloader/cmake/debug_keys.cmake:36 (message):
     

          --------------------------------------------------------------
          --- WARNING: Using generated NSIB public/private key-pair. ---
          --- It should not be used for production.                  ---
          --- See CONFIG_SB_SIGNING_KEY_FILE                         ---
          --------------------------------------------------------------
          

    Call Stack (most recent call first):
      C:/ncs/v2.4.2/nrf/subsys/bootloader/cmake/provision_hex.cmake:37 (include)
      C:/ncs/v2.4.2/nrf/subsys/CMakeLists.txt:17 (include)


    -- libmetal version: 1.3.0 (C:/ncs/v2.4.2/zephyr/samples/bluetooth/hci_rpmsg)
    -- Build type:  
    -- Host:    Windows/AMD64
    -- Target:  Generic/arm
    -- Machine: arm
    -- open-amp version: 1.3.0 (C:/ncs/v2.4.2/modules/lib/open-amp/open-amp)
    -- Host:    Windows/AMD64
    -- Target:  Generic/arm
    -- Machine: arm
    -- C_FLAGS :  -Wall -Wextra
    CMake Warning at ../../../CMakeLists.txt:839 (message):
      No SOURCES given to Zephyr library: lib__libc__common

      Excluding target from build.


    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Ntest/smp_svr/build/hci_rpmsg
    [0/244] Performing build step for 'b0n_subimage'
    [1/29] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
    [2/29] Building C object zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.4.2/nrf/subsys/partition_manager/flash_map_partition_manager.c.obj
    [3/29] Building C object modules/nrf/subsys/bootloader/bl_crypto/CMakeFiles/..__nrf__subsys__bootloader__bl_crypto.dir/bl_crypto_oberon_hash.c.obj
    [4/29] Building C object CMakeFiles/app.dir/src/main.c.obj
    [5/29] Building C object modules/nrf/subsys/bootloader/bl_boot/CMakeFiles/..__nrf__subsys__bootloader__bl_boot.dir/bl_boot.c.obj
    [6/29] Generating linker_zephyr_pre0.cmd
    [7/29] Generating linker_zephyr_pre1.cmd
    [8/29] Building C object modules/nrf/subsys/bootloader/bl_crypto/CMakeFiles/..__nrf__subsys__bootloader__bl_crypto.dir/bl_crypto.c.obj
    [9/29] Building C object modules/nrf/subsys/bootloader/bl_storage/CMakeFiles/..__nrf__subsys__bootloader__bl_storage.dir/bl_storage.c.obj
    [10/29] Building C object modules/nrf/subsys/pcd/CMakeFiles/..__nrf__subsys__pcd.dir/src/pcd.c.obj
    [11/29] Building C object modules/nrf/subsys/bootloader/bl_validation/CMakeFiles/..__nrf__subsys__bootloader__bl_validation.dir/bl_validation.c.obj
    [12/29] Building C object modules/nrf/subsys/fw_info/CMakeFiles/..__nrf__subsys__fw_info.dir/fw_info.c.obj
    [13/29] Linking C static library app\libapp.a
    [14/29] Linking C static library modules\nrf\subsys\bootloader\bl_boot\lib..__nrf__subsys__bootloader__bl_boot.a
    [15/29] Linking C static library modules\nrf\subsys\bootloader\bl_crypto\lib..__nrf__subsys__bootloader__bl_crypto.a
    [16/29] Linking C static library modules\nrf\subsys\bootloader\bl_storage\lib..__nrf__subsys__bootloader__bl_storage.a
    [17/29] Linking C static library modules\nrf\subsys\pcd\lib..__nrf__subsys__pcd.a
    [18/29] Linking C static library modules\nrf\subsys\fw_info\lib..__nrf__subsys__fw_info.a
    [19/29] Linking C static library modules\nrf\subsys\bootloader\bl_validation\lib..__nrf__subsys__bootloader__bl_validation.a
    [20/29] Linking C static library zephyr\libzephyr.a
    [21/29] Linking C executable zephyr\zephyr_pre0.elf

    [22/29] Generating dev_handles.c
    [23/29] Building C object zephyr/CMakeFiles/zephyr_pre1.dir/dev_handles.c.obj
    [24/29] Linking C executable zephyr\zephyr_pre1.elf

    [25/29] Generating linker.cmd
    [26/29] Generating isr_tables.c, isrList.bin
    [27/29] Building C object zephyr/CMakeFiles/zephyr_final.dir/dev_handles.c.obj
    [28/29] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
    [29/29] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       23530 B      34176 B     68.85%
                 RAM:        3456 B        64 KB      5.27%
               SRAM1:          0 GB        64 KB      0.00%
            IDT_LIST:          0 GB         2 KB      0.00%
    [18/244] Building C object zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.4.2/nrf/subsys/bluetooth/services/lbs.c.obj
    FAILED: zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.4.2/nrf/subsys/bluetooth/services/lbs.c.obj
    C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DNRF5340_XXAA_NETWORK -DUSE_PARTITION_MANAGER=1 -DVALIDATION_INFO_MAGIC=0x281ee6de,0x86518483,79106 -DVALIDATION_POINTER_MAGIC=0x281ee6de,0x6919b47e,79106 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.4.2/zephyr/kernel/include -IC:/ncs/v2.4.2/zephyr/arch/arm/include -IC:/ncs/v2.4.2/nrf/drivers/mpsl/clock_control -IC:/ncs/v2.4.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.4.2/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/ncs/v2.4.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.4.2/zephyr/subsys/bluetooth -IC:/ncs/v2.4.2/nrf/include -IC:/ncs/v2.4.2/nrf/lib/multithreading_lock/. -IC:/ncs/v2.4.2/nrf/subsys/bluetooth/controller/. -IC:/ncs/v2.4.2/nrf/tests/include -IC:/ncs/v2.4.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.4.2/zephyr/modules/hal_nordic/nrfx/. -Imodules/libmetal/libmetal/lib/include -IC:/ncs/v2.4.2/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.4.2/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.4.2/nrfxlib/mpsl/include -IC:/ncs/v2.4.2/nrfxlib/mpsl/include/protocol -IC:/ncs/v2.4.2/nrfxlib/softdevice_controller/include -isystem C:/ncs/v2.4.2/zephyr/lib/libc/minimal/include -isystem c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -fno-strict-aliasing -Os -imacros C:/Ntest/smp_svr/build/hci_rpmsg/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33+nodsp -mthumb -mabi=aapcs --sysroot=C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.4.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/ncs/v2.4.2/zephyr/samples/bluetooth/hci_rpmsg=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.4.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.4.2=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.4.2/nrf/subsys/bluetooth/services/lbs.c.obj -MF zephyr\CMakeFiles\zephyr.dir\C_\ncs\v2.4.2\nrf\subsys\bluetooth\services\lbs.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.4.2/nrf/subsys/bluetooth/services/lbs.c.obj -c C:/ncs/v2.4.2/nrf/subsys/bluetooth/services/lbs.c
    In file included from C:\ncs\v2.4.2\nrf\subsys\bluetooth\services\lbs.c:23:
    C:\ncs\v2.4.2\zephyr\include\zephyr\bluetooth\gatt.h:727:34: error: 'CONFIG_BT_MAX_PAIRED' undeclared here (not in a function); did you mean 'CONFIG_BT_MAX_CONN'?
      727 |         #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
          |                                  ^~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.4.2\zephyr\include\zephyr\bluetooth\gatt.h:745:36: note: in expansion of macro 'BT_GATT_CCC_MAX'
      745 |         struct bt_gatt_ccc_cfg cfg[BT_GATT_CCC_MAX];
          |                                    ^~~~~~~~~~~~~~~
    [19/244] Building C object CMakeFiles/app.dir/C_/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_bt_lbs.c.obj
    FAILED: CMakeFiles/app.dir/C_/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_bt_lbs.c.obj
    C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DNRF5340_XXAA_NETWORK -DUSE_PARTITION_MANAGER=1 -DVALIDATION_INFO_MAGIC=0x281ee6de,0x86518483,79106 -DVALIDATION_POINTER_MAGIC=0x281ee6de,0x6919b47e,79106 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/Ntest/ncs-esb-ble-mpsl-demo-master/common -IC:/ncs/v2.4.2/nrf/drivers/mpsl/clock_control -IC:/ncs/v2.4.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.4.2/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/ncs/v2.4.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.4.2/zephyr/subsys/bluetooth -IC:/ncs/v2.4.2/nrf/include -IC:/ncs/v2.4.2/nrf/lib/multithreading_lock/. -IC:/ncs/v2.4.2/nrf/subsys/bluetooth/controller/. -IC:/ncs/v2.4.2/nrf/tests/include -IC:/ncs/v2.4.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.4.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.4.2/zephyr/modules/hal_nordic/nrfx/. -Imodules/libmetal/libmetal/lib/include -IC:/ncs/v2.4.2/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.4.2/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.4.2/nrfxlib/mpsl/include -IC:/ncs/v2.4.2/nrfxlib/mpsl/include/protocol -IC:/ncs/v2.4.2/nrfxlib/softdevice_controller/include -isystem C:/ncs/v2.4.2/zephyr/lib/libc/minimal/include -isystem c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -fno-strict-aliasing -Os -imacros C:/Ntest/smp_svr/build/hci_rpmsg/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33+nodsp -mthumb -mabi=aapcs --sysroot=C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.4.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/ncs/v2.4.2/zephyr/samples/bluetooth/hci_rpmsg=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.4.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.4.2=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/C_/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_bt_lbs.c.obj -MF CMakeFiles\app.dir\C_\Ntest\ncs-esb-ble-mpsl-demo-master\common\app_bt_lbs.c.obj.d -o CMakeFiles/app.dir/C_/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_bt_lbs.c.obj -c C:/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_bt_lbs.c
    In file included from C:\Ntest\ncs-esb-ble-mpsl-demo-master\common\app_bt_lbs.c:8:
    C:\ncs\v2.4.2\zephyr\include\zephyr\bluetooth\gatt.h:727:34: error: 'CONFIG_BT_MAX_PAIRED' undeclared here (not in a function); did you mean 'CONFIG_BT_MAX_CONN'?
      727 |         #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
          |                                  ^~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.4.2\zephyr\include\zephyr\bluetooth\gatt.h:745:36: note: in expansion of macro 'BT_GATT_CCC_MAX'
      745 |         struct bt_gatt_ccc_cfg cfg[BT_GATT_CCC_MAX];
          |                                    ^~~~~~~~~~~~~~~
    [36/244] Building C object CMakeFiles/app.dir/C_/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_timeslot.c.obj
    C:/Ntest/ncs-esb-ble-mpsl-demo-master/common/app_timeslot.c: In function 'mpsl_timeslot_callback':
    C:\Ntest\ncs-esb-ble-mpsl-demo-master\common\app_timeslot.c:155:43: warning: implicit declaration of function 'RADIO_IRQHandler' [-Wimplicit-function-declaration]
      155 |                         if(m_in_timeslot) RADIO_IRQHandler();
          |                                           ^~~~~~~~~~~~~~~~
    [42/244] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
    ninja: build stopped: subcommand failed.
    [38/54] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:      162336 B     474624 B     34.20%
                 RAM:       56892 B       440 KB     12.63%
            IDT_LIST:          0 GB         2 KB      0.00%
    [40/54] Generating zephyr/mcuboot_primary.hex
    FAILED: modules/nrf/samples/hci_rpmsg_subimage-prefix/src/hci_rpmsg_subimage-stamp/hci_rpmsg_subimage-build hci_rpmsg/zephyr/zephyr.hex hci_rpmsg/zephyr/zephyr.elf hci_rpmsg/zephyr/merged_CPUNET.hex
    cmd.exe /C "cd /D C:\Ntest\smp_svr\build\hci_rpmsg && C:\ncs\toolchains\31f4403e35\opt\bin\cmake.exe --build . --"
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'c:\Ntest\smp_svr\build'

    If I go to the line of "#define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)" for example and check if it is finding it through ctrl+click it can find it at the "C:/ncs/v2.4.2/zephyr/subsys/bluetooth/host/kconfig and hovering over it showing value 0.

    Even if I include the "CONFIG_BT_MAX_PAIRED" into the "hci_rpmsg.conf" in the smp_svr child image folder or directly in the hci_rpmsg prj.conf the error still persists and says that it cannot be set anyway as the default prj.conf of hci_rpmsg project has the CONFIG_BT_HCI_RAW=y but for the CONFIG_BT_MAX_PAIRED you need to enable CONFIG_BT_HCI_HOST which has a dependeny on !BT_HCI_RAW so I don't know what to do at this point and where the error comes from.

  • Hi

    How does your config file look here? The error messages seem to be struggling to find CONFIG_BT_MAX_PAIRED which should be enabled in the configs of the Bluetooth Host controller. I think starting out with a Bluetooth sample and adding ESB features will be easier than adding the overlay-bt.conf altogether on your end. Have you made sure that the NET core has the Bluetooth controller enabled in its configs as well (should be done in the child image).

    Best regards,

    Simon

  • Hello,

    I am modifying the hci_rpmsg project that gets called from smp_svr as child image. I am trying to build only the hci_rpmsg project now for the nrf5340_cpunet core but with the included files from the github the build always fails based on missing configs. I modified the prj.conf of the hci_rpmsg project like this:

    CONFIG_IPC_SERVICE=y
    CONFIG_MBOX=y

    CONFIG_HEAP_MEM_POOL_SIZE=8192

    CONFIG_MAIN_STACK_SIZE=512
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512

    CONFIG_BT=y
    CONFIG_BT_HCI=y
    CONFIG_BT_HCI_RAW=n
    #CONFIG_BT_HCI_RAW_RESERVE=1
    #CONFIG_BT_MAX_CONN=16

    CONFIG_BT_RPC_STACK=y
    #CONFIG_BT_HCI_HOST=y


    CONFIG_BT_MAX_PAIRED=2
    # Workaround: Unable to allocate command buffer when using K_NO_WAIT since
    # Host number of completed commands does not follow normal flow control.
    CONFIG_BT_BUF_CMD_TX_COUNT=10

    # Enable and adjust the below value as necessary
    # CONFIG_BT_BUF_EVT_RX_COUNT=16
    # CONFIG_BT_BUF_EVT_RX_SIZE=255
    # CONFIG_BT_BUF_ACL_RX_SIZE=255
    # CONFIG_BT_BUF_ACL_TX_SIZE=251
    # CONFIG_BT_BUF_CMD_TX_SIZE=255

    Some of the old things like CONFIG_BT_HCI_RAW I had to disable as CONFIG_BT_MAX_PAIRED has dependencies on CONFIG_BT_HCI_HOST that has dependencies on !CONFIG_BT_HCI_RAW. I have added the ones that had dependencies form others. But the problem now is BT_MAX_PAIRED still isn't assignable because BT_CONN isn't set. BT_CONN cannot be user set and is dependent on CONFIG_BT and CONFIG_BT_HCI which are both set and yet the system gives me back that CONFIG_BT_CONN=n. Picture from nRF Kconfig GUI:

    I would like to use the smp_svr + hci_rpmsg as it is a good starting point on porting the transmission protocol from bluetooth to ESB and just reverse engineer the packets and how to send the binary over ESB and keep the stack that writes the packets into the bootloader. If you have any other better suggestion on how to solve this or another angle please let me know.

    Best regards,

    Domen

  • Hi again

    After a bit of digging around researching your issue I found/was made aware of this GitHub sample by one of our devs that have passed by me. It is an ESB + BLE sample for the nRF5340 that should build/run as is. Can you take a look at that, as these prj.conf snippets don't tell me much, and the ESB expert here on tech support is currently busy, so what specifics we can help with are a bit limited at the time being unfortunately.

    Best regards,

    Simon

Related