Commit Graph

138 Commits

Author SHA1 Message Date
Vadim Bendebury
84b20f9225 gsctool: add option to disable RMA mode
The --rma_auth command line option is being extended to treat the
auth_code of value of 'disable' as a user request to cancel CCD RMA
mode on the device.

BRANCH=none
BUG=b:68213540
TEST=verified that passing '-f disable' to gsctool causes CCD state on
     the Cr50 changed to 'Locked'

Change-Id: I8764e0207977a6290d3d10dc4678f98631be0360
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/784354
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-11-28 15:44:16 -08:00
Chun-Ta Lin
f326fb05b5 hammer: enable large block reading on usb i2c passthru.
Originally, i2c passthru is limited to use I2C_XFER_SINGLE flag where
it can only read at most 255 bytes at a time.  For application that
requires larger i2c bus reading, we change the flag setting and the
command protocol.

TEST=old ./touchpad_updater still works (previous protocol)
TEST=new ./touchpad_updater can get more than 500 bytes per transaction
TEST=Debug message only print when -d assigned.
     ./touchpad_updater -d
TEST=Manually change #define CONFIG_USB_I2C_MAX_READ_COUNT (1024 - 6)
     to #define CONFIG_USB_I2C_MAX_READ_COUNT (1024 - 4) and trigger
     POWER_OF_TWO assertion.
BRANCH=none
BUG=b:35587174, b:63993891

Change-Id: Id75b11ea49ba89bab8e18af24d47219030c778c5
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/542716
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-11-24 02:39:04 -08:00
Vadim Bendebury
88011d8ea5 gsctool: clean up error processing
The gsctool utility is inconsistent in using stdio channels when
reporting errors. All error messages should go into stderr.

Also, to avoid confusion, this patch makes options -s and -t mutually
exclusive.

BRANCH=none
BUG=b:68213540
TEST=verified that passing both -t and -s command line options causes
     an error.

Change-Id: Ieb50cf08314aa37594964ef4bbfa4a850741da2f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/784353
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-11-21 23:55:30 -08:00
Nick Sanders
26090a142b servo: add usb_console to chroot
add usb_console, console.py to chroot install.
This tool allows directly accessing the usb
console of servo v4, servo micro, cr50, etc.

BUG=b:69016431
BRANCH=None
TEST=usb_console -d 18d1:501b

Change-Id: If9d5d49cf31d785ea9a7cec0a4eeeb34abae9cd1
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/773400
2017-11-16 21:07:40 -08:00
Nick Sanders
5cee174602 servo_updater: allow differing console enpoints
servo_micro has the console on intf 3, while servo_v4
has it's console on intf 0. Abstract this into the
config file rather than hardcoding.

BUG=b:37513705
BRANCH=None
TEST=update servo_micro

Signed-off-by: Nick Sanders <nsanders@chromium.org>
Change-Id: I0090a0d081e001e62ffa7235eebbd6131ea00dcf
Reviewed-on: https://chromium-review.googlesource.com/769794
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-11-15 13:23:33 -08:00
Nicolas Boichat
54588e40a7 usb_updater2: Add support for touchpad debugging feature
Add support for touchpad debugging in usb_updater2, allowing an
arbitrary parameter to be passed.

BRANCH=none
BUG=b:63993891
TEST=./usb_updater2 -g 00 -d 18d1:502b

Change-Id: I1242e3bab9dc69ec3a92dd158c85606211e40f21
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/763575
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
2017-11-14 03:22:32 -08:00
Mengqi Guo
d51eb529b6 sweetberry: save to specified directory
This CL modifies the 2 flags --save_stats and --save_raw_data
so that they can take arguments to save the corresponding file
into directories that we specify. It also provides a new flag
--no_print_raw_data to suppress printing sweetberry readings in
real time.

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 ./xxx --save_raw_data ./xxx --no_print_raw_data

Change-Id: I01ebeafc5f4eebd0a77746e9968367f267e93d83
Signed-off-by: Mengqi Guo <mqg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/756255
Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2017-11-09 19:16:37 -08:00
Vadim Bendebury
a0f43d59d0 gsctool: provide an option to set/clear password
This patch makes use of a recently introduced vendor command for
password control.

The new option '-P,password' is introduced to allow the device user to
set/clear the CCD password. Command line echo is suppressed when
password is being entered, so it is required to enter it twice.

