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

With Butonless DFU "bootloader_secure_ble" geting out DFU mode

Hi

I did DFU with button, i can enter and load zip pack over nrfToolbox mobile.

I tried butonlessDFU, i copied services "experimental_ble_app_buttonless_dfu" and with sending request device enter to boot but jump back apk quickly with a reset.

With buton i hold pushing more so continues bootcode but with butonless after reset, i think NRF_POWER->GPREGRET became 0.

I use SDK13.0 "bootloader_secure_ble" code and almost orginal.

Another issue, I couldnt get BLE_GATTS_EVT_HVC event with nrfconnect, so i add (void)bootloader_start(); to BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
This works but as i told jumping back to apk about 3sec.

void ble_dfu_on_ble_evt(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt)
{
    VERIFY_PARAM_NOT_NULL_VOID(p_dfu);
    VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt);

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            on_connect(p_dfu, p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnect(p_dfu, p_ble_evt);
            break;

        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            //(void)bootloader_start();
            NRF_POWER->GPREGRET = 0xB1;
            NVIC_SystemReset();
            on_rw_authorize_req(p_dfu, p_ble_evt);
            break;

        case BLE_GATTS_EVT_WRITE:
            on_write(p_dfu, p_ble_evt);
            break;

        case BLE_GATTS_EVT_HVC:
            on_hvc(p_dfu, p_ble_evt);
            break;

        default:
            // no implementation
            break;
    }

}

Regards

Ferhat

  • Hello,

    Out of curiosity, where is this snippet fetched from? Which SDK do you use, and is this from the ble_app_buttonless_dfu example?

    However, If the error is related to writing to NRF_POWER->GPREGRET, it might be that the writing is not finished before you reset. You can try to add a short delay before you call NVIC_SystemReset();

    Try to read the register, and call add a while loop while the GPREGRET is not the correct value.

    But why did you need to change this? I am not too familiar with the bootloader source code, but did it not work, or do you want to something else?

    Best regards,

    Edvin

  • Im using SDK 13, Code snipnet fetced from ble_dfu.c.

    I copied dfu service from "experimental_ble_app_buttonless_dfu" and add to my main.c

    I can enter boot area with using with "(void)bootloader_start();" method

    Or i can enter boot area with using two lines below;

    NRF_POWER->GPREGRET = 0xB1;
    NVIC_SystemReset();

    ----------------------------------------

    So i dont have problem jumping bootaddress.

    I have led blink in "bootloader_secure_ble" loaded in bootloder area, Im understanding jumping boot success when with this blinking. Below code snipnet from "nrf_dfu.c"

    static void wait_for_event()
    {
        // Transport is waiting for event?
        nrf_gpio_pin_write(14,1);
        while(true)
        {
            // Can't be emptied like this because of lack of static variables
    #ifdef BLE_STACK_SUPPORT_REQD
            //(void)sd_app_evt_wait();
    #else
            __WFI();
    #endif
            app_sched_execute();
            Blink01();
        }
    }
    

    GPREGRET = 0xB1 control pass one time  with nrf_dfu_enter_check(). I think after 2-3 second, makes a reset but i think NRF_POWER->GPREGRET not still 0xB1.

    So my problem is in "bootloader_secure_ble" where bootloader area loaded.

  • Hello,

    Sorry for the late reply. Does it work if you use the bootloader_start() function instead of only writing to the register?

    I have not had the time to test this myself yet (I am out of office, but I try to check in on my cases every now and then). I understand that you might want to change the bootloader_start() function, but I want to know whether the issue is writing to the register, or if it is the check of the register that fails. I believe the bootloader_start() function should work. 

    Best regards,

    Edvin

  • Hello Edvin

    I dont want to change "bootloader_start()" function , i tested that first then tried writing to register0xB1 directly. I add these functions here becouse i get BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST by clicking "Butonless DFU"  with nrF Connect (Android)

    -------------------------------------------------------------------

    I can enter BLE_GATTS_EVT_HVC event. All orginal "ble_dfu.c" at SDK13

    1. I removed snipnet above and make orginal at "ble_dfu.c" in my applicaion.
    2. I load softdevice and bootcode by nRFgo
    3. I load my zip file by clicking buton with nRF Connect (Andrıid). Here i see DFUTarg
    4. My apk started. I see my SSID now. My apk has Secure DFU Service.
    5. I connected to my SSID with nRF Connect (Android)
    6. I can see DFU symol near DISCONNECT,  Click it, Select zip file again,
    7. Writing  Starting bootloader than Connecting than Starting bootloader again... goes like that
    8. Not jumping boot area.

    Regards

    Ferhat

Related