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

nrf51822 DFU procedure nrf toolbox not working ?

Hello,

I am using nrftoolbox code available here:github.com/.../IOS-nRF-Toolbox to perform the DFU procedure.

I have taken the firmware zip file.

I have integrated the iOSDFULibrary in my ios application using POD. Currently I have manually writing 0x0100 command on BLE application to put it into Bootloder mode. I feel that I am successfully able to put it in DFU mode but after that i am using below code :

DFUFirmware *selectedFirmware = [[DFUFirmware alloc] initWithUrlToZipFile:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"xyz" ofType:@"zip"]]];
            
            
            DFUServiceInitiator *initiator = [[DFUServiceInitiator alloc] initWithCentralManager:self.centralManager target:self.sensorTag];
            [initiator withFirmware:selectedFirmware];
            // Optional:
            // initiator.forceDfu = YES/NO; // default NO
            // initiator.packetReceiptNotificationParameter = N; // default is 12
            initiator.logger = self; // - to get log info
            initiator.delegate = self; // - to be informed about current state and errors
            initiator.progressDelegate = self; // - to show progress bar
            // initiator.peripheralSelector = ... // the default selector is used
            
            DFUServiceController *controller = [initiator start];

which fails with the below given log.

here is my DFU logs:

2017-04-05 11:24:48.270660 BLETemperatureReader[3595:805070] findCharacteristicFromUUID
2017-04-05 11:24:48.270976 BLETemperatureReader[3595:805070] dfu data:<0100>
2017-04-05 11:24:53.864257 BLETemperatureReader[3595:805070] didDisconnectPeripheral
2017-04-05 11:24:54.319596 BLETemperatureReader[3595:805070] didConnectPeripheral
2017-04-05 11:24:54.320346 BLETemperatureReader[3595:805070] Peripheral State = 2
2017-04-05 11:24:54.320419 BLETemperatureReader[3595:805070] DFU mode activated
2017-04-05 11:24:54.378580 BLETemperatureReader[3595:805070] level String: Info, message :Connected to Beam
2017-04-05 11:24:54.378728 BLETemperatureReader[3595:805070] level String: Verbose, message :Discovering services...
2017-04-05 11:24:54.378814 BLETemperatureReader[3595:805070] level String: Debug, message :peripheral.discoverServices(nil)
2017-04-05 11:24:54.380225 BLETemperatureReader[3595:805070] peripheral connecting for DFU
2017-04-05 11:24:54.468923 BLETemperatureReader[3595:805070] level String: Info, message :Services discovered
2017-04-05 11:24:54.471858 BLETemperatureReader[3595:805070] level String: Verbose, message :Starting Legacy DFU...
2017-04-05 11:24:54.472976 BLETemperatureReader[3595:805070] level String: Info, message :Connected to Beam
2017-04-05 11:24:54.473277 BLETemperatureReader[3595:805070] level String: Info, message :Services discovered
2017-04-05 11:24:54.473463 BLETemperatureReader[3595:805070] level String: Verbose, message :Legacy DFU Service found
2017-04-05 11:24:54.474766 BLETemperatureReader[3595:805070] level String: Verbose, message :Discovering characteristics in DFU Service...
2017-04-05 11:24:54.475164 BLETemperatureReader[3595:805070] level String: Debug, message :peripheral.discoverCharacteristics(nil, for: 00001530-1212-EFDE-1523-785FEABCD123)
2017-04-05 11:24:54.479716 BLETemperatureReader[3595:805070] level String: Info, message :DFU characteristics discovered
2017-04-05 11:24:54.481872 BLETemperatureReader[3595:805070] level String: Verbose, message :Reading DFU Version number...
2017-04-05 11:24:54.482126 BLETemperatureReader[3595:805070] level String: Debug, message :peripheral.readValue(00001534-1212-EFDE-1523-785FEABCD123)
2017-04-05 11:24:54.527232 BLETemperatureReader[3595:805070] level String: Error, message :Reading DFU Version characteristic failed
2017-04-05 11:24:54.528259 BLETemperatureReader[3595:805070] level String: Error, message :Error 1: The handle is invalid.
2017-04-05 11:24:54.528724 BLETemperatureReader[3595:805070] level String: Verbose, message :Writing to characteristic 00001531-1212-EFDE-1523-785FEABCD123...
2017-04-05 11:24:54.530311 BLETemperatureReader[3595:805070] level String: Debug, message :peripheral.writeValue(0x06, for: 00001531-1212-EFDE-1523-785FEABCD123, type: .withResponse)
2017-04-05 11:24:54.586075 BLETemperatureReader[3595:805070] level String: Application, message :Reset (Op Code = 6) request sent
2017-04-05 11:24:54.586317 BLETemperatureReader[3595:805070] level String: Warning, message :Device disconnected before sending ACK
2017-04-05 11:24:54.586546 BLETemperatureReader[3595:805070] level String: Warning, message :Error 1: The handle is invalid.