To stay consistent with the 'ccd' Cr50 console command conventions the
word 'clear' should be used as the password when one wants to clear
the CCD password. All policies for setting/clearing the password are
the same as when setting it from the Cr50 console.

BRANCH=cr50
BUG=b:62537474
TEST=set and clear password when accessing over /dev/tpm0. Verified
     that attempts to set/clear password over USB fail.

Change-Id: I7721d9ce12da8b7c89fc80eaa69cb8dd001abdb8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/741172
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-10-30 10:44:58 -07:00
Nick Sanders
28a5ad1646 servo: add usb updater
This updater combines console and firmware update commands to
update both RO and RW sections of servo_v4 and servo_micro.

BRANCH=None
BUG=b:37513705
TEST=updated firmware

Change-Id: I9f585c90f5849f8dd7c9d2e08111ffbd5770fd54
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/668156
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-10-25 01:38:45 -07:00
Vadim Bendebury
9f68af75f6 gsctool: allow to pass optional value for --rma
It would be much easier to use the --rma command line option if it
allowed to pass the authentication code in a separate invocation.

This patch changes the behavior of the --rma command line option and
improves the help message to match actual features of gsctool.

When passed without an extra parameter it requests the Cr50 to
generate the RMA authentication challenge, prints the challenge on the
console as before, and then exits instead of waiting for the user to
enter the authentication code.

When the extra parameter is given, it is considered the authentication
code received from the server, the code is passed to the Cr50 and the
response is reported to the user.

BRANCH=none
BUG=b:37952913
TEST=verified the expected behavior:

  localhost tmp # ./gsctool -r -t
  Challenge:
   CCYAQ 5ZUDP 9Q8NY S7TQR 7PVUR ETX7P T5YQK NGV9S
   7TY8Z QY7H5 5DEH3 5EEWY UBJPA WN7YX SE35G TPS76
  localhost tmp # ./gsctool -t -r EYE3E
  Processing response...
  rma unlock failed, code 1
  localhost tmp # echo $?
  3
  localhost tmp # ./gsctool -t -r EYE3EWQG
  Processing response...RMA unlock succeeded.
  localhost tmp # echo $?
  0
  localhost tmp #

Change-Id: I2c61ff3a3ef1718eb4f192321bebd8caba388aeb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/722115
2017-10-17 13:02:50 -07:00
Vadim Bendebury
e63e0515e4 gsctool: harden the APIs marking pointers const
This is just a tweak marking pointers to the vendor command payloads
as const, as the command payloads are not supposed to be modified by
the communication layers.

BRANCH=none
BUG=none
TEST=make buildall -j; make -c ./extra/usb_updater

Change-Id: I68f15e8c77dc892173ff0241072128d960712a80
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/722114
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2017-10-17 13:02:49 -07:00
Vadim Bendebury
a08f61506c g: rename usb_updater into gsctool
The usb_updater utility has long been not just an updater, and has
long been using other interfaces in addition to USB. gsctool is a much
more suitable name.

CQ-DEPEND=CL:709776
BRANCH=cr50
BUG=b:67007500

TEST=verified that make -C ./extra/usb_updater generates
     ./extra/usb_updater/gsctool:

  $ ./extra/usb_updater/gsctool --help

  Usage: gsctool [options] <binary image>

  This updates the Cr50 RW firmware over USB.
  The required argument is the full RO+RW image.

  Options:
  [...]
  $

Change-Id: I3ab70c28acf3664ddefaa923a87ba1fd5c3c437b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/709738
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-10-10 22:13:43 -07:00
Vadim Bendebury
81682e06bc gsctool: add RMA authentication option
This patch uses the VENDOR_CC_RMA_CHALLENGE_RESPONSE vendor command to
request the Cr50 generate the RMA authentication challenge and to have
the Cr50 verify the authentication code received from the server.

The new command line option is -r/--rma_auth. Presently it works only
when Cr50 is accessed over the TPM interface (as opposed to USB), i.e.
command line options -s or -t are also present, and the utility is
running on the Chrome OS device.

