Commit Graph

425 Commits

Author SHA1 Message Date
Gwendal Grignou
c70fb0f9eb motion: Add MOTIONSENSE_CMD_DATA: retrieve single sensor data
MOTIONSENSE_CMD_DATA return the value of a sinlge sensor.

BRANCH=none
BUG=chrome-os-partner:39900
TEST=On Smaug, using the new cros-ec-sensors driver,
check sensors data using iio sysfs interface.

Change-Id: I618ff050e0c7b4247ac56cfb0ca25e351270e1d6
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274824
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-03 19:46:19 +00:00
Sheng-Liang Song
7a54beba50 sb_firmware: fixed the last write delays
BUG=chrome-os-partner:40569
BRANCH=none
TEST=Begin
1. Install noraml linux images
2. Connected Battery which is having old firmware(100)
3. power on DUT and goto crosh (In normal mode)
4. run "battery_firmware update "
5. Remove AC to interrupt the update
6. Power OFF and power on the DUT again
7. Now seen critical firmware update screen.
8. Reboot around 4 min.
9. See login window.
End

Change-Id: I2090cfa9200a7402a5fba2e111073dd1d7e7b422
Signed-off-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273660
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-30 02:11:11 +00:00
Gwendal Grignou
c89ebdb66c ectool: query packet size and set them properly internally.
Allow to negotiate the packet command and responses to
whatever values the EC can support.
Set the buffer size including the necessary V3 header.

If the EC run v3 protocol with large packet support, but the kernel
does not have v3 support (3.10), we can not support sending or
receiving large commands.
Be aware that on 3.10, commands like ectool console will fail if
the EC wants to send command larger than the kernel can handle.

Copied kernel_version_ge from libusb-1.0.19/libusb/os/linux_usbfs.c.

BUG=chrome-os-partner:31989,chrome-os-partner:31660,chromium:454324,chrome-os-partner:39265
BRANCH=none
TEST=Build a special firmware to exchange 300 bytes.
Check ectool console works with the righ size.
Check that ectool is calling uname.
Check on Nyan_big: without change, "ectool version" crashes kernel. With
changes, "ectool version" works.

In conseuqence, it reverts commit be0bd9b835,
"ectool: Do not increase buffer size after probe max size from ec"

Change-Id: I54ffd43488ea81272f30789dc87a261085769fe0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274086
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-30 01:04:29 +00:00
Shawn Nematbakhsh
e216906c93 flash_ec: Add support for glados and glados_pd
BUG=None
BRANCH=None
TEST=`flash_ec --board=glados`

Change-Id: I8a23cbd0324d9a321a07bdfd182c996efac79f4c
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273359
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-05-27 03:58:11 +00:00
Yunlian Jiang
a6d1e65cdf ec: fix -Wuninitialized warning.
BUG=chromium:488540
Signed-off-by: yunlian@chromium.org
BRANCH=none
TEST=FEATURES="test" CC=x86_64-cros-linux-gnu-clang
     CXX=x86_64-cros-linux-gnu-clang++ emerge-falco chromeos-ec

Change-Id: If70f7de921a2e973c093a92f03fa0f1603ee0b08
Reviewed-on: https://chromium-review.googlesource.com/271476
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Commit-Queue: Sheng-liang Song <ssl@chromium.org>
Tested-by: Sheng-liang Song <ssl@chromium.org>
2015-05-15 20:41:57 +00:00
Rong Chang
91b9c336ee oak: Add oak EC and PD flash_ec support
flash_ec script supports stm32 ec and usbpd. This change adds new board
name and MCU map.

BUG=none
TEST=manual
  flash_ec --board oak --image ec.bin
  flash_ec --board oak_pd --image pd.bin

