Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Framework, Chromebook] Battery care support based on the cros_charge-control driver (as of Linux 6.11) #765

Open
linrunner opened this issue Oct 4, 2024 · 14 comments

Comments

@linrunner
Copy link
Owner

linrunner commented Oct 4, 2024

Based on the preliminary work from @chutz, here is a rewrite of the plugin requiring the new driver cros_charge-control released with [EDIT] Linux 6.11.

EDIT: the plugin has been converted from a framework-specific to a generic one for all laptops with ChromeOS EC. It supports the following hardware:

  • Framework Laptop 13/16 Intel/AMD
  • Chromebooks modded with chrultrabook/coreboot custom UEFI firmware

For the test you either need TLP 1.7.0, supplemented by the download of /usr/share/tlp/bat.d/55-chromeos-ec, or you can build a package for your distribution based on Branch feature/bat.d/framework.

I need at least the output of

sudo tlp-stat -s -b -v

If the plugin is properly activated, the output contains this:

+++ Battery Care
Plugin: chromeos-ec
Supported features: charge thresholds, recalibration
Driver usage:
natacpi (cros_charge_control) = active (charge thresholds, recalibration)

Only if the plugin is properly activated
Depending on whether the battery name is BAT0 or BAT1 (check tlp-stat -b output), start the corresponding automatic test script (with sudo or as root) and show the output:

It requires the tool clitest to be installed. Should be available as a package in most distributions.

References:

@t-8ch @Simerax @chutz

linrunner added a commit that referenced this issue Oct 4, 2024
* Supports Framework Laptop 13/16 Intel/AMD
* Requires cros_charge-control module (Linux 6.10+)
* Start and stop threshold
* Force discharge not supported (planned)

* charge_control_start_threshold:
  - Valid values: 0..100 - limited to 0..99
  - Default value: 0

* charge_control_end_threshold:
  - Valid values: 0..100 - limnited to 1..100
  - Default value: 100

Credits:
* Thomas Weißschuh
* Patrick McLean

Reference:
* https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/drivers/power/supply/cros_charge-control.c?h=review-hans&id=c6ed48ef52599098498a8442fd60bea5bd8cd309
* https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/tree/drivers/power/supply/cros_charge-control.c?h=review-hans
* #765
@linrunner linrunner added this to the 1.8 Release milestone Oct 4, 2024
@t-8ch
Copy link
Contributor

t-8ch commented Oct 5, 2024

  • The module is from 6.11
  • The vendor check actually reads the model_name, so always fails.

With this fixed:

# tlp-stat -s -b
--- TLP 1.7.0 --------------------------------------------

+++ System Info
System         = Framework A7 Laptop 13 (AMD Ryzen 7040Series)
BIOS           = 03.05
OS Release     = Arch Linux
Kernel         = 6.12.0-rc1-00312-g798df27d5d3f #12 SMP PREEMPT_DYNAMIC Sat Oct  5 09:18:53 CEST 2024 x86_64
/proc/cmdline  = initrd=\initramfs-linux-upstream.img rw cryptdevice=/dev/nvme0n1p3:system:discard root=/dev/mapper/system
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = [s2idle]

+++ TLP Status
State          = enabled
RDW state      = not installed
Last run       = 09:36:13, 420 sec(s) ago
Mode           = AC
Power source   = AC

+++ Battery Care
Plugin: framework
Supported features: charge thresholds
Driver usage:
* natacpi (cros_charge_control) = active (charge thresholds)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  0(off)..99
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)

+++ Battery Status: BAT1
/sys/class/power_supply/BAT1/manufacturer                   = NVT
/sys/class/power_supply/BAT1/model_name                     = FRANGWA
/sys/class/power_supply/BAT1/cycle_count                    =     38
/sys/class/power_supply/BAT1/charge_full_design             =   3915 [mWh] *
/sys/class/power_supply/BAT1/charge_full                    =   3522 [mWh] *
/sys/class/power_supply/BAT1/charge_now                     =   3522 [mWh] *
/sys/class/power_supply/BAT1/current_now                    =      0 [mW] *
/sys/class/power_supply/BAT1/status                         = Not charging

