Commit Graph

346 Commits

Author SHA1 Message Date
Gwendal Grignou
4792db413f ectool: compile LPC and i2C support by default.
Currently, LPC or I2C are compiled based on the board.h.
This is not really necessary, code can handle both at the same time.
Note that LPC and I2C access mode are backup modes, the main mode is
dev (accessing ECs through /dev/cros_XX).

BRANCH=None
BUG=chromium:408713
TEST=Compile, tested on Ryu and Samus.

Change-Id: I8b4730f0f5708c543dc034165e9b53de0e543860
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227432
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-11-05 19:48:26 +00:00
Anton Staaf
8513e23df1 USB: Remove special case for iVersion string descriptor
Previously the version string was special cased in the USB stack
because the build system prevented the inclusion of ec_version.h in
any file other than common/version.c.  This lead to common/version.c
being the only place that the USB version string could be computed
and thus the special case of filling in the version string descriptor
at run time.  This made the USB stack more complex, and lead to the
common/version.c file including usb.h, which is actually STM32
specific.

Now, the portion of ec_version.h that is deterministic is only
updated when something in the tree actually changes (by way of a
conditional in the makefile), and ec_version.h no longer has to
depend on all object files (other than the special version.o).
This allows anyone to include ec_version.h as needed.  In particular,
each board that wants to define a USB version string can directly
include ec_version.h and do so.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j
     touch files and verify rebuilds happen correctly

Change-Id: Ic84d0b9da90f82ebb4630fb550ec841071e25a49
Reviewed-on: https://chromium-review.googlesource.com/227211
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-11-04 21:34:39 +00:00
Alec Berg
3a4f718f22 samus_pd: add dual-role port flag to power info host command
Add flag for whether or not device plugged into a given port is a
dual-role PD device. For now, the dual-role flag is always 0, but
need to add the flag to the host command now for compatibility
in the future.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=load onto samus, run ectool --name=cros_pd usbpdpower and
verify that for anything plugged in it says "dedicated charger"

Change-Id: I2d3c8c149802492f27a87a47aaa68fbf505ee7a9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226820
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2014-10-31 22:32:54 +00:00
Alec Berg
498abf833c samus_pd: add host command to get type-c port power info
Get type-c port power info including power role, charger type,
and charging info. Also added host command to get number of type-c
ports.

Also adds new charging suppliers for pericom identified chargers
including DCP, CDP, SDP, proprietary, and other chargers. Priority
of these for charging is set in samus board file.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=run 'ectool --name=cros_pd usbpdpower' and verify correct
status with minimuffin, zinger, and type-C to type-A adapter.

Change-Id: I1dabbe7de4185a23df5684a5ea9a2d944f1f6ff5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223523
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 04:31:34 +00:00
Gwendal Grignou
d5b32aa6e1 core: Add subcommands to MOTION_SENSE_CMD
These subcommands allow accessing sensor (accel+gyro)
over i2c.

BRANCH=ToT
BUG=chrome-os-partner:31071
TEST=Compile.

Change-Id: Ic6c3e9bf9c23f369de9f540c50daab7f2e4582ee
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225653
2014-10-29 22:23:49 +00:00
Katie Roberts-Hoffman
908b3f559b Add initial support for jerry
BUG=chrome-os-partner:33269
TEST=make BOARD=jerry; ./util/flash_ec BOARD=jerry
(on a pinky rev2 as a sanity)

Change-Id: I2c54e4044a65a0014adb32dd46f74bf5ed11b02d
Signed-off-by: Katie Roberts-Hoffman <katierh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225300
Reviewed-by: Alexandru Stan <amstan@chromium.org>
2014-10-25 08:14:16 +00:00
Vic Yang
d1ed75815e MKBP event signalling implementation
This implements a new API for EC modules to define MKBP event sources
and send MKBP event to the AP. Also, a new host command
EC_CMD_GET_NEXT_EVENT is added for the AP to query the pending MKBP
events. Each event type may have custom event data sent along with the
event.

BRANCH=None
BUG=chrome-os-partner:33194
TEST=Enable MKBP event on Ryu. Set a host event from EC console, run
'ectool nextevent', and see MKBP event 0x01 (HOST_EVENT) and the set
host event.

Signed-off-by: Vic Yang <victoryang@chromium.org>
Change-Id: I28a1b7e826bcc102bbe39016c9bb3e37d125664c
Reviewed-on: https://chromium-review.googlesource.com/224905
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-24 01:37:58 +00:00
Ken Chang
89a28fd464 flash_ec: Add support for kitty
Make board kitty to use flash_stm32.

