Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This application note explains how to use the Linux low power mode (the so-called "suspend to RAM") on the Emcraft Systems STM32H7 System-On-Module (SOM). When suspended, the SOM consumes approximately 5 mA @3.3V, at the same time providing instantaneous wake-up on configured I/O events, such as GPIO triggers.

Understanding Implementation

Power Consumption in Normal (Run) Mode

Support for the low power mode is enabled in the standard rootfs project available from the Emcraft software distribution and installed on each module shipped by Emcraft. With Linux booted up to the shell, and with no commands entered from the interactive shell or a shell script, the system is idling awaiting user input or some other I/O events. The power consumption of the SOM is around 80 mA @3.3V on the average at such times. If you create some load for the system, the power consumption will go up. For instance, using the following shell commands to create an endless command loop:

/ # while echo hey > /dev/null
> do
> echo Linux is running
> done
Linux is running
Linux is running
<...>
^C
/ #

You should measure The SOM power consumption of around 130 mA @3.3V.

Power Consumption in Low Power Mode

Now, let's put the system into the low power mode. This is done by running the following command:

/ # echo mem > /sys/power/state
[ 370.654742] PM: suspend entry (deep)
[ 370.657323] Filesystems sync: 0.000 seconds
[ 370.661361] Freezing user space processes
[ 370.666958] Freezing user space processes completed (elapsed 0.001 seconds)
[ 370.672871] OOM killer disabled.
[ 370.676023] Freezing remaining freezable tasks
[ 370.682016] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[ 370.688316] printk: Suspending console(s) (use no_console_suspend to debug)

At this time, the power consumption goes down dramatically and should measure about 5 mA @3.3V.

Resuming from Low Power Mode

Press the BTN1 User Button on the STM32H7-BSB board to wake the system up:

[ 370.871644] OOM killer enabled.
[ 370.874772] Restarting tasks ... done.
[ 370.883581] PM: suspend exit
/ #

Note also that the system automatically restores the TCP/IP stack on wake-up from the suspended state. The following test illustrates this:

/ # ping 192.168.1.1&
[1] 64 ping 192.168.1.1
/ # PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: seq=0 ttl=64 time=3.880 ms
64 bytes from 192.168.1.1: seq=1 ttl=64 time=1.974 ms
64 bytes from 192.168.1.1: seq=6 ttl=64 time=1.927 ms

/ # echo mem > sys/power/state

[ 38.682054] PM: suspend entry (deep)
[ 38.684774] Filesystems sync: 0.000 seconds
[ 38.688727] Freezing user space processes
[ 38.694276] Freezing user space processes completed (elapsed 0.001 seconds)
[ 38.700091] OOM killer disabled.
[ 38.703263] Freezing remaining freezable tasks
[ 38.709326] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[ 38.715668] printk: Suspending console(s) (use no_console_suspend to debug)
[ 38.725384] stm32-dwmac 40028000.ethernet eth0: Link is Down
[ 38.742262] stm32-dwmac 40028000.ethernet eth0: No Safety Features support found
[ 38.742718] stm32-dwmac 40028000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[ 38.743246] stm32-dwmac 40028000.ethernet eth0: configuring for phy/rmii link mode
[ 38.828547] OOM killer enabled.
[ 38.831592] Restarting tasks ... done.
[ 38.835563] PM: suspend exit
/ # [ 41.843648] stm32-dwmac 40028000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
64 bytes from 192.168.1.1: seq=10 ttl=64 time=2069.568 ms
64 bytes from 192.168.1.1: seq=11 ttl=64 time=1068.468 ms
64 bytes from 192.168.1.1: seq=12 ttl=64 time=67.962 ms
64 bytes from 192.168.1.1: seq=13 ttl=64 time=1.983 ms
64 bytes from 192.168.1.1: seq=14 ttl=64 time=1.929 ms

Configuring GPIO Key as a Wake-up Source

The default trigger used for system wake-up is the BTN1 User Button on the STM32H7-BSB development board. It is connected to the PH.2 GPIO on the STM32H7. The button is configured in the rootfs.dts file correspondingly. The button-1 node in gpio-keys specifies the gpio-key,wakeup property to enable wake-up from this pin:

        gpio-keys {
                compatible = "gpio-keys";
                button-1 {
                        label = "user-button-1";
                        linux,code = ;
                        gpios = <&gpioh 2 GPIO_ACTIVE_LOW>;
                        gpio-key,wakeup;
                };
                ...
        }
  • No labels