sebanc / brunch

Boot ChromeOS on x86_64 PC - Supports Intel CPU/GPU from 8th gen or AMD Ryzen
GNU General Public License v3.0
3.54k stars 387 forks source link

powerd unable to detect the power supply state #2085

Closed biplobsd closed 1 week ago

biplobsd commented 1 week ago

Kernel log:

chronos@localhost /sys/class/power_supply/AC $ dmesg | grep cros_ec
[    0.475121] cros_ec_lpcs: unsupported system.

powerd log:

chronos@localhost /sys/class/power_supply/AC $ cat /var/log/powerd.out
2024-06-13T07:24:39.566210Z ERROR powerd: [ec_command.h(189)] cros_ec ioctl command 0x137 failed: Inappropriate ioctl for device (25)
2024-06-13T07:24:39.793711Z ERROR powerd: [ec_command.h(189)] cros_ec ioctl command 0x137 failed: Inappropriate ioctl for device (25)
2024-06-13T07:24:39.808687Z ERROR powerd: [object_proxy.cc(576)] Failed to call method: org.chromium.ChromeFeaturesServiceInterface.IsFeatureEnabled: object_path= /org/chromium/ChromeFeaturesService: org.freedesktop.DBus.Error.InvalidArgs: Chrome can't get state for 'CrOSLateBootLongBluetoothAutosuspend'; feature_library will decide
2024-06-13T07:24:39.830976Z ERROR powerd: [ec_command.h(189)] cros_ec ioctl command 0xaa failed: Inappropriate ioctl for device (25)
2024-06-13T07:24:39.843562Z ERROR powerd_setuid_helper: [ec_command.h(189)] cros_ec ioctl command 0x2c failed: Inappropriate ioctl for device (25)
2024-06-13T07:24:39.843695Z WARNING powerd_setuid_helper: [powerd_setuid_helper.cc(121)] Failed to set force_lid_open to 0
chronos@localhost / $ tail -f /var/log/power_manager/powerd.LATEST
2024-06-13T07:39:44.307482Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:40:14.325875Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:40:44.352113Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:41:14.375746Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:41:44.399239Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:42:14.413820Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:42:32.774902Z INFO powerd: [activity_logger.cc(21)] User activity ongoing; last reported 4 sec ago
2024-06-13T07:42:44.440076Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:43:14.459095Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:43:44.478560Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.187/3.664Ah at 0.000A, 6h8m49s until empty (5h51m52s until shutdown)
2024-06-13T07:44:19.198165Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.185/3.664Ah at 0.000A, 6h10m until empty (5h52m59s until shutdown)
2024-06-13T07:44:22.594157Z INFO powerd: [activity_logger.cc(21)] User activity stopped; last reported 20 sec ago
2024-06-13T07:44:23.012514Z INFO powerd: [activity_logger.cc(21)] User activity reported
2024-06-13T07:44:24.279559Z INFO powerd: [daemon.cc(1275)] On battery at 87% (displayed as 89%), 3.184/3.664Ah at 0.000A, 6h8m28s until empty (5h51m31s until shutdown)

After chatting with chatgpt. Chatgpt said that ChromeOS Embedded Controller (EC) driver does not support your hardware. . Is it correct @sebanc ? if then how to manually configure that driver? is it possible?

Environment: Brunch r125 unstable 20240610 OS: ChromeOS Flex reven R125 Version 125.0.6422.169 (Official Build) (64-bit)

chronos@localhost /sys/class/power_supply/AC $ neofetch
        #####           chronos@localhost 
       #######          ----------------- 
       ##O#O##          OS: on Chrome OS x86_64 
       #######          Host: LENOVO 20F9003GUS 
     ###########        Kernel: 6.6.30-generic-brunch-sebanc 
    #############       Uptime: 1 hour, 28 mins 
   ###############      Packages: 102 (crew) 
   ################     Shell: sh 
  #################     Resolution: 1920x1080 
#####################   WM: chrome 
#####################   Terminal: chrome 
  #################     CPU: Intel i5-6300U (4) @ 3.000GHz 
                        GPU: Intel Skylake GT2 [HD Graphics 520] 
                        Memory: 7502MiB / 11824MiB 
biplobsd commented 1 week ago

Hi @sebanc . I fixed powerd unable to detect the power supply state. Somehow power supply status conflicts with chromeos-config and then powerd and ChromeOS UI can't detect power supply details if it is on AC or battery. I searched about chromeos-config and this config exists in the /run/chromeos-config/v1/ and /usr/share/chromeos-config/ directory. And this files modified by 80-unibuild.sh file. Then I mount sdz7 and changed the file extension .bk so that this brunch patch should not be executed. After boot powerd, setting successfully detects the AC and battery state.

I liked the brunch framework. If you have enough time please patch this issue. It might be more helpful for laptop users..

Here is the step to now fix this issue:

  1. sudo fdisk -l Look for brunch kernel and patch partition. Mine is /dev/sdz7
  2. sudo mount /dev/sdz7 /mnt/empty
  3. cd /mnt/empty/patches 4. mv 80-unibuild.sh 80-unibuild.sh.bk for disabling execution.
  4. sudo nano 80-unibuild.sh
  5. Now add two lines below of this line echo "external" > /tmp/configfs/v1/chromeos/configs/0/hardware-properties/stylus-category. Make sure the line is indent correctly by tab.
    mkdir -p /tmp/configfs/v1/chromeos/configs/0/power
    echo "1" > /tmp/configfs/v1/chromeos/configs/0/power/has-barreljack
  6. cd ~ && sudo umount /mnt/empty
  7. sudo edit-brunch-config Make any change for triggering brunch rebuild
  8. Now reboot and hopefully if you connect the AC then you will see the battery charging icon..

Because of configs changed. I saw build name also changed in the Diagnostics tool on the top. In my test all of now ok. But without @sebanc patched it might be issue when upgrading ChromeOS or Brunch. I didn't test yet..

Related issues: #1875 #1792 #1770

Edit: I found a specific power config flag has-barreljack. When this file exists with value 1 the powerd detect power supply state.