Configure Bluetooth: Peripheral UART application, bootloader and etc.

Hi !

I have selected sample https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.2.0/nrf/samples/bluetooth/peripheral_uart/README.html#peripheral-uart

as basis for evaluate USB_CDC_ACM connectivity to app core and USB_CDC_ACM Recovery mode ( app and network core) via MCUBoot bootloader.

I assume SMP server need to be allocated in MCUBoot and App core and Network core can be updated  ( without using any copies in flash memory ) by using mcumgr utility.

1.

I hide some definition in environmental variables for operate with simple command line :

west build --build-dir ./build  . --pristine --board nrf5340dk_nrf5340_cpuapp -- -DBOARD_ROOT=. -DDTC_OVERLAY_FILE="app.overlay" -DCONF_FILE="prj.conf"

this configuration can be compiled and flashed without any problems. I can see some debug traces from DK board via ACM0 and 1 USB serial ports.

I assume VS and command line build environment is configured properly.

2. Change App core connectivity from serial to USB_CDC_ACM according recommendation

west build --build-dir ./build  . --pristine --board nrf5340dk_nrf5340_cpuapp -- -DBOARD_ROOT=. -DDTC_OVERLAY_FILE="usb.overlay" -DCONF_FILE="prj_cdc.conf"

Errors

"

Loaded configuration '/home/yevgen/ncs/v2.2.0/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_defconfig'
Merged configuration '/home/yevgen/nsctest/cpuapp/prj_cdc.conf'

warning: BT_SMP (defined at subsys/bluetooth/host/Kconfig:317, subsys/bluetooth/host/Kconfig:317) has direct dependencies (BT_CONN && BT_HCI_HOST && BT_RPC_STACK) || (BT_CONN && BT_HCI_HOST && BT_HCI && BT) with value n, but is currently being y-selected by the following symbols:
- BT_NUS_SECURITY_ENABLED (defined at /home/yevgen/nsctest/cpuapp/Kconfig:23), with value y, direct dependencies y (value: y)

error: Aborting due to Kconfig warnings

CMake Error at /home/yevgen/ncs/v2.2.0/zephyr/cmake/modules/kconfig.cmake:328 (message):
command failed with return code: 1

"

if I disable BT security, other errors popups

"

42 | #define DEVICE_NAME CONFIG_BT_DEVICE_NAME
| ^~~~~~~~~~~~~~~~~~~~~
/home/yevgen/ncs/v2.2.0/zephyr/include/zephyr/bluetooth/bluetooth.h:375:30: note: in definition of macro 'BT_DATA'
375 | .data_len = (_data_len), \
| ^~~~~~~~~
../src/main.c:43:33: note: in expansion of macro 'DEVICE_NAME'
43 | #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
| ^~~~~~~~~~~
../src/main.c:76:53: note: in expansion of macro 'DEVICE_NAME_LEN'
76 | BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),

"

So it is exists some errors in application ?

3. I have returned to original configuration DCONF_FILE="prj.conf" and try to add MCUBoot configuration to application and configure MCUBoot itself.

e.g add extra lines to prj.conf

# MCUBoot serial
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y

# The following configurations are required to support serial recovery of the
# network image
CONFIG_PCD_APP=y

CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n

CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
CONFIG_NRF53_RECOVERY_NETWORK_CORE=y

CONFIG_MCUBOOT_INDICATION_LED=y

OR

west build --build-dir ./build . --pristine --board nrf5340dk_nrf5340_cpuapp -- -DBOARD_ROOT=. -DDTC_OVERLAY_FILE="app.overlay" -DCONF_FILE="prj.conf" -DOVERLAY_CONFIG="nrf5340dk_mcuboot_sr_net.conf"

and

Merged configuration '/home/yevgen/nsctest/cpuapp/prj.conf'