/sys/class/power_supply/BAT1/charge_control_start_threshold =      0 [%]
/sys/class/power_supply/BAT1/charge_control_end_threshold   =    100 [%]
/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =  100.0 [%]
Capacity                                                    =   90.0 [%]
[~/src/tlp]$ sudo clitest unit-tests/charge-thresholds_framework
#1	# +++ Framework laptops +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#2	#
#3	# --- tlp start
#4	sudo tlp start -- START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1= START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#5	sudo tlp start -- START_CHARGE_THRESH_BAT1="60" STOP_CHARGE_THRESH_BAT1="100" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#6	sudo tlp start -- START_CHARGE_THRESH_BAT1="100" STOP_CHARGE_THRESH_BAT1="100" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#7	sudo tlp start -- START_CHARGE_THRESH_BAT1="0" STOP_CHARGE_THRESH_BAT1="0" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#8	sudo tlp start -- START_CHARGE_THRESH_BAT1="0" STOP_CHARGE_THRESH_BAT1="101" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#9	sudo tlp start -- START_CHARGE_THRESH_BAT1="97" STOP_CHARGE_THRESH_BAT1="97" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#10	sudo tlp start -- START_CHARGE_THRESH_BAT1="95" STOP_CHARGE_THRESH_BAT1="96" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#11	sudo tlp start -- START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF" START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0=
#12	sudo tlp start -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
#13	#
#14	# --- tlp setcharge w/o arguments
#15	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="60" STOP_CHARGE_THRESH_BAT1="100" X_SOC_CHECK=0
#16	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="100" STOP_CHARGE_THRESH_BAT1="100"
#17	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="0" STOP_CHARGE_THRESH_BAT1="0"
#18	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="0" STOP_CHARGE_THRESH_BAT1="101"
#19	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="97" STOP_CHARGE_THRESH_BAT1="97"
#20	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="95" STOP_CHARGE_THRESH_BAT1="96"
#21	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="95" STOP_CHARGE_THRESH_BAT1="96"
#22	sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #22, line 56] sudo tlp setcharge -- START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
@@ -1,3 +1,3 @@
 Setting temporary charge thresholds for BAT1:
-  stop  = 100
   start =   0
+  stop  = 100
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#23	sudo tlp setcharge -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
#24	#
#25	# --- tlp setcharge w/ arguments
#26	sudo tlp setcharge 60 100 -- X_SOC_CHECK=0
#27	sudo tlp setcharge 100 100
#28	sudo tlp setcharge 0 0
#29	sudo tlp setcharge 0 101
#30	sudo tlp setcharge XYZZY 0
#31	sudo tlp setcharge 0 XYZZY
#32	sudo tlp setcharge 97 97
#33	sudo tlp setcharge 95 96
#34	sudo tlp setcharge 95 96 -- X_THRESH_SIMULATE_READERR="1"
#35	sudo tlp setcharge 95 96
#36	sudo tlp setcharge DEF DEF
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #36, line 90] sudo tlp setcharge DEF DEF
@@ -1,3 +1,3 @@
 Setting temporary charge thresholds for BAT1:
-  stop  = 100
   start =   0
+  stop  = 100
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#37	sudo tlp setcharge BAT0
#38	sudo tlp setcharge 0 3 BAT0
#39	sudo tlp setcharge XYZZY ABCDE BAT0
#40	#
#41	# --- tlp-stat
#42	# steps require a kernel >= 5.17 -- with 'charge_behaviour'
#43	sudo tlp-stat -b | grep -E 'charge_(control|behaviour)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #43, line 103] sudo tlp-stat -b | grep -E 'charge_(control|behaviour)'
@@ -1,3 +1,4 @@
+* natacpi (cros_charge_control) = active (charge thresholds)
 /sys/class/power_supply/BAT1/charge_control_start_threshold =      0 [%]
 /sys/class/power_supply/BAT1/charge_control_end_threshold   =    100 [%]
 /sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#44	sudo tlp-stat -b -- X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #44, line 107] sudo tlp-stat -b -- X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
@@ -1,3 +1,4 @@
+* natacpi (cros_charge_control) = active (charge thresholds)
 /sys/class/power_supply/BAT1/charge_control_start_threshold = (not available) [%]
 /sys/class/power_supply/BAT1/charge_control_end_threshold   = (not available) [%]
 /sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#45	#
#46	# --- Reset test machine to configured thresholds
#47	sudo tlp setcharge  > /dev/null 2>&1
#48	#

