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

Add buttonless dfu to my own application

Hi, I'm trying to add buttonless dfu to my own application (unbonded). I have followed the tutorials listed below:

1, https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader#h23sjziacp7vrw0scs2t3tua1ax0426

2, https://github.com/gamnes/nRF52832-buttonless-dfu-development-tutorial

3, https://rigado.zendesk.com/hc/en-us/articles/360025376053-Add-Nordic-DFU-to-a-SDK-Example

And I'm able to run the sample code, ble_app_buttonless_dfu.

However, when I tried to add the sample code into my own application, the code doesn't work. Here are the things I have done:

1, I tried to add bottonless dfu into ble_app_uart sample code.

2, copy necessary c files and headers and paths from  ble_app_buttonless_dfu into ble_app_uart.

3, Add the following to the Preprocessor definitions

Fullscreen
1
2
BL_SETTINGS_ACCESS_ONLY
NRF_DFU_TRANSPORT_BLE=1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


4, modify the options and open sdk_config.h
Fullscreen
1
2
3
#define BLE_DFU_ENABLED 1
#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 1
#define NRF_SDH_BLE_SERVICE_CHANGED 1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


5, add the following code into main.c file:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void ble_dfu_buttonless_evt_handler(ble_dfu_buttonless_evt_type_t event)
{
...
}
static bool app_shutdown_handler(nrf_pwr_mgmt_evt_t event)
{
...
}
NRF_PWR_MGMT_HANDLER_REGISTER(app_shutdown_handler, 0);
static void services_init(void)
{
...
ble_dfu_buttonless_init_t dfus_init =
{
.evt_handler = ble_dfu_buttonless_evt_handler
};
err_code = ble_dfu_buttonless_init(&dfus_init);
APP_ERROR_CHECK(err_code);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


6, generate the setting.hex file for bootloader.

7, flash the merged bootloader, softdevice, setting and application hex files into the chip.
Then, I got the code stuck at advertising_init() in the main() function.
I thought it might be the starting address problem of the RAM. Then, I modify it according to ble_app_buttonless_dfu:
Fullscreen
1
2
3
4
5
6
7
8
FLASH_PH_START=0x0
FLASH_PH_SIZE=0x80000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x10000
FLASH_START=0x26000
FLASH_SIZE=0x52000
RAM_START=0x20002228
RAM_SIZE=0xddd8
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Then I got in the RTT Viewer,
Fullscreen
1
2
3
4
5
6
7
0> <info> app: Setting vector table to bootloader: 0x00078000
0> <info> app: Setting vector table to main app: 0x00026000
0> <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
0> <warning> nrf_sdh_ble: Change the RAM start location from 0x20002228 to 0x20002A98.
0> <warning> nrf_sdh_ble: Maximum RAM size for application is 0xD568.
0> <error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.
0> <error> app: Fatal error
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Does anybody know what's the problem here?