flash_sync_mpsl: timeout when using dfu_target_mcuboot

Hi,

We are using the API from dfu_target_mcuboot.c to perform DFU on NRF52840.

We set the following flags in prj.conf.

CONFIG_STREAM_FLASH=y
CONFIG_STREAM_FLASH_ERASE=y
CONFIG_DFU_TARGET=y
CONFIG_DFU_TARGET_MCUBOOT=y
CONFIG_DFU_MULTI_IMAGE=y
CONFIG_BOOTLOADER_MCUBOOT=y

After finishing the call of "dfu_target_mcuboot_set_buf" and "dfu_target_init", we call "dfu_target_mcuboot_write" to write the image data to mcuboot_secondary partition.

But there is a "flash_sync_mpsl: timeout" error when "dfu_target_stream" flush the buffer to flash.

Do we miss some initialization steps?

How can we fix the bug?

Regards.

Parents
  • Hi,

    Can you elaborate a bit more on what you do and your code? Note that a somewhat common issue when writing to flash via MPSL APIs is to not use the multithread locking. You should encapsulate calls with  MULTITHREADING_LOCK_ACQUIRE() / MULTITHREADING_LOCK_RELEASE().

    It could also be that that the MPSL is not able to schedule the operation if you are for instance doing this with too tight Bluetooth or other connection parameters, so that a flash page erase would cause problems for the wireless protocol.

  • Hi,

    For all I know, nRF Connect SDK does not support Mesh DFU. We want to implement Mesh DFU with nRF Connect SDK.

    Specifically, we want to transfer the firmware over the Mesh network, flush the received firmware on the node device, and finally reboot with new firmware with MCUBootloader.

    We follow the instruction of DFU target. We select MCUboot-style upgrades,  call "dfu_target_mcuboot_set_buf" to set the buffer, and call "dfu_target_mcuboot_init" to init DFU target.

    However, when we call "dfu_target_mcuboot_write" to flush the firmware segment to device flash, the error "flash_sync_mpsl: timeout" occurs. We trace the function "dfu_target_mcuboot_write", the call chain is "dfu_target_mcuboot_write-->dfu_target_stream_write-->stream_flash_buffered_write-->flash_sync-->stream_flash_erase_page".

    The error rises from "stream_flash_erase_page", which wants to erase the page where the firmware segment needs write to.

  • Hi,

    freshweek said:
    For all I know, nRF Connect SDK does not support Mesh DFU. We want to implement Mesh DFU with nRF Connect SDK.

    That is correct, DFU over Bluetooth mesh is not currently supported.

    freshweek said:
    The error rises from "stream_flash_erase_page", which wants to erase the page where the firmware segment needs write to.

    I see. And this in turn calls into flash_sync_mpsl()  in nrf/drivers/mpsl/flash_sync/flash_sync_mpsl.c which prints the first error you see, after the flash operation times out. (By the way, I see from the implementation there that my earlier advice about using MULTITHREADING_LOCK_ACQUIRE()/RELEASE() was incorrect, as that is done in that implementation).

    I cannot see from this why you are not able to complete the flash operation, but as you can see from Timing-activities and priorities, flash operations have low priority, so to improve this you should try to do less of the higher priority operations.

Reply
  • Hi,

    freshweek said:
    For all I know, nRF Connect SDK does not support Mesh DFU. We want to implement Mesh DFU with nRF Connect SDK.

    That is correct, DFU over Bluetooth mesh is not currently supported.

    freshweek said:
    The error rises from "stream_flash_erase_page", which wants to erase the page where the firmware segment needs write to.

    I see. And this in turn calls into flash_sync_mpsl()  in nrf/drivers/mpsl/flash_sync/flash_sync_mpsl.c which prints the first error you see, after the flash operation times out. (By the way, I see from the implementation there that my earlier advice about using MULTITHREADING_LOCK_ACQUIRE()/RELEASE() was incorrect, as that is done in that implementation).

    I cannot see from this why you are not able to complete the flash operation, but as you can see from Timing-activities and priorities, flash operations have low priority, so to improve this you should try to do less of the higher priority operations.

Children
No Data
Related