Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 SDK14.2 "ble_app_buttonless_dfu" example: What is the value written to the characteristic when entering the bootloader using nRF Connect application (Android).

I am trying the buttonless DFU example from SDK14.2.0. I am not following the testing procedure mentioned at infocentre for SDK14.2. 

Followed test procedure:

1. Erase device.

2. Upload softdevice v5.0.0

3. Upload bootloader_secure_ble bootloader.

4. Compile ble_app_buttonless_dfu example and generate a ZIP package.

5. Device advertising as DfuTarg. Connect and upload generated ZIP package using nRF Connect (Android).

6. Connect to Nordic_Buttonless.

7. Select: Secure DFU Service.

8. Enable Notification and click on Write Characteristic icon.

9. Prompt: "Enter Bootloader mode?"

10. Select: Yes

11. Device exits application, enters bootloader mode and advertises as DfuTarg.

The above procedure works absolutely fine.

Problem arises when I change the vendor specific UUID. 

On doing so, all the steps from 1 to 8, mentioned above work fine, however, I do not get a prompt from step 9. This is expected as the nRF Connect application does not recognise the new UUID and service.

I have to manually enter the value to enable bootloader.

In SDK12.2.0, this value used to be 0x01, however this value does not work for this version of SDK. 

I have tried both 0x01 and 0xB1, but to no vain.

Can you please recreate this test and/or suggest me the exact value to be entered to enter bootloader mode 

  • Hi Rishi,

    Quick question: are you using an nrf52 Dev Kit?

    Just finished testing on my nrf 52 DK with a 52832 chip. I went through the exact same procedure as you did and got it working with both the nordic base uuid & a vendor specific UUID using SDK 14.2!

    To get the vendor specific UUID, I used this online generator to generate the UUID. Then, I went into ble_dfu.h in the buttonless dfu app & wrote this code underneath the #define BLE_NORDIC_VENDOR_BASE_UUID.

    /**@brief Test vendor-specific base UUID, 3fd64673-9a82-49c5-adaa-349a9faadece from
     https://www.uuidgenerator.net/
     */
    #define BLE_VENDOR_SPECIFIC_BASE_UUID               \
    {{                                                  \
        0xCE, 0xDE, 0xAA, 0x9F, 0x9A, 0x34, 0xAA, 0xAD, \
        0xC5, 0x49, 0x82, 0x9A, 0x73, 0x46, 0xD6, 0x3F  \
    }}

    Then, in ble_dfu.c, I added a line under: ble_uuid128_t   nordic_base_uuid = BLE_NORDIC_VENDOR_BASE_UUID;

    where I defined the vendor_base_uuid:

    ble_uuid128_t   vendor_base_uuid = BLE_VENDOR_SPECIFIC_BASE_UUID; // added by BK

    Lastly, I changed the code err_code = sd_ble_uuid_vs_add(&nordic_base_uuid, &m_dfu.uuid_type); 

    to:

    err_code = sd_ble_uuid_vs_add(&vendor_base_uuid, &m_dfu.uuid_type);

    I used the regular bootloader with private & public keys & followed the Nordic secure dfu blog post to get that set up. Should work with the debug bootloader too, but I have not tested this.

    I then followed your steps 1-7 & on step 8 I press the button with the up & down arrows next to the unknown characteristic. A cross mark should appear on the button. This characteristic should have the same base UUID that you generated with the online calculator above. Then, I pressed the write button (the one with the upwards arrow) & wrote 0x01 to the characteristic & pressed send. 

    You should then notice that the DK enters bootloader mode because LEDs 1 & 3 start lighting up. I tested this using nrf connect for mobile on both Android & iPhone & both methods worked out of the box.

    Hope that helps! Kind Regards,

    Bjørn Kvaale

  • Hey Bjorn,

    I am using nRF52832 (PCA10040) board.

    I repeated your test procedure and it worked out fine.

    The issue persists if I define these parameters in separate include and source files. As I do not wish to make changes to the SDK files, I defined a new function to initialise the buttonless service. However, this is where things don't work out.

    Also, I call dfu_buttonless_init(&dfus_init) in the services_init(function. So this is consistent.

    Please check the function included below and try performing a similar test. I would like to ensure if I am missing out on something or there are some other dependencies which are causing this issue on having a new file.

    Thanks,

    Rishi

    /**@brief Function to initialize buttonless bootloader service.
     */
    uint32_t dfu_buttonless_init(const ble_dfu_buttonless_init_t * p_dfu_init)
    {
        uint32_t        err_code;
        ble_uuid_t      service_uuid;
        ble_uuid128_t   vendor_base_uuid = BLE_UUID_OUR_BASE_UUID;
    
        VERIFY_PARAM_NOT_NULL(p_dfu_init);
    
        // Initialize the service structure.
        m_dfu.conn_handle                  = BLE_CONN_HANDLE_INVALID;
        m_dfu.evt_handler                  = p_dfu_init->evt_handler;
        m_dfu.is_waiting_for_reset         = false;
        m_dfu.is_ctrlpt_indication_enabled = false;
    
        err_code = ble_dfu_buttonless_backend_init(&m_dfu);
        VERIFY_SUCCESS(err_code);
        
        BLE_UUID_BLE_ASSIGN(service_uuid, BLE_UUID_OUR_SERVICE_UUID);
    
        // Add the DFU service declaration.
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                            &service_uuid,
                                            &(m_dfu.service_handle));
    
        VERIFY_SUCCESS(err_code);
    
        // Add vendor specific base UUID to use with the Buttonless DFU characteristic.
        // err_code = sd_ble_uuid_vs_add(&nordic_base_uuid, &m_dfu.uuid_type);
        err_code = sd_ble_uuid_vs_add(&vendor_base_uuid, &m_dfu.uuid_type);
        VERIFY_SUCCESS(err_code);
    
        // Add the Buttonless DFU Characteristic (with bonds/without bonds).
        err_code = ble_dfu_buttonless_char_add(&m_dfu);
        VERIFY_SUCCESS(err_code);
    
        return NRF_SUCCESS;
    }

  • Hi Rishi,

    Did you remember to comment out the SDK version of ble_dfu_buttonless_init() in the ble_dfu.c & the header file? Regarding the struct ble_dfu_buttonless_init_t in the ble_dfu.h header file, I guess it might be better to leave it in the old header file & only write your new code in your new files (.c. & .h) to see the code separation between the SDK & what you have customized. See this link for good practice regarding making changes to the SDK code. Then, I would remember to search in your copy of the buttonless DFU SDK example & include the new header file in all of the places that the old ble_dfu_buttonless_init() function got called. Remember to include ble_dfu.h in your new header file. If you are only making this change & adding your custom vendor specific base UUID like I mentioned, this should be pretty straightforward. Hope that helps & good luck!

    Kind Regards,

    Bjørn Kvaale

Related