CQ-DEPEND=CL:690992
BRANCH=none
BUG=b:37952913
TEST=on a Bob device ran the command with correct and incorrect
     authentication codes, observed expected behavior (reported
     success or error):

  localhost ~ # /var/tmp/usb_updater  -t -r
  Challenge:
   B9FPX D93GM JTJE7 ZNR74 E2GZF 94E8B TXBFX UJ4WZ
   3ZQ98 XZ42D D4MVT RA2WG UDMKP A8FMH GXJQG BAKAS
  Now enter response: 7996N3NW
  RMA unlock succeeded.
  localhost ~ # /var/tmp/usb_updater  -t -r
  error 4                        <<=== this is the time throttle error
  localhost ~ # /var/tmp/usb_updater  -t -r
  Challenge:
   B9BLC F7B3D 7WY8V DKGQF 6CFP8 UCZRU UCZRW YKUG7
   ZGNVC F4ZEH X75LE BANWE UDMKP A8FMH GXJQG BAKAS
  Now enter response: 7996N3NW   <<==== this is an incorrect code

  rma unlock failed, code 6
  localhost ~ #

Change-Id: Ifbf1a349e3d2655cea6c33f928d9cf58a6408531
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/690443
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-10-03 14:26:12 -07:00
Vadim Bendebury
b097ecdcc5 cr50: enable rma_auth
Enable necessary flags for the Cr50 to start supporting RMA
authentication. This also requires that the RMA server public key
definition is split between the actual and test. Even though they are
the same at this time, the actual public key would be defined in the
new future and it would be different from the test key.

BRANCH=cr50
BUG=b:65253310
TEST=make buildall -j passes. More tests were conducted on the full
     patchset.

Change-Id: I5a3f9d8c71374d78192e3f0a2752391b842da962
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/691554
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-10-02 23:28:24 -07:00
Vadim Bendebury
97c2ae1138 gsctool: improve vendor command processing robustness
With upcoming RMA authentication extensions the size of the vendor
command responses is going to increase. Let's allow 500 bytes per
response (the expected maximum is 80 bytes plus TPM header).

BRANCH=cr50
BUG=b:37952913
TEST=verified that gsctool (aka usb_updater) still allows to retrieve
     Cr59 information and update Cr50 image.

Change-Id: Ic61b6b89ffe20e534029bd12fea4140882a9afc8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/690442
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-10-02 20:25:41 -07:00
Vadim Bendebury
474dbe4ded rma_reset: fix board ID ordering and add the missing break
The Board ID is stored in Cr50 in reversed byte order, make sure it is
used in the challenge calculation in the same form.

BRANCH=none
BUG=b:37952913
TEST=verified that the proper byte order is used when challenge source
     is created.

Change-Id: I6c6b46431005ce9438a4be9aa43aafed30a645aa
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/693615
Reviewed-by: Michael Tang <ntang@chromium.org>
2017-09-30 18:50:37 -07:00
Mengqi Guo
6f7d764e50 sweetberry: adding a flag to print milliwatts
Adding a flag to print power numbers in milliwatts instead of
microwatts, to be the same as servo ina board. This will make it
easier for power team to keep track of power numbers in the
future.

BRANCH=None
BUG=b:35578707
TEST=./powerlog.py -b xxx.board -c xxx.scenario --mW
python -m unittest -v stats_manager_unittest

Change-Id: I397da26561324227682404e62ee025384e7624eb
Signed-off-by: Mengqi Guo <mqg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/688743
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
2017-09-29 20:16:20 -07:00
Mengqi Guo
90d8e5460f sweetberry: calculate statistics for sweetberry readings
This CL provides the tool to calculate statistics for sweetberry
readings and present them in a clear & easy to read format. It
also provides the flag to store raw data and statistics
summary, should the need arise.
There are also some code cleanup for powerlog.py.

BRANCH=None
BUG=b:35578707
TEST=./powerlog.py -b xxx.board -c xxx.scenario --print_stats \
--save_stats --save_raw_data
python -m unittest -v stats_manager_unittest

Change-Id: I4aa732756fe6512f37acfcb59b11d950101887d7
Signed-off-by: Mengqi Guo <mqg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/667241
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2017-09-29 17:42:58 -07:00
Sam Hurst
579605f0af Update rma_reset command line interface.
Usage: rma_reset --key_id <arg> --board_id <arg> --device_id <arg>
                                   --hw_id <arg> | --auth_code <arg>

These value are used for generating the challenge response and all are
                                                              mandatory.