BUG=chrome-os-partner:33035
BRANCH=None
TEST=Run util/flash_ec on kitty, verify flashing
complete successfully.

Change-Id: I302cfc85bfe5fa36fdf1a61d59b4dc21b36cc06a
Signed-off-by: Ken Chang <kenc@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/224231
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-23 09:06:12 +00:00
Vic Yang
00551f7331 Add new build target ryu_p2 for Ryu P2 boards
The new build target ryu_p2 is mostly based on ryu. On ryu_p2, we have a
new EC chip with bigger flash, so make the corresponding changes:
  - Pinout changes
  - HW Timer: TIM5
  - USB PD Tx Timer: TIM3_CH4
  - USB PD Rx Timer: TIM2_CH4
  - Use UART2 for EC console
  - Disable UART Tx DMA as it conflicts with USB PD Tx DMA
  - Use 24MHz HSE x2 = 48MHz for SYSCLK

BRANCH=None
BUG=chrome-os-partner:32660
TEST=Sanity check on a new board:
       - i2cscan
       - PD negotiation
       - UART console
       - gettime

Change-Id: I4ef6b53a928a2777721e3874032aeb0e6b2b4c92
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221404
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-22 00:30:42 +00:00
Bill Richardson
f36a859e06 samus: new algorithm for tmp006 object temperature
The original algorithm is given in the TMP006 User's Guide
(SBOU107.pdf). The algorithm we previously implemented is that,
plus some additional and completely undocumented massaging of the
Tdie and Vobj registers. The original meaning of that hack is now
lost in the mists of time, thanks to our email retention policy.

This CL introduces a new algorithm variant, but at least this
time the details are in the bug report. It's essentially the same
as the User's Guide algorithm, except that we apply one-stage FIR
filters to the Tdie input and the Tobj output.

There are five new parameters: d0, d1, ds, e0, e1. Refer to
tmp006_read_object_temp_k() in ec/driver/temp_sensor/tmp006.c to
see how these new parameters are applied.

CAUTION: The tmp006 sensor algorithm is mostly math and magic
numbers. The spreadsheet attached to the bug report has six
sheets with wildly varying values for those parameters. Since the
correct parameter values haven't yet been determined for Samus,
all I can be sure of with this CL is that it seems to work and
isn't any worse than the old one.

Oh, and note that the EC's 't6cal' console command has been
disabled until/unless we add support for floating point IO. Use
ectool from the host to get and set the params instead.

BUG=chrome-os-partner:32260
BRANCH=ToT,Samus
TEST=manual

After booting, look at the sensor values using ectool:

  localhost ~ # ectool temps all
  0: 312
  1: 314
  2: 313
  Sensor 3 not calibrated
  4: 311
  Sensor 5 not calibrated
  6: 305
  Sensor 7 not calibrated
  8: 306
  Sensor 9 not calibrated
  10: 307
  Sensor 11 not calibrated
  12: 312
  Sensor 13 not calibrated
  localhost ~ #
  localhost ~ # ectool tempsinfo all
  0: 0 PECI
  1: 1 ECInternal
  2: 1 I2C-Charger-Die
  3: 2 I2C-Charger-Object
  4: 1 I2C-CPU-Die
  5: 2 I2C-CPU-Object
  6: 1 I2C-Left C-Die
  7: 2 I2C-Left C-Object
  8: 1 I2C-Right C-Die
  9: 2 I2C-Right C-Object
  10: 1 I2C-Right D-Die
  11: 2 I2C-Right D-Object
  12: 1 I2C-Left D-Die
  13: 2 I2C-Left D-Object
  EC result 2 (ERROR)
  ...
  localhost ~ #

There are six tmp006 object temps that need calibrating. The
index used for the calibration is for the tmp006 objects, not the
3,5,7,.. numbers reported for all temp sensors. See the current
values with tmp006cal:

  localhost ~ # /tmp/ectool tmp006cal 5
  algorithm:  1
  params:
    s0  0.000000e+00
    a1  1.750000e-03
    a2  -1.678000e-05
    b0  -2.940000e-05
    b1  -5.700000e-07
    b2  4.630000e-09
    c2  1.340000e+01
    d0  2.000000e-01
    d1  8.000000e-01
    ds  1.480000e-04
    e0  1.000000e-01
    e1  9.000000e-01
  localhost ~ #

If the s0 param is zero, this sensor is uncalibrated. The params
are entered in the order in which they're displayed You can
change any or all of the parameters. Skip the ones you don't want
to update by specifying '-' for its position. (Note: throw in an
extra '--' first so that ectool doesn't think that negative
numbers are command options).

