FOTA over BLE using external flash (nRF Connect SDK 2.9.0) - upload to device stuck

Hello,

I'm trying to get FOTA over BLE (SoC & external Flash) working on NCS 2.9.0. The sysbuild and MCUboot configurations and overlays seem to be fine. The application builds and runs as expected on a nRF52840 device that has 4MB SPI NOR external flash.

I've had FOTA over BLE running on earlier versions of NCS but now I'm migrating projects over to sysbuild and the latest NCS.

I have verified the sysbuild configurations/overlays with successful DFU over UART for both SoC and external flash use cases. However, I suspect that the  BLE / mcumgr configurations may be missing a step or two.

For test purposes, I'm using the Peripheral LBS app, as in the "FOTA over BLE" example in the NCS Intermediate training course.

The nRF52840 device establishes a bonded connection to an iPad running nRF Connect Device Manager. When the Device Manager tries to upload a signed bin (or DFU zip) file, the uploading gets "stuck" as in the screenshot below.

Here's the RTT log for MCUboot & app.

*** Booting MCUboot v2.1.0-dev-12e5ee106034 ***
*** Using nRF Connect SDK v2.9.0-7787b2649840 ***
*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
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: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0x16000
I: Jumping to the first image slot
*** Booting My Application v1.0.0 - unknown commit ***
*** Using nRF Connect SDK v2.9.0-7787b2649840 ***
*** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
Modified Bluetooth Peripheral LBS to support FOTA over BLE
FOTA over BLE using external Flash on particle_xenon
[00:00:00.012,115] <inf> fs_nvs: 2 Sectors of 4096 bytes
[00:00:00.012,145] <inf> fs_nvs: alloc wra: 0, fd0
[00:00:00.012,145] <inf> fs_nvs: data wra: 0, 1c
[00:00:00.012,359] <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: 
2d 79 a1 c8 6a 40 b7 3c f6 74 f9 0b 22 d3 c4 80 |-y..j@.< .t.."...
74 72 82 ba |tr.. 
[00:00:00.016,418] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.016,479] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.016,510] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 45.41337 Build 3074452168
[00:00:00.017,150] <inf> bt_hci_core: No ID address. App must call settings_load()
Bluetooth initialized
[00:00:00.017,944] <inf> bt_hci_core: Identity: E0:9B:74:CB:35:3B (random)
[00:00:00.017,974] <inf> bt_hci_core: HCI: version 6.0 (0x0e) revision 0x106b, manufacturer 0x0059
[00:00:00.018,005] <inf> bt_hci_core: LMP: version 6.0 (0x0e) subver 0x106b
Advertising successfully started
Connected
Disconnected (reason 19)
Connected
Disconnected (reason 19)
Connected
Disconnected (reason 19)
Connected
[00:04:13.704,620] <wrn> bt_l2cap: Ignoring data for unknown channel ID 0x003a
Passkey for 6E:FD:AB:8C:C4:C7 (random): 963626
Security changed: 6E:FD:AB:8C:C4:C7 (random) level 4
Pairing completed: 88:AE:07:41:7D:47 (public), bonded: 1
[00:04:34.888,580] <inf> mcuboot_util: Image index: 0, Swap type: none

The "Disconnected ( reason 19) were before I paired the device to the iPad. After bonding, I'm able to view slot 0 but image upload gets stuck.


app prj.conf:

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Nordic_LBS"

# Enable the LBS service
CONFIG_BT_LBS=y
CONFIG_BT_LBS_POLL_BUTTON=y
CONFIG_DK_LIBRARY=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Enable FOTA over BLE
CONFIG_MCUMGR=y

# Enable MCUMGR management for both OS and Images
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_IMG=y

# Configure MCUMGR transport to UART
CONFIG_MCUMGR_TRANSPORT_BT=y

# Dependencies
# Configure dependencies for CONFIG_MCUMGR
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y

# Configure dependencies for CONFIG_MCUMGR_GRP_IMG
CONFIG_FLASH=y
CONFIG_IMG_MANAGER=y

# Configure dependencies for CONFIG_IMG_MANAGER
CONFIG_STREAM_FLASH=y
CONFIG_FLASH_MAP=y

# Configure dependencies for CONFIG_MCUMGR_TRANSPORT_BT
CONFIG_BASE64=y

# Disable UART Console and enable the RTT console
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_UART_CONSOLE=n


Am I missing something in the configuration that is preventing the image uploads over BLE to the nRF52840?  

I know Support is currently busy updating DFU/FOTA sections in the NCS Intermediate training course, So, hopefully Support will be able to assist. Thank you.