FAIL: 4 of 48 tests failed
[~/src/tlp]$ sudo clitest unit-tests/charge-thresholds_framework-simulate 
#1	# +++ Framework laptops +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#2	#
#3	# --- tlp start
#4	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#5	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#6	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #6, line 15] sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration at START_CHARGE_THRESH_BAT0="100": not specified, invalid or out of range (0..99). Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#7	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #7, line 18] sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="0": not specified, invalid or out of range (1..100). Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#8	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #8, line 21] sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="101": not specified, invalid or out of range (1..100). Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#9	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="97" STOP_CHARGE_THRESH_BAT0="97" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #9, line 24] sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="97" STOP_CHARGE_THRESH_BAT0="97" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration: START_CHARGE_THRESH_BAT0 >= STOP_CHARGE_THRESH_BAT0. Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#10	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="95" STOP_CHARGE_THRESH_BAT0="96" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#11	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#12	sudo tlp start -- X_BAT_PLUGIN_SIMULATE=framework NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#13	#
#14	# --- tlp setcharge w/o arguments
#15	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" X_SOC_CHECK=0
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #15, line 35] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" X_SOC_CHECK=0
@@ -1,3 +0,0 @@
-Setting temporary charge thresholds for BAT0:
-  start =  60
-  stop  = 100 (no change)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#16	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #16, line 39] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100"
@@ -1 +0,0 @@
-Error in configuration at START_CHARGE_THRESH_BAT0="100": not specified, invalid or out of range (0..99). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#17	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="0"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #17, line 41] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="0"
@@ -1 +0,0 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="0": not specified, invalid or out of range (1..100). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#18	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="101"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #18, line 43] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="0" STOP_CHARGE_THRESH_BAT0="101"
@@ -1 +0,0 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="101": not specified, invalid or out of range (1..100). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#19	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="97" STOP_CHARGE_THRESH_BAT0="97"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #19, line 45] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="97" STOP_CHARGE_THRESH_BAT0="97"
@@ -1 +0,0 @@
-Error in configuration: START_CHARGE_THRESH_BAT0 >= STOP_CHARGE_THRESH_BAT0. Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#20	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="95" STOP_CHARGE_THRESH_BAT0="96"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #20, line 47] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="95" STOP_CHARGE_THRESH_BAT0="96"
@@ -1,3 +0,0 @@
-Setting temporary charge thresholds for BAT0:
-  start =  95
-  stop  =  96
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#21	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="95" STOP_CHARGE_THRESH_BAT0="96"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #21, line 51] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="95" STOP_CHARGE_THRESH_BAT0="96"
@@ -1,3 +0,0 @@
-Setting temporary charge thresholds for BAT0:
-  start =  95 (no change)
-  stop  =  96 (no change)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#22	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #22, line 55] sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
@@ -1,3 +0,0 @@
-Setting temporary charge thresholds for BAT0:
-  start =   0
-  stop  = 100
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#23	sudo tlp setcharge -- X_BAT_PLUGIN_SIMULATE=framework NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#24	#
#25	# --- tlp setcharge w/ arguments
#26	sudo tlp setcharge 60 100 -- X_BAT_PLUGIN_SIMULATE=framework X_SOC_CHECK=0
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #26, line 63] sudo tlp setcharge 60 100 -- X_BAT_PLUGIN_SIMULATE=framework X_SOC_CHECK=0
@@ -1,3 +1,3 @@
-Setting temporary charge thresholds for BAT0:
+Setting temporary charge thresholds for BAT1:
   start =  60
   stop  = 100 (no change)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#27	sudo tlp setcharge 100 100 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #27, line 67] sudo tlp setcharge 100 100 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: start charge threshold (100) for BAT0 is not specified, invalid or out of range (0..99). Aborted.
