This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

6.1.0 bootloader and triggering DFU from app

Hey! I've been working on triggering DFU from within my application. It's obvious that the bootloader in the new SDK has been written to support this but I had some problems getting it working.

The call to ble_stack_init(bool init_softdevice) takes an argument, init_softdevice, which is set to false when DFU has been triggered from within the application. It's used to determine whether or not to call the function sd_mbr_command(). If DFU mode was triggered from within the application, this function does not got called.

The issue I had was this: if I did not call this function, the bootloader would not run. I had to modify the code so it always got called for the device to start advertising in DFU mode.

This works when init_softdefice is false

//if (init_softdevice)
//{
    err_code = sd_mbr_command(&com);
    APP_ERROR_CHECK(err_code);
//}

This doesn't

if (init_softdevice)
{
    err_code = sd_mbr_command(&com);
    APP_ERROR_CHECK(err_code);
}

I wouldn't really call this a problem, I've got my system working, but I am confused about why Nordic wrote code that appears to be broken. Am I doing something fundamentally flawed here or was that a bug?

Parents
  • FormerMember
    0 FormerMember

    Let me know if I have misunderstood:

    The first case will always works because it doesn't check if init_softdevice is trueor false:

    //if (init_softdevice)
    //{
        err_code = sd_mbr_command(&com);
        APP_ERROR_CHECK(err_code);
    //}
    

    The second case will only work if init_softdevice == true, which is what is "written" in the if-statement:

    if (init_softdevice)
    {
        err_code = sd_mbr_command(&com);
        APP_ERROR_CHECK(err_code);
    }
    
  • Unfortunately I'm no longer working on the project where this was an issue so I can't test anything ;( I'd say you're right, though, the code in the if statement only executes if init_softdevice is 'true'. In order for the device to start advertising I always has to call sd_mbr_command(&com) even when the SoftDevice was supposedly already initialised.

Reply
  • Unfortunately I'm no longer working on the project where this was an issue so I can't test anything ;( I'd say you're right, though, the code in the if statement only executes if init_softdevice is 'true'. In order for the device to start advertising I always has to call sd_mbr_command(&com) even when the SoftDevice was supposedly already initialised.

Children
No Data
Related