i.Mx6 Android wakeup/ resume after sleep / suspend on KitKat 4.4

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.Mx6 Android wakeup/ resume after sleep / suspend on KitKat 4.4

Jump to solution
7,867 Views
bill123
Contributor III

System:

Mx6 - Kontron Board &

Mx6  SabreLite / Nitrogen6x Board

Screen: Hdmi

Boundary Devices based on  boundary-kk4.4.2_1.0.0-ga / kk-nitrogen6x-20141007.img.gz

I am trying to figure out how to wakeup my android system after it goes into "deep" sleep mode.. I thought I had this fixed by adding various adds and work around but I am still fighting this..

To not muddy the water with my implementation I when back to the Sabrelite/Nitrogen6x original build..

Created new nitrogen6x SD:

$ cat kk-nitrogen6x-20141007.img | sudo dd bs=1M of=/dev/sdj

On Sabrelite/nitrogen6x board

Uboot# env default -a

Reboot.

In android settings:

    • Turned off "stay awake " in development options
    • Set display->sleep to 30sec

Console output:

After 30sec...

request_suspend_state: sleep (0->3) at 615294170076 (1970-01-02 00:09:48.569896404 UTC)

PM: Syncing filesystems ... done.

suspend: start 1 suspend...

suspend: finish 1 suspend after:0.2537666 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

add wake up source irq 100

add wake up source irq 51

PM: suspend of devices complete after 51.124 msecs

PM: late suspend of devices complete after 0.695 msecs

Disabling non-boot CPUs ...

CPU1: shutdown

CPU2: shutdown

CPU3: shutdown

Enabling non-boot CPUs ...

CPU1: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU1 is up

CPU2: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU2 is up

CPU3: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU3 is up

PM: early resume of devices complete after 0.461 msecs

wakeup wake lock: alarm_rtc

imx-ipuv3 imx-ipuv3.0: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

imx-ipuv3 imx-ipuv3.1: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

remove wake up source irq 51

remove wake up source irq 100

PM: resume of devices complete after 291.861 msecs

Restarting tasks ... done.

suspend: finish 1 suspend after:3.512773928 seconds...

suspend: exit suspend, ret = 0 (1970-01-02 00:09:52.267779666 UTC)

PM: Syncing filesystems ... done.

suspend: start 2 suspend...

suspend: finish 2 suspend after:0.2535333 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

pm_op(): platform_pm_suspend+0x0/0x5c returns -16

PM: Device alarm failed to suspend: error -16

PM: Some devices failed to suspend

PM: resume of devices complete after 60.529 msecs

Restarting tasks ... done.

suspend: finish 2 suspend after:0.146067666 seconds...

suspend: exit suspend, ret = -16 (1970-01-02 00:09:53.012897332 UTC)

PM: Syncing filesystems ... done.

suspend: start 3 suspend...

suspend: finish 3 suspend after:0.2538334 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

I can not wake it from CONSOLE or mouse on usb or unplugging mouse, or unplugging hdmi.. Sabrelite doesn't have any power or home buttons..

I would like to wake up on touch/mouse input or console..

Note: In my implementation I have standard bootargs and have added no_console_suspend=1 and it still shuts down..

In my implentation this "hard" shutdown seems to come and go.. Sometime it just goes into a "lite" sleep where the console stays active and touch screen wakes it up.. But often it will do the CPU1: Shutdown and it's DONE..

Thanks

Bill

0 Kudos
1 Solution
3,068 Views
bill123
Contributor III

I never found a clear answer on this.. One FAE suggested the Micro in Touch screen drive the "wakeup" pin. This was not an option for our application since we buy a off the shelf Touchscreen.

However I found this solution.. I was trying to keep the "DISPLAY ON" all the time by adding a wake_lock...

I added this to a startup script (you can try on Command line)

     echo test > /sys/power/wake_lock

