How to deactivate wifi and bluetooth in sleep mode?

По USB я так думаю уходит в сон хаб, само питание с юсб не снимается, я хотел в своем блоке питания отслеживать сон платы по исчезновению 5в на юсб, но из этого ничего не вышло, плата уходит в сон, кушает порядка 20-30мА но 5в с юсб не пропадает, так-же как и 3,3в и 1,8в, (проверял на гребенке) только что пересмотрел схему, на порты питание идет через мосфет, на портах наверное отключается, завтра проверю, гарнитуру подключать не пробовал, ютуб не мешает уходу в сон, вайфай всегда подключен, так как пока только все тестируется на столе, до машины еще не дошло.

Речь шла про порты, а не гребенку. Про ютуб тоже речи не было. В авто тестируется уже 4 месяца и работает так как написано в первом посту примерно у 15 человек.

Да я уже понял что я вас не так понял:)

1 Like

UPDATE: 4. NEVER - if music is play.

@Terry @Gouwa
Please help.

This is the real big problem for car use.

How to get the Khadas to go into deep sleep and ignore an active Bluetooth connection, playing music, and a network connection?

Hi, Davemf
I will try to add support for it in this week. Thanks :grinning:

1 Like

You can refer to the following modifications. Have a try. Thanks :smile:

diff --git a/kernel/power/earlysuspend.c b/kernel/power/earlysuspend.c
index f428084..da2ec80 100644
--- a/kernel/power/earlysuspend.c
+++ b/kernel/power/earlysuspend.c
@@ -23,6 +23,7 @@
 
 #include "power.h"
 
+extern void release_whole_wake_lock(void);
 enum {
        DEBUG_USER_STATE = 1U << 0,
        DEBUG_SUSPEND = 1U << 2,
@@ -103,6 +104,7 @@ static void early_suspend(struct work_struct *work)
                pr_info("early_suspend: sync\n");
 
        sys_sync();
+       release_whole_wake_lock();
  abort:
        spin_lock_irqsave(&state_lock, irqflags);
        if (state == SUSPEND_REQUESTED_AND_SUSPENDED)
diff --git a/kernel/power/userwakelock.c b/kernel/power/userwakelock.c
index 33f95d9..590eb10 100644
--- a/kernel/power/userwakelock.c
+++ b/kernel/power/userwakelock.c
@@ -147,6 +147,26 @@ ssize_t wake_lock_show(
        return s - buf;
 }
 
+
+void release_whole_wake_lock(void)
+{
+
+       struct rb_node *n;
+       struct user_wake_lock *l;
+       struct user_wake_lock *k;
+
+       mutex_lock(&tree_lock);
+
+       for (n = rb_first(&user_wake_locks); n != NULL; n = rb_next(n)) {
+               l = rb_entry(n, struct user_wake_lock, node);
+               if (wake_lock_active(&l->wake_lock)) {
+                       k = lookup_wake_lock_name(l->name, 0, NULL);
+                       wake_unlock(&k->wake_lock);
+               }
+       }
+       mutex_unlock(&tree_lock);
+}
+
 ssize_t wake_lock_store(
        struct kobject *kobj, struct kobj_attribute *attr,
        const char *buf, size_t n)

3 Likes

It is perfect!!! Many thanks!

@Terry
Hi!
For the “smart mirror” project we need a reverse target.

We need USB, wifi, bluetooth to work in sleep mode. :slight_smile:
How to activate USB in sleep mode?

Thank you!

PS: We have many projects on khadas…

3 Likes

It’s impossible that USB, WiFI, BT work in deep sleep mode. :sweat:

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