This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Mesh SDK v3.1.0 with Buttonless DFU example.

Hi guys, hope all is well. I was hoping someone could help me out with this particular issue. Maybe someone on here has tried to do the same thing.

Just some background about my test setup:

  • Using 2x nRF52840's, custom hardware.
  • One is the client, the other is the server (running the Light Switch example from Mesh SDK v3.1.0)
  • Using SDK v15.2, and my code is based off the examples in there.
  • Using s140 v6.1.0.

I am trying to use the Buttonless DFU example with my code (both light switch server and client), and have had limited success. When performing a DFU via the Buttonless DFU service, all works well and as expected.

My Issue arises when I try and provision a node. It looks like during the provisioning process, the code gets to this point (in mesh_provisionee.c):

static void sd_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context)
{
    (void) p_context;

    if (!m_doing_gatt_reset)
    {
        return;
    }
    switch (state)
    {
        ...
        
        case NRF_SDH_EVT_STATE_DISABLED: /* Gets to this handler */
        {
            uint32_t err_code = nrf_sdh_enable_request();
            APP_ERROR_CHECK(err_code);
            break;
        }
        default:
            break;    
    
    }
}

But in the buttonless dfu code, there is the same handler:

static void buttonless_dfu_sdh_state_observer(nrf_sdh_state_evt_t state, void * p_context)
{
    if (state == NRF_SDH_EVT_STATE_DISABLED)
    {
        // Softdevice was disabled before going into reset. Inform bootloader to skip CRC on next boot.
        nrf_power_gpregret2_set(BOOTLOADER_DFU_SKIP_CRC);

        //Go to system off.
        nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
    }
}

I have run the debugger, and it looks like this code gets executed as well, which powers down the device.  This appears to be the root cause of the problem. I have tried to get around it by doing the following:

static void buttonless_dfu_sdh_state_observer(nrf_sdh_state_evt_t state, void * p_context)
{
    if (state == NRF_SDH_EVT_STATE_DISABLED)
    {

        if(MeshServer_ProvisioningStarted()|| MeshClient_ProvisioningStarted())
            bDeviceProvisioning = true;
        else
            bDeviceProvisioning = false;

        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "[DEBUG] bDeviceProvisioning = %d\n", (int)bDeviceProvisioning);
        if(!bDeviceProvisioning){
            // Softdevice was disabled before going into reset. Inform bootloader to skip CRC on next boot.
            nrf_power_gpregret2_set(BOOTLOADER_DFU_SKIP_CRC);

            //Go to system off.
            nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
        }
    }
}

I check when the device is provisioning, and when it is - I block out this bit of code. It is a bit dirty, and I was wondering if there was a nicer way of doing it. I am aware that there exists built in DFU facilities in the mesh stack. Could I maybe use the Mesh DFU like you would use the Buttonless DFU, ie with a bootloader?

Regards,

Gord

Parents
  • Hi,

    I think it is fine using the workaround you come up it.

    The bootloader DFU, supported in the Mesh DFU, the application is not running, and the bootloader takes care of the transfer. This mode is primarily meant as a fallback mechanism, in case the application malfunctions. The Mesh DFU also supports side-by-side DFU which transfers the new firmware in the background while the application is running and reports to the application when the transfer is done.

Reply
  • Hi,

    I think it is fine using the workaround you come up it.

    The bootloader DFU, supported in the Mesh DFU, the application is not running, and the bootloader takes care of the transfer. This mode is primarily meant as a fallback mechanism, in case the application malfunctions. The Mesh DFU also supports side-by-side DFU which transfers the new firmware in the background while the application is running and reports to the application when the transfer is done.

Children
Related