Afterwards the screen will go blank and moved to suspend state:

  request_suspend_state: sleep (0->3) at 88060821346 (1970-01-02 00:01:04.373401674 UTC)

   request_suspend_state: wakeup (3->0) at 93450869015 (1970-01-02 00:01:09.763448343 UTC)

   request_suspend_state: sleep (0->3) at 123892901018 (1970-01-02 00:01:40.205481679 UTC)

Moving the mouse/touch screen will wake it back up!.

I don't believe wake_lock should work this way.. (should keep screen on all the time).. but it fixed my problem.

View solution in original post

0 Kudos
9 Replies
3,068 Views
gary_bisson
Senior Contributor III

Hi Bill,

There are buttons for the SabreLite available as a separate accessory:

https://boundarydevices.com/product/nit6x_android/

This will allow you to wake up as expected. You can see in the kernel configuration that we specify it:

linux-imx6/imx6qdl-sabrelite.dtsi at boundary-imx-l5.0.0_1.0.0-ga · boundarydevices/linux-imx6 · Git...

Regards,

Gary

0 Kudos
3,068 Views
bill123
Contributor III

Update:

So found the gpio pin that wakes the sabrelite board up.. In playing with it, I discovered this board/build does something similar to what I'm seeing on my Kontron one-off android build.

Sequence of event on SabreLite board/android

-Boot

-On home screen

-Wait  30 seconds

-Android halts cpu and "freezes" (no console response, mouse (usb) wont wake it up) [see logs below]

-Ground gpio (power button)

-Android wakes up and resumes..

Here is the strange part

- wait 30 seconds

- Screen blanks and console shows   (request_suspend_state: sleep (0->3) at... ) but does not freeze or halt!!

- console still responds and mouse move wakes back up.. (see logs)..

This is similar to my project.  Depending on the day my kontron Android builds sometimes stays in "light sleep mode" (will wake up with touch screen) but sometime goes into Hard sleep(halt/freeze) and since I don't have a POWER BUTTON it requires a reboot!.. I need to find away to wake up on USB(Touch screen) and Serial. Note: I have added 

no_console_suspend to my bootargs.

Logs.

Going to sleep 1st time after boot

request_suspend_state: sleep (0->3) at 89176974680 (1970-01-02 00:16:16.102297677 UTC)

PM: Syncing filesystems ... done.

suspend: start 1 suspend...

suspend: finish 1 suspend after:0.2537333 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

add wake up source irq 100

add wake up source irq 51

PM: suspend of devices complete after 47.853 msecs

PM: late suspend of devices complete after 0.682 msecs

Disabling non-boot CPUs ...

CPU1: shutdown

CPU2: shutdown

CPU3: shutdown

Enabling non-boot CPUs ...

CPU1: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU1 is up

CPU2: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU2 is up

CPU3: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU3 is up

PM: early resume of devices complete after 0.464 msecs

wakeup wake lock: alarm_rtc

imx-ipuv3 imx-ipuv3.0: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

imx-ipuv3 imx-ipuv3.1: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

remove wake up source irq 51

remove wake up source irq 100

PM: resume of devices complete after 295.264 msecs

Restarting tasks ... done.

suspend: finish 1 suspend after:1.462211654 seconds...

suspend: exit suspend, ret = 0 (1970-01-02 00:16:20.255655332 UTC)

PM: Syncing filesystems ... done.

suspend: start 2 suspend...

suspend: finish 2 suspend after:0.2536335 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

pm_op(): platform_pm_suspend+0x0/0x5c returns -16

PM: Device alarm failed to suspend: error -16

PM: Some devices failed to suspend

PM: resume of devices complete after 60.883 msecs

Restarting tasks ... done.

suspend: finish 2 suspend after:0.147519335 seconds...

suspend: exit suspend, ret = -16 (1970-01-02 00:16:21.012026000 UTC)

PM: Syncing filesystems ... done.

suspend: start 3 suspend...