I am not sure than I am doing the correct steps.Please guide me. We are using nrf51822 chipset with sdk 11.0.

By using NRFToolbox app DFU procedure. It is giving below log:

Verbose: Connecting to Beam...
Debug: centralManager.connect(peripheral, options:nil)
Debug: [Callback] Central Manager did connect peripheral
Info: Connected to Beam
Verbose: Discovering services...
Debug: peripheral.discoverServices([00001530-1212-EFDE-1523-785FEABCD123, FE59])
Info: Services discovered
Info: Connected to Beam
Verbose: Legacy DFU Service found
Verbose: Discovering characteristics in DFU Service...
Debug: peripheral.discoverCharacteristics(nil, for: 00001530-1212-EFDE-1523-785FEABCD123)
Info: DFU characteristics discovered
Verbose: Reading DFU Version number...
Debug: peripheral.readValue(00001534-1212-EFDE-1523-785FEABCD123)
Info: Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x):0003
Application: Version number read: 3.0
Verbose: Enabling notifications for 00001531-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.setNotifyValue(true, for: 00001531-1212-EFDE-1523-785FEABCD123)
Verbose: Notifications enabled for 00001531-1212-EFDE-1523-785FEABCD123
Application: DFU Control Point notifications enabled
Verbose: Writing to characteristic 00001531-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.writeValue(0x0100, for: 00001531-1212-EFDE-1523-785FEABCD123, type: .withResponse)
Verbose: Writing image sizes (0b, 0b, 25296b) to characteristic 00001532-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.writeValue(0x0000000000000000d0620000, for: 00001532-1212-EFDE-1523-785FEABCD123, type: .withoutResponse)
Info: Data written to 00001531-1212-EFDE-1523-785FEABCD123
Application: Start DFU (Op Code = 1, Upload Mode = 0) request sent
Verbose: Connecting to Beam...
Debug: centralManager.connect(peripheral, options:nil)
Debug: [Callback] Central Manager did disconnect peripheral
Info: Disconnected by the remote device

Thanks Aleksander, After following your suggestions. We now 2 steps ahead. but now we have below logs.

Could you please help me to let know what would be the problem?