Regards,
Ravi
Parents
  • Hi Ravi, 

    I can't think of any reason why it would get stuck in the upload state. Does it stay like this until you exit the app, or does it time out eventually?

    I quickly tested FOTA with the peripheral_lbs sample in SDK v2.9.0 and have included the modified project I used for this test below. Maybe you can compare your configurations with this one?

    Files I added in this project:

    boards\nrf52840dk_nrf52840.conf // enable DFU related configuarations in app
    boards\nrf52840dk_nrf52840.overlay // select qspi flash dev for external memory region
    sysbuild\mcuboot.overlay // select qspi flash dev for external memory region
    sysbuild\mcuboot.conf  // enable QSPI NOR driver (requires multithreading)
    sysbuild.conf // enable bootloader and placement of secondary slot in external flash

    Regards,

    Vidar

    peripheral_lbs_fota.zip

  • Hi Vidar,

    Thank you for your quick response and the attached project. As always, it's much appreciated.
    Regarding the upload issue: The message times out and then displays a "flash write failed: 12" error in the RTT/UARTconsole output and the nRF Connect Device Manager.


    I've also identified the cause of the issue. As I suspected, it was a misconfiguration.

    Custom device under test:: nRF52840 board with 4MB SPI_NOR flash.(Sorry, I forgot to mention this earlier)
    NRF Connect SDK : v2.9.0
    Boot signature key file: ECDSA_P256 custom keys

     
    With the custom nRF52840 board using the SoC Flash, FOTA over BLE works fine when using Kconfig CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU.

    However, this doesn't work if the external flash on the device is SPI_NOR flash.

    A few NCS releases back, someone reported that CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU used QSPI_NOR. I 
    thought the issue (bug?) was resolved.


    Advertising successfully started
    Connected
    Security changed: 88:AE:07:41:7D:47 (public) level 4
    [00:00:51.381,225] <wrn> bt_l2cap: Ignoring data for unknown channel ID 0x003a
    [00:00:53.636,383] <inf> mcuboot_util: Image index: 0, Swap type: none
    [00:00:53.636,779] <inf> mcuboot_util: Image index: 0, Swap type: none
    [00:00:53.636,840] <err> mcumgr_img_grp: Irrecoverable error: flash write failed: 12

    Anyway, if I explicitly list and use the Kconfig fragments defined in CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU, then FOTA over BLE with the external flash works fine.

    I've now completed several tests for FOTA over BLE using both SoC and SPI NOR Flash with NCS v2.9.0. All works fine with nRF Connect Device Manager.
     
    # here, using a list of Kconfig fragments in place of CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU
    CONFIG_MCUMGR=y
    
    # Configure dependencies for CONFIG_MCUMGR 
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    
    # Configure MCUMGR transport to UART
    CONFIG_MCUMGR_TRANSPORT_BT=y
    
    # Enable the Bluetooth mcumgr transport
    CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
    
    # Configure dependencies for CONFIG_MCUMGR_GRP_IMG 
    CONFIG_IMG_MANAGER=y
    
    # Configure dependencies for CONFIG_IMG_MANAGER 
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH=y
    
    # Enable MCUMGR management for both OS and Images
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y
    
    CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
    
    # Configure dependencies for CONFIG_MCUMGR_TRANSPORT_BT
    CONFIG_BASE64=y

    I did check the  /opt/nordic/ncs/v2.9.0/nrf/samples/common/mcumgr_bt_ota_dfu/Kconfig to see if NORDIC_QSPI_NOR is still a requirement for it but didn't see it in the Kconfig, unless the dependency is specified elsewhere.

    It would be nice to have CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU that works for both  
    NORDIC_QSPI_NOR and  SPI_NOR flash. Any chance you could follow up on this with dev? Thanks.


    I would like to take this opportunity to thank Nordic teams for the excellent nRF Connect SDK training courses. 


    Many thanks to you and your colleagues in Support for the on-going effort to bring the courses up to NCS v2.9.0.  We're almost there! It's much appreciated!


    Best Regards,
    Ravi

  • Thank you. CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU no longer selects the QSPI NOR driver as it did in earlier SDK versions, so it should not prevent you from selecting the SPI NOR driver.

    Here is the same sample for the nRF52840 DK board except this version uses the SPIM3 instead of the QSPI for the exernal flash:

    peripheral_lbs_fota_spi.zip

    The key and maybe not obvious difference is that 'SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK' needs to be enabled when you want to use the SPI NOR driver instead.

    Best regards,

    Vidar

  • Hi Vidar,

    Thanks.

    It's odd, as I already had the external driver check Kconfig.

    # Enable MCUboot
    SB_CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Configure bootloader to use more than one slot
    SB_CONFIG_MCUBOOT_MODE_SINGLE_APP=n
    
    # Use external 4MB SPI NOR Flash
    SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
    SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

    I'll check again and update you shortly.


    Regards,
    Ravi
  • Hi Vidar,

    Thank you for sharing the peripheral_lbs_fota_spi.zip.

    It turns out that I had a couple of other Kconfig settings from one of my earlier projects that were the cause of the issue. So, removing them resolved the issue.

    CONFIG_BOOT_ERASE_PROGRESSIVELY=y
    CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
    CONFIG_FPROTECT=y

    Regards,
    Ravi

  • Hi Ravi,

    Thanks for the update. I'm afraid I don't have any obvious explanations for why these configurations caused it to fail. CONFIG_FPROTECT  and CONFIG_BOOT_ERASE_PROGRESSIVELY should both be enabled by default in the bootloader and I don't see why enabling CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS should have any side effect.:

    I don't see a reason to enable FPROTECT in the application since the bootloader is responsible for configuring the flash memory protection.

    Regards,

    Vidar

  • Hi Vidar,

    Thanks. I doubt understand it either but will look re-check again.

    I'll close this ticket. Thank you again.


    Regards,
    Ravi

Reply Children
No Data
Related