suspend: finish 3 suspend after:0.2557000 seconds...

Freezing user space processes ... (elapsed 0.02 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

add wake up source irq 100

add wake up source irq 51

PM: suspend of devices complete after 47.734 msecs

PM: late suspend of devices complete after 0.688 msecs

Disabling non-boot CPUs ...

CPU1: shutdown

CPU2: shutdown

CPU3: shutdown

Enabling non-boot CPUs ...

CPU1: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU1 is up

CPU2: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU2 is up

CPU3: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU3 is up

PM: early resume of devices complete after 0.452 msecs

wakeup wake lock: alarm_rtc

imx-ipuv3 imx-ipuv3.0: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

imx-ipuv3 imx-ipuv3.1: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

remove wake up source irq 51

remove wake up source irq 100

PM: resume of devices complete after 295.643 msecs

Restarting tasks ... done.

suspend: finish 3 suspend after:18.918098333 seconds...

suspend: exit suspend, ret = 0 (1970-01-02 00:16:40.255958334 UTC)

PM: Syncing filesystems ... done.

suspend: start 4 suspend...

suspend: finish 4 suspend after:0.2535334 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

pm_op(): platform_pm_suspend+0x0/0x5c returns -16

PM: Device alarm failed to suspend: error -16

PM: Some devices failed to suspend

PM: resume of devices complete after 60.811 msecs

Restarting tasks ... done.

suspend: finish 4 suspend after:0.146740669 seconds...

suspend: exit suspend, ret = -16 (1970-01-02 00:16:41.011844666 UTC)

PM: Syncing filesystems ... done.

suspend: start 5 suspend...

suspend: finish 5 suspend after:0.2538667 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

Serial console frozen and usb (mouse) won't wake it up

Waking up by GPIO (power button)

PM: resume of devices complete after 295.643 msecs

Restarting tasks ... done.

suspend: finish 3 suspend after:18.918098333 seconds...

suspend: exit suspend, ret = 0 (1970-01-02 00:16:40.255958334 UTC)

PM: Syncing filesystems ... done.

suspend: start 4 suspend...

suspend: finish 4 suspend after:0.2535334 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

pm_op(): platform_pm_suspend+0x0/0x5c returns -16

PM: Device alarm failed to suspend: error -16

PM: Some devices failed to suspend

PM: resume of devices complete after 60.811 msecs

Restarting tasks ... done.

suspend: finish 4 suspend after:0.146740669 seconds...

suspend: exit suspend, ret = -16 (1970-01-02 00:16:41.011844666 UTC)

PM: Syncing filesystems ... done.

suspend: start 5 suspend...

suspend: finish 5 suspend after:0.2538667 seconds...

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

add wake up source irq 100

add wake up source irq 51

PM: suspend of devices complete after 37.735 msecs

PM: late suspend of devices complete after 0.684 msecs

Disabling non-boot CPUs ...

CPU1: shutdown

CPU2: shutdown

CPU3: shutdown

Enabling non-boot CPUs ...

CPU1: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU1 is up

CPU2: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU2 is up

CPU3: Booted secondary processor

Calibrating delay loop (skipped) already calibrated this CPU

i.MXC CPU frequency driver

CPU3 is up

PM: early resume of devices complete after 0.456 msecs

imx-ipuv3 imx-ipuv3.0: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

imx-ipuv3 imx-ipuv3.1: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7)

remove wake up source irq 51

remove wake up source irq 100

wakeup wake lock: event0-2762

PM: resume of devices complete after 295.805 msecs

Restarting tasks ... done.

suspend: finish 5 suspend after:161.901734997 seconds...

request_suspend_state: wakeup (3->0) at 95609069676 (1970-01-02 00:19:23.253088996 UTC)

suspend: exit suspend, ret = 0 (1970-01-02 00:19:23.264526667 UTC)

active wake lock mmc1_detect

active wake lock main