For example, to change s0 and b0:

  localhost ~ # ectool -- tmp006cal 5 1.0 - - -3.0
  localhost ~ #
  localhost ~ # ectool tmp006cal 5
  algorithm:  1
  params:
    s0  1.000000e+00
    a1  1.750000e-03
    a2  -1.678000e-05
    b0  -3.000000e+00
    b1  -5.700000e-07
    b2  4.630000e-09
    c2  1.340000e+01
    d0  2.000000e-01
    d1  8.000000e-01
    ds  1.480000e-04
    e0  1.000000e-01
    e1  9.000000e-01
  localhost ~ #

Now sensor 13 (tmp006 object index 5) is calibrated:

  localhost ~ # ectool temps all
  0: 310
  1: 315
  2: 313
  Sensor 3 not calibrated
  4: 310
  Sensor 5 not calibrated
  6: 305
  Sensor 7 not calibrated
  8: 307
  Sensor 9 not calibrated
  10: 307
  Sensor 11 not calibrated
  12: 312
  13: 313

Change-Id: I61b5da486f5e053a028c533ca9e00b9a82a91615
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/224409
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-22 00:30:31 +00:00
Vic Yang
d0d6befc3f Add stm32mon support for STM32F37xx
This is needed for the new Ryu boards.

BRANCH=none
BUG=chrome-os-partner:32660
TEST=Program STM32F373 chip.

Change-Id: Ib7a58826945090300b7e086e888c43c46fb499ab
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223893
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-21 00:44:29 +00:00
Eric Caruso
bcc5057ad3 lightbar: interpreter additions to encode other patterns
Makes a significant encoding change to existing opcodes and
adds several opcodes to allow for encoding the more complicated
patterns that we have on the lightbar (S0, etc.) as well as
condense the ones we technically could encode but couldn't
fit in the 192-byte footprint allotted to us (KONAMI).

We need this to remove sequences from the EC code.

BUG=chrome-os-partner:32203
BRANCH=ToT
TEST=run test programs on hardware and lightbar simulator

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Change-Id: I12fe908d3a43a924aa39f24ad66adbe53f7f38e1
Reviewed-on: https://chromium-review.googlesource.com/222949
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-15 18:22:37 +00:00
Bill Richardson
8fc80e86e4 lightbar: bring the TAP sequence in gradually
With only four LED segments, it's confusing to indicate a power
percentage by dimming the top segment unless you can see the
indicator smoothly ramping up from all-off. This does that.
Kind of pretty, if I say so myself.

BUG=chrome-os-partner:29041
BRANCH=ToT, Samus
TEST=make buildall

Run "ectool lightbar demo on", then press the T key to invoke the
pattern and the arrow keys to fake the charge state.

Change-Id: Ib6a56aea56078b8c1fc9edddda469d7f41735ff7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223300
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-15 18:22:33 +00:00
Shawn Nematbakhsh
e63ab6da20 ectool: flashpd: Reboot PD after successful RW flash
Reboot the PD device after a successful flash so that it will boot into
the new RW. This syncs the ectool PD update to the implementation in
flash_pd.py.

BUG=chrome-os-partner:31361
TEST="./ectool --name=cros_pd flashpd 0 1 ec.RW.bin", verify flashing
succeeds and PD is rebooted after flash.
BRANCH=samus

Change-Id: I14e7dffe59fcc7ca678c76890dbc825df5b19862
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223062
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-14 23:59:16 +00:00
Sameer Nanda
63c41f2392 temp_metrics: add "--" when invoking ectool tmp006cal
ectool has switched over to using getopt for command line options parsing.
This breaks temp_metrics' invocation of "ectool tmp006cal" command since
some of the coefficients are negative and therefore start with "-".
getopt treats that as another command line option causing ectool to
barf.

BUG=chromium:422160
TEST=On a Pixel issue "sudo start temp_metrics" and check
/var/log/messages to ensure that no new messages such as "init:
temp_metrics main process ended, respawning" show up.
BRANCH=none

Change-Id: I42232b3027ec6339814d226f1d8ab493e3420eea
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222845
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-11 02:22:53 +00:00
Eric Caruso
6713fa2d38 lightbar: Rename structs and macros for kernel cros_ec_commands
This prepends EC_ a macro exposed in ec_commands.h, moves a
macro into lbcc that is not used elsewhere, and changes lb_program
structs to lightbar_program.

BUG=None
BRANCH=ToT
TEST=make buildall -j

