Commit Graph

5 Commits

Author SHA1 Message Date
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
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
Vic Yang
c3adc315b3 Support command versioning of new host command range
We've extended host command range from 8-bit to 16-bit. Extend
EC_CMD_GET_CMD_VERSIONS so that the host may query supported command
versions of the new host commands.

BRANCH=All
BUG=chrome-os-partner:26577
TEST=Extend 'usbpd' to version 1. Test that we can check its version.
TEST=Run 'ectool gpioget' with new ectool and old EC.
TEST=Run 'ectool gpioget' with old ectool and new EC.

Change-Id: I1651aaf21ac2604aea101244b5e53713ead8c1af
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/237622
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-06 02:33:04 +00:00
Randall Spangler
177dc398d3 Allow bigger flash write commands
Version 1 of EC_CMD_FLASH_WRITE will use as big a write as possible given
the available command parameter space.  Falls back to 64 byte writes on old
platforms.

BUG=chrome-os-partner:20571
BRANCH=none
TEST=Copy burn_my_ec onto a link and run it.  Write size should be 64 bytes
     for the first half of the update (since the old EC doesn't support ver.1
     of the write command) and 240 bytes for the second half of the update.

Change-Id: I5900de3a5700d7c82a2e0c3cf9921b7ced1c0343
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60511
2013-07-01 16:14:16 -07:00
Randall Spangler
61820ceb43 Split file read/write functions out of ectool.c
ectool.c has gotten monstrously huge.  Refactor out some utility functions.

This is precursor work to refactoring out a lower-level flash
read/write interface.

BUG=chrome-os-partner:20571
BRANCH=none
TEST=ectool flashread 0x20000 0x80 /tmp foo -> works

Change-Id: I26dae609a73e54e8adaec56edbdce6a0bb4b8758
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60265
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-06-28 10:27:33 -07:00