DFU upload speed through BT SMP is slow

DFU file upload speed through BT SMP is painstakingly slow especially for Matter firmware with MCUboot which are about 800 kB.

I just simply compiled and provisioned Matter lamp example on nRF52840 DK and without modifications the upload speed was around 1.5 kB/s from iPhone 14.

After the following modifications (suggested here):

BT_L2CAP_TX_MTU=498

BT_BUF_ACL_TX_SIZE=251

BT_BUF_ACL_RX_SIZE=502

BT_CTLR_DATA_LENGTH_MAX=251

it became 3.7 kB/s. It's better but still much slower that I would expect. Is it possible to improve it a bit more? 

Parents
  • Hello,

    I just got done working on ours and it seems OK. I've tested from our Android app and it transfers the, almost 500 kB image, in about 35 seconds. We are using the nRF52840 SoC and the nRF21540 FEM on our boards.

    What other config options are you using? One of the main ones is:

    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

    as that will imply the:

    NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP

    config. The NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP will set all of those for you:

    config NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP
    	bool "MCUmgr OTA DFU speedup"
    	depends on BT_CTLR || (NCS_SAMPLE_HCI_RPMSG_CHILD_IMAGE || NCS_SAMPLE_MULTIPROTOCOL_RPMSG_CHILD_IMAGE)
    	help
    	  Enable this option to speed up the OTA DFU transfer over Bluetooth.
    	  This option extends the Bluetooth buffers to extend Bluetooth MTU
    	  size. The buffer configuration should be the same in the Network Core
    	  and Application Core image.
    
    	  This configuration option is automatically applied for the Network
    	  Core child image if the NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP option is
    	  enabled in the main image.
    
    if NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP
    
    config BT_L2CAP_TX_MTU
    	default 498 if BT_HCI_HOST
    
    config BT_BUF_ACL_TX_SIZE
    	default 251
    
    config BT_BUF_ACL_RX_SIZE
    	default 502
    
    config BT_CTLR_DATA_LENGTH_MAX
    	default 251 if BT_CTLR
    
    endif

    For what it's worth, here are the exact BT and bootloader configs I'm using:

    #=======================================================================================================================
    # Bluetooth Configuration
    #=======================================================================================================================
    CONFIG_BT=y
    CONFIG_BT_SMP=n
    CONFIG_BT_MAX_CONN=10
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_THROUGHPUT=y
    CONFIG_BT_COMPANY_ID=0x073A
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
    
    CONFIG_BT_BUF_CMD_TX_SIZE=251
    # CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255
    
    CONFIG_BT_CTLR_PHY_2M=y
    CONFIG_BT_CTLR_CONN_RSSI=n
    CONFIG_BT_CTLR_PHY_CODED=n
    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
    
    CONFIG_BT_DEVICE_NAME=""
    CONFIG_BT_DEVICE_NAME_MAX=6
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=y
    
    CONFIG_BT_GATT_CACHING=y
    CONFIG_BT_GATT_SERVICE_CHANGED=y
    CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n
    
    # Make sure supervision timeout is always 5 seconds (500 * 10ms)
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=500
    
    CONFIG_BT_USER_PHY_UPDATE=y
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    
    
    #=======================================================================================================================
    # Bootloader / Firmware Configuration
    #=======================================================================================================================
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_TRANSPORT_BT=y
    CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
    CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
    CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
    CONFIG_MCUMGR_TRANSPORT_NETBUF_COUNT=6
    CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608
    
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK=y
    CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
    
    CONFIG_IMG_MANAGER=y
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP=y

  •  Hi  

    Thank you very much for your suggestion. I wrongly assumed that if I specify DCONFIG_CHIP_DFU_OVER_BT_SMP, the example will set other options optimized for DFU over BT, but, obviously, I was wrong. When I set CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y the speed increased to 15 kB/s. That's totally awesome, thank you for your help!

Reply Children
Related