6 Replies Latest reply on Mar 18, 2016 6:16 PM by maestr0

    Edison suspend/sleep/hibernate and ISR - how does it work?

    maestr0

      Does Edison support sleep, suspend or hibernate mode?

      When Edison is in the sleep/suspend/hibernate mode, can it be woken up by an interrupt signal from an external sensor which triggers ISR (interrupt service routine) in Node.js app, or can Edison wake itself up based on its internal clock (RTC)?

       

      I want to build a monitoring station which will log sensor data during a day and sleep during a night. The station will be powered from a battery charged from a solar panel. I need Edison to be very energy efficient, ideally, I want it to be sleeping during a night and work in a standard mode during a day. The wake-up event should be triggered either via an interrupt from an external sensor (IRQ capable), or by Edison's internal RTC (timer).

       

      What is the best way to do it knowing I need a reliable solution that will always work.

        • 1. Re: Edison suspend/sleep/hibernate and ISR - how does it work?
          Intel_Alvarado

          Hi,

           

          Yes, the Edison can be in a standby mode and be woken up by an external sensor. There’s a thread discussing this process and the commands needed here Re: New to Edison: Can it wakeup with a sensor, collect data by packet sniffing (like kismet), and go back to low power? . Also since you’re interested in low power sleep mode, take a look at the description of the PWR button:

          PWR: The power button (SW1UI2) is configured by software. In general, pressing and holding this button will cause the Intel® Edison module to power down. (It will leave the I/O configuration in the port expanders in its currentstate.) Pressing this button momentarily when Edison is powered down (but power is still applied) will cause the Intel® Edison module to reboot. If Edison is running, then a momentary press will cause Edison to go into low power sleep mode. Pressing the button momentarily when Edison is asleep, will bring Edison into full power mode. You must press and hold SW1U15 for 8 seconds to reset Edison. Pressing the reset button for 4 seconds will restart Edison.

           

          Sergio

          • 2. Re: Edison suspend/sleep/hibernate and ISR - how does it work?
            Vincenze

            There is one big problem.

            The Edison in the sleep mode consumes a LOT and depletes a battery quickly.

             

            I'll try to get more precise measurements later. If I remember correctly, the regular consumption is ~50mA. The sleep-mode consumption is ~30mA.

             

            A battery-powered device should consume less than 1mA in the sleep mode.

            • 3. Re: Edison suspend/sleep/hibernate and ISR - how does it work?
              maestr0

              The recommended way to put the Edison into and out of standby mode is

               

              echo -n "mem" > /sys/power/state  
              
              

               

              or

               

              echo -n "freeze" > /sys/power/state
              
              
              
              

               

               

              Both commands give me an error after 3 seconds.

               

              echo -n "mem" > /sys/power/state
              -sh: echo: write error: Device or resource busy
              
              
              

               

              When I run

               

              dmesg
              
              
              
              

               

              I see those PM (Power Management???) errors -16

               

              [  212.162166] PM: Syncing filesystems ... done.
              [  212.243105] PM: Preparing system for mem sleep
              [  212.245143] Freezing user space processes ... (elapsed 0.01 seconds) done.
              [  212.265020] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
              [  212.284996] PM: Entering mem sleep
              [  212.285151] Suspending console(s) (use no_console_suspend to debug)
              [  212.414796] snd_intel_sst: runtime_resume called
              [  212.446126] CFG80211-ERROR) wl_cfg80211_disconnect : Reason 3
              [  212.448942] CFG80211-ERROR) wl_is_linkdown : Link down Reason : WLC_E_LINK
              [  212.448960] link down if wlan0 may call cfg80211_disconnected. event : 16, reason=2 from f8:35:dd:c3:e9:2f
              [  212.450385] CFG80211-ERROR) wl_is_linkdown : Link down Reason : WLC_E_DEAUTH
              [  212.455162] snd_intel_sst: runtime_suspend called
              [  212.455172] bcove_thrm bcove_thrm: suspend called.
              [  212.455346] cfg80211: Calling CRDA to update world regulatory domain
              [  212.464627] bcmsdh_sdmmc_suspend Enter
              [  212.464633] bcmsdh_sdmmc_suspend Enter
              [  212.514816] bcmsdh_sdmmc_resume Enter
              [  212.514851] pci_pm_suspend(): sdhci_pci_suspend+0x0/0xd0 returns -16
              [  212.514868] dpm_run_callback(): pci_pm_suspend+0x0/0x1d0 returns -16
              [  212.514883] PM: Device 0000:00:01.3 failed to suspend async: error -16
              [  212.536074] PM: Some devices failed to suspend
              [  212.536564] snd_intel_sst: runtime_resume called
              [  212.536932] bcove_thrm bcove_thrm: resume called.
              [  212.643992] PM: resume of devices complete after 107.909 msecs
              [  212.654570] PM: Finishing wakeup.
              [  212.666510] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
              [  212.679466] snd_intel_sst: runtime_idle called
              [  212.679495] snd_intel_sst: runtime_suspend called
              [  212.654591] Restarting tasks ... done.
              [  216.699825] CFG80211-ERROR) wl_cfg80211_connect : Connectting withf8:35:dd:c3:e9:2f channel (36) ssid "n00b", len (4)
              [  216.699825]
              [  216.791711] wl_bss_connect_done succeeded with f8:35:dd:c3:e9:2f
              [  216.857042] wl_bss_connect_done succeeded with f8:35:dd:c3:e9:2f
              [  380.175181] [mid_powerbtn] power button pressed
              [  380.440857] [mid_powerbtn] power button released
              
              
              
              

               

               

              I have the latest clean fresh Yocto 2.1

               

              configure_edison --version
              159.devkit
              
              
              uname -amnrspv
              Linux unicef 3.10.17-poky-edison+ #1 SMP PREEMPT Fri Jun 19 12:06:40 CEST 2015 i686 GNU/Linux
              
              
              
              

               

              I use the dev board. There is no sd-card, nothing is connected to the USB ports, the only cable plugged-in is 12V external charger. Wifi is on.

               

              Do you have any idea what

              pci_pm_suspend(): sdhci_pci_suspend+0x0/0xd0 returns -16

              means?


              I tried to reboot the Edison many times, but it didn't help.

              • 5. Re: Edison suspend/sleep/hibernate and ISR - how does it work?
                maestr0

                I have two Edisons on the dev board one on the mini breakout board. All the Edison modules are updated to the latest Yocto 2.1 159.devkit as mentioned above.

                 

                I did my tests on the two type of boards. The errors I described above are happening on the dev board only.

                 

                This command works on Edison mini breakout board.

                echo -n "mem" > /sys/power/state

                 

                Edison takes 5mA@7V when sleeping comparing to 50mA in the standard mode (no BT, no Wifi)

                The only problem is that the command works only once. The Edison can be woken up with a single short press of the power button PW1. Subsequent executions of the above command does not do anything (not sure if there were any error in the logs, possibly yes)

                 

                Another important thing. When I deployed a sample blinking LED NodeJs app to the module (mini breakout board), the suspend to memory command didn't work. I run the command via the serial interface. The module froze, but the power consumption stayed at around 200mA.

                 

                My next step is to patch the kernel as it's mentioned in some other post and see if Edison will be able to go into the suspend mode more than once

                 

                UPDATE March 16th

                 

                I was able to go into the sleep mode on the dev board after running these commands to stop wifi and wpa supplicant.

                 

                ifconfig wlan0 down
                systemctl stop wpa_supplicant
                
                

                 

                Power consumption is 21mA@7V comparing to ~50mA@7V in the standard mode. I guess there is no point to measure a power consumption on the dev board because of all these additional components on the board which use a lot of power.

                 

                dmesg logs confirming that sleep mode works

                 

                [  264.875145] wifi_platform_set_power = 0

                [  275.092469] PM: Syncing filesystems ... done.

                [  275.148534] PM: Preparing system for mem sleep

                [  275.154907] Freezing user space processes ... (elapsed 0.01 seconds) done.

                [  275.172370] Freezing remaining freezable tasks ... (elapsed 0.02 seconds) done.

                [  275.202404] PM: Entering mem sleep

                [  275.202611] Suspending console(s) (use no_console_suspend to debug)

                [  275.342222] snd_intel_sst: runtime_resume called

                [  275.376944] snd_intel_sst: runtime_suspend called

                [  275.377772] bcmsdh_sdmmc_suspend Enter

                [  275.377778] bcmsdh_sdmmc_suspend Enter

                [  275.377788] bcmsdh_sdmmc_suspend Enter

                [  275.379297] bcove_thrm bcove_thrm: suspend called.

                [  275.443541] PM: suspend of devices complete after 70.220 msecs

                [  275.444928] PM: late suspend of devices complete after 1.371 msecs

                [  275.641810] HSU serial 0000:00:04.0: Refused to change power state, currently in D0

                [  275.672029] PM: noirq suspend of devices complete after 227.100 msecs

                [  275.672037] Disabling non-boot CPUs ...

                [  275.673582] Cannot set affinity for irq 271

                [  275.674837] smpboot: CPU 1 is now offline

                [  599.894540] wakeup from  IRQ 5

                [  599.895078] Enabling non-boot CPUs ...

                [  599.895236] smpboot: Booting Node 0 Processor 1 APIC 0x2

                [  599.905386] Initializing CPU#1

                [  599.906501] Skipped synchronization checks as TSC is reliable.

                [  599.907923] Num p-states 2

                [  599.907934] State [0]: core_frequency[500] transition_latency[100] control[0x525]

                [  599.907941] State [1]: core_frequency[500] transition_latency[100] control[0x525]

                [  599.908100] CPU1 is up

                [  600.131353] PM: noirq resume of devices complete after 222.652 msecs

                [  600.132689] PM: early resume of devices complete after 1.045 msecs

                [  600.133134] bcmsdh_sdmmc_resume Enter

                [  600.133140] bcmsdh_sdmmc_resume Enter

                [  600.133147] bcmsdh_sdmmc_resume Enter

                [  600.133216] bcove_thrm bcove_thrm: resume called.

                [  600.133802] snd_intel_sst: runtime_resume called

                [  600.238338] PM: resume of devices complete after 105.633 msecs

                [  600.240276] PM: Finishing wakeup.

                [  600.240291] Restarting tasks ... done.

                [  600.253156] snd_intel_sst: runtime_idle called

                [  600.253183] snd_intel_sst: runtime_suspend called

                 

                It is not possible to put the Edison into the sleep mode more than once per reboot.

                 

                dmesg logs after the second run of

                 

                echo -n "mem" > /sys/power/state

                 

                 

                [  838.124983] PM: Syncing filesystems ... done.

                [  838.127830] PM: Preparing system for mem sleep

                [  838.129370] Freezing user space processes ... (elapsed 0.01 seconds) done.

                [  838.144959] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

                [  838.164942] PM: Entering mem sleep

                [  838.165005] Suspending console(s) (use no_console_suspend to debug)

                [  838.314805] snd_intel_sst: runtime_resume called

                [  838.349776] snd_intel_sst: runtime_suspend called

                [  838.349869] bcove_thrm bcove_thrm: suspend called.

                [  838.350230] bcmsdh_sdmmc_suspend Enter

                [  838.350236] bcmsdh_sdmmc_suspend Enter

                [  838.350246] bcmsdh_sdmmc_suspend Enter

                [  838.416194] PM: suspend of devices complete after 70.315 msecs

                [  838.417577] PM: late suspend of devices complete after 1.368 msecs

                [  838.644601] PM: noirq suspend of devices complete after 227.024 msecs

                [  838.644609] Disabling non-boot CPUs ...

                [  838.647376] smpboot: CPU 1 is now offline

                [  838.648646] SC device/devices not in d0i3!!

                [  838.648656] pmu2_states[0] = FFCFC3FC

                [  838.648662] pmu2_states[1] = FFFFFFFF

                [  838.648668] pmu2_states[2] = FFFFFF3F

                [  838.648673] pmu2_states[3] = FFFFFFFF

                [  838.648684] ------------[ cut here ]------------

                [  838.648709] WARNING: at /data/jenkins_worker/workspace/edison-weekly/linux-kernel/arch/x86/platform/intel-mid/intel_soc_pmu.c:2039 mid_suspend_enter+0xb7/0x1a0()

                [  838.648743] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

                [  838.648757] CPU: 0 PID: 244 Comm: sh Tainted: G           O 3.10.17-poky-edison+ #1

                [  838.648764] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

                [  838.648801]  c1ad7ac8 00000000 f5179e60 c18d9eea f5179e88 c12408be c1ae1657 c1ad7ac8

                [  838.648833]  000007f7 c1236f17 c1236f17 00000003 00000000 00000000 f5179e98 c1240982

                [  838.648865]  00000009 00000000 f5179ec0 c1236f17 00000003 f5179ec0 c1590e2c 00000003

                [  838.648869] Call Trace:

                [  838.648895]  [<c18d9eea>] dump_stack+0x16/0x18

                [  838.648915]  [<c12408be>] warn_slowpath_common+0x5e/0x80

                [  838.648931]  [<c1236f17>] ? mid_suspend_enter+0xb7/0x1a0

                [  838.648946]  [<c1236f17>] ? mid_suspend_enter+0xb7/0x1a0

                [  838.648963]  [<c1240982>] warn_slowpath_null+0x22/0x30

                [  838.648979]  [<c1236f17>] mid_suspend_enter+0xb7/0x1a0

                [  838.648996]  [<c1590e2c>] ? pm_wakeup_pending+0xec/0x130

                [  838.649014]  [<c1288665>] suspend_devices_and_enter+0x485/0x4f0

                [  838.649029]  [<c18d7f19>] ? printk+0x1c/0x1e

                [  838.649047]  [<c12888ab>] pm_suspend+0x1db/0x290

                [  838.649062]  [<c12877bb>] state_store+0x5b/0xb0

                [  838.649077]  [<c1287760>] ? wakeup_count_show+0x50/0x50

                [  838.649096]  [<c14cffa7>] kobj_attr_store+0x17/0x30

                [  838.649113]  [<c13807ca>] sysfs_write_file+0x9a/0x100

                [  838.649129]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

                [  838.649147]  [<c132611e>] vfs_write+0x9e/0x1c0

                [  838.649166]  [<c13267a9>] SyS_write+0x49/0x90

                [  838.649185]  [<c18df928>] syscall_call+0x7/0xb

                [  838.649197] ---[ end trace 9f12c5e912e5ec88 ]---

                [  838.649937] wakeup from  IRQ 6

                [  838.649952] IRQ 6,action name:intel_pmu_driver

                [  838.650458] Enabling non-boot CPUs ...

                [  838.650616] smpboot: Booting Node 0 Processor 1 APIC 0x2

                [  838.660763] Initializing CPU#1

                [  838.661881] Skipped synchronization checks as TSC is reliable.

                [  838.663396] Num p-states 2

                [  838.663407] State [0]: core_frequency[500] transition_latency[100] control[0x525]

                [  838.663415] State [1]: core_frequency[500] transition_latency[100] control[0x525]

                [  838.663574] CPU1 is up

                [  838.896921] PM: noirq resume of devices complete after 232.743 msecs

                [  838.898257] PM: early resume of devices complete after 1.043 msecs

                [  838.898532] bcove_thrm bcove_thrm: resume called.

                [  838.898762] bcmsdh_sdmmc_resume Enter

                [  838.898768] bcmsdh_sdmmc_resume Enter

                [  838.898775] bcmsdh_sdmmc_resume Enter

                [  838.899050] snd_intel_sst: runtime_resume called

                [  839.002285] PM: resume of devices complete after 104.013 msecs

                [  839.005190] PM: Finishing wakeup.

                [  839.005538] snd_intel_sst: runtime_idle called

                [  839.005559] snd_intel_sst: runtime_suspend called

                [  839.005206] Restarting tasks ... done.

                • 6. Re: Edison suspend/sleep/hibernate and ISR - how does it work?
                  maestr0

                  I built a custom image from edison-image-ww25.5-15 sources with the suspend mode kernel patch from pmu: stop powering up the pci device without driver · 01org/edison-linux@149de7a · GitHub

                   

                  You can download my build from here:

                  edison-image-ww25.5-15-suspend-mode-patch.zip - Google Drive

                   

                   

                  With the patched kernel the suspend to mem command always works on the dev board. But remember to turn off wifi

                  ifconfig wlan0 down

                  systemctl stop wpa_supplicant

                  echo -n "mem" > /sys/power/state

                   

                  Edison on the dev board takes 23mA@7V when sleeping.

                   

                  I flashed the image on my OSX via Phone Flash Tool Lite because ./flashall.sh script doesn't work for me. It always gets stuck on waiting for dfu device

                   

                  Using U-Boot target: edison-blank
                  Now waiting for dfu device 8087:0a99
                    *(I plug the board in and get this...)*
                  dfu-util: Device has DFU interface, but has no DFU functional descriptor
                  Flashing IFWI
                  Flashing U-Boot
                  Flashing U-Boot Environment
                  Flashing U-Boot Environment Backup and rebooting to apply partiton changes
                  Now waiting for dfu device 8087:0a99