Change-Id: I481562da72d91f846c64cf9af40338027641462c
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222406
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-09 23:29:42 +00:00
Shawn Nematbakhsh
0938563284 zinger: Remove references to SHA1 hash
The PD protocol no longer uses a SHA1 RW hash. Instead, it uses the
first 20 bytes of the SHA-256 hash. Update constants and comments
accordingly.

BUG=chrome-os-partner:31361
TEST='make buildall -j'
BRANCH=samus

Change-Id: Ice74b841dbd1d81205c1ef0079a5e18fca2153b6
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222446
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-09 20:44:39 +00:00
Mohammed Habibulla
0fd73ae937 ectool: replace thermal_threshold_version with ec_cmd_version_supported
BUG=none
TEST='ectool thermalget' works as expected
BRANCH=none

Change-Id: Ie225ef0aaeae913162e8cd6c56193dedd9f56f2f
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221745
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-08 05:07:33 +00:00
Todd Broch
c1714dac12 dingdong: Initial board and USB PD support.
Allows dingdong to receive initial USB PD communication (source
capabilities payload) and with some manual manipulation (see 'TEST=')
drive DPout.

CL is based heavily off hoho dongle where all files were copied from
   board/hoho:
     7b1e58c ectool: Add host command support to set fan RPM for each
             fan separately

   Files gpio.inc, board.h & board.c were modified but others should
   be identical.

BRANCH=none
BUG=chrome-os-partner:31193
TEST=manual,

When attaching dingdong to samus_pd and configured via
  'pd dualrole source'

I see following on samus_pd console:
    C1 st9
    Switch to 5000 V 900 mA (for 900/900 mA)
    C1 st10
    C1 st11
    C1 st12

showing power constract and transition to SRC_RDY:
    > pd 1 state
    Port C1, Enabled - Role: SRC Polarity: CC1 State: SRC_READY

    > typec 1 dp

Also if I connect in CC1 configuration and get access to dingdong
console I can
   > gpioset PD_SBU_ENABLE 1

And see dingdong drive external monitor

Change-Id: I30ef6f8503a3fb015cfb8806bc36fb98f5150e40
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221913
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-08 05:07:29 +00:00
Alexandru M Stan
c5b30aa9f2 Renaming board veyron -> pinky
Seems that all previous boards used the subvariant specific name, and had an
alias from emerge-variant_subvariant to the ec subvariant folder.

BUG=chrome-os-partner:32331
BRANCH=None
TEST=cd board/pinky; make clean && make -j && ../../util/flash_ec --board=pinky

Change-Id: Ie6e0c977b6659687357a1b5aa2915cf0e40a5da7
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-10-08 02:51:13 +00:00
Mohammed Habibulla
72aee5c113 ectool: Fix help string for pwmsetfanrpm
BUG=none
TEST='ectool pwmsetfanrpm' prints correct help command
BRANCH=none

Change-Id: I6b1ecc7a581bb916563177f878f6361841e3ed90
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221957
2014-10-08 02:51:10 +00:00
Mohammed Habibulla
5c8da35f87 ectool: hostcmd support to set fans auto control individually
ectool autofanctrl 1 - set auto fan control for fan 1

BUG=chrome-os-partner:23803
TEST=Tested the above EC command on Auron
BRANCH=none

Change-Id: Idcd3690ad98d7965420f26f7cc445207fe73704d
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221816
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-07 20:58:33 +00:00
Vincent Palatin
c817472c07 Update Zinger flashing process
Convert the Zinger flash update commands to the new RSA signature
mechanism.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=from the workstation:
./util/flash_pd.py -m 1 build/zinger/ec.RW.bin
from Samus command-line :
ectool --name=cros_pd flashpd 0 1 ec.RW.bin

Change-Id: Ie8cd7f644ec94e461c5775a4dbbcd408782c72e1
Reviewed-on: https://chromium-review.googlesource.com/221560
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 03:37:48 +00:00
Mohammed Habibulla
876b0f0bdc ectool: Add hostcmd support to set fan duty cycle for each fan separately
ectool fanduty <percent>	- set all fans to <percent> duty cycle
ectool fanduty <fan> <percent>	- set <fan> to <percent> duty cycle

BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none

Change-Id: I06ca1552bd8f3412f6e90245da302c9f86ab6103
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221505
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-07 01:29:36 +00:00
Mohammed Habibulla
7b1e58cc43 ectool: Add host command support to set fan RPM for each fan separately
First case is for legacy support
ectool pwmsetfanrpm <targetrpm>		- set all fans to <targetrpm>
ectool pwmsetfanrpm <fan> <targetrpm>	- set <fan> to <targetrpm>

BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none
CQ-DEPEND=CL:220960

Change-Id: I8f447f53289abaa9c5cc1285f9f0921328fbf32c
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221291
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 22:27:03 +00:00
Mohammed Habibulla
75d7e31b9c ectool: add new host command to get number of fans
BUG=chrome-os-partner:23803
TEST="ectool pwmgetnumfans" returns correct number of fans on Auron
BRANCH=none

Change-Id: I2a1930a8f0965b08558bfb3c6424c571a6149bbb
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220960
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 22:26:52 +00:00
Mohammed Habibulla
938ba82bd7 ectool: Fix fanduty help
BUG=none
BRANCH=none
TEST=none

Change-Id: Iff09a24064d4245d2660dd307084cd701d03676b
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221202
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 04:30:01 +00:00
Vincent Palatin
beaddbf1a3 zinger: check RW firmware signature
The Zinger RW is now signed with 2048-bit RSA key (using SHA-256 as
digest).
This CL implements the verification mechanism.

note: the RSA key used for signing must be provided as a .pem file.
The path to .pem file must be provided in the PEM environment variable.
By default, it's using the dev key stored in zinger_dev_key.pem.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=on Zinger, run with properly signed RW firmware and corrupted
firmware and check the serial traces.

Change-Id: Ia58482458904a3ed72d6b0e95996cae86a0ead83
Reviewed-on: https://chromium-review.googlesource.com/220178
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-02 23:18:25 +00:00
Alec Berg
0330d9adf2 zinger: minimuffin: add board support for minimuffin
Minimuffin is identical to zinger, same MCU, same gpio, same
circuitry aroundt the MCU with two differences:
- Rated current is 2.25A instead of 3A
- USB PD hardware device ID needs to be different so that host
can differentiate between the two.

Due to the similarity between the two, minimuffin is defined
as a symlink to the zinger board.

BUG=none
BRANCH=samus
TEST=make BOARD=minimuffin
load onto a zinger and verify that samus reads device ID correctly
and limits input current limit to 2.25mA.

Change-Id: Ie39ec43262c7d14663eb68abff073bfeec451a24
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220689
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-02 20:51:10 +00:00
Vincent Palatin
1ec56e8546 stm32mon: add option to read firmware image from stdin
Add a command-line option to ask stm32mon to read the EC firmware image
to flash from the standard input when the filename is replaced by a "-".

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chromium:398165 chromium:396233
TEST=use the following flashing commands:
cat build/fruitpie/ec.bin | ./util/flash_ec --board=fruitpie --image=-
./util/flash_ec --board=fruitpie
./util/flash_ec --board=fruitpie --image=build/fruitpie/ec.RO.flat
and check the content of the flash.

Change-Id: I8039ecb6910f912161a7f59c5f5e2fc80447ce7b
Reviewed-on: https://chromium-review.googlesource.com/220842
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-02 07:02:54 +00:00
Eric Caruso
28891eaaab lightbar: treat HALT like a normal opcode
This removes the special casing around HALT. It saves us a string
literal and some logic. In total, we gain about 50 bytes and a
little cleanup for this.

BUG=None
BRANCH=ToT
TEST=Tried a program that uses HALT (i.e. red-green-blink) in
  simulator and on hardware.

Change-Id: Iffee1b559983fd1ecd385cc6b8967f72a6b968a0
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220589
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-01 01:47:39 +00:00
Bill Richardson
87762fa699 Add compiler/decompiler for lightbar bytecode programs.
BUG=none
BRANCH=ToT
TEST=manual

  make BOARD=samus
  for i in extra/lightbar/programs/[g-z]*.bin; do
    ./build/samus/util/lbcc -d $i /tmp/x.lbs
    ./build/samus/util/lbcc /tmp/x.lbs /tmp/x.bin
    cmp $i /tmp/x.bin
  done

Change-Id: I86c014c425e917ecafadd1c6845fcf2e5b4edbb7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220244
2014-09-30 01:53:53 +00:00
Eric Caruso
fb5ff7b1bb lightbar: add seq type PROGRAM for user-programmable sequences
This diff allows the user to send small programs to the EC and
gain control of the lightbar. Right now, this is only exposed
through ectool, and sysfs support will come later.

To send a program to the EC, use
$ ectool lightbar program /path/to/program.bin
and then start running the program with
$ ectool lightbar seq program