+Error: start charge threshold (100) for BAT1 is not specified, invalid or out of range (0..99). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#28	sudo tlp setcharge 0 0 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #28, line 69] sudo tlp setcharge 0 0 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: stop charge threshold (0) for BAT0 is not specified, invalid or out of range (1..100). Aborted.
+Error: stop charge threshold (0) for BAT1 is not specified, invalid or out of range (1..100). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#29	sudo tlp setcharge 0 101 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #29, line 71] sudo tlp setcharge 0 101 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: stop charge threshold (101) for BAT0 is not specified, invalid or out of range (1..100). Aborted.
+Error: stop charge threshold (101) for BAT1 is not specified, invalid or out of range (1..100). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#30	sudo tlp setcharge XYZZY 0 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #30, line 73] sudo tlp setcharge XYZZY 0 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: start charge threshold (XYZZY) for BAT0 is not specified, invalid or out of range (0..99). Aborted.
+Error: start charge threshold (XYZZY) for BAT1 is not specified, invalid or out of range (0..99). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#31	sudo tlp setcharge 0 XYZZY -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #31, line 75] sudo tlp setcharge 0 XYZZY -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: stop charge threshold (XYZZY) for BAT0 is not specified, invalid or out of range (1..100). Aborted.
+Error: stop charge threshold (XYZZY) for BAT1 is not specified, invalid or out of range (1..100). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#32	sudo tlp setcharge 97 97 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #32, line 77] sudo tlp setcharge 97 97 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: start threshold >= stop threshold for BAT0. Aborted.
+Error: start threshold >= stop threshold for BAT1. Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#33	sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #33, line 79] sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1,3 +1,3 @@
-Setting temporary charge thresholds for BAT0:
+Setting temporary charge thresholds for BAT1:
   start =  95
   stop  =  96
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#34	sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework X_THRESH_SIMULATE_READERR="1"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #34, line 83] sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework X_THRESH_SIMULATE_READERR="1"
@@ -1 +1 @@
-Error: could not read current charge threshold(s) for BAT0. Aborted.
+Error: could not read current charge threshold(s) for BAT1. Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#35	sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework X_THRESH_SIMULATE_START="60" X_THRESH_SIMULATE_STOP="100"
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #35, line 85] sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework X_THRESH_SIMULATE_START="60" X_THRESH_SIMULATE_STOP="100"
@@ -1,3 +1,3 @@
-Setting temporary charge thresholds for BAT0:
+Setting temporary charge thresholds for BAT1:
   start =  95
   stop  =  96
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#36	sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #36, line 89] sudo tlp setcharge 95 96 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1,3 +1,3 @@
-Setting temporary charge thresholds for BAT0:
+Setting temporary charge thresholds for BAT1:
   start =  95 (no change)
   stop  =  96 (no change)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#37	sudo tlp setcharge DEF DEF -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #37, line 93] sudo tlp setcharge DEF DEF -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1,3 +1,3 @@
-Setting temporary charge thresholds for BAT0:
-  stop  = 100
+Setting temporary charge thresholds for BAT1:
   start =   0
+  stop  = 100
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#38	sudo tlp setcharge BAT1 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #38, line 97] sudo tlp setcharge BAT1 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +0,0 @@
-Error: battery BAT1 not present.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#39	sudo tlp setcharge 0 3 BAT1 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #39, line 99] sudo tlp setcharge 0 3 BAT1 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1,3 @@
-Error: battery BAT1 not present.
+Setting temporary charge thresholds for BAT1:
+  start =   0 (no change)
+  stop  =   3
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#40	sudo tlp setcharge XYZZY ABCDE BAT1 -- X_BAT_PLUGIN_SIMULATE=framework
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #40, line 101] sudo tlp setcharge XYZZY ABCDE BAT1 -- X_BAT_PLUGIN_SIMULATE=framework
@@ -1 +1 @@
-Error: battery BAT1 not present.
+Error: start charge threshold (XYZZY) for BAT1 is not specified, invalid or out of range (0..99). Aborted.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#41	#
#42	# --- tlp-stat
#43	# steps require a kernel >= 5.17 -- with 'charge_behaviour'
#44	sudo tlp-stat -b -- X_BAT_PLUGIN_SIMULATE=framework | grep -E 'charge_(control|behaviour)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #44, line 106] sudo tlp-stat -b -- X_BAT_PLUGIN_SIMULATE=framework | grep -E 'charge_(control|behaviour)'
@@ -1,3 +1,4 @@
-/sys/class/power_supply/BAT0/charge_control_start_threshold =      0 [%]
-/sys/class/power_supply/BAT0/charge_control_end_threshold   =    100 [%]
-/sys/class/power_supply/BAT0/charge_behaviour               = [auto] inhibit-charge force-discharge
+* natacpi (cros_charge_control) = active (charge thresholds)
+/sys/class/power_supply/BAT1/charge_control_start_threshold =      0 [%]
+/sys/class/power_supply/BAT1/charge_control_end_threshold   =      3 [%]
+/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#45	sudo tlp-stat -b -- X_BAT_PLUGIN_SIMULATE=framework X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #45, line 110] sudo tlp-stat -b -- X_BAT_PLUGIN_SIMULATE=framework X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
@@ -1,3 +1,4 @@
-/sys/class/power_supply/BAT0/charge_control_start_threshold = (not available) [%]
-/sys/class/power_supply/BAT0/charge_control_end_threshold   = (not available) [%]
-/sys/class/power_supply/BAT0/charge_behaviour               = [auto] inhibit-charge force-discharge
+* natacpi (cros_charge_control) = active (charge thresholds)
+/sys/class/power_supply/BAT1/charge_control_start_threshold = (not available) [%]
+/sys/class/power_supply/BAT1/charge_control_end_threshold   = (not available) [%]
+/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge
----------------------------------------------------------------------------------------------------------------------------------------------------------------
#46	#
#47	# --- Reset test machine to configured thresholds
#48	sudo tlp setcharge BAT0  > /dev/null 2>&1
#49	#

