<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>DFU Mode through selecting the GPREGRET Register</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54225/dfu-mode-through-selecting-the-gpregret-register</link><description>Hi Nordic Team, 
 I&amp;#39;m working with Nordic NRF52832 BLE development Kit. Currently, we are working with DFU Secure bootloader. In this bootloader, we tried the button pressed mode, it goes to DFU mode. I tried to enable the GPREGRET by NRF_BL_DFU_ENTER_METHOD_GPREGRET</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Mar 2021 07:15:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54225/dfu-mode-through-selecting-the-gpregret-register" /><item><title>RE: DFU Mode through selecting the GPREGRET Register</title><link>https://devzone.nordicsemi.com/thread/296746?ContentTypeID=1</link><pubDate>Mon, 01 Mar 2021 07:15:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ff914b6-4cee-4199-8f8e-69825cb2d52c</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Mano,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should look at the&amp;nbsp;&lt;span&gt;ble_app_buttonless_dfu example found in&lt;/span&gt; examples\ble_peripheral\ble_app_buttonless_dfu. The decleration of m_dfu looks like this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Declared in ble_dfu.c
static ble_dfu_buttonless_t             m_dfu;                      /**&amp;lt; Structure holding information about the Buttonless Secure DFU Service. */


// Declared in ble_dfu.h 

/**@brief Type holding memory used by Secure DFU Buttonless Service.
  */
typedef struct
{
    uint8_t                             uuid_type;                      /**&amp;lt; UUID type for DFU UUID. */
    uint16_t                            service_handle;                 /**&amp;lt; Service Handle of DFU (as provided by the SoftDevice). */
    uint16_t                            conn_handle;                    /**&amp;lt; Connection handle for the current peer. */
    ble_gatts_char_handles_t            control_point_char;             /**&amp;lt; Handles related to the DFU Control Point characteristic. */
    uint32_t                            peers_count;                    /**&amp;lt; Counter to see how many persistently stored peers must be updated for Service Changed indication. This value will be counted down when comparing write requests. */
    ble_dfu_buttonless_evt_handler_t    evt_handler;                    /**&amp;lt; Event handler that is called upon Buttonless DFU events. See @ref ble_dfu_buttonless_evt_type_t. */
    bool                                is_waiting_for_reset;           /**&amp;lt; Flag indicating that the device will enter bootloader. */
    bool                                is_waiting_for_svci;            /**&amp;lt; Flag indicating that the device is waiting for async SVCI operation */
} ble_dfu_buttonless_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BLE_DFU_EVT_BOOTLOADER_ENTER and NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU are enumerations, not macros.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The declaration of the&amp;nbsp;BLE_DFU_EVT_BOOTLOADER_ENTER enum is found in&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Nordic Buttonless DFU Service event type .
 */
typedef enum
{
    BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE,   /**&amp;lt; Event indicating that the device is preparing to enter bootloader.*/
    BLE_DFU_EVT_BOOTLOADER_ENTER,           /**&amp;lt; Event indicating that the bootloader will be entered after return of this event.*/
    BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED,    /**&amp;lt; Failure to enter bootloader mode.*/
    BLE_DFU_EVT_RESPONSE_SEND_ERROR,        /**&amp;lt; Failure to send response.*/
} ble_dfu_buttonless_evt_type_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The declaration of the&amp;nbsp;&lt;span&gt;NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU enum&amp;nbsp;is found in nrf_pwr_mgmt.h&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Power management shutdown types. */
typedef enum
{
    NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF,
    //!&amp;lt; Go to System OFF.

    NRF_PWR_MGMT_SHUTDOWN_STAY_IN_SYSOFF,
    //!&amp;lt; Go to System OFF and stay there.
    /**&amp;lt;
     * Useful when battery level is dangerously low, for example.
     */

    NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU,
    //!&amp;lt; Go to DFU mode.

    NRF_PWR_MGMT_SHUTDOWN_RESET,
    //!&amp;lt; Reset chip.

    NRF_PWR_MGMT_SHUTDOWN_CONTINUE
    //!&amp;lt; Continue shutdown.
    /**&amp;lt;
     * This should be used by modules that block the shutdown process, when they become ready for
     * shutdown.
     */
} nrf_pwr_mgmt_shutdown_t;&lt;/pre&gt;&lt;/p&gt;
[quote user="doctormano"]Would this function be called from main application to start a subsequent DFU?[/quote]
&lt;p&gt;&amp;nbsp;Yes, the ble_dfu_buttonless_bootloader_start_finalize function should be called from the main application to enter bootloader mode.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Mode through selecting the GPREGRET Register</title><link>https://devzone.nordicsemi.com/thread/295926?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 20:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77a6f30d-548c-4d3d-91f9-67ee919269a9</guid><dc:creator>Mano</dc:creator><description>&lt;p&gt;Hello Bjorn,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; I am wondering if you could share the declaration of&lt;/p&gt;
&lt;p&gt;1- m_dfu.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I found one in nrf_dfu_ble.h in the secure_bootloader_ble_s140_pca10056 in SDK 17.2&lt;/p&gt;
&lt;p&gt;typedef struct&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; service_handle;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;lt; Handle of the DFU Service (as provided by the SoftDevice). */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uuid_type;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;lt; UUID type assigned to the DFU Service by the SoftDevice. */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ble_gatts_char_handles_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfu_pkt_handles;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;lt; Handles related to the DFU Packet Characteristic. */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ble_gatts_char_handles_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfu_ctrl_pt_handles;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;lt; Handles related to the DFU Control Point Characteristic. */&lt;br /&gt;} ble_dfu_t;&lt;/p&gt;
&lt;p&gt;but this one doesn&amp;#39;t have evt_handler as a member.&lt;/p&gt;
&lt;p&gt;Also where are these macros declared?&lt;/p&gt;
&lt;p&gt;2- BLE_DFU_EVT_BOOTLOADER_ENTER, and&lt;/p&gt;
&lt;p&gt;3- NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Would this function be called from main application to start a subsequent DFU?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Mano&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Mode through selecting the GPREGRET Register</title><link>https://devzone.nordicsemi.com/thread/219456?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2019 12:12:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e929bbe2-f7b1-45fc-89c9-96679f105dba</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Poovai, in order to enter the bootloader using the GPREGRET method you will need to write a specific value to the GPREGRET register and then perform a SoftReset. This is how we do it in our ble_app_buttonless_dfu example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_dfu_buttonless_bootloader_start_finalize(void)
{
    uint32_t err_code;

    NRF_LOG_DEBUG(&amp;quot;In ble_dfu_buttonless_bootloader_start_finalize\r\n&amp;quot;);

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    VERIFY_SUCCESS(err_code);

    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    VERIFY_SUCCESS(err_code);

    // Indicate that the Secure DFU bootloader will be entered
    m_dfu.evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER);

    // Signal that DFU mode is to be enter to the power management module
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>