[RESPONDED] Gnome Extension Battery Health Charging info /test for Framework laptop

I am interested in adding Frameworks laptops ability to control battery charging limit to Gnome extension “Battery Health Charging” which provides a GUI in gnome-shell quick settings menu, that few might be interested.
From information that I have gathered, I found 2 tools to can be used to change charge limit.

  1. ectool - Dhowett found on Github (Damn cannot post more than two links)
  • Can be set by the command sudo ectool fwchargelimit 80
  • The first and most popular tool used for changing charching limit.
  • Also found mentioned ArchLinux website. (cannot post more than two links)
  • Default installation location when install from archlinux repository /usr/bin/fw-ectool
  1. framework_tool
  • Officially supported by Frameworks (cannot post more than two links but it is in the repo framework-system)
  • Can be set by command sudo framework_tool --charge-limit 80
  • Also found mentioned ArchLinux website (Again cannot post more than two links)
  • Default installation location when install from archlinux repository /usr/bin/framework_tool

I wasn’t sure which tool to go for as I do not know the benefits/drawback for each tool. (Feedback on this is appreciated) . Since framework_tool is officially supported, I have already build a drafted test version of extension around the framework_tool.
The only prerequisite is that framework_tool will have to be installed/copied at /usr/bin/ as the extension check if the file present. In other words extension will notify that device not supported if failed to find /usr/bin/framework_tool
Since I don’t have framework laptop, I cannot test and dont know if this will work.

Anyone interested in testing and providing feedback let me know. I am open to suggestions.

draft version is found here:
Gnone 42-44

Gnome 45

1 Like

Just and FYI Currently neither of these work with the amd frameworks; David hasn’t updated his efi tool either to support the amd ec. There is an out of tree patchset which I am just testing, but it was knocked back from inclusion into mainline and needs to be resubmitted with some trivial adjustments.

1 Like

Echoing this.

Do you know when the support for AMD laptop will be available?

Sometimes I just want to set the charge limit to 100% if I need to go out, is there any workaround for that?

ATM I just starred those two projects

Which seems to be the official ones

There is a patchset which I am using without issue, but it needs to get resubmitted for inclusion in mainline.

Likewise the userspace tools will need updating to support the AMD EC.

There is actually a sysfs EC expose knob which makes the EC available from standard kernel fs structures, but it’s disabled in most sane distro kernels.

3 Likes

There is actually a sysfs EC expose knob which makes the EC available from standard kernel fs structures, but it’s disabled in most sane distro kernels.

Interesting, so there are 3 ways to set charging threshold. 2 tools and a kernel module.
Thats great. I think I will wait for the kernel module to be released or merge with mainline then.

Hello @jwp
I am building the extension around the kernel module.
Just wanted to imformation if you have the following sysfs path when using DHowetts kernel module?

ls -l /sys/devices/platform/framework_laptop

The extension supports several laptop of different make module and usually check is the a file exist to determine which laptop it is installed on and loads options/settings accordingly.

If File exist
(/sys/devices/platform/msi-ec/ && /sys/class/power_supply/BAT1/charge_control_end_threshold)
Then load options/settings for MSI laptop

If File exist
(/sys/module/asus_wmi && /sys/class/power_supply/BAT1/charge_control_end_threshold)
Then load options/settings for Asus laptop

Just wanted the information, if there is any file that is unique to Framework laptop

The EC Debug option is Flagged in the upstream as dangerous ; you can build it as a module but you will need to configure it in the kernel config and rebuild.

the cros_ec_lpc patch is harmless but you’ll need to patch the kernel source with the patch for it currently as it’s out of tree for the moment.

I don’t have

/sys/devices/platform/framework_laptop

but rather