FAIL: 29 of 49 tests failed

@linrunner
Copy link
Owner Author

  • The vendor check actually reads the model_name, so always fails.

Thanks, I now check if /sys/class/dmi/id/sys_vendor is "Framework".

[~/src/tlp]$ sudo clitest unit-tests/charge-thresholds_framework

Improved. Please test again.

[~/src/tlp]$ sudo clitest unit-tests/charge-thresholds_framework-simulate

Oh, no! Do not run this: It only works as a simulation on a ThinkPad (for my dev qa) not on real Framework hardware ...

The fact that the mAh/mA sysfiles read plausible values is new to me:

/sys/class/power_supply/BAT1/charge_full_design = 3915 [mWh] *
/sys/class/power_supply/BAT1/charge_full = 3522 [mWh] *
/sys/class/power_supply/BAT1/charge_now = 3522 [mWh] *
/sys/class/power_supply/BAT1/current_now = 0 [mW] *

I only know of implausible values that are presumably to be interpreted as mWh/mW, see here.

+++ System Info
System = Framework AA Laptop
BIOS = 03.17

++ Battery Care

+++ Battery Status: BAT1
/sys/class/power_supply/BAT1/manufacturer = NVT
/sys/class/power_supply/BAT1/model_name = Framewo
/sys/class/power_supply/BAT1/charge_full_design = 35720 [mAh]
/sys/class/power_supply/BAT1/charge_full = 31970 [mAh]
/sys/class/power_supply/BAT1/charge_now = 14530 [mAh]
/sys/class/power_supply/BAT1/current_now = 1 [mA]

A well-known coreboot disease. Doesn't seem to be the case with your model then, I have removed the coreboot workaround.

Please show

sudo tlp-stat -s -b -v

again.

@t-8ch
Copy link
Contributor

t-8ch commented Oct 6, 2024

$ sudo clitest unit-tests/charge-thresholds_framework
#1	# +++ Framework laptops ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...
OK: 48 of 48 tests passed
$ sudo tlp-stat -s -b -v                           
--- TLP 1.7.0 --------------------------------------------

+++ System Info
System         = Framework A7 Laptop 13 (AMD Ryzen 7040Series)
BIOS           = 03.05
OS Release     = Arch Linux
Kernel         = 6.12.0-rc1-00308-g695f7def8da4 #14 SMP PREEMPT_DYNAMIC Sat Oct  5 10:06:10 CEST 2024 x86_64
/proc/cmdline  = initrd=\initramfs-linux-upstream.img rw cryptdevice=/dev/nvme0n1p3:system:discard root=/dev/mapper/system
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = [s2idle]

+++ TLP Status
State          = enabled
RDW state      = not installed
Last run       = 15:51:02, 52 sec(s) ago
Mode           = AC
Power source   = AC

+++ Battery Care
Plugin: framework
Supported features: charge thresholds
Driver usage:
* natacpi (cros_charge_control) = active (charge thresholds)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  0(off)..99
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)

+++ Battery Status: BAT1
/sys/class/power_supply/BAT1/manufacturer                   = NVT
/sys/class/power_supply/BAT1/model_name                     = FRANGWA
/sys/class/power_supply/BAT1/cycle_count                    =     38
/sys/class/power_supply/BAT1/charge_full_design             =   3915 [mAh]
/sys/class/power_supply/BAT1/charge_full                    =   3483 [mAh]
/sys/class/power_supply/BAT1/charge_now                     =    844 [mAh]
/sys/class/power_supply/BAT1/current_now                    =   2438 [mA]
/sys/class/power_supply/BAT1/status                         = Charging

