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

Adding DFU in custom application

Hi all,

There are lots of posts on the devzone about adding DFU service to a custom application and they have been very helpful in getting to this point.

At this point, I have an application that works very well on its own. Within this application I have defined a custom service with a 128-bit UUID. For adding the DFU service I am following the buttonless_dfu example (which works well on its own).

Now in the services_init() function when I call ble_dfu_init(&m_dfus, &dfus_init); and ble_ais_init(&m_ais, &ais_init);both, the application doesn't advertise anything. The log shows:

SDH:DEBUG:sd_ble_enable: RAM start at 0x20002128
:INFO:running nrf_dfu_settings_init
APP_ERROR:ERROR:Fatal

If I run the application with only the DFU service and do not initialise my own service, it does advertise. Similarly, if I init my own service only it works fine (functionally) without the DFU service.

The problem appears to be similar to these posts:

devzone.nordicsemi.com/.../

devzone.nordicsemi.com/.../

The two main solutions are to increment vs_uuid_count and/or to increase the GATT table size. I have tried the first one and that still results in the same problem. I don't know how to increase the GATT table size and what value should it be increased to. Additionally, I have updated my linker file with the bootloader settings section as well.

Can someone point me in the direction of how to go about finding the root cause of the problem here? I am using SDK 12.2 with nRF52832.

UPDATE:

I am getting an error code of 4, when doing the init of the second service (regardless of whether its the DFU or my custom one - even if I change their orders).

  • Do mean it does not advertise at all when you add the dfu service?

    If so, how do you know if the code has not crashed?

    Did you turn on logging or run the code in a debugger ?

    Btw. Why do you want to add the dfu service to your application. I thought the normal process is for the bootloader to provide the dfu service, and your application just needs to reboot into the bootloader dfu mode when an upload of firmware is required

  • Roger, I have turned on logging and I know that the code has crashed. I get a fatal error and then keeps rebooting and same thing happens. For adding the dfu service, what I have understood is that I need to add the service to implement buttonless dfu so that when I write to its characteristic I can start the bootloader in DFU mode. Is that not right?

  • @anasimtiaz

    Take a look at the buttonless DFU.

    Basically, AFIK, that service sets up some data on non-volatile storage and then reboots.

    So that if you have the DFU bootloader installed, it checks the non-volatile storage to find out if it needs to do a normal boot or whether to enter DFU (i.e advertise as a DFU service etc)

    Nordic seem to have changed the implementation of how they signal from the main application to the bootloader i.e via some sort of non-volatile storage, and in SDK 11 and SDK 13, I think this is is via a non volatile register in the MCU, but in SDK 12 they use some of the flash for this purpose.

  • That's right but still need to include nrf_dfu to init the service in the application.

  • Hi Anasimtiaz,

    You are right on the fact that you need to add the DFU service in to enable DFU buttonless.

    Error code 4 means NRF_ERROR_NO_MEM. Your issue is most likely caused by the limit of the size of the attribute table.

    The attributable size is configured in side the ble_enable_params_t, by default it's the value configured by softdevice_enable_get_default_config() call inside ble_stack_init(). What you can do is to change the ble_enable_params.gatts_enable_params.attr_tab_size = > BLE_GATTS_ATTR_TAB_SIZE_DEFAULT to enable more attributes in the table.

    @Roger: You still need the DFU service declared so that the DFU master can write to it to send the command to the application to switch to the bootloader.

Related