Change-Id: I51a4a22b5188dda35d7b8c34a0115997f374f413
Reviewed-on: https://chromium-review.googlesource.com/267042
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Queue: Rong Chang <rongchang@chromium.org>
2015-05-15 10:32:40 +00:00
Sheng-Liang Song
6cd67659db sb_firmware: Fixed firmware version check
Added firmware version check to handle the following cases:
   - when the data table version is the same and fw version is newer
   or
   - when the fw version is the same and data table version is newer.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: If3d28f6ae7a89fc7c41fd60214ab3616f1abfe5a
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270387
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 15:42:35 +00:00
Sheng-Liang Song
764c3fa790 sb_firmware: enable retry for status.fw_update_supported
Added retry logic when see fw_update_supported=0.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I441c9763df9b1e91b3de08d2f30ecfa49c59f677
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270179
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 15:42:30 +00:00
Sheng-Liang Song
be99fa290e sb_firmware: Enable Updates for Simplo Battery Only.
If can get battery info, enable updates if it is Simplo Battery.
If can not get battery info, assume a Simplo Battery is a bad state.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I0db6b50b5a382b72fd9682621990d0a6dd9e6a2b
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/266044
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 07:52:45 +00:00
Sheng-Liang Song
58382b98f2 sb_firmware: Use new delay values suggested by Simplo & TI.
Used fixed delay values suggested by Simplo & TI.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: Ibc2d135cfd5e4c01fce0f8fcc56f5f850fab3c16
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265754
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 07:52:38 +00:00
Sheng-Liang Song
b09bfe5946 sb_firmware: check if last full charge is zero
Detect if the last full charge is zero or not.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I078b860acc96f60830c82af8f85cfb98e27095cb
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/263156
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 06:48:37 +00:00
Vincent Palatin
decd6a545f add hash for locally emerged builds
When the EC is built using "emerge-<board> chromeos-ec" on a developer
workstation with the chromeos-ec package "cros-worked'on", put
"1.1.9999-<git-sha1>" rather than "no_version" in the version string.

Emerge is exporting the current git SHA-1 hash in the VCSID id but the
.git repository is not available during the build.

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

BRANCH=none
BUG=none
TEST=try the following build setups:
- local emerge
$ emerge-smaug chromeos-ec
$ strings /build/smaug/firmware/ec.bin | grep ryu
ryu_p4p5_1.1.9999-ebe18ef
- local build
$ make BOARD=ryu_p4p5
$ strings build/ryu_p4p5/ec.bin | grep ryu
ryu_p4p5_v1.1.3127-ebe18ef-dirt
- trybot build
$ cbuildbot --remote -g 270554 smaug-firmware
$ tar xvjf firmware_from_sources.tar.bz2
$ strings ec.bin | grep ryu
ryu_p4p5_v1.1.3137-9b52578

Change-Id: I386f80d82d95b5e99a1660a1eb242c47c54d17ef
Reviewed-on: https://chromium-review.googlesource.com/270554
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-13 22:23:06 +00:00
Gwendal Grignou
17487510e3 ec: Add Inventory command
Add command that list supported features by the firmware.
Also let the firmware indicates if more features are expected in the RW
version.

This will help the cros_ec framework load the right driver(s) for
exposing information via sysfs.

BUG=chromium:428364
BRANCH=none
TEST=Test on samus on both ec and pd:
localhost ~ # ectool inventory
EC supported features:
1   : Flash support
2   : Direct Fan power management support
3   : Keyboard backlight support
4   : Lightbar support
6   : Motion Sensors support
7   : Keyboard support
9   : BIOS Port 80h access support
10  : Thermal management support
11  : Switch backlight on/off support
12  : Switch wifi on/off support
13  : Host event support
14  : GPIO support
15  : I2C master support
16  : Charger support
17  : Simple Battery support
18  : Smart Battery support
21  : Control downstream MCU support
localhost ~ # ectool --name cros_pd inventory
EC supported features:
1   : Flash support
14  : GPIO support
15  : I2C master support
22  : USB Cros Power Delievery support

Change-Id: Ib6eaac91fda86835e754c5316ecf81fbc27786e5
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/263463
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2015-05-07 22:25:25 +00:00
Vincent Palatin
13b555dc63 ryu: fork P4/P5 support
In preparation for Proto 6 board support which won't be backward
compatible, fork the EC for Proto 4 and Proto 5 for people who need to
support older boards.

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

BRANCH=none
BUG=chrome-os-partner:39202
TEST=make buildall

Change-Id: I520bbf146cc1c1dc04e55283be57807ec19ebaa1
Reviewed-on: https://chromium-review.googlesource.com/266064
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-02 16:49:05 +00:00
Alec Berg
6dce2424d9 charge_manager: modify PD power HC to give more info on current
Change the EC_CMD_USB_PD_POWER_INFO host command to report the input
current limit and the max current theoretically possible given the
charger. The input current limit field is useful for logging purposes
and the max current field is useful to give to powerd to determine
if we have a low power charger connected.

The max current is determined by checking if the charge supplier is
allowed to ramp. If the charge supplier is allowed to ramp and has
not completed ramping yet, then max current is the max current that
we are allowed to ramp up to. Once the ramp has completed, then max
current is the stable charging current. If the charge supplier is not
allowed to ramp, then max current is simply the max current as
registered with charge_manager. The point here is to keep the max as
high as possible until we know for sure it is lower to avoid showing
the user the low power notification until we know for sure.

