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

Bonding issue with DFU BLE on custom board with SDK v10 and SD v8.0

In nutshell, I intend to achieve

Buttonless DFU over BLE on a custom board with SDK v10.0.0 and Softdevice v8.0.0 with bonding retained.

On this custom board, there are neither any buttons nor any external clock, hence I had to make corresponding changes in the sample bootloader (that comes with SDK v10.0.0) and in my application. Currently DFU over BLE is working (triggering DFU from bootloader and/or triggering DFU from the application), but the bonding is getting removed after DFU is completed (see the snip from the MCP logs below)

A 16:11:58.706 [DFU] Activate and Reset request sent
I 16:11:58.949 [DFU] Disconnected by the remote device
D 16:11:58.976 [DFU] gatt.refresh() (hidden)
D 16:11:59.102 [DFU] gatt.close()
V 16:11:59.150 [DFU] Removing bond information...
D 16:11:59.183 [DFU] gatt.getDevice().removeBond() (hidden)
D 16:11:59.244 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
D 16:11:59.299 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
I 16:11:59.335 Bond information deleted

Enviornment:

  • SD: v8.0.0
  • SDK: v10.0.0
  • SOC: nrf51822QFAA
  • SOC IC revision: 2
  • Central Application for testing DFU BLE: Nordic's Android phone app, MCP

According to the Compatibility matrix, IC revision 2 is not supported on SDK v10.0.0, but I was told by a Nordic Employee in this thead , that IC revision 2 could also work with SDK v10.0.0 and such efforts are best left to the customers to validate. So, I started porting the application (Bond sharing between Bootloader and Application was not possible with sdk v6.1.0 and SD v7.1.0). The application was ported fine and I did some basic connectivity, and services related tests and it worked well. Now during the DFU over BLE, I face this problem of bonding getting deleted. I suspect the problem is with firmware and not with the IC compatibility issue.

I've set the memory settings for Bootlader in KEIL MDK5 Toolchain, according to this thread and is as follows:

IROM1 Start: 0x0003C000 Size: 0x3C00
IRAM1 Start: 0x20002C00 Size: 0x1380
IRAM2 Start: 0x20003F80 Size: 0x80 (NoInit Checked)

And, Memory settings for application in Keil MDK5 Toolchain:

IROM1 Start: 0x18000 Size: 0x28000 (Total 256 kB main flash memory)
IRAM1 Start: 0x20002000 Size: 0x4000 (Total 16 kB of RAM) 

Some code snips from Application:

// 1: Retain bonding
bool erase_bonds = false;
device_manager_init(erase_bonds);

// 2: Low frequency internal clock source to be used by the SoftDevice
#define NRF_CLOCK_LFCLKSRC NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION

void ble_stack_init()
{
............

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC, NULL);
............

}

// 3: Allow service change characteristics
#define IS_SRVC_CHANGED_CHARACT_PRESENT     1

In the bootloader, same clock source (NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION) is used in ble_stack_init() and I have commented out following two lines in sample Bootloader code:

//    buttons_init(); /* No buttons on this custom board */

//    dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0) ? true: false); /* no use */

and Service changed characteristic is also set to '1':

// Allow service change characteristics
#define IS_SRVC_CHANGED_CHARACT_PRESENT     1

Setup for "dfu_ble_svc.c" in the bootloader project configuration:

image description

The complete DFU logs collected using nRFLog is attached here.

Has someone seen such behavior ? and how to fix this issue ? My gut feeling is that this is not a IC compatibility issue and I'm probably missing something important in the firmware side.

Please suggest.

Update: 27.05.2019

Attaching central and peripheral logs (please refer my last comment)

Central logs: dfu_central_logs.txt

Peripheral logs: dfu_peripheral_logs.txt

  • I tried to achieve the same feat: buttonless dfu with a custom board while preserving bonds with the 51822QFAA (256kB flash 16kB RAM) using SDK 10.0 SD 8.0 . I guess that my main problem was to determine what to put in the memory areas of the options dialogbox. Here is what I have for both bootloader: image description

    and target:

    image description

    My major problem was to omit the noinit section, which is used to pass the bonding parameters from the application to the bootloader.

    I used the stock bootloader from SDK 10 with the following changes:

    In file ble_dfu.c line 180: changed:

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
    

    to:

    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm);
    

    To restrict acces to the dfu process

    In bootloder_settings.c (line 18), added const and = {BANK_VALID_APP}; to make sure that I can download a merged hex (bootloader and application)

    In dfu_types.h, line 56:

    #define DFU_APP_DATA_RESERVED           0x1000
    

    as mentionned by Bjorn

    In main.c, line 154, changed the SD init to use the internal RC instead of the crystal:

    SOFTDEVICE_HANDLER_APPSH_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION, true);
    

    I also commented all references to leds and buttons as you did.

    In both pstorage_platform.h (bootloader and app) line 30:

    #define PSTORAGE_NUM_OF_PAGES       3
    

    I don't know if it is mandatory though...

    In doing so, I can upgrade my application without losing bonds using my iphone. However, I have to restart bluetooth (ON->OFF->ON) on the iphone before it works. I know that I haven't lost the bonds because my application won't reconnect othewise.

    Good luck !

  • @sidekick : Have been able to solve this issue or are you still having problems?

  • @bjorn-spockeli: Lately, I was busy with other tasks, so haven't had a chance to visit this topic. Hopefully, I'll soon revisit this topic. Thank you for your help.

Related