Way to revert back incase of failure while using application based DFU in nRF52840 SoC

Hi, 

I'm trying to implement application-based DFU as mentioned here.

https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/smp

I'm facing issues with the serial recovery method so I'm trying this application-based DFU using which I'm able to load the new firmware into slot 1 and boot it using mcumgr confirm command.

But after confirming the slot 1 image(which is not an smp_svr), how can I revert back to the slot which is having the SMP_SVR ( and without SMP_SVR running, how can I switch  slots as my current slot only have RCP firmware running and SMP is in the inactive slot) 

Any Suggestions?

Thanks.

  • Hi,

    I think you can use dfu_target_schedule_update to tag the secondary slot as "test" or "confirm". I have not tested this, so I suggest you try this in a minimal sample to learn how DFU Target works first.

    To trigger this from the RCP, try to use a user vendor hook.

    Regards,
    Sigurd Hellesvik

  • Hi, 

    Is there any example implementation you could find, as the documentation has no samples, and how can it be implemented for my query?

    Thanks.

  • Searching for dfu_target_schedule_update inside the v2.3.0/nrf folder gave me these results:

    subsys/zigbee/lib/zigbee_fota/src/dfu_multi_target.c
    163:	return dfu_target_schedule_update(DFU_TARGET_SCHEDULE_ALL_IMAGES);
    
    subsys/dfu/dfu_target/src/dfu_target.c
    160:int dfu_target_schedule_update(int img_num)
    
    subsys/net/lib/fota_download/src/fota_download.c
    215:			err = dfu_target_schedule_update(0);
    
    subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_firmware.c
    390:	return dfu_target_schedule_update(0);
    714:		ret = dfu_target_schedule_update(0);
    
    doc/nrf/libraries/dfu/dfu_target.rst
    35:#. When the application is ready to install the image, call the :c:func:`dfu_target_schedule_update` function to mark it as ready for update.
    71:2. Call the :c:func:`dfu_target_schedule_update` function to mark the firmware as *ready to be booted*.
    77:   The application can schedule the upgrade of all the image pairs at once using the :c:func:`dfu_target_schedule_update` function.
    86:When the transfer has completed, the application must call the :c:func:`dfu_target_done` function to release modem resources and then call :c:func:`dfu_target_schedule_update` to request the modem to apply the patch.
    104:The DFU target library does not perform the upgrade and calling the :c:func:`dfu_target_schedule_update` function has no effect.
    
    samples/matter/lock/src/software_images_swapper.cpp
    56:	result = dfu_target_schedule_update(-1);
    
    lib/bin/lwm2m_carrier/os/lwm2m_os.c
    880:		err = dfu_target_schedule_update(0);
    
    include/dfu/dfu_target.h
    157:int dfu_target_schedule_update(int img_num);
    
    tests/subsys/dfu/dfu_target/mcuboot/src/main.c
    103:	(void)dfu_target_schedule_update(0);
    152:	dfu_target_schedule_update(0);
    176:	err = dfu_target_schedule_update(0);
    182:	err = dfu_target_schedule_update(0);
    
    tests/subsys/net/lib/fota_download/src/test_fota_download.c
    83:int dfu_target_schedule_update(int img_num)
    

    I recommend starting with  tests/subsys/net/lib/fota_download/src/test_fota_download.c

    Regards,
    Sigurd Hellesvik

Related