This CL also adds a new charger type, USB_CHG_TYPE_UNKNOWN. For a short
period after a charger is plugged in, the supplier type may change and
PD negotiation is still in process, and therefore we tell the host we
have an unknown charger type. This allows powerd to show the charging
icon, but delay determining if this is a low power charger until we
know for sure.

BUG=chrome-os-partner:38548
BRANCH=samus
TEST=tested with zinger, a DCP, an SDP, and a proprietary charger.
tested that low power notification never pops up with zinger, even
if you purposely wedge charge circuit with "charger voltage 7000" on
EC console. tested that the other chargers all pop up low power
notification once the supplier changes from UNKNOWN to the real
supplier. used "ectool --name=cros_pd usbpdpower" to check current
values.

Change-Id: If8a9a1799504cc2a13238f4e6ec917d25d972b22
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265066
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2015-05-01 03:44:19 +00:00
Rong Chang
08013b206b stm32mon: add STM32F09X chip id
Adds the support of STM32F09X with 256KB flash.

BUG=none
Test=manual
    Check stm32mon ChipID output:
      ChipID 0x442 : STM32F09x
      Bootloader v3.1, commands : 00 01 02 11 21 31 44 63 73 82 92
      Flash read unprotected.
      Waiting for the monitor startup ...Done.
      Flash write unprotected.
      Waiting for the monitor startup ...Done.
      Flash erased.
      Writing 262144 bytes at 0x08000000

Change-Id: Ied967716750820a335011f244aae5885c507360a
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/266972
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-04-24 05:07:45 +00:00
Divya Jyothi
9aea3710b2 mec1322: lfw loader + RO/RW architecture
mec1322 only has 96KB program memory, vs 256KB
flash space on lm4.We no longer have enough program
memory to load both RO and RW at boot. We'll want to
implement a small loader program that will load either
RO or RW from flash, and then jump to the loaded image.

CONFIG_FW_INCLUDE_RO is enabled to include RO image into
the build.

pack.py script is altered to load the (lfw + R)O on boot.

Software sync is not added.Distinguish between
RO/RW is yet to be added.

flash_ec is altered to support padding 0xFFs to 256k ec.bin
to match the size of the SPI flash of the board.

BUG=chromium:37510
BRANCH=None
TEST=Make -j buildall,Verified ec.bin to be 256k.
Verified RW image at offset 0h and (lfw + RO) at offset 2000h.
On boot sysjump to lfw. lfw checks in shared SRAM (currently RO)
and jumps to RO image.

Change-Id: Ib9b114e2f24a615d5e5bd8b3803be621d1e5bd17
Signed-off-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265807
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Icarus W Sparry <icarus.w.sparry@intel.com>
2015-04-23 07:04:41 +00:00
Yunlian Jiang
e4f8b16a62 ec: fix a clang warning by use a unused variable.
This uses the variable 'usage' in an error message to fix a clang
warning.

BUG=chromium:475960
TEST=CC=x86_64-cros-linux-gnu-clang emerge-falco ec-devutils
BRANCH=none
Signed-off-by: yunlian@chromium.org

Change-Id: Ic5703636040805661c7b81b83fc182e127ceab8c
Reviewed-on: https://chromium-review.googlesource.com/266404
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
2015-04-20 23:02:02 +00:00
Yunlian Jiang
908c93bf00 ec: fix duplicate 'const' warning for clang..
It fixes duplicate 'const' warning.

BUG=chromium:475960
TEST=the warning is gone.
BRANCH=none
Signed-off-by: yunlian@chromium.org

Change-Id: I348fbefec4d681bb8b20c6b8cf84acec4561b391
Reviewed-on: https://chromium-review.googlesource.com/266109
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
2015-04-18 00:13:20 +00:00
Vincent Palatin
0df89000a5 pd: add a connection flag to pd port info for host
Export what the PD protocol stack thinks about the port connection
state. This simplifies getting a meaningful data role/power role from the
host (eg we are not really a UFP if we are simply dual-role toggling but
not connected).

Do not increment the command version as this is mostly
backward-compatible and currently no client actually uses that field.

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

BRANCH=samus
BUG=none
TEST=ectool --name=cros_pd usbpd 0
plug and unplug various accessories on the port and check the result.

