Add getting battery info thorugh SMBUS#350
Merged
Merged
Conversation
416dfd9 to
63d9117
Compare
Add a new --smartbattery command to read basic Smart Battery System (SBS) information via I2C passthrough to the EC. This includes: - Battery mode, serial number, manufacture date - Temperature, voltage, individual cell voltages - Cycle count, device name, manufacturer name Reference: TI Smart Battery System specification Signed-off-by: Daniel Schaefer <dhs@frame.work>
Add support for reading TI BQ40z50 ManufacturerAccess registers: - Unseal/seal commands for protected data access - OperationStatus, SafetyAlert/Status, PFAlert/Status registers - LifeTimeDataBlocks 1-5 with detailed field decoding - State of Health (remaining capacity in mAh/Wh) Features: - Hidden input for unseal key (no terminal echo) - Multi-line operation status display with flag decoding - Detailed lifetime statistics (voltages, temps, currents, events) Requires nix "term" feature for Unix terminal control. Signed-off-by: Daniel Schaefer <dhs@frame.work>
Add BatteryData struct for collecting and serializing battery data: - write_to_file/read_from_file for simple text-based dump format - collect_data() method to gather all data into struct - display_battery_data() function for formatted output - Refactor dump_data() to use collect_data + display_battery_data - dump_to_file() method for saving data to file Add unit tests for: - Parsing battery dump files - Lifetime data validation - Hex encode/decode roundtrip - Manufacture date decoding - Temperature unit conversion Signed-off-by: Daniel Schaefer <dhs@frame.work>
Add analyze_health() function to evaluate battery condition: - Safety and permanent failure status check - Cell voltage balance analysis (current and historical) - Temperature extreme detection - Safety event counting (over-voltage, under-voltage, over-current) - Gauging health metrics (charge termination rate, resistance updates) Prints a summary with status (HEALTHY/GOOD/NEEDS ATTENTION), any issues or warnings, and key statistics including cycle count, remaining capacity, and cell balancing times. Signed-off-by: Daniel Schaefer <dhs@frame.work>
The --smartbattery flag now accepts an optional file path to load previously dumped battery data instead of reading from the actual battery. This enables offline analysis and debugging. Signed-off-by: Daniel Schaefer <dhs@frame.work>
Add battery authentication using TI's nested SHA-1 HMAC method: - calculate_ti_hmac(): Implements SHA1(Key || SHA1(Key || Challenge)) - authenticate_battery(): Challenge-response authentication flow - interactive_authenticate(): CLI interface with unseal/auth key prompts The authentication verifies battery authenticity by: 1. Sending a random 20-byte challenge to the battery 2. Waiting 250ms for the gauge to compute the response 3. Computing expected response locally using the auth key 4. Comparing responses to verify genuineness Add --smartbattery-auth CLI flag for interactive authentication. Requires sha1 and rand crate dependencies. Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Read standard SBS registers (current, charge state, capacity, design specs, battery status, chemistry) that are always available without unsealing. Also attempt MAC block reads (lifetime, safety, SOH) in sealed mode with fallback, and reorder display to group identity fields.
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
6711269 to
56c98f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.