warning: BOOT_IMAGE_ACCESS_HOOKS (defined at modules/Kconfig.mcuboot_bootutil:24) was assigned the
value 'y' but got the value 'n'. Check these unsatisfied dependencies: MCUBOOT_BOOTUTIL_LIB (=n).
See docs.zephyrproject.org/.../kconfig.html and/or look up
BOOT_IMAGE_ACCESS_HOOKS 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: FLASH_SIMULATOR (defined at drivers/flash/Kconfig.simulator:6) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: DT_HAS_ZEPHYR_SIM_FLASH_ENABLED (=n).
See docs.zephyrproject.org/.../kconfig.html and/or look up
FLASH_SIMULATOR 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: FLASH_SIMULATOR_DOUBLE_WRITES (defined at drivers/flash/Kconfig.simulator:25) was assigned
the value 'y' but got the value 'n'. Check these unsatisfied dependencies: FLASH_SIMULATOR (=n). See
docs.zephyrproject.org/.../kconfig.html and/or look
up FLASH_SIMULATOR_DOUBLE_WRITES 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/yevgen/nsctest/cpuapp/prj.conf:53: warning: attempt to assign the value 'y' to the undefined symbol MCUBOOT_SERIAL

/home/yevgen/nsctest/cpuapp/prj.conf:54: warning: attempt to assign the value 'y' to the undefined symbol MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD

/home/yevgen/nsctest/cpuapp/prj.conf:65: warning: attempt to assign the value 'y' to the undefined symbol NRF53_RECOVERY_NETWORK_CORE

/home/yevgen/nsctest/cpuapp/prj.conf:67: warning: attempt to assign the value 'y' to the undefined symbol MCUBOOT_INDICATION_LED

error: Aborting due to Kconfig warnings

4. Could it be possible to guide me with MCUBoot configuration for this project ?

The next features are expected:

- SMP server located in MCUBoot only

- Serial recovery method is used for update App and Network cores ( no extra copies of firmware in mcu's flash memory or external serial memory )

- USB_CDC_ACM connectivity to MCUBoot

- Enable multiimage build e.g *zip what contains updates for both cores.

5. Also not so clear how to change child network core project for current image. Looks like it is hardcoded somewhere.

Regards,

Eugene

 

  • Hi,

    Hiihtaja said:

    Looks like I should inform mcuboot or/and b0n that image in that slot and force update somehow.

    How I can do it ? Does reboot is mandatory ?

    For SMP Server in the application, you need to tag the new image with either "test" or "confirm".

    For Serial Recovery, you upload it directly. Here is a quick sample I made to test this:

    mcuboot_netcore_serial_recovery.zip

    To upload to the netcore, use

    mcumgr  -c acm1 image upload build/zephyr/net_core_app_update.bin  -n 3

    Then wait for ca 2 minutes before restarting the device.

    Regards,
    Sigurd Hellesvik

  • Hi !

    I should enable in prj.conf few lines in your sample

    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_SMP_UART=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y

    $ mcumgr -c acm1 image upload build/zephyr/net_core_app_update.bin -n 3
    181.71 KiB / 181.71 KiB [===============================================================================================================] 100.00% 1.80 KiB/s 1m41s
    Done

    App image is also uploaded to some space

    $ mcumgr -c acm1 image upload build/zephyr/app_update.bin
    58.02 KiB / 58.02 KiB [=====================================================================================================================] 100.00% 956 B/s 1m2s
    Done

    But actual update is not happens.

    Partition info

    But how images are updated on fly ?

    Looks like network and app core is up and running with normal images and need to be 

    updated by MCUMGR

    Regards,

    Eugene

  • Hiihtaja said:
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_SMP_UART=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y

    The sample is configured for Serial Recovery, so the above configuration is not needed.

    To enter Serial Recovery mode, hold Button 1 when resetting.
    LED1 should now light up, signaling that the board is in Serial Recovery mode.

    Now you can use mcumgr commands.

    If you want to use an SMP Server in the Application  instead, try my Non Simultaneous update of nRF5340 sample instead.

    Regards,
    Sigurd Hellesvik

  • Hi !

    Yes, I have tried in serial recovery as well. What is partition 3  ? It is SRAM ?

    In case of SMP server in application, I think I need flash memory extra space for app and network.

    Is this so ?

    Regards,

    Eugene

  • Hiihtaja said:
    Yes, I have tried in serial recovery as well. What is partition 3  ? It is SRAM ?

    I think the numbering here is a bit bugged.
    So I am not sure which one number 3 is.

    My guess is that it is mcuboot_primary_1.

    Hiihtaja said:

    In case of SMP server in application, I think I need flash memory extra space for app and network.

    Is this so ?

    I assume you mean external flash?

    You do not have to have external flash for this to work.

    Since you need a secondary slot, the application only have half flash available, so you may want to have external flash for that reason.

    Regards,
    Sigurd Hellesvik

Related