Change-Id: Ief3e0d47b6a288bcfc5b8fbb8156f29fd09dd336
Reviewed-on: https://chromium-review.googlesource.com/266120
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-17 19:38:11 +00:00
Mike Frysinger
f55a7e5774 clean up x86 i/o checks
Rather than hardcode a specific mips toolchain, do a build-time test to
see if the target is x86 based.

BUG=chromium:443783
TEST=link still includes comm-lpc
TEST=arm64 omits comm-lpc
BRANCH=none

Change-Id: I0253df6cbe89bee231ec643dd6bb3498eb040708
Reviewed-on: https://chromium-review.googlesource.com/265793
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2015-04-17 01:47:34 +00:00
Vincent Palatin
72ca4cc9f9 util: workaround warm_reset issue in flash_ec
The warm_reset_l signal is an open drain output on the servo side and
its input value can be read back as on (level 0) when the AP power rails
are off on the DUT side and not pulling it up.

So the current mechanism of reading the warm_reset input value with
dut-control at the beginning, then restoring it at the end is sometimes
broken because when the AP is OFF, we are reading input == on (while we
had actually set output to "off" but we have no pull-up) and then
restoring a "hard" on (drive low on the servo side).

In this workaround, just assume we don't want to pull warm_reset after
flashing the EC and restore it to off.
A better solution might be to have a mechanism in dut-control to read
the output register rather than the input value for GPIO, so we can save
and restore them safely.

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

BRANCH=none
BUG=chrome-os-partner:30738
TEST=On Ryu P5 with the AP off, run ./util/flash_ec --board=ryu
then boot the AP properly with the power button.

Change-Id: I96e65c2fec5e6d604445af3fe26fce73678b1d3b
Reviewed-on: https://chromium-review.googlesource.com/265223
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-04-11 00:36:08 +00:00
Shawn Nematbakhsh
2e19bcb0cf util: Remove mec1322 comm driver
The mec1322 LPC / EMI comm driver is no longer functional due to recent
EC changes. Rather than re-implementing a working driver across user
space tools, the plan of action is to use the kernel device driver
(through comm-dev) for all access.

BUG=chrome-os-partner:38103
TEST=Manual on glower with pending kernel cros_ec_lpc changes. Verify
"ectool version" and "ectool gpioget" succeed.
BRANCH=None

Change-Id: I770cb06ca534a7c31794e6b37c226e952361ee32
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265031
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-10 18:48:39 +00:00
Bill Richardson
b4496c4443 Use futility to sign the USB-PD chargers
This replaces a special-purpose python script with futility, to
sign the firmware for those boards that require a signed RW image
instead of using software sync.

Currently, the only boards that do that use a signature scheme
that is somewhat opaque (refer to commit b5a439241f in the
vboot_reference repo for details). Futility calls that scheme
"--type usbpd1".

BUG=chromium:231574
BRANCH=ToT
CQ-DEPEND=CL:*212135
TEST=manual

To test, I obtained a reworked zinger that could be connected to
servo. I first flashed it with a dev-key-signed RO+RW image built
prior to this CL, then I applied this change, built a new image
(with a minor change to the startup message), and updated only
the RW half from Samus using

  ectool --name=cros_pd flashpd 0 1 /mnt/stateful_partition/ec.RW.bin

Watching the zinger console when plugging and unplugging, I
confirmed that the RO firmware was still the original and the
verified-by-RO RW firmware was the new version.

Note: I also had to build a custom AP kernel without the cros_pd
driver, to prevent interference with the manual update.

Change-Id: I22d8e75c85dab7701af8fe98287f14ebe77dbbd4
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264508
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2015-04-08 19:12:03 +00:00
Aseda Aboagye
3282296f2b ec: Created lightbar params v2
The 'lightbar params' v1 command has a parameter list that exceeds 120 bytes,
which will not work over i2c. Therefore, I created a params v2 command which
breaks up the existing parameters into logical groups which are less than 120
bytes.

TEST=Tested new lightbar params2 command and ran get/sets on all groups for
samus. Repeated test on ryu as well.
BUG=chromium:467716
BRANCH=none

Change-Id: If0fa92e9a2f373b20257f8ce7eb66b7836d9ac60
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/263106
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-31 23:00:33 +00:00
Gwendal Grignou
fe293908ed ectool: Revert: Do not increase buffer size after probe max size from ec
Not needed with kernel fix:
Commands are currenly limited to 252 bytes. Even if EC support protocol
v3, ectool would only limit the command sizes, never go beyond 252
bytes.

