This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Soft device enable and disable - [DFU] disconnected by the remote device

Hello all

I am facing a very strange issue, already searched the forum but didnt find anything like it.

Okay so I can get DFU to work. For our custom application we have to disable the soft device for some time for sensor acquisitions and re enable it at a later time for OTA upgrades.

I simply use nrf_sdh_disable_request() to de initialize the soft device successfully, which it does.

I later re - enable soft device using the standard ble calls in example code:

ble_stack_init();
    peer_manager_init();
    gap_params_init();
    gatt_init();
    advertising_init();
    services_init_2();
    conn_params_init();   
     
    //Start execution.
    application_timers_start();
    advertising_start(erase_bonds);

BLE gets initialized successfully, device is advertised and connects to as well. The problem is in DFU. When I attempt DFU, it keeps getting stuck into trying to switch to bootloader, repeatedly giving
"[DFU] disconnected by the remote device"

The logs then try to open the firmware file again, re initiating the process but nothing happen. I have spend quite some time on this and hit a blocker. Any help is appreciated. There must be a step I am missing during re-enabling the soft device

Parents
  • Hello,

    "[DFU] disconnected by the remote device"

    Where is this message printed? Is it in the mobile app on iOS or Android? And have you tried to debug the FW app to see if it hangs or enters the app_error_fault_handler() function?

    Okay so I can get DFU to work. For our custom application we have to disable the soft device for some time for sensor acquisitions and re enable it at a later time for OTA upgrades.

    Sure you really need to disable the Softdevice for this? The only case I can think of where it makes sense to disable the Softdevice is when there is a need to stop the LF clock. 

    Best regards,

    Vidar

  • Hi Vidar.
    I read an article here which said that in order to disable a service and re-enable it later, I need to disable the whole soft device as the services at start up become part of the "stack"

    if there is another way, please let me know. Basically I just want to disable the DFU service and show that service at some other point

    Also, this message appeared on the android app

  • Hi,

    This is good progress. Though I don't think I have seen this instability problem before. Are you using the same phone for all your tests? My guess is that it might be a timing related issue. In that case, it's probably something you can work around in your app

    As a test, maybe you could try entering DFU mode manually through nrfconnect by following the message sequence chart here: Message sequence charts

  • Yes I am using the same phone, does that matter? I have an old Nokia 6.1 Plus though. It's not a very recent phone

    Okay I will try using nRF Connect and let you know, I'll use the dongle.

    Also, what kind of timing issue it might be?

  • Generally It shouldn't matter what phone you use, but sometimes it does, no devices are perfect. Please let me know if you experience the same behavior with the dongle.

    AliMahmood123 said:
    Also, what kind of timing issue it might be?

    It's hard to say. The disconnect during the transfer could be caused by drift on the LF clock (on either side of the link). A sniffer trace would likely provide some more clues.

  • Hey Vidar. Changing the phone worked. Thanks a lot! You have been of great help

  • However, once again I hope you don't mind. I am facing another problem with LESC + Bonding. I can't debug the application Disappointed

    So I have different copies of my project. DFU with and without bonding I can easily debug even when the application is changed by skipping the CRC check in the bootloader, it works!

    However, the same doesnt happen with Bonding + LESC. I spent a whole day today. Actually the code does start debugging but gets stuck on  SVCALL sd_softdevice_vector_table_base_set which is called inside  ble_dfu_buttonless_async_svci_init(). It's beyond me what is happening

    My thought is that I had to add a _crypto_start and _crypto_end symbol in linker script for nRF crypto to be properly enabled. These symbols were coming from the cc310.lib files. The same code works perfectly with flashing the hex file, but it doesnt work the same on debug. In fact I get block verification error on j-link when debugging

    Regarding why I need to debug urgently. I added NUS service and did some custom changes with the Bonding + LESC DFU. After that, upon DFU, before nrf_pwr_mgt_shutdown is hit, the system restarts automatically. I just wanted to know what's causing that even before shutdown

    So there I have two issues again Disappointed But hopefully these will be the last ones

Reply
  • However, once again I hope you don't mind. I am facing another problem with LESC + Bonding. I can't debug the application Disappointed

    So I have different copies of my project. DFU with and without bonding I can easily debug even when the application is changed by skipping the CRC check in the bootloader, it works!

    However, the same doesnt happen with Bonding + LESC. I spent a whole day today. Actually the code does start debugging but gets stuck on  SVCALL sd_softdevice_vector_table_base_set which is called inside  ble_dfu_buttonless_async_svci_init(). It's beyond me what is happening

    My thought is that I had to add a _crypto_start and _crypto_end symbol in linker script for nRF crypto to be properly enabled. These symbols were coming from the cc310.lib files. The same code works perfectly with flashing the hex file, but it doesnt work the same on debug. In fact I get block verification error on j-link when debugging

    Regarding why I need to debug urgently. I added NUS service and did some custom changes with the Bonding + LESC DFU. After that, upon DFU, before nrf_pwr_mgt_shutdown is hit, the system restarts automatically. I just wanted to know what's causing that even before shutdown

    So there I have two issues again Disappointed But hopefully these will be the last ones

Children
  • AliMahmood123 said:
    However, the same doesnt happen with Bonding + LESC. I spent a whole day today. Actually the code does start debugging but gets stuck on  SVCALL sd_softdevice_vector_table_base_set which is called inside  ble_dfu_buttonless_async_svci_init(). It's beyond me what is happening

    Can you post a screenshot showing the call stack, disassembly, and register view when it hangs?

    AliMahmood123 said:
    In fact I get block verification error on j-link when debugging

    During debugging or when you try to flash the FW? Please post a screenshot of this as well.

  • Okay so I managed to debug the project at least. I dont merge all files and then flash and debug. I flashed the bootloader and then started to debug the project.

    The debugger reaches till NVIC_SystemReset() meaning the system does try to go into DFU mode.

    if ((m_pwr_mgmt_evt == NRF_PWR_MGMT_EVT_PREPARE_RESET)
         || (m_pwr_mgmt_evt == NRF_PWR_MGMT_EVT_PREPARE_DFU))
        {
            NVIC_SystemReset();
        }

    Anyways, the debugger hits NRF_BREAKPOINT_COND in app_error_fault_handler in app_error_weak.c and then restarts.

    So I think the system should have gone into DFU mode at least, but either it didnt go or something else happened. Any thoughts?

    I promise I am going to close the issue after this haha. We have a release pending with all these features actually

  • The program can't reach both NVIC_SystemReset() in the pwr module and the flash breakpoint NRF_BREAKPOINT_COND in one session. Can you read out the error information from the app error handler?

  • Sorry I meant that this happens after I attempt DFU. As soon as I press DFU, the program reaches NVIC_SystemReset(). After this restart it is expected for firmware to go into DFU mode right. Instead it just reboots the app

  • Lets focus on the assert for now. Can you please read the error information from the app error handler when you have hit the flash breakpoint (i.e. error code, file name, and line number) ?

Related