/sys/class/power_supply/BAT1/voltage_min_design             =  15480 [mV]
/sys/class/power_supply/BAT1/voltage_now                    =  16204 [mV]

/sys/class/power_supply/BAT1/charge_control_start_threshold =      0 [%]
/sys/class/power_supply/BAT1/charge_control_end_threshold   =    100 [%]
/sys/class/power_supply/BAT1/charge_behaviour               = [auto] inhibit-charge force-discharge

Charge                                                      =   24.2 [%]
Capacity                                                    =   89.0 [%]

A well-known coreboot disease. Doesn't seem to be the case with your model then, I have removed the coreboot workaround.

Only the Framework Chromebook uses coreboot.
That's not the case for my machine.

@linrunner
Copy link
Owner Author

@t-8ch LGTM :-). Thank you for testing.

@linrunner linrunner changed the title [Framework] Battery care support based on the cros_charge-control driver (as of Linux 6.10) [Framework] Battery care support based on the cros_charge-control driver (as of Linux 6.11) Oct 7, 2024
@linrunner
Copy link
Owner Author

linrunner commented Oct 11, 2024

@t-8ch I have finished the second stage of the plugin with discharge/recalibrate. Please test it with

 sudo tlp discharge

You can force an earlier end to the discharging process by specifying a certain charge level (in mAh) with the debug parameter X_BAT_DISCHG_END. Example:

 sudo tlp discharge -- X_BAT_DISCHG_END=3000

I would also like to ask for your feedback on the safety message:

Caution: discharge/recalibrate operation is blocked for safety reasons.

Your laptop's EC firmware will not stop until the battery is completely discharged.
This will cause the laptop to suddenly power off, which can lead to data loss and data corruption.
TLP will stop discharging before this happens, but it can't respond to unforeseen battery behavior.

Add CHROMEOS_EC_UNBLOCK_DISCHARGE=1 to your configuration to accept the risk and unblock
discharge/recalibrate. Make sure all data is saved and backups are in place.

linrunner added a commit that referenced this issue Oct 16, 2024
* Framework driver converted into a generic one

* Supports laptops with ChromeOS EC:
  - Framework Laptop 13/16 Intel/AMD
  - Chromebooks modded with chrultrabook/coreboot custom UEFI firmware

* Requires cros_charge-control module (Linux 6.10+)
* Start and stop threshold
* Recalibrate/discharge (locked by default)

* charge_control_start_threshold:
  - Valid values: 0..100 - limited to 0..99
  - Default value: 0

* charge_control_end_threshold:
  - Valid values: 0..100 - limnited to 1..100
  - Default value: 100

Credits:
* Thomas Weißschuh
* Patrick McLean
* iks230

References:
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6ed48ef52599098498a8442fd60bea5bd8cd309
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/power/supply/cros_charge-control.c
* #765
* https://docs.chrultrabook.com/docs/firmware/
* https://thinkpad-forum.de/threads/c13-yoga-gen-1-chromebook-%E2%80%93-tipps-erfahrungen.240712/#post-2404669
@linrunner linrunner changed the title [Framework] Battery care support based on the cros_charge-control driver (as of Linux 6.11) [Framework, Chromebook] Battery care support based on the cros_charge-control driver (as of Linux 6.11) Oct 16, 2024
@linrunner
Copy link
Owner Author

linrunner commented Oct 16, 2024

@t-8ch After I found a tester by chance, I converted the plugin from a framework-specific to a generic one for all laptops with ChromeOS EC. See 1st post.

The automatic test script moves to unit-tests/charge-thresholds_chromeos-ec-BAT1

@MithicSpirit
Copy link

Doesn't seem to be working on my Framework 16, even though the cros_charge_control kmod is loaded.

$ sudo tlp-stat -s -b -v
--- TLP 1.8.0-alpha.0 --------------------------------------------