This reverts commit be0bd9b835.
It also remove a TODO.

CQ-DEPEND=CL:262870
TEST=With proper kernel, and firmware supporting commands > 252 bytes,
check that ectool console does not crash anymore.
/usr/sbin/ectool --name cros_sh console
returns more character than before.
Check ectool version as well.
/usr/sbin/ectool --name cros_sh version
BUG=chromium:399057,chromium:454324,chrome-os-partner:31989,chrome-os-partner:23823
BRANCH=none

Change-Id: I058ab0e6df96196a0fae186d1ffedcfa16e5dc3b
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262885
Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
2015-03-28 00:58:06 +00:00
Sheng-Liang Song
bf931b2cce sb_firmware: update arguments and configs
- Updated arguments to support two sub commands:
   - check: check if AC adapter is connect.
   - update: trigger battery firmware update.

- All Delay values are from .cfg file.

BUG=chrome-os-partner:36310
BRANCH=none
CQ-DEPEND=CL:260868
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I7324e1f329383cf5ee62660f4ac4cb0b1c30c056
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/260210
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-03-27 05:24:39 +00:00
Sheng-Liang Song
be42949a4f sb_firmware: write PID to lockfile for powerd
Add logic to write PID to /var/lock/battery_tool_powerd.lock
while performing destructive battery firmware update actions.

BUG=chrome-os-partner:36310
BRANCH=none
CQ-DEPEND=CL:261318
TEST=Verified on glimmer.

Change-Id: I47f34a3a2cb890e66591ef16ac5cf7186d662900
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/260868
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-03-27 05:24:34 +00:00
Shawn Nematbakhsh
911da8c150 ectool: Always try v0 of GET_VERSIONS command if v1 fails
The ioctl return status for CROS_EC_DEV_IOCXCMD is inconsistent across
kernel versions:

- In 3.8 kernel, on INVALID_VERSION EC result, -EBADMSG is returned
- In 3.14 kernel, on INVALID_VERSION EC result, success status is
  returned

In both cases, the INVALID_VERSION result is written to the
cros_ec_command.result parameter.

The inconsistency here should be fixed with kernel patches. In any case,
there is little harm with trying v0 of GET_VERSIONS on any failure of the v1
command.

BUG=chrome-os-partner:37668,chromium:466896
TEST=Manual on peppy. Verify 'ectool thermalget 0 0' prints threshold info.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic1eb3f8f2fa95711ec15a5afb740af8f18b88b55
Reviewed-on: https://chromium-review.googlesource.com/260004
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Bill Richardson <wfrichar@chromium.org>
Trybot-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-14 00:45:41 +00:00
Scott Collyer
23716f05aa honeybuns: Initial /board files
Modified version of /board/fruitpie.
Attempted to capture GPIO definitions. Other changes
consisted of modifying functions to enable compilation.
No real functionality as of yet.

TEST=Serial console and I2C functions have been verified
BUG=chrome-os-partner:37078
BRANCH=samus

Change-Id: Iedfc724a058e4220176193ef0f66e5bf45eabbd9
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/252426
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-03-12 03:42:12 +00:00
Bernie Thompson
e93d91558f flash_ec: add support for strago and cyan
BUG=None
BRANCH=None
TEST=`flash_ec --board=strago --image /ec.bin`
`flash_ec --board=cyan --image /ec.bin`
Verify flashing success.

Change-Id: I10b93f5e646687ac1f299b12ff5a91aedfdd3d75
Signed-off-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/255950
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-03-06 08:49:07 +00:00
Sheng-Liang Song
07b4158649 sb_firmware: shorter console messages
Reduced console log messages

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Compile Only

Change-Id: I0e30a3094d77673a5fd238efed3851a726fdcdb6
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/254931
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Bernie Thompson <bhthompson@chromium.org>
2015-03-02 21:37:17 +00:00
Sheng-Liang Song
51910da94c sb_firmware: clean up sb firmware update program
- battery firmware filename need match with gs:// filename
   - changed from "%04X" to "%04x"
   - A fix for LGC battery firmware update.

- Add control flags:
	F_AC_PRESENT - 1 iff AC is connected.
	F_VERSION_CHECK - 1 if do version check
             - option to disk version check for stress test.

- Add detail log messages

- Remove old debug flag.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=run ec_sb_firmware_update on glimmer