-k,--key_id         Index of the server private key
-b,--board_id     BoardID type field
-d,--device_id    Device-unique identifier
-w,--hw_id         Hardware id

The -t parameter, not listed, will use the default values to generate
                                                the challenge response

This value is the authorization code and any other parameters are ignored
-a,--auth_code    Reset authorization code

BUG=b:37952913
BRANCH=none
TEST=make buildall
Signed-off-by: Sam Hurst <shurst@chromium.org>

Change-Id: Idc916b123928328a3425fa4eee22afc2ec179fc1
Reviewed-on: https://chromium-review.googlesource.com/665388
Commit-Ready: Sam Hurst <shurst@google.com>
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Michael Tang <ntang@chromium.org>
2017-09-29 14:35:33 -07:00
Vadim Bendebury
18cbbffe32 rma_reset: hide generated files from git
This prevents the files from showing in 'git status' output.

BRANCH=none
BUG=none

TEST=verify that the running the following does not show any generated
     files:

  make -C extra/rma_reset; git status

Change-Id: Ib3ff7772cf4a66e4a0d23ed859c30ac05c2e507d
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/691016
Reviewed-by: Michael Tang <ntang@chromium.org>
2017-09-28 23:26:25 -07:00
Nick Sanders
55c90fe6fe tigertool: add serial number check
Add --check_serial to check serial number.

BRANCH=None
BUG=b:35849284
TEST=check serial number.

Change-Id: I1e2d5617bcf65e2388b88aca7ed63b9cdc096d87
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/676723
Reviewed-by: Wai-Hong Tam <waihong@google.com>
2017-09-28 20:51:01 -07:00
Vadim Bendebury
8c9f9ad861 usb_updater: allow to communicate with cr50 using trunks_send
It is necessary to be able to access Cr50 using usb_updater without
stopping trunksd services. This patch adds another option for
usb_updater to communicate with Cr50, using the trunks_send command.

A new command line option '-t' is added to allow to choose the new
interface.

When communicating over trunks_send the same processing is used as
when communicating over /dev/tpm0, just instead of talking to the
hardware device, popen() function is used to run trunks_send --raw
command and to gain access to its console output.

BRANCH=none
BUG=none
TEST=ran various commands using the new '-t' option:
  # ./usb_updater -t /opt/google/cr50/firmware/cr50.bin.prod
  read 524288(0x80000) bytes from /opt/google/cr50/firmware/cr50.bin.prod
  start
  target running protocol version 6
  keyids: RO 0xaa66150f, RW 0xb93d6539
  offsets: backup RO at 0x40000, backup RW at 0x4000
  sending 0x32288 bytes to 0x4000
  -------
  update complete
  reboot requested
  image updated

  [reboot...]

  # ./usb_updater -t -f
  start
  target running protocol version 6
  keyids: RO 0xaa66150f, RW 0xb93d6539
  offsets: backup RO at 0x40000, backup RW at 0x4000
  Current versions:
  RO 0.0.10
  RW 0.0.23

Change-Id: I9c7481c30c2f6908e0d1ac4f204654d2fd1b3b2e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/634629
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2017-09-07 12:56:30 -07:00
Nicolas Boichat
588320d4b8 stack_analyzer: Use board/$BOARD/analyzestack.yaml by default
BRANCH=none
BUG=chromium:648840
TEST=make BOARD=hammer analyzestack

Change-Id: Id05fee7e085a02dd4c2d36880f6891c3eb86b404
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/637550
Reviewed-by: Che-yu Wu <cheyuw@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-07 12:56:29 -07:00
Che-yu Wu
4a98e9c984 extra/stack_analyzer: Configurable exception frame size.
Make the size of extra stack needed by exceptions configurable.
It can be set in the annotation file.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: Idf2a59650dd20257a0291f89d788c0c83b91a7c9
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/649454
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-09-05 23:01:10 -07:00
Che-yu Wu
ce15362e89 extra/stack_analyzer: Support function sets in invalid paths.
There are lots of invalid paths have common segments.
In this patch, each vertex of an invalid path can be a function set.

Examples can be found in extra/stack_analyzer/example_annotation.yaml

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: Ib10d68edd04725af4d803f54f7e208e55d574c7d
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/649453
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-09-05 23:01:09 -07:00
Nicolas Boichat
1cb04976ba usb_updater2: Add support for trackpad update over USB updater
BRANCH=none
BUG=b:63993173
TEST=./usb_updater2 -p SA459C-1211_ForGoogleHammer_3.0.bin