+++ System Info
System         = Framework AG Laptop 16 (AMD Ryzen 7040 Series)
BIOS           = 03.03
OS Release     = NixOS 24.11 (Vicuna)
Kernel         = 6.11.3-xanmod1 #1-NixOS SMP PREEMPT_DYNAMIC Tue Jan  1 00:00:00 UTC 1980 x86_64
/proc/cmdline  = init=/nix/store/xic0jg2pw0d635v9x4f1xhpvqmvbm84h-nixos-system-hipparchus-24.11.20241018.4c2fcb0/init amd_pstate=active root=fstab loglevel=4 vt.default_red=0x29,0xbf,0xa3,0xeb,0x81,0xb4,0x88,0xec,0x43,0xcb,0xb2,0xee,0x9a,0xc0,0x99,0xe5 vt.default_grn=0x2e,0x61,0xbe,0xcb,0xa1,0x8e,0xc0,0xef,0x4c,0x8d,0xcc,0xd5,0xb3,0xa5,0xce,0xe9 vt.default_blu=0x38,0x6a,0x8c,0x8b,0xc1,0xad,0xd0,0xf4,0x5e,0x92,0x9c,0xaa,0xce,0xbb,0xdd,0xf0
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = [s2idle]

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 03:53:31 PM, 314 sec(s) ago
Mode           = AC
Power source   = AC

+++ Battery Care
Plugin: chromeos-ec
Supported features: none available
Driver usage:
* natacpi (cros_charge_control) = inactive (laptop not supported, incompatible firmware)

+++ Battery Status: BAT1
/sys/class/power_supply/BAT1/manufacturer                   = NVT
/sys/class/power_supply/BAT1/model_name                     = FRANDBA
/sys/class/power_supply/BAT1/cycle_count                    =     28
/sys/class/power_supply/BAT1/charge_full_design             =   5491 [mAh]
/sys/class/power_supply/BAT1/charge_full                    =   5583 [mAh]
/sys/class/power_supply/BAT1/charge_now                     =   4748 [mAh]
/sys/class/power_supply/BAT1/current_now                    =      0 [mA]
/sys/class/power_supply/BAT1/status                         = Charging

/sys/class/power_supply/BAT1/voltage_min_design             =  15480 [mV]
/sys/class/power_supply/BAT1/voltage_now                    =  16990 [mV]

Charge                                                      =   85.0 [%]
Capacity                                                    =  101.7 [%]
$ lsmod | grep cros_charge_control
cros_charge_control    16384  0
battery                28672  2 cros_charge_control,framework_laptop

@linrunner
Copy link
Owner Author

@MithicSpirit please show the output of