/sys/devices/platform/cros_ec_lpcs.0/
├── cros-ec-dev.2.auto
│   ├── chromeos
│   │   └── cros_ec
│   │       ├── device -> ../../../cros-ec-dev.2.auto
│   │       ├── flashinfo
│   │       ├── power
│   │       │   ├── async
│   │       │   ├── autosuspend_delay_ms
│   │       │   ├── control
│   │       │   ├── runtime_active_kids
│   │       │   ├── runtime_active_time
│   │       │   ├── runtime_enabled
│   │       │   ├── runtime_status
│   │       │   ├── runtime_suspended_time
│   │       │   └── runtime_usage
│   │       ├── reboot
│   │       ├── subsystem -> ../../../../../../class/chromeos
│   │       ├── uevent
│   │       └── version
│   ├── cros-ec-chardev.5.auto
│   │   ├── driver -> ../../../../../bus/platform/drivers/cros-ec-chardev
│   │   ├── driver_override
│   │   ├── modalias
│   │   ├── power
│   │   │   ├── async
│   │   │   ├── autosuspend_delay_ms
│   │   │   ├── control
│   │   │   ├── runtime_active_kids
│   │   │   ├── runtime_active_time
│   │   │   ├── runtime_enabled
│   │   │   ├── runtime_status
│   │   │   ├── runtime_suspended_time
│   │   │   └── runtime_usage
│   │   ├── subsystem -> ../../../../../bus/platform
│   │   └── uevent
│   ├── cros-ec-debugfs.6.auto
│   │   ├── driver_override
│   │   ├── modalias
│   │   ├── power
│   │   │   ├── async
│   │   │   ├── autosuspend_delay_ms
│   │   │   ├── control
│   │   │   ├── runtime_active_kids
│   │   │   ├── runtime_active_time
│   │   │   ├── runtime_enabled
│   │   │   ├── runtime_status
│   │   │   ├── runtime_suspended_time
│   │   │   └── runtime_usage
│   │   ├── subsystem -> ../../../../../bus/platform
│   │   └── uevent
│   ├── cros-ec-sysfs.7.auto
│   │   ├── driver -> ../../../../../bus/platform/drivers/cros-ec-sysfs
│   │   ├── driver_override
│   │   ├── modalias
│   │   ├── power
│   │   │   ├── async
│   │   │   ├── autosuspend_delay_ms
│   │   │   ├── control
│   │   │   ├── runtime_active_kids
│   │   │   ├── runtime_active_time
│   │   │   ├── runtime_enabled
│   │   │   ├── runtime_status
│   │   │   ├── runtime_suspended_time
│   │   │   └── runtime_usage
│   │   ├── subsystem -> ../../../../../bus/platform
│   │   └── uevent
│   ├── cros-usbpd-charger.3.auto
│   │   ├── driver_override
│   │   ├── modalias
│   │   ├── power
│   │   │   ├── async
│   │   │   ├── autosuspend_delay_ms
│   │   │   ├── control
│   │   │   ├── runtime_active_kids
│   │   │   ├── runtime_active_time
│   │   │   ├── runtime_enabled
│   │   │   ├── runtime_status
│   │   │   ├── runtime_suspended_time
│   │   │   └── runtime_usage
│   │   ├── subsystem -> ../../../../../bus/platform
│   │   └── uevent
│   ├── cros-usbpd-logger.4.auto
│   │   ├── driver -> ../../../../../bus/platform/drivers/cros-usbpd-logger
│   │   ├── driver_override
│   │   ├── modalias
│   │   ├── power
│   │   │   ├── async
│   │   │   ├── autosuspend_delay_ms
│   │   │   ├── control
│   │   │   ├── runtime_active_kids
│   │   │   ├── runtime_active_time
│   │   │   ├── runtime_enabled
│   │   │   ├── runtime_status
│   │   │   ├── runtime_suspended_time
│   │   │   └── runtime_usage
│   │   ├── subsystem -> ../../../../../bus/platform
│   │   └── uevent
│   ├── driver -> ../../../../bus/platform/drivers/cros-ec-dev
│   ├── driver_override
│   ├── misc
│   │   └── cros_ec
│   │       ├── dev
│   │       ├── device -> ../../../cros-ec-dev.2.auto
│   │       ├── power
│   │       │   ├── async
│   │       │   ├── autosuspend_delay_ms
│   │       │   ├── control
│   │       │   ├── runtime_active_kids
│   │       │   ├── runtime_active_time
│   │       │   ├── runtime_enabled
│   │       │   ├── runtime_status
│   │       │   ├── runtime_suspended_time
│   │       │   └── runtime_usage
│   │       ├── subsystem -> ../../../../../../class/misc
│   │       └── uevent
│   ├── modalias
│   ├── power
│   │   ├── async
│   │   ├── autosuspend_delay_ms
│   │   ├── control
│   │   ├── runtime_active_kids
│   │   ├── runtime_active_time
│   │   ├── runtime_enabled
│   │   ├── runtime_status
│   │   ├── runtime_suspended_time
│   │   └── runtime_usage
│   ├── subsystem -> ../../../../bus/platform
│   └── uevent
├── driver -> ../../../bus/platform/drivers/cros_ec_lpcs
├── driver_override
├── modalias
├── power
│   ├── async
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_kids
│   ├── runtime_active_time
│   ├── runtime_enabled
│   ├── runtime_status
│   ├── runtime_suspended_time
│   └── runtime_usage
├── subsystem -> ../../../bus/platform
└── uevent

