BLE Low Power Issue Conflicting with SMP Service for DFU

Hi, 

I am working on a project with nrf52832 and LIS3DH for a beacon. 

I have added the low power feature into my application to go to standby mode in case of inactivity for a set period.

but when i add the following OTA Kconfig define in my project it stops entering the low power mode and also the DFU also doesn't work.   

CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
I tested it both ways :
  • If I remove the low power from my project the OTA works fine.
  • If I remove the DFU header the low power works fine.

SDK Version: ncs 2.9.0 (same toolchain)

Following is the Kconfig file i add to enable the Power Management hooks and the prj.conf file.

Kconfig:

# Copyright (c) 2022 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

menu "Zephyr"
source "Kconfig.zephyr"
endmenu

# module = APP
# module-str = Application
# source "subsys/logging/Kconfig.template.log_config"


config APP_PROVIDE_PM_HOOKS
    bool "Application provides PM hooks"
    default y
    select HAS_PM
-------------------------------------------------------------------------------------------------------

Looking forward to any help in the matter.

Regards,

Salman

  • Hello,

    Do you have any log messages or errors showing why the application is crashing or not entering low power mode? If not, I recommend adding some logging. Please share the details here.

    Kind Regards,

    Abhijith

  • Hey, 

    Actually I am not debugging it since that would negate the low power and I won't be able to test them both together. 

    What i need to confirm is that does the DFU get effected if the device goes into low power during the connection of exchanging the MCUmgr parameters. 

    Because the DFu starts it tries to read the MCU params and times out and doesn't go into any fault.

    Following is the current usage during the mobile app connected: 

    Whereas this is with a one second apart advertisement:

    Thanks

    Salman 

  • Hello,

    Sorry for getting back to you a bit late. From the shared configurations and images, I believe you are entering System ON mode, which means BLE plus DFU should work without any issues.

    I’m not sure about your application implementation, but if your application doesn’t force the system to enter System OFF mode, then I think it should work. None of your screenshots indicate System OFF mode, so I believe you are not implementing that in your application.

    The issue you are seeing might be because the DFU requests are timing out due to the system not waking up fast enough. Try adding a delay after the BLE connection is established before entering sleep mode. This is to ensure the device doesn’t go to sleep too soon, which might interfere with DFU.

    Kind regards,
    Abhijith

  • Hey, 

    You're right,  I haven't forced the system into System OFF mode. I have defined the delays for the power modes as follows: 

        cpus {
            cpu0: cpu@0 {
                cpu-power-states = <&runtime_idle &suspend_to_idle &standby>;
            };

            power-states {
                runtime_idle: runtime-idle {
                    compatible = "zephyr,power-state";
                    power-state-name = "runtime-idle";
                    min-residency-us = <1000000>;
                    exit-latency-us = <10000>;
                };
                suspend_to_idle: suspend-to-idle {
                    compatible = "zephyr,power-state";
                    power-state-name = "suspend-to-idle";
                    min-residency-us = <1100000>;
                    exit-latency-us = <20000>;
                };
                standby: standby {
                    compatible = "zephyr,power-state";
                    power-state-name = "standby";
                    min-residency-us = <1200000>;
                    exit-latency-us = <30000>;
                };
            };

        };
    Other than that i have enabled the runtime power management macro:


    CONFIG_PM=y
    CONFIG_PM_DEVICE=y
    CONFIG_PM_DEVICE_RUNTIME=y
    In the main function I am suspending the ADC and temperature channels: 
        pm_device_action_run(temp_dev, PM_DEVICE_ACTION_SUSPEND);
        pm_device_action_run(adc_dev, PM_DEVICE_ACTION_SUSPEND);
        pm_device_action_run(&led.port, PM_DEVICE_ACTION_SUSPEND);
    I haven't done any other setting related to the power. But even just adding the OTA_DFU macro stops the code from entering the low power. 
    From the settings above can you think anything i might be doing wrong? 
    Looking forward to your response
    Regards,
    Salman
  • Hello,

    This looks good. I'm not sure what is causing the crash. Could you enable logging just once to diagnose the DFU issue, and then disable it completely to return to full low-power operation?

    Kind regards,
    Abhijith

Related