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

DFU from application

Hello Expert,

I am using SDK 6.1 and Softdevice 7.1.0 (s110) for our 256K/32K nrf51822 platform. As of now I wanna port DFU feature into our project. Of course, when burnt with bootloader, nRF toolbox can find device and upgrade application correctly. But you know, I dont wanna add DFU service in my application since the limitted flash memeory size and extra BLE power consuming. if so, please guide me how to enter DFU mode in my application. AFAIK, I must handle uncompleted flash operation and ble disconnection, right? And then, any points to be shared with me? Directly excute NVIC_SystemReset? But how does bootloader know it's from DFU not WDT or power-up?

Another question I found is that when my Android phone installed both nRF toolbox and nRF UART application, DFU APP cannot connect nrf51822 DFU service, it will disconnect unexpectedly in a very short time. My Android version is Lollipop. Any clues?

Thanks, Alex

  • Hi Alex, You can set the GPREGRET retention register before you call NVIC_SystemReset() and then in the bootloader you can check if the correct flag is written to GPREGRET you can enter bootloader mode. Please have a look at section C in this FAQ.

    Regarding the issue with nRFToolbox and nRFUART, could you make sure you have un-pair the device, and also try to turn off and on Bluetooth ? This is to make sure the ATT table cache is cleared. In your application and in the bootloader, you should also set IS_SRVC_CHANGED_CHARACT_PRESENT to 1.

  • Hi Hung, thanks for your answer. You know, my application has no DFU service but bootloader has. As your suggestion, when I do use retention register to force a NVIC softreset, the bootloader will advertise a new DFU service to central. Do you mean I should set IS_SRVC_CHANGED_CHARACT_PRESENT to 1 both for application and bootloader? Seen from FAQ, seems I should share bonded information to bootloader, but if not, how Android app reconnect with this DFU servive? As I tested on my Android phone with nRF tooblox, is this the reason why I can see DFU device but when trying to connect, the connection is closed in a short time?

  • BTW, except the nrf51 device, i am also developing Android's application like nrf toolbox for my device. So please show me how to deal with my case, that is, nrf application has no DFU but force a NVIC_SystemReset, but bootloader has DFU. Is it enough that i just set IS_SRVC_CHANGED_CHARACT_PRESENT=1? How does Android Java code clear ATT cache without manually using settings?

  • @Alex Zhang: Yes, you should set IS_SRVC_CHANGED_CHARACT_PRESENT to 1 for both application and bootloader. However this one would have no effect if the device is not bonded. But to do that you would need to share bond information between the application and bootloader. You can refer to our button-less example in our SDK. Our approach doesn't do a NVIC soft reset but jump directly to the bootloader. Another solution you can use is to change the address of the device to another address, so that the phone will treat it as a new device. This is what we do when the device is started directly in bootloader (with a button press for examle). This way you can get away with the ATT cache issue. But the link when doing DFU is not encrypted.

    If you want to use an app to tell the device to restart in bootloader mode. You just have to define a "enter bootloader" command, and use a write command to write to one of your characteristic to trigger the "restart to bootloader".

  • Thanks, Hung. Actually, we only use UART profile in our application, and our device will receive a DFU-like command via UART characteristic, then the device should disconnect UART connection and then go to bootloader for a firmware upgrade. As your proposal, i will set IS_SRVC_CHANGED_CHARACT_PRESENT and try again. A confused point is that if I enable this service changed indication, does my device or Softdevice send this change automaticlly? How does Android App deal with this indication with callback?

Related