Device Power Management with Matter

Hi there,

I am currently trying to use device sleep modes with Matter. Nevertheless, once I add "CONFIG_PM_DEVICE_RUNTIME=y" to my prj.conf, the main-method is not longer executed.

I based my matter implementation on the "Adding clusters to Matter application"-example found here.

I developed a custom driver for my sensor that supports runtime PM, and use Matter for transmitting the read sample to some border router. Therefore, I first implemented the pm_action-method:

static int bmp280_pm_action(const struct device *dev, enum pm_device_action action)
{
int ret = 0;

switch (action) {
case PM_DEVICE_ACTION_RESUME:
LOG_DBG("Resuming device");
/* init chip here */
break;
case PM_DEVICE_ACTION_SUSPEND:
LOG_DBG("Putting device into sleep mode");
/* Disable the chip here */
break;
default:
return -ENOTSUP;
}
return ret;
}

For automatic power state control, I have the following overlay:

&spi1 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi1_default>;
pinctrl-1 = <&spi1_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
sensor0: sensor0@0 {
compatible = "vendor,sensor-model";
reg = <0>;
spi-max-frequency = <1000000>;
status = "okay";
zephyr,pm-device-runtime-auto;
};
};

The Logs of my driver are printed correctly for any other application. When using it with matter, I have the problem that the sensor is put the sleep at the beginning (which is correct), but the main-method is never executed. No logs (from main method), no debug, nothing.

#include "app_task.h"
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

int main()
{
LOG_INF("Starting Matter example application...");
k_msleep(1000);
CHIP_ERROR err = AppTask::Instance().StartApp();

LOG_ERR("Exited with code %" CHIP_ERROR_FORMAT, err.Format());
return err == CHIP_NO_ERROR ? EXIT_SUCCESS : EXIT_FAILURE;
}


Other information that might be interesting:

Zephyr SDK version 0.17.0
West version: v1.2.0
Full prj.conf:

# Enable CHIP
CONFIG_CHIP=y
CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h"
# 32768 == 0x8000 (example Product ID added temporaly,
# but it must be changed with proper PID from the list:
CONFIG_CHIP_DEVICE_PRODUCT_ID=32768
CONFIG_STD_CPP17=y

# Enable Matter pairing automatically on application start.
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y

# Enable Matter extended announcement and increase duration to 1 hour.
CONFIG_CHIP_BLE_EXT_ADVERTISING=y
CONFIG_CHIP_BLE_ADVERTISING_DURATION=60

# Add support for LEDs and buttons on Nordic development kits
CONFIG_DK_LIBRARY=y

# Bluetooth Low Energy configuration
CONFIG_BT_DEVICE_NAME="MatterTemplate"

# Other settings
CONFIG_THREAD_NAME=y
CONFIG_MPU_STACK_GUARD=y
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_CHIP_LIB_SHELL=y
CONFIG_NCS_SAMPLE_MATTER_TEST_SHELL=y

# Disable NFC commissioning
CONFIG_CHIP_NFC_COMMISSIONING=n

# Reduce application size
CONFIG_USE_SEGGER_RTT=n

# Enable Factory Data feature
CONFIG_CHIP_FACTORY_DATA=y
CONFIG_CHIP_FACTORY_DATA_BUILD=y

# Other Config options
CONFIG_LOG=y
CONFIG_LOG_MAX_LEVEL=4
CONFIG_CBPRINTF_FP_SUPPORT=y

# Enable Kconfigs for SPI and GPIO
CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SENSOR=y
CONFIG_MYSENSOR=y
# Enable Lower power mode
CONFIG_PM_DEVICE_RUNTIME=y

Parents Reply Children
No Data
Related