Skip to content

Unsupported userspace charge control #70

Closed

Description

@tlvince

Device Information

System Model or SKU

Please select one of the following

  • Framework Laptop 13 (11th Gen Intel® Core™)
  • Framework Laptop 13 (12th Gen Intel® Core™)
  • Framework Laptop 13 (13th Gen Intel® Core™)
  • Framework Laptop 13 (AMD Ryzen™ 7040 Series)
  • Framework Laptop 13 (Intel® Core™ Ultra Series 1)
  • Framework Laptop 13 (AMD Ryzen™ AI 300 Series)
  • Framework Laptop 16 (AMD Ryzen™ 7040 Series)

BIOS VERSION

3.03

DIY Edition information

Port/Peripheral information

  1. USB-C expansion card: Framework 60W charger
  2. USB-C expansion card (no peripheral)
  3. USB-C expansion card (no peripheral)
  4. USB-C expansion card (no peripheral)

Standalone Operation

  • Yes
  • No

Describe the bug

Loading cros_charge-control with probe_with_fwk_charge_control=1 should provide /sys/class/power_supply/BAT1/charge_control_{start,end}_threshold for userspace charge control e.g. GNOME 48's Preserve Battery Health feature.

This doesn't work on the AI 300 series (BIOS 3.03). On the 7040's, BIOS 3.09 caused a regression.

Operating System (please complete the following information):

  • OS/Distribution: NixOS
  • Version: 25
  • Linux Kernel Version: 6.14.6