36 directories, 108 files

Oh. Wait. I forgot to confirm with you which kernel module/patch are you using. Are you test ing the below kernel module?

Or Are your testing only specifically cross_ec_lpcs patch for AMD without the framework-laptop-kmod module?

Cause with framework-laptop-kmod module, i think it should create a sysfs path /sys/devices/platform/framework_laptop
But I may be wrong.
Sorry I was not clear with my question posted earlier.
Please confirm if you testing results are with framework-laptop-kmod module installed.

Thanks @jwp

With the module:

aenertia@emiemi-3d-ae-net-nz:~$ modinfo framework_laptop
filename:       /lib/modules/6.7.0-rc4-fwfsync+/updates/framework_laptop.ko
softdep:        pre: cros_ec_lpcs
alias:          platform:framework_laptop
license:        GPL
author:         Dustin L. Howett <dustin@howett.net>
description:    Framework Laptop Platform Driver
rhelversion:    9.99
alias:          acpi*:FRMW0004:*
alias:          acpi*:FRMW0001:*
alias:          dmi*:svn*Framework*:pn*Laptop*:
depends:        
retpoline:      Y
name:           framework_laptop
vermagic:       6.7.0-rc4-fwfsync+ SMP preempt mod_unload 
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        4E:83:D0:C8:ED:8F:5A:F3:74:5E:B8:DE:CD:6A:53:7E:8F:4B:9B:E0
sig_hashalgo:   sha512
signature:      11:73:3A:BF:F4:39:F4:61:3A:0E:4D:3C:77:2C:D7:DE:C4:7B:8F:15:
                63:84:36:AF:E4:D4:50:20:31:C4:BA:23:70:78:BB:DD:DF:29:48:B0:
                B7:81:60:AF:4F:6D:26:E1:BE:99:D4:DF:D2:2E:1B:0D:00:A2:29:7F:
                AC:41:55:FB:37:11:AF:58:DE:56:A6:85:79:77:46:E7:E8:05:AD:97:
                9D:7B:65:42:3C:9F:3B:A9:61:8E:07:01:99:8C:02:40:2F:1D:9C:28:
                A9:B9:18:C5:60:60:C2:65:83:F0:7B:B7:CF:9E:D1:C7:BD:EF:9A:78:
                2C:FA:4A:92:F9:B3:CD:11:F5:CC:AA:8E:B1:1C:4C:3C:56:0B:CA:32:
                FA:E0:B5:91:63:67:7B:82:66:1C:9F:DB:02:6E:E4:8A:19:7B:24:3E:
                88:DE:5C:9E:02:D8:8E:6A:02:11:16:E6:34:2E:D4:03:88:E2:BE:3B:
                12:2C:06:9E:21:DF:5C:27:88:74:9F:DB:3B:A0:ED:95:43:2B:7B:8F:
                50:B5:05:65:B3:89:4E:96:03:D7:5E:7B:40:F4:CB:CB:55:F3:FB:04:
                22:3C:AA:0B:5D:0D:D5:18:88:88:41:CF:E3:77:1E:0A:70:98:92:60:
                FA:20:EC:18:F9:64:30:E3:98:02:DE:BC:7C:26:FE:0C:05:57:65:55:
                D2:69:E4:F8:FD:BB:B6:33:07:6D:A2:CF:FF:5D:BD:42:AE:A3:D4:06:
                EA:2C:E1:7C:8A:63:6B:FD:48:46:E9:66:8E:B1:80:F4:DE:6C:F5:D7:
                A8:42:30:61:28:29:A0:52:CA:53:51:76:33:8A:6D:19:7C:69:84:F6:
                34:A3:F6:60:B0:4C:71:8D:3B:80:DE:FA:B6:33:DC:FE:A7:3E:3C:67:
                C2:3D:F8:C1:88:11:50:1C:A9:0C:62:45:0F:E4:11:66:AB:E5:27:D1:
                0C:CF:F2:6A:5A:6C:94:E9:88:C8:6D:5C:93:02:3D:C0:1B:CE:2D:6F:
                5C:0B:48:6D:29:6C:2F:57:9B:BC:3F:F6:67:24:F6:14:EA:69:C0:48:
                48:98:19:0D:C8:A8:93:17:3A:41:39:32:76:C7:86:B8:67:B6:1B:46:
                49:CD:A1:DB:70:81:C3:78:88:4C:53:AC:F7:44:58:66:19:6C:7C:5D:
                2D:24:E9:6A:65:F9:FD:CD:FD:C9:2F:2F:F7:FB:75:15:F0:9F:52:F9:
                A7:8E:40:20:C0:C8:61:C0:B5:0F:2C:E2:A1:57:5C:5C:C5:E1:22:EB:
                7C:5E:C0:87:5E:03:83:C1:F9:2F:68:BF:98:A1:D0:3F:6B:C5:2D:FC:
                C5:F2:6B:61:AA:7E:A6:95:43:54:4F:42

