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

  • Please make sure you have "Boot validation" disabled in your bootloader settings page when you are debugging.

    $ nrfutil settings generate --help
    Usage: nrfutil settings generate [OPTIONS] HEX_FILE

    Options:
      --family [NRF51|NRF52|NRF52QFAB|NRF52810|NRF52840]
                                      nRF IC family: NRF51 or NRF52 or NRF52QFAB
                                      or NRF52810 or NRF52840  [required]
      --application TEXT              The application firmware file. This can be
                                      omitted ifthe target IC does not contain an
                                      application in flash.Requires --application-
                                      version or --application-version-string.
      --application-version INTEGER   The application version.
      --application-version-string TEXT
                                      The application version string, e.g.
                                      "2.7.31". Will be converted to an integer,
                                      e.g. 207031.
      --bootloader-version INTEGER    The bootloader version.  [required]
      --bl-settings-version INTEGER   The Bootloader settings version.Defined in
                                      nrf_dfu_types.h, the following apply to
                                      released SDKs:
                                      |SDK12.0.0 - SDK15.2.0|1|
                                      |SDK15.3.0 -          |2|  [required]
      --start-address INTEGER         Custom start address for the settings page.
                                      If not specified, then the last page of the
                                      flash is used.
      --no-backup                     Do not overwrite DFU settings backup page.
                                      If not specified, than the resulting .hex
                                      file will contain a copy of DFU settings,
                                      that will overwrite contents of DFU settings
                                      backup page.
      --backup-address INTEGER        Address of the DFU settings backup page
                                      inside flash. By default, the backup page
                                      address is placed one page below DFU
                                      settings. The value is precalculated based
                                      on configured settings address
                                      (<DFU_settings_address> - 0x1000).
      --app-boot-validation [NO_VALIDATION|VALIDATE_GENERATED_CRC|VALIDATE_GENERATED_SHA256|VALIDATE_ECDSA_P256_SHA256]
                                      The method of boot validation for
                                      application.
      --sd-boot-validation [NO_VALIDATION|VALIDATE_GENERATED_CRC|VALIDATE_GENERATED_SHA256|VALIDATE_ECDSA_P256_SHA256]
                                      The method of boot validation for
                                      SoftDevice.
      --softdevice FILE               The SoftDevice firmware file. Must be given
                                      if SD Boot Validation is used.
      --key-file FILE                 The private (signing) key in PEM format.
                                      Needed for ECDSA Boot Validation.
      --help                          Show this message and exit.

  • Hi Vidar

    Sorry for the late reply. I figured out the DFU problem on my own, I replaced the bootloader project with my old one at it worked.

    So this feature has gone successfully into our candidate release. However I still can't debug the project with NO_VALIDATION. Here's what the IDE shows me when I try to go past ble_dfu_buttonless_async_svci_init()

    Btw I will get out of your hair after this one :)

  • Okay so I have another finding related to this. When I simply Build & Run the example Bootloader project, it works. Shifting it to detect bonds does not work, it keeps restarting when trying to enabling BLE : app: Received an error: 0x00000003!

    Okay so that's kinda obvious I think.

    However, is this the same reason I am unable to debug a project with bonded bootloader, and it is unable to go past ble_dfu_buttonless_async_svci_init()? Am I to do something while generating the settings?

    Moreover, By changing my main app project to without bonding, as well as non bonded bootloader, I am able to debug the application successfully, even without doing NO_VALIDATION on the settings page

    So I am thinking it's got something to do with bonds

  • The CPU starts execution directly from the application's Reset_Handler when you use "Build & run", effectively bypassing the Softdevice and Bootloader. So please use "Build and Debug" instead. This will follow the project configuration and use address 0x0 as the entry point.

    AliMahmood123 said:
    However, is this the same reason I am unable to debug a project with bonded bootloader, and it is unable to go past ble_dfu_buttonless_async_svci_init()? Am I to do something while generating the settings?

    Where does it hang? Can you post a screenshot showing the call stack and cpu registers?

Reply Children
  • Hi,

    I'm not sure if I have seen this error before. It's as if the debugger loses connection to the target. I was not able to replicate this here either. I programmed the bootloader, softdevice, buttonless template app and the settings page (with bonds enabled), and then stepped through the ble_dfu_buttonless_async_svci_init() function in main.

    Are you able to reproduce this with the original projects?

  • Yes I reproduced it with the original project as well. What do you think could be the issue then? I have also tried multiple Dev boards here.

    and the settings page (with bonds enabled),

    Is there a different BL settings page for bond enabled?

  • Just to confirm, you were able to reproduce this with the original unmodified SDK example as well (i.e. unmodified except for the bond configuration setting)? What SDK version do you use?

  • Hi Vidar. Our custom project was in debug mode, and the bootloader project is always in Release Mode. So both need to be in Release mode.

    Although I don't know why that is necessary. Thanks a lot for all your help and patience :)

  • Hi,

    Thanks for the update. However, it should not be necessary to align the build configuration between the bootloader and app. The difference between release and debug in our projects is that debug disables code optimization and enables the DEBUG and DEBUG_NRF flag as you can see here:

      <configuration Name="Release"
        c_preprocessor_definitions="NDEBUG"
        link_time_optimization="No"    gcc_optimization_level="Optimize For Size" />
      <configuration Name="Debug"
        c_preprocessor_definitions="DEBUG; DEBUG_NRF"
        gcc_optimization_level="None"/>

    Maybe your debug jlink settings file is corrupted. You can try to delete the *.jlink setting files in your project directory. SES will create a new setting file next time you start a debug session.

Related