mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 08:31:52 +00:00
This CL adds the flag --save_stats_json which prints the MEAN of sweetberry readings into json format. Corresponding unit test has been added too. Printing just the MEAN in json format makes it easier to read it back in power_telemetry_logger, which uploads the stats to the dashboard. This CL is part of the effort to start sweetberry measurements while running power autotests. BRANCH=None BUG=b:68956240 TEST=./powerlog.py -b xxx.board -c xxx.scenario \ --save_stats_json [directory to store it] python -m unittest -v stats_manager_unittest Change-Id: I8274bcac21175f6c53184ced79b6ffe5e7d7a72a Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807636 Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
133 lines
4.5 KiB
Plaintext
133 lines
4.5 KiB
Plaintext
Sweetberry USB power monitoring
|
|
|
|
This tool allows high speed monitoring of power rails via a special USB
|
|
endpoint. Currently this is implemented for the sweetberry baord.
|
|
|
|
To use on a board, you'll need two config files, one describing the board,
|
|
a ".board" file, and one describing the particular rails you want to
|
|
monitor in this session, a ".scenario" file.
|
|
|
|
|
|
Converting from servo_ina configs:
|
|
|
|
Many configs can be found for the servo_ina_board in hdctools/servo/data/.
|
|
Sweetberry is plug compatible with servo_ina headers, and config files
|
|
can be converted with the following tool:
|
|
|
|
./convert_servo_ina.py kevin_r0_loc.py
|
|
|
|
This will produce kevin_r0_loc.board and kevin_r0_loc.scenario which
|
|
can be used with powerlog.py.
|
|
|
|
|
|
Board files:
|
|
|
|
Board files contain a list of rails, supporting 48 channels each on up to two
|
|
sweetberries. For each rail you must specify a name, sense resistor value,
|
|
and channel number. You can optionally list expected voltage and net name.
|
|
The format is as follows, in json:
|
|
|
|
example.board:
|
|
[
|
|
{ "name": "railname",
|
|
"rs": <sense resistor value in ohms>,
|
|
"sweetberry": <"A" for main sweetberry, "B" for a secondary sweetberry>,
|
|
"channel": <0-47 according to board schematic>,
|
|
"v": <optional expected bus voltage in volts>,
|
|
"net": <optional schematic net name>
|
|
},
|
|
{...}
|
|
]
|
|
|
|
|
|
Scenario files:
|
|
|
|
Scenario files contain the set of rails to monitor in this session. The
|
|
file format is simply a list of rail names from the board file.
|
|
|
|
example.scenario:
|
|
[
|
|
"railname",
|
|
"another_railname",
|
|
...
|
|
]
|
|
|
|
|
|
Output:
|
|
|
|
powerlog.py will output a csv formatted log to stdout, at timing intervals
|
|
specified on the command line. Currently values below "-t 10000" do not work
|
|
reliably but further updates should allow faster updating.
|
|
|
|
An example run of:
|
|
./powerlog.py -b board/marlin/marlin.board -c board/marlin/marlin_short.scenario -t 100000
|
|
|
|
Will result in:
|
|
ts:32976us, VBAT uW, VDD_MEM uW, VDD_CORE uW, VDD_GFX uW, VDD_1V8_PANEL uW
|
|
0.033004, 12207.03, 4882.81, 9155.27, 2441.41, 0.00
|
|
0.066008, 12207.03, 3662.11, 9155.27, 2441.41, 0.00
|
|
0.099012, 12207.03, 3662.11, 9155.27, 2441.41, 0.00
|
|
...
|
|
|
|
The output format is as follows:
|
|
ts:32976us: Timestamps either zero based or synced to system clock,
|
|
in seconds. The column header indicates the selected
|
|
sampling interval. Since the INA231 has specific
|
|
hardware defines sampling options, this will be the
|
|
closest supported option lower than the requested "-t"
|
|
value on the command line.
|
|
VBAT uW: microwatt reading from this rail, generated on the INA
|
|
by integrating the voltage/amperage on the sense resistor
|
|
over the sampling time, and multiplying by the sampled bus
|
|
voltage.
|
|
... uW: Further microwatt entry columns for each rail specified in
|
|
your scenario file.
|
|
|
|
|
|
Calculate stats and store data and stats:
|
|
|
|
When appropriate flag is set, powerlog.py is capable of calculating statistics
|
|
and storing statistics and raw data.
|
|
|
|
Example 1:
|
|
./powerlog.py -b board/eve_dvt2_loc/eve_dvt2_loc.board -c board/eve_dvt2_loc/eve_dvt2_loc.scenario --save_stats [<directory>]
|
|
|
|
If <directory> is specified, this will save stats as:
|
|
<directory>/sweetberry<timestemp>/summary.txt
|
|
If <directory> does not exist, it will be created.
|
|
|
|
If <directory> is not specified but the flag is set, this will save stats under
|
|
the directory which powerlog.py is in:
|
|
<directory of powerlog.py>/sweetberry<timestemp>/summary.txt
|
|
|
|
If --save_stats flag is not set, stats will not be saved.
|
|
|
|
Example 2:
|
|
./powerlog.py -b board/eve_dvt2_loc/eve_dvt2_loc.board -c board/eve_dvt2_loc/eve_dvt2_loc.scenario --save_raw_data [<directory>]
|
|
|
|
If <directory> is specified, this will save raw data in:
|
|
<directory>/sweetberry<timestemp>/raw_data/
|
|
If <directory> does not exist, it will be created.
|
|
|
|
If <directory> is not specified but the flag is set, this will save raw data
|
|
under the directory which powerlog.py is in:
|
|
<directory of powerlog.py>/sweetberry<timestemp>/raw_data/
|
|
|
|
If --save_raw_data flag is not set, raw data will not be saved.
|
|
|
|
Example 3:
|
|
./powerlog.py -b board/eve_dvt2_loc/eve_dvt2_loc.board -c board/eve_dvt2_loc/eve_dvt2_loc.scenario --save_stats_json [<directory>]
|
|
|
|
If <directory> is specified, this will save MEANS in json as:
|
|
<directory>/sweetberry<timestemp>/summary.json
|
|
If <directory> does not exist, it will be created.
|
|
|
|
If <directory> is not specified but the flag is set, this will save MEANS in
|
|
json under the directory which powerlog.py is in:
|
|
<directory of powerlog.py>/sweetberry<timestemp>/summary.json
|
|
|
|
If --save_stats flag is not set, stats will not be saved.
|
|
|
|
--save_stats_json is designed for power_telemetry_logger for easy reading and
|
|
writing.
|