Change-Id: Iebc15222a7a55a786291ce2d8931e70acc5b3c4d
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/253970
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-28 03:46:42 +00:00
Shawn Nematbakhsh
c7bc5965fa charge_manager: Classify VBUS supplier type
Add a new supplier type for VBUS chargers (USB chargers which supply VBUS
but are not identified as another charger type).

BUG=chrome-os-partner:37168
TEST=Manual on Samus with subsequent kernel commit. Modify code to
reject all non-VBUS suppliers, charge with SDP port, and verify charge
icon appears in OS.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I5fbdb1cb57bd0224b01aaf5a763f93b678b6d204
Reviewed-on: https://chromium-review.googlesource.com/254346
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-27 02:21:25 +00:00
Bill Richardson
8a94ea4fbd Add USE_GIT_DATE=1 to make args to build repeatable images
Up until now, every image includes the time of compilation in the
build information. This makes it impossible to verify that a
particular image came from a particular source code snapshot.

With this change, specifying USE_GIT_DATE=1 to the make command
will use the author date of HEAD as the timestamp. That means
that successive builds from the same source will produce
bitwise-identical output (assuming the same toolchain, of
course).

BUG=none
BRANCH=none
TEST=manual

Do this twice:

  \rm -rf build
  make BOARD=cr50 USE_GIT_DATE=1
  md5sum build/cr50/ec.bin

The md5sum should be the same for both runs.

Change-Id: If64307101a453cb13c62fa003f1bf432f4998273
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/252751
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-25 03:33:18 +00:00
Vic Yang
accd0da789 Remove ryu_p1 board
P1 boards are not used anymore. We haven't built ryu_p1 EC for a while.
Let's get rid of it.

BRANCH=None
BUG=chrome-os-partner:35138
TEST=make buildall

Change-Id: Ie0c0b91ce0af99a0975050935af920503ca7383a
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/252340
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-02-24 03:07:59 +00:00
Sheng-Liang Song
036482b6b8 EC: Support firmware updater to auto select a battery fw image
Auto select a battery firmware image based on the current "battery info."

sprintf(auto_image_name,"/lib/firmware/battery/maker.%04X.hwid.%04X.bin"
                        maker_id, hardware_id);

BUG=chrome-os-partner:24741
BRANCH=glimmer
TEST=Verified Simplo Battery Update on glimmer

Change-Id: Ie6b2f797a4629fdde3a45e9a6a83c4568655db7a
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250130
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-20 08:33:08 +00:00
Julius Werner
672d37789f flash_ec: Add --no-ns-pid check and freeze instead of kill PTY clients
The switch to PID namespaces inside the chroot broke flash_ec's ability
to detect (and then kill) other processes that use the EC serial PTY
(leading to potential flashing failures). After a long discussion we
decided that users who need features like this should be forced to run
their chroot without PID namespacing (using cros_sdk --no-ns-pid). This
patch adds a hard check for this to flash_ec, so that using it in an
unsafe way becomes impossible.

In addition, this ports the more advanced SIGSTOP/SIGCONT logic to
flash_ec that was pioneered in fwgdb. With this, other processes
accessing that PTY will just freeze and become available again after
flash_ec finished.

BRANCH=none
BUG=chromium:444931
TEST=Ran on a Jerry with and without --no-ns-pid, with and without
an open EC terminal, all results as expected.

Change-Id: I45ffc3ec6cfe9c25a0b82b4d5288a41485c326c4
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249835
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-17 19:32:52 +00:00
Shawn Nematbakhsh
96536de3f4 pd_log: Add command to request PD MCU to write a log
When we find that charging is in a wedged state, we may wish to write a
PD log entry, but the PD MCU cannot detect such a state on its own.
Therefore, add a new command to ask the PD MCU to write a log of a given
type, and add a new board-specific custom log event.

BUG=chrome-os-partner:36668
TEST=Manual on samus:
./ectool --dev=1 pdwritelog charge 0
./ectool --dev=1 pdwritelog charge 1
./ectool --dev=1 pdwritelog 1 0
./ectool --dev=1 pdwritelog 2 0
./ectool --dev=1 pdlog
Verify log output matches expectation:
2015-02-12 11:12:49.290 P0 SRC
2015-02-12 11:12:49.296 P1 SNK Charger PD 20286mV max 20000mV / 3000mA
2015-02-12 11:12:49.303 P0 New connection
2015-02-12 11:12:49.310 P0 Board-custom event
--- END OF LOG --
Also, verify kernel logging of wedged event:
[  181.378420] PDLOG 2015/02/12 19:13:44.019 P0 Event 02 (0000) []
Also, trigger wedged state on Samus and verify log entry is written.
BRANCH=Samus
Change-Id: I55c7c839cf8300fcd3931dccdaaf16c1065e31a8
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248981
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-12 23:08:45 +00:00
Ben Lok
a9ae00b101 llama: add llama board support
This is to add llama board support:
  - new files in board/llama folder, including battery.c and led.c
  - new file power/mediatek.c, which is mostly based on power/tegra.c
  - modified flash_ec for llama board
  - disable tests for llama board.