BUG=None
BRANCH=ToT
TEST=Using the above steps with hand-assembled programs.
  Checked that infinite bytecode loops do not hang the EC.
  Checked that bad opcodes exit with an error.
  Stress tested pushing programs and changing sequences.

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Change-Id: I635fb041a5dc5c403f7c26fb9a41b5563be9b6b7
Reviewed-on: https://chromium-review.googlesource.com/219558
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-25 07:59:16 +00:00
Puthikorn Voravootivat
be0bd9b835 ectool: Do not increase buffer size after probe max size from ec
During the communication init, ectool will probe max request and
response packet size from ec and set packet size accordind to that.
However, with older kernel's ec driver, the buffer allocated by
kernel is not large enough and this will cause kernel bug.

BUG=chrome-os-partner:31989
TEST=ectool version runs fine on blaze
BRANCH=ToT

Change-Id: I499a5305c8fa8b0fd6f3be8554c9cf066b7e0828
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219114
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
2014-09-23 00:05:03 +00:00
Todd Broch
3bfb7ee2a1 pd: make flash_pd.py forward compatible.
Older versions of flash VDM supported a 'rw_hash' command that has
since been deprecated in favor of 'info' command.  This CL makes
flash_pd.py try either in order to determine whether the pd flash
erase was successful.

BRANCH=none
BUG=chrome-os-partner:28330
TEST=manual, succesfully run on zinger with only 'info' command support
    util/flash_pd.py -m 1 zinger_ec.RW.flat
    2014-09-18 14:35:39,305 - root - INFO - Current PD FW version is zinger_v1.1.2192-5cd
    2014-09-18 14:35:39,305 - root - INFO - Flashing 11532 bytes
    2014-09-18 14:35:45,779 - root - INFO - Successfully erased flash.
    2014-09-18 14:35:45,890 - root - INFO - Chunk 0 of 481 done.
    ...
    2014-09-18 14:36:39,133 - root - INFO - Chunk 480 of 481 done.
    2014-09-18 14:36:46,072 - root - INFO - Flashing DONE.
    2014-09-18 14:36:46,072 - root - INFO - SHA-1: f6b296ba d474edc4 2e917ad0 33cd16cb 0f51a3fc
    2014-09-18 14:36:46,090 - root - INFO - New PD FW version is zinger_v1.1.2226-bea

Change-Id: I32f8b06fa546aa99c8290b6b73faa9b8df05e4fb
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/218878
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-22 21:15:41 +00:00
Gwendal Grignou
fab7ac3b9a ectool: add new parameter to identify proper EC.
Add parameter name to identify which EC to talk to.
Superseed --dev parameter, removed soon.

--name cros_ec (the default): send commands to /dev/cros_ec.
--name cros_pd: send commands to /dev/cros_pd.
...

BUG=chrome-os-partner:31513
TEST=Tested on samus:
check ectool --name cros_pd version returns proper data:
ectool --name=cros_pd version
RO version:    samus_pd_v1.1.2079-8e4f9fc-dirt
....

CQ-DEPEND=CL:217297
BRANCH=ToT

Change-Id: Ie8b5c6c184d73a89b4445e88d6f104169176b9f3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217311
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-14 09:52:11 +00:00
Todd Broch
f5b7b32423 samus: enhance usbpd host command to return port status.
CL provides some useful information similar to the EC console command
'pd state <port>' when host command 'usbpd <port>' is sent from host
with no additional arguments.

Also added a few build asserts for role & mux strings.

BRANCH=none
BUG=chrome-os-partner:31690
TEST=manual

  ectool --interface=lpc --dev=1 usbpd 1
  Port C1 is enabled. Role:SNK Polarity:CC1 State:6
  # has zinger attached
  ectool --interface=lpc --dev=1 usbpd 0
  Port C0 is enabled. Role:SNK Polarity:CC1 State:2

Change-Id: Id44eb7bf6a6fcfa888a0008a2249601967c50bcc
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217138
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-11 20:00:12 +00:00
Todd Broch
7698c323ea samus: Add host command to query USB type-C accessory attached.
PD accessories that are RW update-able will broadcast their rw_hash
SHA1 digest upon connection to the PD MCU which will store it.

For update purposes, the host needs that accessories device id and
rw_hash to determine its proper firmware update payload.

This CL creates a host command that requests the type-C accessory info
attached to a particular port.  It also implements an ectool command
to expose the host command.

BRANCH=none
BUG=chrome-os-partner:31361
TEST=manual,
  # connect zinger to port 1 on samus
  ectool --dev=1 --interface=lpc infopddev 1
  Port:0 Device:1 Hash:  0x7f4d7a13 0xf07b65b9 0x41181e10 0xb99b3d5f 0x9dee1206

  ectool --dev=1 --interface=lpc infopddev 0
  Port:0 has no valid device

