Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_dfu_flash_callback_t changed in SDK 15

Hello,

 with SDK15 the definition of the nrf_dfu_flash_callback_t changed from

typedef nrf_fstorage_evt_handler_t dfu_flash_callback_t;

typedef void (*nrf_fstorage_evt_handler_t)(nrf_fstorage_evt_t * p_evt);

typedef struct
{
    nrf_fstorage_evt_id_t   id;         //!< The event ID.
    ret_code_t              result;     //!< Result of the operation.
    uint32_t                addr;       //!< Address at which the operation was performed.
    uint32_t                len;        //!< Length of the operation.
    void                  * p_param;    //!< User-defined parameter passed to the event handler.
} nrf_fstorage_evt_t;

to

typedef void (*nrf_dfu_flash_callback_t)(void * p_buf);

we used the nrf_fstorage_evt_t->result to determine the success of the operation in the callback, but now with the (void* p_buf) we can't do it, because there is no description what data is in this buffer and in what form.

If someone could provide a solution, I would appreciate it.

Thanks in advance and best regards,

Niclas

Parents
  • Hi,

    The p_buf pointer will be set to the source buffer (buffer written to flash) by dfu_fstorage_evt_handler(), which calls the callback function. I have not been able to determine why this change was done, though.

  • In the SDK 15.0 there is only one example of this usage that can be found in nrf_dfu_req_handler.c. There it seems that void * p_buf is used a function pointer and not a buffer pointer.

     /* Callback to on_dfu_complete() after updating the settings. */
     dfu_settings_callback = (nrf_dfu_flash_callback_t)(on_dfu_complete);

    and above

     static void on_dfu_complete(nrf_fstorage_evt_t * p_evt)
     { blabla }

    That implementation make sense (in a way), but contradicts your explanation... Am I looking it the wrong way here?

  • I think you are looking at it the wrong way, but I have to admit that I am looking at it the first time now (It is vacation time in Norway, so I have not been able to get hold of any of the original developers).

    The line you refer to in nrf_dfu_req_handler.c:

    dfu_settings_callback = (nrf_dfu_flash_callback_t)(on_dfu_complete);

    is essentially just making dfu_settings_callback be a function pointer to on_dfu_complete(), which is a static function implemented in the beginning of the file. This is subsequently passed to nrf_dfu_settings_write(), which calls nrf_dfu_flash_store() and via a few more function calls it ends up in the dfu_fstorage_evt_handler(), which calls the registered callback function (on_dfu_complete() in this case).

Reply
  • I think you are looking at it the wrong way, but I have to admit that I am looking at it the first time now (It is vacation time in Norway, so I have not been able to get hold of any of the original developers).

    The line you refer to in nrf_dfu_req_handler.c:

    dfu_settings_callback = (nrf_dfu_flash_callback_t)(on_dfu_complete);

    is essentially just making dfu_settings_callback be a function pointer to on_dfu_complete(), which is a static function implemented in the beginning of the file. This is subsequently passed to nrf_dfu_settings_write(), which calls nrf_dfu_flash_store() and via a few more function calls it ends up in the dfu_fstorage_evt_handler(), which calls the registered callback function (on_dfu_complete() in this case).

Children
Related