BRANCH=none
BUG=none
TEST=make BOARD=llama

Change-Id: Ie1ae068c1a402f08e1449668b1be8f31105bb804
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/243510
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: lok.ben ben.mtk <ben.lok.mtk@gmail.com>
Commit-Queue: lok.ben ben.mtk <ben.lok.mtk@gmail.com>
2015-02-10 08:46:06 +00:00
Vic Yang
d73e8cb9c9 Assert warm reset while flashing STM32 parts
The STM32 bootloader reacts to the first command it sees and then sticks
to that interface. On some devices, the AP is connected to I2C or UART
on the EC, and if the AP talks when we are trying to flash the EC, the
EC sticks to that interface and ignores requests from the servo board.
Fix this by holding warm_reset so that the AP is down.

BRANCH=None
BUG=None
TEST=Flash Ryu several times.
TEST=Flash Plankton to make sure it doesn't break devices without
warm_reset.

Change-Id: I860fc65ba7fdaf0cbc9a0be641148b5095de394b
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/247360
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@google.com>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-02-09 03:35:57 +00:00
Vic Yang
0fc37f1291 Add flash_ec support for Glower
Just so that we can program the EC more conveniently.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Program a Glower.

Change-Id: Iaba0839c4a5b8dee805f7d31e4049198ce43918f
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/247142
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-02-09 02:13:56 +00:00
Shawn Nematbakhsh
d93544bbed mcdp28x0: Move structure definitions to ec_commands.h
mcdp_info is a logging payload, so related structures need to be moved
to the public include file.

BUG=chrome-os-partner:35935
TEST=make buildall -j
BRANCH=Samus

Change-Id: Idb939db884821fa85faafbfe643e713f5bcdbc59
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/244780
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-31 04:32:30 +00:00
Todd Broch
70afa3898c ectool: parse accessory logs for dingdong & hoho
Signed-off-by: Todd Broch <tbroch@chromium.org>

BUG=chrome-os-partner:35935
TEST=manual

  # With dingdong in C0 & hoho in C1

  # Enter GFU mode for dingdong & hoho
  ectool --name cros_pd pdsetmode 0 0x18d1 1 1
  ectool --name cros_pd pdsetmode 1 0x18d1 1 1

  # read logs
  ectool --name cros_pd pdlog

  2015-01-26 14:36:54.787 P0 SRC
  2015-01-26 14:36:54.780 P1 SRC
  2015-01-26 14:36:53.680 P0 DP mode enabled
  2015-01-26 14:36:53.375 P1 HDMI Codec: family:000e chipid:0001 irom:1.0.0 fw:0.0.0
  2015-01-26 14:36:53.771 P1 DP mode enabled

  # remove hoho & plug in zinger instead
  ectool --name cros_pd pdlog

  2015-01-26 14:44:36.991 P1 SNK Charger Type-C 5153mV max 5000mV / 3000mA
  2015-01-26 14:44:37.011 P1 SNK Charger PD 5021mV max 20000mV / 3000mA
  2015-01-26 14:44:37.116 P1 SNK Charger PD 20211mV max 20000mV / 3000mA

Change-Id: I0289cfd1d43ef1a22123b437bc8df86920fbf1a7
Reviewed-on: https://chromium-review.googlesource.com/243375
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2015-01-28 11:14:27 +00:00
Todd Broch
17f68998fb pd: Allow multiple mode entry.
Current simplified implementation allows single mode entry.  Specification
allows multiple mode entry and its advantageous for things like flashing RW
while staying in DisplayPort mode on video dongles.

CL adds capability on DFP to track as many alternate modes as supported by the
DFP.  Initial mode entered is still the default supported mode ( 1st entry, 1st
opos).  Policy manager can then use host command, EC_CMD_USB_PD_SET_AMODE, to
enter additional supported modes.

