How to deactivate wifi and bluetooth in sleep mode?

May be, deactivate deep sleep…
How to deactivate deep sleep? We does not need it on this project.

You can try to modify the file common/kernel/power/suspend.c

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 2a4fc43..bedf4d7 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -400,6 +400,9 @@ int pm_suspend(suspend_state_t state)
 {
        int error;
 
+       if (1)
+               return 0;
+
        if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
                return -EINVAL;
1 Like

Hi, @Terry

How to go into deep sleep and ignore an active Bluetooth connection, playing music, and a network connection on Android 9 VIMs and Android 10 EDGE? Android 9 and 10 don’t contain /kernel/power/earlysuspend.c and /kernel/power/userwakelock.c files.

@Terry
It’s really need for car usage. You did it on VIM1 & 2 (Nougat) and after that all people switched to khadas boards only. But Android PIE does not have this and VESA resolutions and people don’t want to use new khadas board anymore.
I want to help you and build new ROM for all new khadas boards for car usage.
Can you help me?

2 Likes

That would be awesome!

About how to go into deep sleep and ignore an active Bluetooth connection, playing music, and a network connection on Android Pie.
You can modify the source code on kernel.

diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 1896386..ca700a3 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -197,6 +197,7 @@ static struct wakelock *wakelock_lookup_add(const char *name, size_t len,
 
 int pm_wake_lock(const char *buf)
 {
+#if 0
        const char *str = buf;
        struct wakelock *wl;
        u64 timeout_ns = 0;
@@ -241,6 +242,8 @@ int pm_wake_lock(const char *buf)
  out:
        mutex_unlock(&wakelocks_lock);
        return ret;
+#endif
+       return 0;
 }
 
 int pm_wake_unlock(const char *buf)

3 Likes

Good idea to ignore all locks wakelock :))))))))
It works!

Hi, @Terry
It’s work perfect on VIMs board only. It does not work on EDGE board.
How to go into deep sleep and ignore an active Bluetooth connection, playing music, and a network connection on EDGE?

Thank you!

@davemf
Edge android 10.0