I get :

/sys/devices/platform/framework_laptop/
├── driver -> ../../../bus/platform/drivers/framework_laptop
├── driver_override
├── leds
│   └── framework_laptop::kbd_backlight
│       ├── brightness
│       ├── device -> ../../../framework_laptop
│       ├── max_brightness
│       ├── power
│       │   ├── autosuspend_delay_ms
│       │   ├── control
│       │   ├── runtime_active_time
│       │   ├── runtime_status
│       │   └── runtime_suspended_time
│       ├── subsystem -> ../../../../../class/leds
│       ├── trigger
│       └── uevent
├── modalias
├── power
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_time
│   ├── runtime_status
│   └── runtime_suspended_time
├── subsystem -> ../../../bus/platform
└── uevent

9 directories, 17 files
1 Like

Also note that with the default KDE/Plasma energy module powerdevil/Energy Centre - granular Keyboard backlight control becomes available. As does reporting the BIOS set correct charge limit for the battery with no additional work required (99% in my case)

image

1 Like

Great!!!
Thank you @jwp for the information
So with the kernel module installed and working, I think Gnome 45 keyboard backlight changes should work out of the box.
For charging threhsold, I will add Framework to Battery Health Charging Gnome extension, so setting charging threshold should work if the extension is used.

Quick toggle

Settings

Oh I just realized, I am still lacking on one information.
This extension has a option to change the behavior of systems charging icon displayed.
On Gnome when Battery level is greater than charging threshold, the Upower report charge-pending or discharging even when laptop is running on charger power. So gnome system battery icon displays as “Discharging (Charger unplugged)” . I have added an option “Change battery indicator icon behavior” So that when charger is plugged in it should display “Charger plugged in Icon”
It does this by reading the charger’s power-supply online status in sysfs. The name can vary depending on laptop. It could be one of the standard path mentioned below and something completely unique

/sys/class/power_supply/AC0/online
/sys/class/power_supply/AC1/online
/sys/class/power_supply/ADP0/online
/sys/class/power_supply/ADP1/online

Can you also provide me the output of

ls /sys/class/power_supply/
/sys/class/power_supply/
├── ACAD -> ../../devices/pci0000:00/0000:00:14.3/ACPI0003:00/power_supply/ACAD
├── BAT1 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:44/PNP0C0A:00/power_supply/BAT1
├── ucsi-source-psy-USBC000:001 -> ../../devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:001
├── ucsi-source-psy-USBC000:002 -> ../../devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
├── ucsi-source-psy-USBC000:003 -> ../../devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:003
└── ucsi-source-psy-USBC000:004 -> ../../devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:004

7 directories, 0 files

Thank you @jwp for all the help with information. In few days this extension with Frameworks laptop supported be available here

https://extensions.gnome.org/extension/5724/battery-health-charging/

1 Like