Change-Id: I49fed10e408c7c8c63bea10109760fc0f02ab74c
Signed-off-by: Nicolas Boichat <drinkcat@google.com>
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/593374
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
2017-09-03 01:49:36 -07:00
Che-yu Wu
816a8d87cd extra/stack_analyzer: Support to remove invalid paths.
Invalid paths (with arbitrary length) can be annotated and removed.
Report set of possible function cycles.
Sort the callsite outputs by filename and line number.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         --export_taskinfo=./build/elm/util/export_taskinfo.so \
         --section=RW \
         --annotation=./extra/stack_analyzer/example_annotation.yaml \
         ./build/elm/RW/ec.RW.elf
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: I9d443df6439b55d5b92a7624bdd93cb6e18494e2
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/640393
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-09-01 00:44:32 -07:00
Nicolas Boichat
463aead11b usb_updater2: Add code to fetch touchpad information
BRANCH=none
BUG=b:63418037
TEST=./usb_updater2 -t

Change-Id: Ibed7cfc1d706f0f0ff8072f3ec08997f40a89038
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/593001
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
2017-08-31 04:52:20 -07:00
KT Liao
cde2cf1d11 Hammer : Add multi-ic support in touchpad_updater
Elan has shipped other AVL IC in Chromebook recently.
And it will support hammer project "charger"
Original code use constant definition for FW page count.
Unfortunatlly new IC's page count is different.
I add a code to judge IC first,
and then get the correct page count before FW updating

Signed-off-by: KT Liao <kt.liao@emc.com.tw>
BRANCH=none
BUG=None
TEST=Execute fw updating in hammer system

Change-Id: Ibdd9f7c0b61118950d8e751b7bbaaefeaaa3fb27
Reviewed-on: https://chromium-review.googlesource.com/620451
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: KT Liao <kt.liao@emc.com.tw>
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
2017-08-31 02:37:08 -07:00
Nicolas Boichat
2777b7771e presubmit_check: Check unittests results on extra/stack_analyzer
BRANCH=none
BUG=none
TEST=util/presubmit_check.sh

Change-Id: I6078377603719de1d633660c69ad3a40b29ffadf
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/640191
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Che-yu Wu <cheyuw@google.com>
2017-08-29 22:08:20 -07:00
Che-yu Wu
af32f8918e extra/stack_analyzer: Eliminate annotated indirect calls.
Indirect calls can be eliminated by adding corresponding annotations.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         --export_taskinfo=./build/elm/util/export_taskinfo.so \
         --section=RW \
         --annotation=./extra/stack_analyzer/example_annotation.yaml \
         ./build/elm/RW/ec.RW.elf
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: I18c317f9c6478b5b431ee04d882453791df27891
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/631082
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-29 04:45:51 -07:00
Nick Sanders
4fc9cf4c11 sweetberry: converter tool for servo_ina
convert_servo_ina.py can convert power log config
files from hdctools/servo/data into sweetberry configs

BRANCH=None
BUG=b:35578707
TEST=compare kevin_r0_loc.py output with kevin.board

Change-Id: Iadc57fe4eb1f5b220c6bffe3a3fe8a10b0d6b5a2
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/634486
2017-08-28 21:15:34 -07:00
Nick Sanders
c2d4746c37 tigertool: add power log and version
--power provides a single sample from the INA
--powerlog [n] provides n samples
--check_version returns the tigertail's firmware version
--bus selects which bus to probe power on [vbus|cc1|cc2]

BRANCH=None
BUG=b:35849284
TEST=check power readings, version.