Activity

  1. Serafean commented on May 27, 2025

    @Serafean

    Hi, I've been going through this issue here.

    The TLDR version is you need this kernel patch and probe_with_fwk_charge_control=1.

    So should be fixed in kernel 6.15.

  2. JohnAZoidberg commented on May 27, 2025

    @JohnAZoidberg
    Member

    Hi, I've been going through this issue here.

    The TLDR version is you need this kernel patch and probe_with_fwk_charge_control=1.

    So should be fixed in kernel 6.15.

    Oh thanks, I haven't seen that.
    But 6.15 was already released without this patch.

  3. Serafean commented on May 27, 2025

    @Serafean

    Oh thanks, I haven't seen that. But 6.15 was already released without this patch.

    My bad, made the assumption that it had landed...
    Good to know.

  4. tlvince commented on May 28, 2025

    @tlvince
    Author

    The TLDR version is you need this kernel patch and probe_with_fwk_charge_control=1.

    Thanks. Applied on top of v6.14.7. Works for me:

    ❯ upower -i /org/freedesktop/UPower/devices/battery_BAT1
        ...
        charge-start-threshold:        75%
        charge-end-threshold:          80%
        charge-threshold-enabled:          1
        charge-threshold-supported:          1
    

    Although the start threshold seems to be ignored - it hovers around 80% /cc @t-8ch.

  5. Serafean commented on May 29, 2025

    @Serafean

    @tlvince since you're also using charge control, could you please confirm a separate issue?
    When I set the start and end thresholds to the same number, it never starts charging. The discharge rate slows down to a minimum when it hits that percentage, but level still falls.

  6. JohnAZoidberg commented on May 29, 2025

    @JohnAZoidberg
    Member

    When I set the start and end thresholds to the same number, it never starts charging. The discharge rate slows down to a minimum when it hits that percentage, but level still falls.

    What do you expect to happen? What's the purpose of setting them to the same number?

    Although the start threshold seems to be ignored

    Yes, it's not implemented in the EC

  7. Serafean commented on May 29, 2025

    @Serafean

    What do you expect to happen? What's the purpose of setting them to the same number?

    My expectation is for the charge level to stay at that percentage while on AC.

    right now I have start 79%, end 80%.

  8. Serafean commented on May 29, 2025

    @Serafean

    Also the KDE UI sort of leads to setting them to the same number.

    https://github.com/user-attachments/assets/0e87663a-878d-407c-805c-edf7da307e81
    Manually set max to 83, min to 82, then used scroll wheel in "stop charging at" . Note how they're tied.

  9. JohnAZoidberg commented on May 29, 2025

    @JohnAZoidberg
    Member

    What do you expect to happen? What's the purpose of setting them to the same number?

    My expectation is for the charge level to stay at that percentage while on AC.

    right now I have start 79%, end 80%.

    But it's enough to set the maximum, no? Then the system charges until that number, stops and stays there

  10. Serafean commented on May 29, 2025

    @Serafean

    The reason I reported this it is that I just scrolled the max down to 80% in the KDE UI (which set the min to 80%, hadn't even thought about setting that), applied.
    Then in the morning found the AC connected laptop discharged to about 60% - under both thresholds. Found the behaviour to be very surprising, so reporting it.
    This may be because powerdevil sets both numbers, while the EC expectation is that only one will be set?

  11. tlvince commented on May 29, 2025

    @tlvince
    Author

    Yes, it's not implemented in the EC

    Please consider implementing this 😄

    When I set the start and end thresholds to the same number, it never starts charging

    Setting both to the same value doesn't make sense, IMO. Sounds like a validation bug. Although not charging at all sounds like its triggering another bug.

    Either way, I think we can close this issue.

  12. JohnAZoidberg commented on Jun 7, 2025

    @JohnAZoidberg
    Member

    Please consider implementing this 😄

    Yes, we're planning to retire our own host commands eventually and use the battery limit/saver commands of chromium ec.

    Either way, I think we can close this issue.

    Great, thanks, good that it's wroking now.

  13. tlvince commented on Jul 22, 2025

    @tlvince
    Author

    @JohnAZoidberg unfortunately 3.04 seems to have broken this. With the BIOS charge limit and extender options disabled and mfd: cros_ec: Separate charge-control probing from USB-PD applied to 6.15.7 as before, GNOME/upower detects the charge limit, but it keeps charging past 80%:

      battery
        present:             yes
        rechargeable:        yes
        state:               charging
        warning-level:       none
        energy:              61.3627 Wh
        energy-empty:        0 Wh
        energy-full:         61.9974 Wh
        energy-full-design:  60.6042 Wh
        energy-rate:         4.08672 W
        voltage:             17.783 V
        charge-cycles:       27
        time to full:        9.3 minutes
        percentage:          98%
        capacity:            100%
        technology:          lithium-ion
        charge-start-threshold:        75%
        charge-end-threshold:          80%
        charge-threshold-enabled:          1
        charge-threshold-supported:          1
        icon-name:          'battery-full-charging-symbolic'
      History (rate):
        1753199608  4.087   charging
        1753199604  4.056   charging
        1753199574  4.180   charging
        1753199544  4.226   charging
        1753199514  4.272   charging
    

    Could this issue be reopened? @Serafean can you reproduce?

  14. Serafean commented on Jul 22, 2025

    @Serafean

    Yes, I can, kernel 6.15.7, but I'm still on 3.03
    DMI: Framework Laptop 13 (AMD Ryzen AI 300 Series)/FRANMGCP09, BIOS 03.03 03/10/2025

    I also note that you have

        charge-start-threshold:        75%
        charge-end-threshold:          80%
    

    Which are the exact same numbers I show, but aren't the limits I have set.

  15. Serafean commented on Jul 22, 2025

    @Serafean

    The output is a upower discrepancy, the cat /sys/class/power_supply/BAT1/charge_control_{start,end}_threshold files report the set values correctly.

  16. tlvince commented on Jul 22, 2025

    @tlvince
    Author

    Thanks. I can reproduce on 6.15.5 with 3.04, but couldn't with 6.15.5 with 3.03

  17. Serafean commented on Jul 27, 2025

    @Serafean

    BIOS 03.04 06/10/2025 , kernel 6.15.8, charge limit sort of works.
    I think it is only the BIOS limit that is respected though, changing the min/max values from userspace doesn't seem to do anything.
    And because I'm an idiot who deleted the old kernels almost immediately, checking that a previous version works remains on my TODO list :/
    My gut tells me it's coming from the patches not being correct anymore.

  18. tlvince commented on Jul 28, 2025

    @tlvince
    Author

    Yeah, I'm using the EC charge limiter for now. It can be controlled via ectool, but its less convenient. I've pinged the driver maintainer in the meantime.

  19. tlvince commented on Jul 29, 2025

    @tlvince
    Author

    With the BIOS limiter set to 100% and extender disabled and cros_charge-control enabled, in the EC logs, I see:

    [238553.413200 Sustainer enabled: 75 ~ 100%]
    [238553.423500 Sustainer updated: 75 ~ 80% (from 75 ~ 100%)]
    [238553.552500 Sustainer disabled]
    

    ... which suggests the limits are being passed through correctly, but then being reset.

    This looks like the culprit: FrameworkComputer/EmbeddedController@d2a654b#diff-c97fadb96709544efeb068ef6acb07cc573d36d2b4498033b7d5f84b8a24ae41L85-L141

    @JohnAZoidberg could you take a look? Perhaps this could be solved by an explicit charge limit toggle in the BIOS.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions