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

Charging thresholds don't persist through an EC reset #128

Closed
leviport opened this issue Oct 28, 2020 · 3 comments · Fixed by #498
Closed

Charging thresholds don't persist through an EC reset #128

leviport opened this issue Oct 28, 2020 · 3 comments · Fixed by #498

Comments

@leviport
Copy link
Member

If I set custom charging thresholds on oryp6, they reset when shutting the machine down and disconnecting the charger. I discovered this while testing pop-os/system76-power#197.

@crawfxrd
Copy link
Member

Could be done with #63.

@crawfxrd
Copy link
Member

Using a minimized implementation of #256 for just battery thresholds:

  • 4 bytes beginning at second to last sector (EC flash size - 2 KiB)
    • Avoids sector used for saving dynamic keyboard layout
      • Note: Hard-coded at 0x1FC00, even on 256 KiB flash, so not always last sector of flash
    • Layout
      • 2 bytes: magic value
      • 1 byte: start threshold
      • 1 byte: end threshold

Could increase it to reserve some space.

  • Some kind of control byte?
  • Space for second battery values?

EC should do bounds checking on the values when read even if the magic byte is valid and fall back to the defaults if it fails.

There's probably multiple things that set thresholds on boot now since they aren't persistent. EC should probably only write thresholds to flash if they've been changed to minimize the amount of writing to EC flash. It would mean having the distinction of "apply" (change is only in RAM) vs "commit" (change is written to flash).

@crawfxrd crawfxrd linked a pull request Dec 13, 2024 that will close this issue
@crawfxrd
Copy link
Member

Basic implementation done in #498.

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

Successfully merging a pull request may close this issue.

2 participants