Failed to build FOTA firmware (nRF 1.9.1)

We have an nRF5340 application that builds fine for our custom board. However, it is not very straightforward what steps need to be performed to enable FOTA updates. I have looked into the "bluetooth/peripheral_uart" example and some tutorials, so I have added the following options in `prj.conf` :

# All below settings included from: https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu
# Enable mcumgr.
CONFIG_MCUMGR=y

# Enable the Bluetooth (unauthenticated) and shell mcumgr transports.
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL=y
# CONFIG_MCUMGR_SMP_SHELL=y

# Enable most core commands.
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y

# Enable custom SMP request to erase settings partition.
CONFIG_MCUMGR_GRP_ZEPHYR_BASIC=y
CONFIG_MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE=y

# Allow for large Bluetooth data packets.
CONFIG_BT_L2CAP_TX_MTU=498
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=502

# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0+0"
CONFIG_UPDATEABLE_IMAGE_NUMBER=2

CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

CONFIG_MAIN_STACK_SIZE=4096

But when I build the application, I am getting the following error:

C:\Nordic_ncs\incus\zephyr\include\toolchain\gcc.h:61:36: error: static assertion failed: "Missing partitions?"
   61 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
      |                                    ^~~~~~~~~~~~~~
C:\Nordic_ncs\incus\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt\src\zephyr_img_mgmt.c:26:1: note: in expansion of macro 'BUILD_ASSERT'
   26 | BUILD_ASSERT(IMG_MGMT_UPDATABLE_IMAGE_NUMBER == 1 ||
      | ^~~~~~~~~~~~
[304/591] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/smp.c.obj

I have several questions:

1. How to make the project build for multi-image FOTA, BLE updates? Do I need to include the following in the MCUboot configuration?

CONFIG_BOOT_UPGRADE_ONLY - The simultaneous update of multiple images does not support network core image reversion, so you need to disable application image reversion.

CONFIG_PCD_APP - Enable commands exchange with the network core.

CONFIG_UPDATEABLE_IMAGE_NUMBER - Enable support for multiple update partitions by setting this option to 2.

2. I haven't found any nRF samples that demonstrate how to do an FOTA update via BLE, using the nRF5340-DK. Can you please point me to any?

3. The peripheral_uart example uses external flash for the FOTA update. We don't have an external flash chip on our custom board, will there be enough space in the internal flash storage? I read here there may not be enough: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_thingy53.html#external-flash But we do have an SD card which we could use.

Thank you.

Parents
  • I was able to update the nRF5340 DK using the peripheral_uart sample and following the steps in DFU over Bluetooth. Here is the sample I used, 

    Here is the diff of the changes I applied to peripheral_uart:

    diff --git a/samples/bluetooth/peripheral_uart/prj.conf b/samples/bluetooth/peripheral_uart/prj.conf
    index e5262de64..e055dfb1e 100644
    --- a/samples/bluetooth/peripheral_uart/prj.conf
    +++ b/samples/bluetooth/peripheral_uart/prj.conf
    @@ -48,3 +48,24 @@ CONFIG_LOG_BACKEND_RTT=y
     CONFIG_LOG_BACKEND_UART=n
     
     CONFIG_ASSERT=y
    +
    +# Enable mcumgr.
    +CONFIG_MCUMGR=y
    +
    +# Enable most core commands.
    +CONFIG_MCUMGR_CMD_IMG_MGMT=y
    +CONFIG_MCUMGR_CMD_OS_MGMT=y
    +
    +# Ensure an MCUboot-compatible binary is generated.
    +CONFIG_BOOTLOADER_MCUBOOT=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
    +
    +# Some command handlers require a large stack.
    +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    \ No newline at end of file
    diff --git a/samples/bluetooth/peripheral_uart/src/main.c b/samples/bluetooth/peripheral_uart/src/main.c
    index 8a1ca1e50..c1445c13e 100644
    --- a/samples/bluetooth/peripheral_uart/src/main.c
    +++ b/samples/bluetooth/peripheral_uart/src/main.c
    @@ -32,6 +32,10 @@
     
     #include <logging/log.h>
     
    +#include <mgmt/mcumgr/smp_bt.h>
    +#include "os_mgmt/os_mgmt.h"
    +#include "img_mgmt/img_mgmt.h"
    +
     #define LOG_MODULE_NAME peripheral_uart
     LOG_MODULE_REGISTER(LOG_MODULE_NAME);
     
    @@ -76,7 +80,9 @@ static const struct bt_data ad[] = {
     };
     
     static const struct bt_data sd[] = {
    -	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
    +	BT_DATA_BYTES(BT_DATA_UUID128_ALL,
    +		      0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
    +		      0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
     };
     
     #if CONFIG_BT_NUS_UART_ASYNC_ADAPTER
    @@ -571,6 +577,10 @@ void main(void)
     	if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED)) {
     		bt_conn_auth_cb_register(&conn_auth_callbacks);
     	}
    +	printk("build time: " __DATE__ " " __TIME__ "\n");
    +	os_mgmt_register_group();
    +	img_mgmt_register_group();
    +	smp_bt_register();
     
     	err = bt_enable(NULL);
     	if (err) {
    

    Here is the output I got

    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot
    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    Starting Nordic UART service example
    build time: Jun  7 2022 14:22:19
    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot
    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    Starting Nordic UART service example
    build time: Jun  7 2022 14:24:45

    1. How to make the project build for multi-image FOTA, BLE updates? Do I need to include the following in the MCUboot configuration?

    Fullscreen
    1
    2
    3
    4
    5
    CONFIG_BOOT_UPGRADE_ONLY - The simultaneous update of multiple images does not support network core image reversion, so you need to disable application image reversion.
    CONFIG_PCD_APP - Enable commands exchange with the network core.
    CONFIG_UPDATEABLE_IMAGE_NUMBER - Enable support for multiple update partitions by setting this option to 2.

    No, if you just want to update the application, you don't need to add these

    2. I haven't found any nRF samples that demonstrate how to do an FOTA update via BLE, using the nRF5340-DK. Can you please point me to any?

    Check my attached sample above

    3. The peripheral_uart example uses external flash for the FOTA update. We don't have an external flash chip on our custom board, will there be enough space in the internal flash storage? I read here there may not be enough: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_thingy53.html#external-flash But we do have an SD card which we could use.

    I was able to perform a DFU using the peripheral_uart and the nRF5340 without using external flash (confirmed it by running ninja partition_manager_report from the build folder). However, if your application is large, you might need to use external flash.

    Also, could you change your title and include 'nRF5340', so other people can find it more easily

    Best regards,

    Simon

Reply
  • I was able to update the nRF5340 DK using the peripheral_uart sample and following the steps in DFU over Bluetooth. Here is the sample I used, 

    Here is the diff of the changes I applied to peripheral_uart:

    diff --git a/samples/bluetooth/peripheral_uart/prj.conf b/samples/bluetooth/peripheral_uart/prj.conf
    index e5262de64..e055dfb1e 100644
    --- a/samples/bluetooth/peripheral_uart/prj.conf
    +++ b/samples/bluetooth/peripheral_uart/prj.conf
    @@ -48,3 +48,24 @@ CONFIG_LOG_BACKEND_RTT=y
     CONFIG_LOG_BACKEND_UART=n
     
     CONFIG_ASSERT=y
    +
    +# Enable mcumgr.
    +CONFIG_MCUMGR=y
    +
    +# Enable most core commands.
    +CONFIG_MCUMGR_CMD_IMG_MGMT=y
    +CONFIG_MCUMGR_CMD_OS_MGMT=y
    +
    +# Ensure an MCUboot-compatible binary is generated.
    +CONFIG_BOOTLOADER_MCUBOOT=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
    +
    +# Some command handlers require a large stack.
    +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    \ No newline at end of file
    diff --git a/samples/bluetooth/peripheral_uart/src/main.c b/samples/bluetooth/peripheral_uart/src/main.c
    index 8a1ca1e50..c1445c13e 100644
    --- a/samples/bluetooth/peripheral_uart/src/main.c
    +++ b/samples/bluetooth/peripheral_uart/src/main.c
    @@ -32,6 +32,10 @@
     
     #include <logging/log.h>
     
    +#include <mgmt/mcumgr/smp_bt.h>
    +#include "os_mgmt/os_mgmt.h"
    +#include "img_mgmt/img_mgmt.h"
    +
     #define LOG_MODULE_NAME peripheral_uart
     LOG_MODULE_REGISTER(LOG_MODULE_NAME);
     
    @@ -76,7 +80,9 @@ static const struct bt_data ad[] = {
     };
     
     static const struct bt_data sd[] = {
    -	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
    +	BT_DATA_BYTES(BT_DATA_UUID128_ALL,
    +		      0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
    +		      0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
     };
     
     #if CONFIG_BT_NUS_UART_ASYNC_ADAPTER
    @@ -571,6 +577,10 @@ void main(void)
     	if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED)) {
     		bt_conn_auth_cb_register(&conn_auth_callbacks);
     	}
    +	printk("build time: " __DATE__ " " __TIME__ "\n");
    +	os_mgmt_register_group();
    +	img_mgmt_register_group();
    +	smp_bt_register();
     
     	err = bt_enable(NULL);
     	if (err) {
    

    Here is the output I got

    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot
    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    Starting Nordic UART service example
    build time: Jun  7 2022 14:22:19
    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    I: Bootloader chainload address offset: 0xc000
    I: Jumping to the first image slot
    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    Starting Nordic UART service example
    build time: Jun  7 2022 14:24:45

    1. How to make the project build for multi-image FOTA, BLE updates? Do I need to include the following in the MCUboot configuration?

    Fullscreen
    1
    2
    3
    4
    5
    CONFIG_BOOT_UPGRADE_ONLY - The simultaneous update of multiple images does not support network core image reversion, so you need to disable application image reversion.
    CONFIG_PCD_APP - Enable commands exchange with the network core.
    CONFIG_UPDATEABLE_IMAGE_NUMBER - Enable support for multiple update partitions by setting this option to 2.

    No, if you just want to update the application, you don't need to add these

    2. I haven't found any nRF samples that demonstrate how to do an FOTA update via BLE, using the nRF5340-DK. Can you please point me to any?

    Check my attached sample above

    3. The peripheral_uart example uses external flash for the FOTA update. We don't have an external flash chip on our custom board, will there be enough space in the internal flash storage? I read here there may not be enough: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_thingy53.html#external-flash But we do have an SD card which we could use.

    I was able to perform a DFU using the peripheral_uart and the nRF5340 without using external flash (confirmed it by running ninja partition_manager_report from the build folder). However, if your application is large, you might need to use external flash.

    Also, could you change your title and include 'nRF5340', so other people can find it more easily

    Best regards,

    Simon

Children
Related