Also do the same on port 0 with similar results.

Change-Id: Id63c7edad77a43d43c14d8cd6bd96e08d0d9b501
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216814
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-11 20:00:07 +00:00
Todd Broch
d9c6380a66 samus: Add host command to store USB PD device id & rw_hash entry.
PD accessories that are RW update-able will broadcast their rw_hash
SHA1 digest upon connection and remain in RO briefly for a response.

In order to speed-up the response and decouple common case of
accessory is up-to-date, the PD MCU will keep a small 4 entry table of
PD accessory device ids and their corresponding RW hashes for quick
lookup.

The AP will be the source of new updates and their corresponding
device id's and RW hashes and therefore needs a method to update the
PD MCU table.

This CL creates the table, host command & ectool command to facilitate
future driver / daemon to update the RW hash entries.

BRANCH=none
BUG=chrome-os-partner:31361
TEST=manual,

  # from AP
  for i in `seq 1 8` ; do
    ectool --dev=1 --interface=lpc rwhashpd $i $i $i $i $i $i
  done

  # from samus_pd console
  pd rwhash
  Device:5 Hash: 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005
  Device:6 Hash: 0x00000006 0x00000006 0x00000006 0x00000006 0x00000006
  Device:7 Hash: 0x00000007 0x00000007 0x00000007 0x00000007 0x00000007
  Device:8 Hash: 0x00000008 0x00000008 0x00000008 0x00000008 0x00000008

Change-Id: Ibe87b3594793cd5215eba42160489b26974aadbc
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/214366
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-11 19:59:59 +00:00
Alec Berg
b16cda06a8 plankton: add flag for prog_en to flash_ec
Add setting of new GPIO, prog_en, to flash_ec to be able to program
new plankton boards. This pin must be on for boot0 and nrst to be
connected from the FTDI to the MCU.

BUG=chrome-os-partner:31633
BRANCH=none
TEST=manual,

sudo servod -c plankton.xml
util/flash_ec --board=plankton

CQ-DEPEND=CL:216160

Change-Id: I29f882856e24147a7af283c5e82298c7736b8662
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216161
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-09-10 14:01:46 +00:00
Sheng-Liang Song
b550e7cbb4 EC: Add util for battery firmware update
Ref: Common Smart Battery System Inferface Specification v8.0.
Implemented smart battery firmware update util based the above spec.

BUG=chrome-os-partner:24741
CQ-DEPEND=CL:210032
CQ-DEPEND=CL:210033
CQ-DEPEND=CL:215720
BRANCH=ToT
TEST=Verified LGC & Simplo Battery Update on glimmer

Change-Id: Ia61a49f4643ea349d42a4b87d6010c1ac011729b
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205324
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-05 07:20:49 +00:00
Gwendal Grignou
41fdea92b5 stm32mon: add support for i2c transport.
BUG=chromium:405601
TEST=Able to read/erase/write flash on Ryu. Able to send go command.
BRANCH=ToT

Change-Id: I588cfee3dbbb3d8e3b66fe9d1044f3612f9b02c3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/214032
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-09-04 15:47:49 +00:00
Puthikorn Voravootivat
61f2327f07 ectool: read max outsize/insize from ec during comm_init
Current ectool uses max outsize / insize from protocol v2
even if we have a v3 protocol ec. This makes some command
not working when actual size supported by ec is less than
max size from protocol v2.

This CL uses protoinfo command to read max size from ec
during the initialization process to correctly set max size
for ec with protocol v3+. For ec with protocol v2, protoinfo
command won't exist, hence ectool won't modify the max size
and used the size that we set when init the protocol.

BRANCH=none
BUG=chrome-os-partner:31660
TEST=Run 'ectool flashread 0 0x1000 /tmp/fr' in ryu

Change-Id: I226b6c2fb2f7e9be73032f2c5146d2710939b293
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/214838
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-29 21:55:34 +00:00
Alec Berg
e913bc15b8 samus: add host commands for flashing zinger RW
This adds a new host commmand for sending RW updates to PD devices.
The host command has a variety of sub-commands for performing the
update, including: erase RW, reboot, write new hash, write flash.