active wake lock PowerManagerService.Display

active wake lock PowerManagerService.Broadcasts

active wake lock KeyEvents

active wake lock PowerManagerService.WakeLocks

30 seconds later...

request_suspend_state: sleep (0->3) at 165611178689 (1970-01-02 00:20:33.255197009 UTC)

-- console stays awake and movement of mouse wakes up screen

Stays in this cycle until powercycled...

Can someone shed some light on this?

Again the ask is to Always wake up on USB(touchscreen)

0 Kudos
3,069 Views
bill123
Contributor III

I never found a clear answer on this.. One FAE suggested the Micro in Touch screen drive the "wakeup" pin. This was not an option for our application since we buy a off the shelf Touchscreen.

However I found this solution.. I was trying to keep the "DISPLAY ON" all the time by adding a wake_lock...

I added this to a startup script (you can try on Command line)

     echo test > /sys/power/wake_lock

Afterwards the screen will go blank and moved to suspend state:

  request_suspend_state: sleep (0->3) at 88060821346 (1970-01-02 00:01:04.373401674 UTC)

   request_suspend_state: wakeup (3->0) at 93450869015 (1970-01-02 00:01:09.763448343 UTC)

   request_suspend_state: sleep (0->3) at 123892901018 (1970-01-02 00:01:40.205481679 UTC)

Moving the mouse/touch screen will wake it back up!.

I don't believe wake_lock should work this way.. (should keep screen on all the time).. but it fixed my problem.

0 Kudos
3,068 Views
damienhuang
Contributor IV

Hi Bill,

Can I know how you set up a startup script? - I have the same sleep issue because my application required 24*7 day monitor on.

At the moment, with my situation, the monitor would not turn off as long as my application is running, but if I switched to other menu and the monitor was off, then I can not turn it on any more. Touch screen doesn't wake it up, also as I don't have the power button, so I have to reboot the machine in such situation.

Also, is there a way that I can permanent disable/remove power save?

Cheers,

Damien

0 Kudos
3,068 Views
bill123
Contributor III

Hi Damien,

I think Gary's answer might be  your best choice..

However I will answer the "How" I added it to my startup.

Android has a file called init.rc.  This works differently from linux's init.rc. You can find info on android init.rc  at init/readme.txt - platform/system/core - Git at Google

Init.rc is part of the "ram disk" image and Can't be edited directly (you can edit it but it will disappear on next boot).  You can find the source at  /device/fsl/imx6/etc/init.rc

I added

   class_start start1

below

   class_start main

    class_start core

    class_start main

    class_start start1

    class_start start2

Then add

service startonce /system/bin/sh /data/startonce.sh

    user root

    group root

    class start1

    oneshot

FYI: I also have another setup.. this script will "restart" if it dies.

# restarts if exits

service startabei /system/bin/sh /data/mystartup.sh

    user root

    group root

    class start2

In the startonce.sh I added:

     echo test > /sys/power/wake_lock

Hope that helps!

0 Kudos
3,068 Views
damienhuang
Contributor IV

Thanks Bill for taking the time to help. Yes, I will follow Gary's instruction to handle this.

0 Kudos
3,068 Views
gary_bisson
Senior Contributor III

Hi Damien,

You can enable the "Stay Awake" option in the developers options of the Settings app.

If you want this to be on by default you can modify/add an overlay, here is an example:

cnt: change overlay to add stay awake default option · boundarydevices/android_device_boundary@7acc8...

Regards,

Gary

0 Kudos
3,068 Views
damienhuang
Contributor IV

Thanks Gary, the Stay Awake option works for me.

0 Kudos
3,068 Views
bill123
Contributor III

Gary,

Good Morning and thank you for your quick responses.

Our application does not have any external gpio switches interfaces designed into it.. We need to wake via USB or serial interaction.

Is there a way to wake up on Serial port  or USB (touch screen) interaction?

Thanks!

0 Kudos