This document details how developers can use hardware tools like Servo and Sweetberry and software tools within dev-util/hdctools
and other repos to measure power on a Chrome OS device (DUT, device under test).
Servo-like devices, including Servo V2, Servo V4, Micro Servo and Suzy-Qable, can be used to measure power on the DUT with Analog-to-Digital Converters (ADCs) on the board. For simplicity, this doc refers to them as just “Servo” devices.
See Servo for more information on Servo.
Sweetberry, Servo V1, or Servo INA adapter can be used when there are no ADCs on the DUT. Sweetberry is the preferred method. A hardware rework on the DUT is often required to place sense resistors on the power rails and to attach ‘Medusa style’ header (HIROSE DF13A-40DP-1.25V(55)) to the sense resistors and ground.
See Sweetberry Configuration for more information on Sweetberry.
Servo and Sweetberry can measure power on the DUT, but they have no awareness of what power rails are being measured, or what size the sense resistors are. Therefore, a configuration file is necessary to provide information about the hardware setup. This configuration file is usually manually created by an engineer and is fed into the power measurement software tool later.
File format: .py
See INA Configuration Files for instructions on how to write the configuration file.
There are some slight differences between configuration files for Servo and that for Sweetberry. See this example for configuration for Servo.
There are two ways to write Sweetberry configuration files. See servo_sweetberry_rails_addr.py
and servo_sweetberry_rails_pins.py
.
The .py
files created in the previous part need to be compiled into formats required by the software tool.
If you created or edited the .py
configuration file, first you need to run:
(chroot) $ cros_workon --host start dev-util/hdctools
This only needs to be run ONCE.
Then, every time after you edit the .py
configuration file, run:
(chroot) $ sudo emerge dev-util/hdctools
To verify that you have generated configuration files successfully, look into this directory:
(chroot) $ /usr/lib64/python2.7/site-packages/servo/data/
File format: .xml
for servod, .board
and .scenario
for powerlog.
Start a servod instance in chroot to talk to the Servo or Sweetberry that is attached to the DUT:
# For setup with on-board INA chip (chroot) $ sudo servod --board $BOARD --config $CONFIG_FILE.xml # For setup with sweetberry only (chroot) $ sudo servod --config $CONFIG_FILE.xml
Note that $CONFIG_FILE.xml
is generated in the previous step. Both dut-power
and dut-control
are servod clients that talk to servod and fetch power data from the Servo or Sweetberry.
Recommended, for users who only want measurements in power.
(chroot) $ dut-power [arguments] # Example arguments for setup with sweetberry only (chroot) $ dut-power --vbat-rate 0 -t 5
dut-power
queries the selected servod to read power measurements from the Servo or Sweetberry. See dut-power -h
for setting arguments. dut-power
works with both Servo and Sweetberry. It packs configuring the ADCs, reading data, calculating statistics, and saving to file into one command.
For power users, provides more info than power.
dut-control
can collect power measurements from both EC and on-board ADCs.
dut-control
can query battery power via EC’s connection (I2C) to the battery, namely ppvar_vbat
. On newer devices, same data averaged over 1 minute can be queried by avg_ppvar_vbat
.
dut-control
can query power rails specified in the configuration file.
dut-control
can query power, bus voltage and current for all rails above, and additionally shunt voltage for on-board ADCs.
The on-board ADCs can be configured to more accurately measure power depending on the size of the sense resistors and shunt voltage across the sense resistors. Choose from the follow quick configs:
Config | Context |
---|---|
regular_power | S0 measurements |
regular_power_no_hw_avg | S0 measurements w/out avg (for debug) |
low_power | < S0 measurements |
low_power_no_hw_avg | < S0 measurements w/out avg (for debug) |
Create helper variable, without ppvar_vbat
.
(chroot) $ mv=$(dut-control bus_voltage_rails | cut -f 2 -d: | tr -d ',') (chroot) $ ma=$(dut-control current_rails | cut -f 2 -d: | tr -d ',') (chroot) $ mw=$(dut-control power_rails | cut -f 2 -d: | tr -d ',') (chroot) $ cfg_reg=$(echo $mv | sed 's/_mv/_cfg_reg/g')
Configure on-board ADCs (everytime after running servod
).
(chroot) $ for cfg in $cfg_reg ; do dut-control $cfg:regular_power $cfg; done
Or
(chroot) $ for cfg in $cfg_reg ; do dut-control $cfg:low_power $cfg; done
Measure each power rail once.
(chroot) $ dut-control $mv (chroot) $ dut-control $ma (chroot) $ dut-control $mw
And
(chroot) $ dut-control avg_ppvar_vbat_mw (chroot) $ dut-control avg_ppvar_vbat_ma (chroot) $ dut-control avg_ppvar_vbat_mw
Or
(chroot) $ dut-control ppvar_vbat_mv (chroot) $ dut-control ppvar_vbat_ma (chroot) $ dut-control ppvar_vbat_mw
Measure power for 1 second 30 times.
(chroot) $ dut-control -t 30 -z 1000 $mw | grep @@ | cut -b 6-