To program zinger RW, you should send host commands in this order:
write new hash to all 0's
reboot (zinger boots into RO since RW hash doesn't match)
erase RW
write flash
write new hash to match contents of RW
reboot

This also adds an ectool command to write a new RW. Just pass it
the RW .flat or .bin file.

BUG=chrome-os-partner:31361
BRANCH=none
TEST=ectool --dev=1 --interface=lpc flashpd 0 0 zinger.RW.flat

Change-Id: Ia81615001b83ad7ee69b1af2bf1d7059177cde04
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213239
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-26 23:06:23 +00:00
Todd Broch
f8fbd1e440 flash_pd.py: Add retries for commands for collision resilience.
The original version of the script worked but as the USB PD protocol
SM has been enhanced to handle more complicated scenarios the
occurrence of collisions on the baseband comm has grown and script
needs to account for that.

Script now checks status of ACK from zinger 'DONE 0' and retries two
additional times for commands that failed.  If those three attempts
are unsuccessful script raises exception and quits.

Also added some more logging around retries and progress of chunk
writes.

BRANCH=none
BUG=chrome-os-partner:30135
TEST=manual, util/flash_pd.py build/zinger/ec.RW.flat succeeds in
programming zinger even in light of some retries.

Change-Id: Iaa8a22c2510ea5f4ebd92e1715be5fe062e13c61
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213131
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-20 21:07:26 +00:00
Mohammed Habibulla
df13541440 Auron: Initial EC commit
Clone of Peppy with only string changes

BUG=chrome-os-partner:31285
TEST=emerge-auron chromeos-ec
BRANCH=none

Change-Id: I1f7288e44cdc5ff1caa41de5ee299dbfa3411fa1
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212971
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-20 02:12:53 +00:00
Puthikorn Voravootivat
be060242e3 Fix ec detection for i2c protocol
ectool seems to looks at wrong location for ec.
This patch fix that

BRANCH=none
BUG=chromium:402581,chrome-os-partner:30707
TEST=ectool hello runs fine on ryu

Change-Id: I7b847b0eaf3fd39a8ba2948a87879b3f8223c582
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212483
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2014-08-18 23:16:32 +00:00
Todd Broch
e1ff1a3cae hoho: Initial board configuration.
Create necessary boiler plate files for USB type-C to HDMI dongle.

BRANCH=none
BUG=chrome-os-partner:31192
TEST=manual
1. Compiles & can program via fruitpie.
2. Can access uart (w/ rework for tx/rx).
3. Can drive HDMI capable monitor.

test details ...

Programming:
------------
   # connect fruitpie + fruitpie std-adapter(red) with u-USB (CN3) & type-A
   # (CN1) both to host that will run servod.
   FPIE_PORT=9993
   sudo servod -p 0x5009 --port $FPIE_PORT

   dut-control --port $FPIE_PORT "ec_uart_cmd:gpioset USB_C_5V_EN 1"
   dut-control --port $FPIE_PORT "ec_uart_cmd:usbmux usb"
   util/flash_ec --board=hoho

Configuring samus for DPout on both ports:
------------------------------------------

    sudo servod -b samus

    for port 0 1; do
        dut-control "usbpd_uart_cmd:pd ${PORT} dualrole off"
        dut-control "usbpd_uart_cmd:gpioset USB_C${PORT}_CHARGE_EN_L 1"
        dut-control "usbpd_uart_cmd:typec ${PORT} dp"
        dut-control "usbpd_uart_cmd:gpioset USB_C${PORT}_5V_EN 1"
        dut-control "usbpd_uart_cmd:typec ${PORT}"
    done
Change-Id: I39bbe1e347d1cfd777b68f3fdac6c5c6dd22800d
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212523
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-16 05:26:40 +00:00
Dominic Chen
67281b9807 flash_ec: add support for closed-case debugging
Passing the "--usb" argument will now utilized case-closed
debugging for flashing the EC. Currently this is only supported
for the samus LM4-based board.

BRANCH=none
BUG=none
TEST=verify that when the case-closed debugging flag is set, the
alternate openocd config file is used for samus, and an error is
thrown for all other boards

Change-Id: I0642bc2e9c2657cd8dbd83ee6e282365275d665a
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211744
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-15 21:07:35 +00:00
Dominic Chen
fd9eed96fd openocd: update configuration files
1. use ftdi interface driver instead of deprecated ft2232
2. remove custom target config and use upstream stellaris target
3. replaced deprecated servo_v2.cfg with servo_v2_slower.cfg
4. deprecated openocd.cfg

BUG=none
BRANCH=none
TEST=flash samus works
CQ-DEPEND=CL:210778

Change-Id: I572a717613eedc3afc44009a0f1aba1f1d36d7f7
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210920
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-08-15 21:07:31 +00:00