Change-Id: I728d954b6649fe0401093bf3beb7ec89f27822a6
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/634566
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-25 21:52:51 -07:00
Che-yu Wu
4f21ee309c extra/stack_analyzer: Show indirect calls.
Show the indirect calls found in disassembly.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         --export_taskinfo=./build/elm/util/export_taskinfo.so \
         --section=RW \
         --annotation=./extra/stack_analyzer/example_annotation.yaml \
         ./build/elm/RW/ec.RW.elf
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: Ib82e68e0bc6c4be56ab679c297f256cbfe94bbb7
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/628048
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-24 01:25:51 -07:00
Che-yu Wu
eeeee803b7 extra/stack_analyzer: Show callsite information.
Show callsite details in the call trace.
Handle another addr2line failure output.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         --export_taskinfo=./build/elm/util/export_taskinfo.so \
         --section=RW \
         --annotation=./extra/stack_analyzer/example_annotation.yaml \
         ./build/elm/RW/ec.RW.elf
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: I3f36584af85f578f1d298bcd06622ba8e7e5262d
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/628000
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-23 23:13:38 -07:00
Nicolas Boichat
bee02b49b0 usb_updater2: Add support for INJECT_ENTROPY command
Necessary for pairing support. Cleaner implementation to be moved
to hammerd.

BRANCH=none
BUG=b:38487027
TEST=Flash hammer. On host, reboot hammer to RO:
     usb_updater2 -r; sleep 0.5; usb_updater2 -s
     usb_updater2 -e (adds entropy)
     EC console: check that rollbackinfo shows secret is updated

Change-Id: I7b354c7bb1b6d4260939dc33fe6cb4ab4ecd50e0
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/513809
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
2017-08-23 19:04:17 -07:00
Nick Sanders
493b974124 sweetberry: modify powerlog.py to support multiple devices
powerlog.py can now take -A serialA -B serialB to collect data
from both left and right sweetberries simultaneously.

Also, the Spower class has been modified to allow API usage
rather than console only usage.

BRANCH=None
BUG=chromium:608039
TEST=log from both sweetberries on marlin

Signed-off-by: Nick Sanders <nsanders@chromium.org>
Change-Id: Iaeaddad223f35f0e5cad1549b85fa3f7e4d5e1c7
Reviewed-on: https://chromium-review.googlesource.com/422496
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-22 21:34:43 -07:00
Sam Hurst
b59ba48d7e extra: Add Dummy RMA reset auth challenge-response application
Dummy RMA reset application that's used by the RMA Server
Side implementer. Currently everything is hard coded in the app.
This application will be replaced when the actual app is ready.

BUG=b:37952913
BRANCH=none
TEST=make buildall -j
     ./rma_test
     Board Id:
     Z Z C R

     Device Id:
     T H X 01 01 03 08 fe

     Server Key Id:
     10

     Server Private Key:
     47 3b a5 db c4 bb d6 77
     20 bd d8 bd c8 7a bb 07
     03 79 ba 7b 52 8c ec b3
     4d aa 69 f5 65 b4 31 ad

     Server Public Key:
     03 ae 2d 2c 06 23 e0 73
     0d d3 b7 92 ac 54 c5 fd
     7e 9c f0 a8 eb 7e 2a b5
     db f4 79 5f 8a 0f 28 3f

     Challenge:
     CC5QQ LALUS BUPJC TWSYN PAPPN AUEVZ HEMUD GD5DK
     DSM5C VH4SZ LJAZL GDUYM U4JPK FJUCA 2AEAS GCH8W

     Authorization Code:
     P5PSCTS6

     Challenge String:
https://www.google.com/chromeos/partner/console/cr50reset/request?challenge=CC5QQLALUSBUPJCTWSYNPAPPNAUEVZHEMUDGD5DKDSM5CVH4SZLJAZLGDUYMU4JPKFJUCA2AEASGCH8W&hwid=HWIDTEST2082

     Enter Authorization Code: abcd

     Code is invalid

     Enter Authorization Code: P5PSCTS6
     Code Accepted

Change-Id: Id4141861b53745cf7bb67a885fa01dd6f4b4cd04
Signed-off-by: Sam Hurst <shurst@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/622283
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Michael Tang <ntang@chromium.org>
2017-08-22 21:34:42 -07:00
Che-yu Wu
00e0222729 extra/stack_analyzer: Fix cbz/cbnz and addr2line parsing.
Fix the cbz/cbnz operands parsing.
Parse the discriminator output of addr2line.

BUG=none
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py

Change-Id: Iade1c14db0dc63fa65ef0f5df778b4f4f1e4f802
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/625498
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-22 05:08:48 -07:00
Che-yu Wu
ef09835e19 ec: Add annotation feature to the stack analyzer.
Get stack analyzer supported to read annotation file and do basic
annotation on the callgraph.