On the UFP (hoho, dingdong) a small modification to track multiple svid mode
entries was made.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:33946
TEST=manual, On hoho
1. Still successfully enter default mode DP
2. Using ectool's pdsetmode can successfully enter/exit multiple modes.
   For example,
   # port:1 svid:18d1 opos:1 cmd:1==enter
   ectool --name cros_pd pdsetmode 1 0x18d1 1 1

   Checking with pdgetmode shows both modes entered.

3. Works across hard & soft resets
4. Can flash via ectool --name cros_pd flashpd 4 <port> <RW image>
5. Still drives external display.  With bootarg drm.debug=0x6 and following
   command: 'tail -f /var/log/messages | grep "Received HPD" &'
   I see HPD assert & deassert when switching between GFU and DP mode.
   If both modes entered screen stays lit (after reboot) during write.

Change-Id: I7a21ebea377402eb1b0a0cf1d29df59694e301b1
Reviewed-on: https://chromium-review.googlesource.com/241790
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2015-01-28 11:13:58 +00:00
Todd Broch
4ce63213f0 pd: refactor object position index.
Renaming this to 'opos' for consistency with USP-PD specifications
'object position' in VDM header.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:35495
TEST=manual, On hoho
1. Still successfully enter default mode DP
2. Using ectool's pdgetmode pdsetmode can successfully enter/exit
other modes
3. Works across hard & soft resets

Change-Id: I08cb8e003ced4de481adcb503bcba3437ebb1ab7
Reviewed-on: https://chromium-review.googlesource.com/241718
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2015-01-28 11:13:50 +00:00
Shelley Chen
7e9fc466b0 flash_ec: fixing servo v3 support for beaglebone
Adding setup_openocd function to take care of setup of either servo v2 and or
servo v3 setup (setting up OCD_PATH and OCD_CFG variables).  Have modified
flash_link, flash_lm4, and flash_npcx functions to use setup_openocd function.

BUG=chromium:412249
BRANCH=None
TEST=made sure that outputted flash_ec command lines prior/after change on host
     are identical for link and peppy.  Also made sure that flash_ec command
     works on peppy with updated image on beaglebone.  Also ran "make runtests".

Change-Id: Iacf42fae1f175d6acd08bbd16352afb8f3bd21b0
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242043
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-23 00:28:49 +00:00
Vincent Palatin
194bde6367 ectool: more compact PD event log format
Use one line per entry and display the real time for the events.

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

BRANCH=samus
BUG=chrome-os-partner:33248
TEST=ectool --name=cros_pd pdlog
and see a nice log like:
2015-01-20 15:14:02.974 P0 Disconnected
2015-01-20 15:14:05.676 P0 SNK Charger Type-C 4958mV max 5000mV / 500mA
2015-01-20 15:14:11.810 P1 SRC
2015-01-20 15:14:14.460 P0 Disconnected
2015-01-20 15:14:17.277 P0 SNK Charger Type-C 5185mV max 5000mV / 3000mA
2015-01-20 15:14:17.287 P0 SNK Charger PD 5015mV max 20000mV / 3000mA
2015-01-20 15:14:17.383 P0 SNK Charger PD 20198mV max 20000mV / 3000mA
--- END OF LOG ---

Change-Id: Ibf189cdb9e5d9ba74cb1fb241a2945439dfb50f7
Reviewed-on: https://chromium-review.googlesource.com/242082
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-01-21 06:44:38 +00:00
Vincent Palatin
9e07dfb6cb pd: export the data role to the AP
For dual-role USB ports (host/device), let the AP know whether we are
currently DFP (USB host) or UFP (USB device) by exporting the data role
in addition to the power role in the EC_CMD_USB_PD_CONTROL response.

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

BRANCH=samus
BUG=none
TEST=ectool --name=cros_pd usbpd 0
plug various accessories on the port and see properly "SRC DFP" for the
USB key, "SNK DFP" for the power supply and "SNK UFP" for a regular
C-to-A charging cable.

Change-Id: I292da15fa8cf3566109dd05995ef1d00bed6f92d
Reviewed-on: https://chromium-review.googlesource.com/242012
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-01-21 05:05:53 +00:00
Todd Broch
815cb84866 pd: ectool: fix bug in infopddev command.
Change 94515d9e failed to set ec param port prior to sending the host command.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=none
TEST=manual, with two devices with different vid:pid see correct values now.

Change-Id: I6a0b9d30905509847c9481c222fa7e3c9a0264a1
Reviewed-on: https://chromium-review.googlesource.com/241951
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2015-01-20 20:56:38 +00:00