Verbose: Connecting to Beam+...
Debug: centralManager.connect(peripheral, options: nil)
Debug: [Callback] Central Manager did connect peripheral
Info: Connected to Beam+
Verbose: Discovering services...
Debug: peripheral.discoverServices(nil)
Info: Services discovered
Verbose: Starting Legacy DFU...
Info: Connected to Beam+
Info: Services discovered
Verbose: Legacy DFU Service found
Verbose: Discovering characteristics in DFU Service...
Debug: peripheral.discoverCharacteristics(nil, for: 00001530-1212-EFDE-1523-785FEABCD123)
Info: DFU characteristics discovered
Verbose: Reading DFU Version number...
Debug: peripheral.readValue(00001534-1212-EFDE-1523-785FEABCD123)
Info: Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x): 0100
Application: Version number read: 0.1
Verbose: Enabling notifications for 00001531-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.setNotifyValue(true, for: 00001531-1212-EFDE-1523-785FEABCD123)
Verbose: Notifications enabled for 00001531-1212-EFDE-1523-785FEABCD123
Application: DFU Control Point notifications enabled
Warning: Application with buttonless update found
Verbose: Writing to characteristic 00001531-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.writeValue(0x0104, for: 00001531-1212-EFDE-1523-785FEABCD123, type: .withResponse)
Info: Data written to 00001531-1212-EFDE-1523-785FEABCD123
Application: Jump to bootloader (Op Code = 1, Upload Mode = 4) request sent
Debug: [Callback] Central Manager did disconnect peripheral
Info: Disconnected by the remote device
Verbose: Connecting to Beam+...
Debug: centralManager.connect(peripheral, options: nil)
Debug: [Callback] Central Manager did connect peripheral
Info: Connected to Beam+
Verbose: Discovering services...
Debug: peripheral.discoverServices([00001530-1212-EFDE-1523-785FEABCD123])
Info: Services discovered
Verbose: Legacy DFU Service found
Verbose: Discovering characteristics in DFU Service...
Debug: peripheral.discoverCharacteristics(nil, for: 00001530-1212-EFDE-1523-785FEABCD123)
Info: DFU characteristics discovered
Verbose: Reading DFU Version number...
Debug: peripheral.readValue(00001534-1212-EFDE-1523-785FEABCD123)
Info: Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x): 0100
Application: Version number read: 0.1
Verbose: Enabling notifications for 00001531-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.setNotifyValue(true, for: 00001531-1212-EFDE-1523-785FEABCD123)
Verbose: Notifications enabled for 00001531-1212-EFDE-1523-785FEABCD123
Application: DFU Control Point notifications enabled
Warning: Application with buttonless update found
Verbose: Writing to characteristic 00001531-1212-EFDE-1523-785FEABCD123...
Debug: peripheral.writeValue(0x0104, for: 00001531-1212-EFDE-1523-785FEABCD123, type: .withResponse)
Info: Data written to 00001531-1212-EFDE-1523-785FEABCD123
Application: Jump to bootloader (Op Code = 1, Upload Mode = 4) request sent

Application just stop there and nothing happens.

  • I am assuming that you've flashed the bootloader, your custom application and the SoftDevice to you device. Have you've added DFU Support to the custom application as explained on this Infocenter page? Have you created the firmware zip file using the nrfutil.exe tool? If yes, could you post the command you used to generate the zip file?

  • Hi Bjorn, I have follwed the steps mentioned in DFU infocenter. and created the zip file using below command:

    nrfutil.exe dfu genpkg "xyz.zip" --application "xyz.hex" --application-version 0xFF --dev-revision 1 --dev-type 1 --sd-req 0xFFFE
    
  • Are you using the safety checking mechanisms in bootloader, see this page, since your setting the type and revision? If you're not using it, then could you try to generate the zip file using the default values, i.e.

    nrfutil.exe dfu genpkg "xyz.zip" --application "xyz.hex" --application-version 0xFFFFFFFF --dev-revision 0xFFFF --dev-type 0xFFFF --sd-req 0xFFFE
    

    Are you seeing the same behavior when performing a DFU with the nRF Toolbox app with the image you generated?

  • Hi Bjorn, I have updated my question with the NRFToolbox app. FYI, I tried by cloning the NRFToolbox app which supports secure buttonless DFU. It is also not able to provide more help.

  • Hi Nik,

    I see couple of issues:

    • Regarding this:

    The first log contains:

    2017-04-05 11:24:54.527232 BLETemperatureReader[3595:805070] level String: Error, message :Reading DFU Version characteristic failed
    2017-04-05 11:24:54.528259 BLETemperatureReader[3595:805070] level String: Error, message :Error 1: The handle is invalid.
    

    This means that your iPhone has cached services. Are you sure you have Service Changed characteristic in Generic Attribute service? Is your device bonded or not?

    • Why do you jump to bootloader on your own? Do you have a custom solution for that? If you are using bonding, is your newer than 8? (In 8-11 the bootloader sends Service Changed indication after jump to let the host know that it now has different services.)

    • DFU Version seems incorrect.

    You second log says:

    Verbose: Reading DFU Version number...
    Debug: peripheral.readValue(00001534-1212-EFDE-1523-785FEABCD123)
    Info: Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x):0003
    Application: Version number read: 3.0
    

    Supported versions for this char are 0x0100 = v0.1 - application mode with buttonless support, 0x0[5-8]00 = v.0.5-0.8 - bootloader with some different features.

    The value 0x0003 is not supported. It may be that the lib just reads another characteristic at the same handle number as it may have cached previous services. To avoid caching on non-bonded device enable Service Changed char.

    BR, Aleksander

Related