grep . /sys/class/power_supply/BAT1/*

@MithicSpirit
Copy link

$ grep . /sys/class/power_supply/BAT1/*
/sys/class/power_supply/BAT1/alarm:550000
/sys/class/power_supply/BAT1/capacity:85
/sys/class/power_supply/BAT1/capacity_level:Normal
/sys/class/power_supply/BAT1/charge_control_end_threshold:85
/sys/class/power_supply/BAT1/charge_full:5595000
/sys/class/power_supply/BAT1/charge_full_design:5491000
/sys/class/power_supply/BAT1/charge_now:4759000
/sys/class/power_supply/BAT1/current_now:0
/sys/class/power_supply/BAT1/cycle_count:28
grep: /sys/class/power_supply/BAT1/device: Is a directory
grep: /sys/class/power_supply/BAT1/hwmon3: Is a directory
/sys/class/power_supply/BAT1/manufacturer:NVT
/sys/class/power_supply/BAT1/model_name:FRANDBA
grep: /sys/class/power_supply/BAT1/power: Is a directory
/sys/class/power_supply/BAT1/present:1
/sys/class/power_supply/BAT1/serial_number:0342
/sys/class/power_supply/BAT1/status:Charging
grep: /sys/class/power_supply/BAT1/subsystem: Is a directory
/sys/class/power_supply/BAT1/technology:Li-ion
/sys/class/power_supply/BAT1/type:Battery
/sys/class/power_supply/BAT1/uevent:DEVTYPE=power_supply
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_NAME=BAT1
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_TYPE=Battery
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_STATUS=Charging
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_PRESENT=1
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_TECHNOLOGY=Li-ion
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CYCLE_COUNT=28
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_VOLTAGE_MIN_DESIGN=15480000
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_VOLTAGE_NOW=16996000
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CURRENT_NOW=0
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CHARGE_FULL_DESIGN=5491000
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CHARGE_FULL=5595000
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CHARGE_NOW=4759000
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CAPACITY=85
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_CAPACITY_LEVEL=Normal
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_MODEL_NAME=FRANDBA
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_MANUFACTURER=NVT
/sys/class/power_supply/BAT1/uevent:POWER_SUPPLY_SERIAL_NUMBER=0342
/sys/class/power_supply/BAT1/voltage_min_design:15480000
/sys/class/power_supply/BAT1/voltage_now:16996000

@linrunner
Copy link
Owner Author

linrunner commented Oct 22, 2024

@MithicSpirit

/sys/class/power_supply/BAT1/charge_control_end_threshold:85

The out-of-tree module framework_laptop is loaded and has moved in front of cros_charge-control. Unfortunately, atm I don't know how to prevent this. Try to unload framework_laptop and cros_charge-control, then load cros_charge-control only.

@MithicSpirit
Copy link

Doesn't seem to fix it. I'll try disabling the framework_laptop module later when I have time.

linrunner added a commit that referenced this issue Oct 25, 2024
Rationale: in case that framework_laptop preempts the module cros_charge-control,
the cros-ec plugin cannot initialize and we continue with the framework plugin.

Reference:
* #765 (comment)
@linrunner
Copy link
Owner Author

@MithicSpirit I have now restored the original plugin for the framework_laptop module which support only a stop threshold. You need to install /usr/share/tlp/bat.d/55-chromeos-ec and /usr/share/tlp/bat.d/56-framework. Then show

 sudo tlp-stat -s -b -v

@MithicSpirit
Copy link

MithicSpirit commented Oct 25, 2024

Seems to be working now.

$ sudo tlp-stat -s -b -v
--- TLP 1.8.0-alpha.0 --------------------------------------------

+++ System Info
System         = Framework AG Laptop 16 (AMD Ryzen 7040 Series)
BIOS           = 03.03
OS Release     = NixOS 24.11 (Vicuna)
Kernel         = 6.11.3-xanmod1 #1-NixOS SMP PREEMPT_DYNAMIC Tue Jan  1 00:00:00 UTC 1980 x86_64
/proc/cmdline  = init=/nix/store/2cvwm5nzb7gs2sinsjy7a44ypkl6rc0c-nixos-system-hipparchus-24.11.20241020.1997e4a/init amd_pstate=active root=fstab loglevel=4 vt.default_red=0x29,0xbf,0xa3,0xeb,0x81,0xb4,0x88,0xec,0x43,0xcb,0xb2,0xee,0x9a,0xc0,0x99,0xe5 vt.default_grn=0x2e,0x61,0xbe,0xcb,0xa1,0x8e,0xc0,0xef,0x4c,0x8d,0xcc,0xd5,0xb3,0xa5,0xce,0xe9 vt.default_blu=0x38,0x6a,0x8c,0x8b,0xc1,0xad,0xd0,0xf4,0x5e,0x92,0x9c,0xaa,0xce,0xbb,0xdd,0xf0
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = [s2idle]

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 10:03:07 AM, 18 sec(s) ago
Mode           = AC
Power source   = AC

+++ Battery Care
Plugin: framework
Supported features: charge threshold
Driver usage:
* natacpi (framework_laptop) = active (charge thresholds)
Parameter value ranges:
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)

+++ Battery Status: BAT1
/sys/class/power_supply/BAT1/manufacturer                   = NVT
/sys/class/power_supply/BAT1/model_name                     = FRANDBA
/sys/class/power_supply/BAT1/cycle_count                    =     28
/sys/class/power_supply/BAT1/charge_full_design             =   5491 [mAh]
/sys/class/power_supply/BAT1/charge_full                    =   5505 [mAh]
/sys/class/power_supply/BAT1/charge_now                     =   4674 [mAh]
/sys/class/power_supply/BAT1/current_now                    =   1055 [mA]
/sys/class/power_supply/BAT1/status                         = Discharging

/sys/class/power_supply/BAT1/voltage_min_design             =  15480 [mV]
/sys/class/power_supply/BAT1/voltage_now                    =  16579 [mV]

/sys/class/power_supply/BAT1/charge_control_end_threshold   =     80 [%]

Charge                                                      =   84.9 [%]
Capacity                                                    =  100.3 [%]

@linrunner
Copy link
Owner Author

linrunner commented Oct 25, 2024

@MithicSpirit lhe framework plugin is intended as a fallback in case you need framework_laptop for reasons other than battery care. I would be happy if you could still blacklist framework_laptop and then test the extended functionality of the chromeos-ec plugin based on the cros_charge-control module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants