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

Unable to do a dfu when application is modified.

Hi,

I am using NRF52832 sdk 15.2.0.

I am trying to do a device firmware update by following this link: https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader#h44sjziaea6x739chl3s2bk6zz9163

I have successfully finished up to step D. I used blinky as my application zip and upto that point everything was successful. In my development kit I have only 2 buttons so I set button 4 as dfu button here: NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN. Then I created an updated application zip and pressed that button in the dk to update it. It is not entering into  DFU mode. What is it that I am doing wrong. Please help.

Parents
  • Hello,

    I am a bit confused. You have only two buttons, and you set the button 4 as NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN? Where is button 4? 

    And does your application have any way of entering the bootloader? Or is it only the bootloader + softdevice that is programmed on your nRF?

  • Hi Edvin,

    Sorry for the error in the question. I set my second button as dfu button. I have boot-loader + soft device programmed into my nrf development kit along with it I have flashed ble_app_blinky  (sdk's example flashed using nrf tool box app as instructed in the tutorial above specified). Now if I make a change in blinky and I want to update it how do I enter into dfu mode? should I code it into blinky? If so how can I do it?

Reply
  • Hi Edvin,

    Sorry for the error in the question. I set my second button as dfu button. I have boot-loader + soft device programmed into my nrf development kit along with it I have flashed ble_app_blinky  (sdk's example flashed using nrf tool box app as instructed in the tutorial above specified). Now if I make a change in blinky and I want to update it how do I enter into dfu mode? should I code it into blinky? If so how can I do it?

Children
  • If you have programmed the bootloader, and it is set up to use the second button, then you have to reset the device (turn it off and on again) while holding the second button. By default, the examples in our SDK doesn't have a way of entering DFU mode. If you want this, I suggest you look into the ble_app_buttonless_dfu example, which has a service intended for this. If you write 0x01 to this service, the device will restart, and enter DFU mode, so that you can send a packet. 

    But if you have a button, and you want to use this to trigger DFU mode, it should already be working if you hold down this button when the device is reset. If you want to, you can also have a button handler telling the device to reset, e.g. using NVIC_SystemReset() when button 2 is pressed. This way, it will reset, and since this is pretty fast, it will detect that the button is still held down when the device resets, and enter DFU mode.

    Best regards,

    Edvin

  • Hi Edvin,

    I changed my application in order to enter into dfu mode.

    In nus_data_handler function I added this code snippet.

    for(uint8_t i=0; i<4; i++)
    {
        recieved_val[i] = p_evt->params.rx_data.p_data[i];
        NRF_LOG_INFO("recieved value is: %c", recieved_val[i]);
        
    }
    
    if(memcmp(boot_command, recieved_val, sizeof(boot_command)) == 0)
    {
        nrf_power_gpregret_set(BOOTLOADER_DFU_START);
        NVIC_SystemReset();
    }

    Now it is working with a ble command. Hope this way is correct.

  • That is one way to do it. It may be "cleaner" to use a separate service and characteristic for this, but if that works for you, that is fine. Just be aware that if something sends exactly that data without intending to enter DFU, then it will do that. 

Related