Skip to content

Conversation

@TychoVrahe
Copy link
Contributor

@TychoVrahe TychoVrahe commented Oct 21, 2025

This PR does some preparation for using two different battery vendors in one device.

The battery model is selected based on info in unit properties. The model/fuel gauge is adjusted so that dynamic model selection is enabled.

@TychoVrahe TychoVrahe self-assigned this Oct 21, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs review in Firmware Oct 21, 2025
@github-actions
Copy link

github-actions bot commented Oct 21, 2025

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 18933393067

@TychoVrahe TychoVrahe requested a review from Copilot October 21, 2025 10:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces battery type selection support by reading battery configuration from OTP (One-Time Programmable) storage and using it to dynamically select the appropriate battery model parameters for the fuel gauge system.

  • Adds battery_type field to unit properties read from OTP storage
  • Refactors battery model functions to use a battery_model_t structure instead of global constants
  • Initializes battery model parameters in fuel gauge based on the detected battery type

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
core/embed/util/unit_properties/stm32/unit_properties.c Reads battery type from OTP data[4] and marks it as valid
core/embed/util/unit_properties/inc/util/unit_properties.h Adds battery_type field and validity flag to unit_properties_t struct
core/embed/sys/power_manager/stm32u5/power_monitoring.c Updates battery function calls to pass model pointer
core/embed/sys/power_manager/stm32u5/power_manager.c Adds initialization check and passes model pointer to battery functions
core/embed/sys/power_manager/fuel_gauge/fuel_gauge.h Adds battery_model_t member to fuel_gauge_state_t
core/embed/sys/power_manager/fuel_gauge/fuel_gauge.c Initializes battery model parameters based on battery type from unit properties
core/embed/sys/power_manager/fuel_gauge/battery_model.h Defines battery_model_t struct and updates all function signatures to accept model pointer
core/embed/sys/power_manager/fuel_gauge/battery_model.c Refactors all functions to use model pointer instead of global constants
core/embed/sys/power_manager/fuel_gauge/battery_data_jyhpfl333838.h Renames all constants with JYHPFL333838 prefix for model-specific identification

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@TychoVrahe TychoVrahe force-pushed the tychovrahe/T3W1/battery_type branch 2 times, most recently from f4d4aae to c43f2f7 Compare October 21, 2025 11:09
@TychoVrahe TychoVrahe marked this pull request as ready for review October 21, 2025 11:10
@TychoVrahe TychoVrahe requested a review from kopecdav October 21, 2025 11:10
@github-project-automation github-project-automation bot moved this from 🔎 Needs review to 🏃‍♀️ In progress in Firmware Oct 29, 2025
@TychoVrahe TychoVrahe force-pushed the tychovrahe/T3W1/battery_type branch from 52ee6d0 to fc3936b Compare October 30, 2025 07:39
@TychoVrahe TychoVrahe merged commit 0dee3ac into main Oct 30, 2025
105 checks passed
@TychoVrahe TychoVrahe deleted the tychovrahe/T3W1/battery_type branch October 30, 2025 08:56
@github-project-automation github-project-automation bot moved this from 🏃‍♀️ In progress to 🤝 Needs QA in Firmware Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🤝 Needs QA

Development

Successfully merging this pull request may close these issues.

3 participants