BLE DFU using External SPI Flash on nRF7002DK

I'm working with the nRF7002DK board using NCS version 2.6.0. The internal flash is full, so I need to perform BLE DFU using external flash. Is there a sample available for this?

Parents Reply Children
  • I referred to the ticket  RE: nrf5340 DFU with external flash  which provides a sample example for BLE DFU using SPI. Following that, I applied the suggested configurations,

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

    # Enable the Bluetooth mcumgr transport (unauthenticated).
    CONFIG_MCUMGR_TRANSPORT_BT=y
    CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
    CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y


    # Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies.
    # MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands,
    # transmitted with the maximum possible MTU value: 498 bytes.
    CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
    CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=2475
    CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
    CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608

    CONFIG_MCUMGR=y
    CONFIG_STREAM_FLASH=y
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    # Required by the taskstat command.
    CONFIG_THREAD_MONITOR=y
    # Support for taskstat command
    CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    # Enable most core commands.
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_STAT=y

    # Enable MCUmgr and dependencies.
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y

    in the prj.conf file. I also added the two required files

    3731.nrf7002dk_nrf5340_cpuapp.conf  5126.nrf7002dk_nrf5340_cpuapp.overlay 

    to the child_image/mcuboot/boards directory and included the relevant configuration,

    # General MCUboot image configurations for all boards.

    # Disable serial output
    CONFIG_SERIAL=n
    CONFIG_UART_CONSOLE=n

    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_BOOT_MAX_IMG_SECTORS=256

    # Logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_LOG_LEVEL_WRN=y # Enable simultaenous multi-core updates
    CONFIG_NRF53_MULTI_IMAGE_UPDATE=y
    CONFIG_UPDATEABLE_IMAGE_NUMBER=2
    CONFIG_BOOT_UPGRADE_ONLY=y
    CONFIG_PCD_APP=y # Dependencies for CONFIG_NRF53_MULTI_IMAGE_UPDATE
    CONFIG_FLASH=y
    CONFIG_FLASH_SIMULATOR=y
    CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
    CONFIG_FLASH_SIMULATOR_STATS=n

    in the mcuboot.conf file under the child_image folder.

    Additionally, I placed those below two files in the boards directory as well.

    3731.nrf7002dk_nrf5340_cpuapp.conf

    5126.nrf7002dk_nrf5340_cpuapp.overlay

    The application built successfully, SMP (Simple Management Protocol) services are active, and the DFU option is visible. Then updated the firmware by uploading the new binary file (app_update.bin) via nrf Device Manager. The file was successfully written to external flash. However, the process gets stuck at the swap stage, and the new firmware is not being swapped. Even after resetting the board, the old firmware continues to run. Performing a board erase doesn't help either, as the image still remains in the external flash and isn't removed.

  • Hello,

    hemakumar said:
    CONFIG_NORDIC_QSPI_NOR=y

    You need to make this CONFIG_SPI_NOR=y. Also try adding  CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y 

    A frequent cause for the swap not occurring is a mismatch between the primary and secondary image slot sizes. Both must be the same size for MCUboot to perform the swap correctly. If the secondary slot (in external flash) is smaller or not properly aligned, the swap will fail silently or get stuck. See here:  Unable to do FOTA using Bluetooth and external flash memory .

    Also, for the network core, make sure you have the b0n bootloader enabled. See discussion here:  nRF5340 custom board using sysbuild missing "SUPPORT_NETCORE" causing issue to enable b0n build  

    Regards,

    Swathy

Related