The basic annotation includes:
1. Add missing calls to the callgraph
2. Ignore functions on the callgraph

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         --export_taskinfo=./build/elm/util/export_taskinfo.so \
         --section=RW \
         --annotation=./extra/stack_analyzer/example_annotation.yaml \
         ./build/elm/RW/ec.RW.elf
     make BOARD=elm SECTION=RW \
         ANNOTATION=./extra/stack_analyzer/example_annotation.yaml \
         analyzestack

Change-Id: I4cc7c34f422655708a7312db3f6b4416e1af917f
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/614825
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-21 23:48:14 -07:00
Che-yu Wu
79e3b1c5e2 ec: Fix object comparison in the stack analyzer
Handle the case of comparing with different kinds of objects.

BUG=none
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py

Change-Id: I01056cd39e14d75442d4029b6c64d9843c49cf2a
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/616367
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-16 02:06:00 -07:00
Che-yu Wu
64ecddfd86 ec: Add a task information library for the stack analyzer.
Add a shared library to export task information.
Modified the stack analyzer to get information from the shared library.
Show allocated stack sizes of tasks in the stack analyzer.

To get the all task information (including the allocated stack size),
A shared library is added and compiled with the board to export all
configurations of the tasklist.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         --export_taskinfo=./build/elm/util/export_taskinfo.so \
         --section=RW \
         ./build/elm/RW/ec.RW.elf
     make BOARD=${BOARD} SECTION=${SECTION} analyzestack

Change-Id: I72f01424142bb0a99c6776a55735557308e2cab6
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/611693
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-15 00:25:20 -07:00
Che-yu Wu
1bf7abdc20 ec: Add analysis tool for firmware stack usage.
Add a static analysis tool for firmware stack usage.
Add an new Makefile rule to analyze the stack usages of firmwares.

Details about the tool can be found in extra/stack_analyzer/README.md.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && make BOARD=elm build/elm/RW/ec.RW.taskinfo && \
         extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         ./build/elm/RW/ec.RW.elf ./build/elm/RW/ec.RW.taskinfo
     make BOARD=${BOARD} SECTION=${SECTION} analyzestack

Change-Id: Ifb1b5f5ad6be8f8b125b14d6ee03e25cb385895b
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/576411
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-14 05:54:35 -07:00
Gwendal Grignou
734ebcbbb4 extra: usb_updater: include config.h
board.h and config-chip.h should only be called from config.h, otherwise
some #define may not be set properly.

BUG=chromium:746471
BRANCH=none
TEST=Found a bug while compiling OTP changes (c/580289/)
(https://luci-milo.appspot.com/buildbot/chromiumos.tryserver/
         no_vmtest_pre_cq/81548)
The size of the serial number string is set in config.h when
CONFIG_USB_SERIALNO is needed.
Compile with ec-utils with cr50_onboard USE flag set.

Change-Id: I5a2306bd0dc1dea29265226f2986829b768cfb61
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/581887
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-28 17:45:12 -07:00
Vadim Bendebury
a9c26a97ef usb_updater: fix transposed symbolic board ID representation
When usb_udpater reads board ID information from a binary blob, in
case the ID field can be represented as a 4 character ASCII string the
updater transposes the characters, resulting in a reversed string
printed.

Fix the transposition to verify that the result is printed properly.

BRANCH=none
BUG=b:63597142
TEST=ran the following commands:
  $ make BOARD=cr50
  $ CR50_BOARD_ID='TEST:ff00:ff00' H1_DEVIDS='0x0169c181 0x04656742' \
      ./util/signer/bs
  $  ./extra/usb_updater/usb_updater -b build/cr50/ec.bin
  read 524288(0x80000) bytes from build/cr50/ec.bin
  RO_A:4919.0.0 RW_A:0.0.21[TEST:0000ff00:0000ff00] RO_B:-1.-1.-1 ...

Change-Id: I852cf9505d6b8b9e7133ca1008be1b22081a9d88
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/567681
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-07-11 22:19:59 -07:00
Vadim Bendebury
f50e0086e6 usb_updater: display board ID information from RW headers
This patch adds code to interpret the contents of the Cr50 image's RW
headers board ID fields.

Board ID fields are added to the RW and RW_B version strings, as a
three field colon separated value.