--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -205,6 +205,7 @@ static struct wakelock *wakelock_lookup_add(const char *name, size_t len,
 
 int pm_wake_lock(const char *buf)
 {
+#if 0
        const char *str = buf;
        struct wakelock *wl;
        u64 timeout_ns = 0;
@@ -249,6 +250,8 @@ int pm_wake_lock(const char *buf)
  out:
        mutex_unlock(&wakelocks_lock);
        return ret;
+#endif
+       return 0;       
 }


The same approach works with Edge Android 9.0
Maybe it’s your modification. The compilation doesn’t work,Or wrong firmware upgrade.
Or there is something wrong with the test method. Do you check the log or the current to judge whether it is dormant?

I can not use Linux-uart port, because it is disable after this changes
Some time EDGE go to deep sleep fast.

Summary

But usually it does not sleep.

Summary

And it has many messages: Could not find 'android.hardware.radio@1.1 Do you know what is the masseges? Why do you have not this massages?


Me too. It doesn’t matter.

Then you can restore it and catch log to find out the reason why you can’t sleep there.
Or send me your firmware for verification.

1 Like

Please check my ROM https://cloud.mail.ru/public/kDmu/jM4Vc4KCT

your firmware + me boot.img
There was no problem with the test.

1 Like

Good! Thank you!
My boot.img was patched via magisk manager…
When does Boot.img build?
In this step or not?

$ cd PATH_YOUR_PROJECT
$ cd u-boot
$ make mrproper
$ ./make.sh kedge

2 Likes

Yes, I mean not generate img file, I mean build source for boot.
Ok, It look like that magisk manager makes some changes, and after that EDGE can not go to deep sleep fast. I’ll chek it late.
Thank you!
Do you know, how to get root for EDGE without Magisk manager? Like VIMs board.

RKDocs/android/patches/box/rootservice_for_android10.rar

1 Like

I deleted all my changes from u-boot and kernel, add only this change.
And checked kernel messages.

The first press power button - USB ports have +5V
[   39.491750] init: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start
[   39.493445] done.
[   39.494572] PM: suspend exit
[   39.596158] PM: suspend entry (deep)
[   39.596235] PM: Syncing filesystems ... done.
[   39.838040] Freezing user space processes ... (elapsed 0.004 seconds) done.
[   39.842897] OOM killer disabled.
[   39.842952] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[   39.845994] Suspending console(s) (use no_console_suspend to debug)
INFO:    sleep mode config[0xde]:
INFO:           AP_PWROFF
INFO:           SLP_ARMPD
INFO:           SLP_PLLPD
INFO:           DDR_RET
INFO:           SLP_CENTER_PD
INFO:    wakeup source config[0x804]:
INFO:           GPIO interrupt can wakeup system
INFO:           PWM interrupt can wakeup system
INFO:    PWM CONFIG[0x4]:
INFO:           PWM: PWM2D_REGULATOR_EN
INFO:    APIOS info[0x0]:
INFO:           not config
INFO:    GPIO POWER INFO:
INFO:           GPIO0_B5
INFO:           GPIO1_B5
INFO:    PMU_MODE_CONG: 0x1466bf51

after that sometime LED flash on EDGE board and terminal has this messages, but I didn’t push any buttons and USB power was disabled:

USB power off
[   45.620275] Suspending console(s) (use no_console_suspend to debug)
INFO:    sleep mode config[0xde]:
INFO:           AP_PWROFF
INFO:           SLP_ARMPD
INFO:           SLP_PLLPD
INFO:           DDR_RET
INFO:           SLP_CENTER_PD
INFO:    wakeup source config[0x804]:
INFO:           GPIO interrupt can wakeup system
INFO:           PWM interrupt can wakeup system
INFO:    PWM CONFIG[0x4]:
INFO:           PWM: PWM2D_REGULATOR_EN
INFO:    APIOS info[0x0]:
INFO:           not config
INFO:    GPIO POWER INFO:
INFO:           GPIO0_B5
INFO:           GPIO1_B5
INFO:    PMU_MODE_CONG: 0x1466bf51

Then I pressed button to wake up.

The third press power button - the second enter to sleep
[  117.920995] PM: suspend entry (deep)
[  117.921037] PM: Syncing filesystems ... done.
[  117.927542] Freezing user space processes ... (elapsed 0.003 seconds) done.
[  117.931219] OOM killer disabled.
[  117.931227] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[  117.934105] Suspending console(s) (use no_console_suspend to debug)
INFO:    sleep mode config[0xde]:
INFO:           AP_PWROFF
INFO:           SLP_ARMPD
INFO:           SLP_PLLPD
INFO:           DDR_RET
INFO:           SLP_CENTER_PD
INFO:    wakeup source config[0x804]:
INFO:           GPIO interrupt can wakeup system
INFO:           PWM interrupt can wakeup system
INFO:    PWM CONFIG[0x4]:
INFO:           PWM: PWM2D_REGULATOR_EN
INFO:    APIOS info[0x0]:
INFO:           not config
INFO:    GPIO POWER INFO:
INFO:           GPIO0_B5
INFO:           GPIO1_B5
INFO:    PMU_MODE_CONG: 0x1466bf51
INFO:    RK3399 the wake up information:
INFO:    wake up status: 0x4
INFO:           GPIO interrupt wakeup
INFO:           GPIO0: 0x0
INFO:           GPIO1: 0x400000
INFO:           GPIO2: 0x0
INFO:           GPIO3: 0x0
INFO:           GPIO4: 0x0

after that sometime LED flash on EDGE board and enable USB power.
Why does EDGE power up the USB?

When EDGE does not power off USB, USB mouse can wake up EDGE and it never sleep.

BUT SOME TIME, AFTER DEEP SLEEP, I WAKE UP BOARD. IT WAKE UP AND GO TO SLEEP AGAIN!
Why is it happened???

This log contains this issue.

This is my new ROM with one change only.

change in kernel
davemf@i7-8700-64gb-ram:~/EDGE_Qt/kernel$ git diff
diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 105df4d..ec8ecb9 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -205,6 +205,7 @@ static struct wakelock *wakelock_lookup_add(const char *name, size_t len,
 
 int pm_wake_lock(const char *buf)
 {
+#if 0
        const char *str = buf;
        struct wakelock *wl;
        u64 timeout_ns = 0;
@@ -249,6 +250,8 @@ int pm_wake_lock(const char *buf)
  out:
        mutex_unlock(&wakelocks_lock);
        return ret;
+#endif
+        return 0;
 }
 
 int pm_wake_unlock(const char *buf)
davemf@i7-8700-64gb-ram:~/EDGE_Qt/kernel$ cd ../u-boot/
davemf@i7-8700-64gb-ram:~/EDGE_Qt/u-boot$ git status
Not currently on any branch.
nothing to commit, working directory clean
davemf@i7-8700-64gb-ram:~/EDGE_Qt/u-boot$ 

Well, it’s not feasible to use this crude method. We have to use other methods. Where do you need to go into deep sleep? If it is a screen saver, do you need to enter deep sleep?

The deepsleep needs when I short press Power button only or XPWR Pads (like on VIMs).
After short press EDGE ignores an active Bluetooth connection, playing music, and a network connection, it go to deepsleep fast (1-2seconds) and power off USB ports.
This mechanism is realize on VIMs boards with this change. Need to realize it on EDGE too.

I have some comment about VIMs board. I use this change on all VIMs boards. And USB port is short enable (0.1sec) and disable again periodically. But it works fine.