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

NRF51822 DFU Problem

I built the GCC bootloader from source based on the suggestion of another user in this forum instead of using a precompiled hex file. The Softdevice is 7.1.

It shows DfuTarg. And using nRF Toolbox, I can send a zip package of a new application. It works 100% of the time.

The new application is using the same Softdevice and SDK. I added the Dfu service by using the reference code in ble hrs sample.

Once that new application is sent, I can select its device name in nRF Toolbox in the DFU menu, and send the same zip application just to try a firmware update.

However, with the application running, it fails 100% of the time. Upload failed : Gatt Error (133).

With nRF Master Control Panel, the log shows : Error (0x81) : GATT Internal Error, then Error (0x85) GATT Error.

I searched on google and this forum and I haven't found a problem similar to this.

Here is the parameters I used :

Linker script for bootloader : /* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x00035000, LENGTH = 44K 
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x2000 
  BOOTLOADER_SETTINGS (rwx) : ORIGIN = 0x0003FC00, LENGTH = 0x400
}
SECTIONS
{
    .bootloaderSettings 0x0003FC00 :
  {
	
  } 
	.uicrBootStartAddress 0x10001014 :
	{
    
  } 
}	

INCLUDE "gcc_nrf51_common.ld"

Linker script for application :

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x00016000, LENGTH = 0x2A000 
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x2000 
}

INCLUDE "gcc_nrf51_common.ld"

Modified dfu_types.h

#define BOOTLOADER_REGION_START         0x00035000 

To create the init packet :

nrf.exe dfu genpkg app.zip --application firmware.hex --application-version 0xffff --dev-revision 0xffff --dev-type 0xffff --sd-req 0x5a

At the end of ble_service_init:

    ble_dfu_init_t   dfus_init;

    // Initialize the Device Firmware Update Service.
    memset(&dfus_init, 0, sizeof(dfus_init));

    dfus_init.evt_handler    = dfu_app_on_dfu_evt;
    dfus_init.error_handler  = NULL; //service_error_handler - Not used as only the switch from app to DFU mode is required and not full dfu service.
    dfus_init.revision       = DFU_REVISION;

    err_code = ble_dfu_init(&m_dfus, &dfus_init);
    APP_ERROR_CHECK(err_code);
    
    dfu_app_reset_prepare_set(reset_prepare);

Function reset_prepare:

static void reset_prepare(void)
{
	uint8_t err_code;
    if(mConnectionHandle != BLE_CONN_HANDLE_INVALID)
    {
        err_code = sd_ble_gap_disconnect(mConnectionHandle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
        APP_ERROR_CHECK(err_code);
    }
    else
    {
        // If not connected, then the device will be advertising. Hence stop the advertising.
        sd_ble_gap_adv_stop();
    }
}

I tried hundreds of combination of differents parameters to try to understand what is going on... Anybody have an idea how could I fix this ?

Thank you very much again!

Simon

Parents Reply Children
No Data
Related