The actual board ID is likely to be a 4 symbol ASCII string, if it
is, the 4 ASCII characters are displayed. If it is not - the 8
character hex value is printed. The rest of the fields are displayed
as 8 characters hex values.

BRANCH=none
BUG=b:62294740
TEST=tried the new option on various Cr50 images:
  $ ./extra/usb_updater/usb_updater -b build/cr50/ec.bin
  read 524288(0x80000) bytes from build/cr50/ec.bin
  RO_A:4919.0.0 RW_A:0.0.21[00000000:00000000:00000000] ...
  $ ./extra/usb_updater/usb_updater  -b cr50.bin.dev
  read 524288(0x80000) bytes from cr50.bin.dev
  RO_A:0.0.10 RW_A:0.0.21[XXXR:00000004:00000001]...

Change-Id: I5a92a600d24e4a7d6d615f256b5979414e883d77
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/562919
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-07-10 11:22:36 -07:00
Chun-Ta Lin
b3a7ede47d hammer: prepare and update the trackpad firmware
Implement the necessary bits for updating the trackpad firmware over
I2C, primarily following the protocol from open source driver.

BRANCH=none
BUG=b:35587174
TEST=Manually update firmware and confirmed reported FW version changed.

Change-Id: Ice5098269803f524de0b6a853f5a98f28382a7fb
Reviewed-on: https://chromium-review.googlesource.com/532765
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-22 03:34:50 -07:00
Vadim Bendebury
bdbb45b14a usb_updater: allow symbolic Board IDs
When specifying board ID to program, it is convenient to be able to
specify the ID as a string, as reported by the RLZ stored in the VPD.

With this patch the first component of the board_id command line
option is considered a string if it is no longer than 4 bytes.

BRANCH=cr50
BUG=b:35587387,b:35587053

TEST=ran the following commands (interleaved with erasing INFO1 on the
     target):

  localhost ~ # usb_updater -s -i
  Board ID space: ffffffff:ffffffff:ffffffff
  localhost ~ # usb_updater -s -i ABCD
  localhost ~ # usb_updater -s -i
  Board ID space: 41424344:bebdbcbb:0000ff00
  localhost ~ # usb_updater -s -i
  Board ID space: ffffffff:ffffffff:ffffffff
  localhost ~ # usb_updater -s -i 0x41424344:0x1234
  localhost ~ # usb_updater -s -i
  Board ID space: 41424344:bebdbcbb:00001234
  localhost ~ # usb_updater -s -i
  Board ID space: ffffffff:ffffffff:ffffffff
  localhost ~ # usb_updater -s -i ABCD:0x1234
  localhost ~ # usb_updater -s -i
  Board ID space: 41424344:bebdbcbb:00001234

Change-Id: Ied8b240d60ea50f6fc8633f919ce4bc81ac17727
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/528440
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-09 13:27:52 -07:00
Chun-Ta Lin
0b5e3aa642 hammer: initial commit for trackpad firmware updater
Tool to update the trackpad firmware over USB. Primarily borrowed from
extra/usb_console/usb_console.c

BRANCH=none
BUG=b:35587174
TEST=Manually executed with hammer

Change-Id: Icad951d2478a3e231f293e11fb461eaae20e5042
Reviewed-on: https://chromium-review.googlesource.com/525192
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-09 07:10:41 -07:00
Vadim Bendebury
25fb7bb3e5 Cr50: usb_updater: add commands to get/set board id
This patch enhances the Cr50 usb_updater to allow to get and set Board
ID value saved in the Cr50's INFO1 space using the earlier introduced
dedicated vendor commands.

Getting or Setting the board ID does not require establishing a
connection with the Cr50, the new option is --board_id/-i. When
specified without a parameter, the new option will cause the Board ID
to be read. When specified with a parameter, the board ID value will
be set. The parameter includes one or two values in a single string,
the values separated by a colon.

The first value is a 4 byte board ID, and the second value is the
flags field. The default flags field is set to 0xff00.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=verified that it is possible to get and set the board ID value
      using usb_updater, both over USB and TPM.

      verified that it is not possible to set a new board ID value is
      the INFO1 space has been already programmed.

      verified that it is not possible to set a board ID value which
      would not allow the currently running image to start (even
      though there is no run time check yet).

Change-Id: Ief175d8b2ef3177db13fa86f831914088d9447b0
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525096
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-07 03:02:55 -07:00