# Using PSM (Power Saving Mode) with Legato

**URL:** <https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149>\
**Category:** Uncategorized\
**Created:** [April 14, 2020, 5:45pm UTC](https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149 "2020-04-14T17:45:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![noeltaillardat](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@noeltaillardat](https://forum.legato.io/u/noeltaillardat)\
**Post date:** [April 14, 2020, 5:45pm UTC](https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149/1 "2020-04-14T17:45:40Z")

</div>

Hi,

I am working on a **WP7702 module** , using Legato Application Framework. The module being 3GPP LTE Release 13 compliant and my aim is to use the Power Saving Mode 3GPP’s feature (a non-generic power mode, since network dependent).

While _Power Saving Mode_ and _Ultra Low Power Mode_ (PSM & ULPM) are both configurable through AT commands on the WP7702, only ULPM-related commands can be used from Legato.

I was wondering if PSM was still intended to be implemented in Legato API, as suggested in a previous WP7702 Product Technical Specification (_revision 2_):

> **Table 3-7: PSM-Related Commands**
> 
> | Type | Command | Description |
> | --- | --- | --- |
> | AT | +CPSMS | Configure PSM Settings |
> | | | Use this command to: |
> | | | - Enable/disable LTE PSM. |
> | | | - Configure Period TAU timer (T3412) with the maximum duration of the dormant period. |
> | | | - Configure Active timer (T3324) with the ‘idle mode time’ (the duration the module remains idle before going dormant) |
> | | | Note: These settings take effect immediately, and then persist across power cycles (e.g. after a power cycle, the settings will be used starting during network attach). |
> | AT | | Further commands pending future firmware release. |
> | API | | **Not currently supported, pending future firmware release.** |

while it is not explicitly written as is in the latest revision (here from latest [WP7702 Product Technical Specification](https://source.sierrawireless.com/resources/airprime/hardware_specs_user_guides/airprime_wp77xx_product_technical_specification/#sthash.0HHYrTbc.uxUamtgr.dpbs) revision, r5):

> **Table 3-7: ULPS-Related Application User Interfaces**
> 
> | Type | Description | Interface |
> | --- | --- | --- |
> | AT | +CPSMS | 3GPP-defined command (3GPP TS27.007 Release 12) that allows direct control of all LTE PSM parameters, and is useful for advanced users wanting to test/experiment with different options. This command is limited to networks that support PSM. It is not expected that every user must be fully versed in the details of PSM to take advantage of its capabilities. |
> | | | […] |
> | | | |
> | AT | !POWERMODE | Custom Sierra Wireless command that allows application developers to simplify the harmonization of PSM and ULPM without needing to consider whether PSM is supported on the network to which the WP module is currently attached. |
> | | | The command can be used to select the power mode (ULPM, PSM, PSM with ULPM fallback). |
> | | | **_Note: The Legato ulpm API provides equivalent functionality._** |
> | | | |
> | AT | !POWERWAKE | Custom Sierra Wireless command used to configure the wakeup sources for both PSM and ULPM, such as GPIOs, ADCs, and ULPS timer. |
> | | | **_Note: The Legato ulpm API provides equivalent functionality._** |
> | | | |
> | | | _Important: Sierra Wireless recommends not combining use of +CPSMS and !POWERWAKE. These commands have some functional overlap, which may result in unexpected effects._ |
> | | | |
> | API | Legato Power Services: Power Manager - Ultra Low Power Mode - Boot Reason Query | Legato APIs and Linux sysfs nodes are available to configure and enable the feature. |

So `AT+CPSMS` is only accessible from AT commands, and if `AT!POWERMODE` can be used from `le_ulpm` API, as written above, I have not seen in [`le_ulpm` Legato documentation](https://docs.legato.io/latest/c_ulpm.html) how to chose the low power mode (between PSM with ULPM fallback, PSM only, ULPM only, as configurable with `AT!POWERMODE`).

**Questions:**

So, my first question was : _are PSM-related commands still intended to be implemented in Legato API?_ and if not, what is the best way to use this feature (I have seen that Legato provides an AT Service, but I have not tried it yet).

Also, while using AT commands to configure & go to PSM, I was not sure about how Legato services handle this Power Saving Mode: its aim is to keep network registration, and I am wondering how the Data Connection (`le_data`), Modem Data Control (`le_mdc`) and/or Modem Radio Control (`le_mrc`) Services manage this at reboot.

I would welcome any comment or feedback regarding those questions! 🙂

---

<div class="post-metadata">

**Author:** ![plu](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@plu](https://forum.legato.io/u/plu)\
**Post date:** [April 23, 2020, 3:25pm UTC](https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149/2 "2020-04-23T15:25:49Z")

</div>

hi @noeltaillardat,

For configuring [ULPM](https://docs.legato.io/latest/le __ulpm__ interface_8h.html), these APIs can be used:

**le\_ulpm\_BootOnTimer  
 le\_ulpm\_BootOnGpio   
le\_ulpm\_ShutDown**

For configuring PSM, there’s no Legato APIs available that currently

The only way to configure PSM on the Linux side is to directly write to the kernel swimcu sysfs nodes.

For more information, the kernel driver documentation has more details on how to configure PSM:

> kernel/Documentation/power/swimcu-pm.txt

Example: Enable PSM:

# T3324 value in seconds $ echo 15 \> /sys/module/swimcu\_pm/psm/active\_time   
# T3412 value in seconds $ echo 360 \> /sys/module/swimcu\_pm/psm/psm\_time  
 # Enable PSM $ echo 5 \> /sys/module/swimcu\_pm/psm/enable

Enable PSM with ULPM fallback:

# T3324 value in seconds $ echo 15 \> /sys/module/swimcu\_pm/psm/active\_time   
# T3412 value in seconds $ echo 360 \> /sys/module/swimcu\_pm/psm/psm\_time  
 # Rising edge GPIO36 $ echo rising \> /sys/module/swimcu\_pm/boot\_source/gpio36/edge   
# Pull down resistor $ echo down \> /sys/module/swimcu\_pm/boot\_source/gpio36/pull  
 # Enable PSM with ULPM fallback $ echo 1 \> /sys/module/swimcu\_pm/psm/enable

**AT+CPSMS** command is the AT command to configure and enable the PSM, you can try to use it with the AT command service in Legato .

BR

---

<div class="post-metadata">

**Author:** ![noeltaillardat](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@noeltaillardat](https://forum.legato.io/u/noeltaillardat)\
**Post date:** [April 27, 2020, 1:15pm UTC](https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149/3 "2020-04-27T13:15:03Z")

</div>

Hi @plu,

I eventually managed to use PSM using AT commands from inside Legato applications, using the AT Service to enable and configure it.

I saw that using `AT+CPSMS` was indeed modifying the kernel swimcu sysfs nodes you discussed, however I have not seen the documentation you mentioned, and still, I cannot find it. Where exactly should I look for “`kernel/Documentation/power/swimcu-pm.txt`”? I would realy like to go through it, so thank you for highlighting it!

Best regards

---

<div class="post-metadata">

**Author:** ![plu](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@plu](https://forum.legato.io/u/plu)\
**Post date:** [April 27, 2020, 2:28pm UTC](https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149/4 "2020-04-27T14:28:53Z")

</div>

hi @noeltaillardat,  
the file can be retrieved from the linux distribution which can be downloaded from the source website:  
[https://source.sierrawireless.com/resources/airprime/software/wp77xx/wp77xx-firmware-latest-release-components/#sthash.N8Z22vnK.dpbs](https://source.sierrawireless.com/resources/airprime/software/wp77xx/wp77xx-firmware-latest-release-components/#sthash.N8Z22vnK.dpbs)  
BR

---

<div class="post-metadata">

**Author:** ![noeltaillardat](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@noeltaillardat](https://forum.legato.io/u/noeltaillardat)\
**Post date:** [April 28, 2020, 8:38am UTC](https://forum.legato.io/t/using-psm-power-saving-mode-with-legato/5149/5 "2020-04-28T08:38:21Z")

</div>

Thanks, I will take a look at this !

Best regards
