summaryrefslogtreecommitdiff
path: root/util/comm-host.c
Commit message (Collapse)AuthorAgeFilesLines
* util/comm-i2c: Add switch to specify I2C busHarry Cutts2019-10-041-13/+16
| | | | | | | | | | | | | | | | | | | | Currently, devices running CrOS EC that aren't actually the embedded controller (such as touchpad or fingerprint MCUs) can only be contacted over I2C if they are in the device tree. To avoid having to recompile the Kernel, Coreboot, or `ectool`, the `--i2c_bus` switch allows `ectool` to be used for testing as-is. BRANCH=none BUG=none TEST=Checked various commands (hello, version, inventory...) with `--i2c_bus=7`, connecting to a MAX32660. Verified that a contradictory `--interface` switch is rejected. Checked that invalid bus numbers (≥32) are rejected. Change-Id: I92f3307bbbdf88978b9f8271610a3ae222279767 Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1828064 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ectool: Check address of comm_init_lpc/_i2c before calling themDaisuke Nojiri2019-01-171-2/+4
| | | | | | | | | | | | | | | | | | | This patch makes ectool check the address of comm_init_lpc and comm_init_i2c before calling them. Related bug:b/35571850 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/122478187 BRANCH=none TEST=buildall Change-Id: I32499174d7f82e45941cd97cf7780ea04517115f Reviewed-on: https://chromium-review.googlesource.com/1414706 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@google.com>
* ectool: fix battery commandDaisuke Nojiri2019-01-101-3/+3
| | | | | | | | | | | | | | | | | This patch fixes the ec_readmem function pointer, which is currently set to fake_readmem unconditionally. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/122568808 BRANCH=none TEST=Verify 'ectool battery' runs successfully on Nami. Change-Id: I2d57d0ca7103d9b9a1e44e685bc966d158a16a47 Reviewed-on: https://chromium-review.googlesource.com/1404148 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ectool: Don't acquire lock when dev interface is usedDaisuke Nojiri2019-01-051-31/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The /dev/cros_ec interface has a built-in mutex, thus we do not need to use /run/lock to arbitrate access since we can assume other tools (mosys, flashrom) also use the dev interface. $ generate_logs ... feedback/cbi_info ... $ cat feedback/cbi_info [0] As integer: 1 (0x1) As binary: 01 02 [1] As integer: 3 (0x3) As binary: 03 [2] As integer: 103 (0x67) As binary: 67 3a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:849399 BRANCH=none TEST=Verify 'ectool version' runs on Nami. Verify lock is acquired when '--interface=lpc' is specified. Verify debugd can run cbi_info. Change-Id: Id94317472917a974218bb137bda11fe5618a4b88 Reviewed-on: https://chromium-review.googlesource.com/1393729 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ectool: use poll interfaceVincent Palatin2018-01-231-0/+3
| | | | | | | | | | | | | | | | | | | Test polling for MKBP events through the kernel cros_ec/pd/fp/.. driver node. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:69460856 TEST=run on Eve EVT: ectool --name=cros_fp fpmode fingerdown && \ ectool --name=cros_fp waitevent 5 10000 Change-Id: Ibdec137a3b646cf017a29afcf24ff5bbfb731198 Reviewed-on: https://chromium-review.googlesource.com/806167 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* ectool: add servo v2 spi supportVincent Palatin2018-01-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new transport for ectool to send host command V3 over the Servo v2 SPI interface using libftdi. Build this new communication mechanism only for the 'build' architecture as it has a dependency on libftdi, the new ectool binary is called ectool_servo. Fix the 'build' tools build if they don't have a source file matching their binary name. The serial number of the servo board can be passed in the 'name' parameter, e.g. : sudo ectool_servo --name=905537-00474 version Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:70320279 TEST=with ZerbleBarn connected to a servo V2, run: sudo ectool_servo version Change-Id: Ia7067d465a42f76695fed5932f32fac9a6d0988e Reviewed-on: https://chromium-review.googlesource.com/864164 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* ectool: do not try other communication methods for none cros_ec devicesWei-Ning Huang2017-08-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | There are none cros_ec devices running EC codebase connected to chromebook, which can be accessed by ectool with `cros_ec --name=SOME_DEV ...`. In the case when SOME_DEV is not found, do not fallback to other communication methods such as LPC or I2C, since ectool will instead get the reply of real cros_ec device. BRANCH=none BUG=b:64468324 TEST=on poppy, `ectool --name=cros_tp version` should show: `Unable to establish host communication Couldn't find EC` Change-Id: I2ac232122e0f928703f7607da365d5c1dc6f7194 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/604977 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* ectool: Revert "ectool: Remove CROS_EC_DEV_IOCRDMEM"Gwendal Grignou2016-04-221-3/+8
| | | | | | | | | | | | | | | | | CROS_EC_DEV_IOCRDMEM must be used on architecture where legacy IO mapped registers are accessed inderectly via EMI. The kernel is taking care of the translation. TEST=Check on reks that we need to use the IOCTL. BUG=chrome-os-partner:52550,chromium:602832 BRANCH=none This reverts commit de45353bbdf0 ("ectool: Remove CROS_EC_DEV_IOCRDMEM"). Change-Id: I8efad56df90c58c25bdc9ccd70a508547e629a77 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/340348 Reviewed-by: Shawn N <shawnn@chromium.org>
* ectool: Remove CROS_EC_DEV_IOCRDMEMGwendal Grignou2016-04-151-8/+3
| | | | | | | | | | | | | | | | | On !LPC EC, we can read memory via CROS_EC_DEV_IOCXCMD ioctl, using command EC_CMD_READ_MEMMAP. On platform that supports direct memory access (lpc), we access the memory directly, bypassing the ioctl. BUG=chromium:602832 TEST=On gnawty and veyron, check 'ectool battery' works. Verify that gnawty use io mapped registers. BRANCH=none Change-Id: I9bfcddcf450bf8df63ead78e1df97dd7392289e6 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/338853 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ectool: fix sizes one more time.Gwendal Grignou2015-09-171-6/+8
| | | | | | | | | | | | | | | ectool is only sending payload. kernel is adding header for v3 commands. (length, crc, ...) Put back the header I previously deleted in cl:274086 BRANCH=ryu BUG=chrome-os-partner:45304 TEST=ectool flashwrite now works. Change-Id: I40fa30bc477a090261048eb51b382483f28d4ab1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/300024 Reviewed-by: Shawn N <shawnn@chromium.org>
* ectool: query packet size and set them properly internally.Gwendal Grignou2015-05-301-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 be0bd9b83538427cc350ad38d64b821dfcad82a0, "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>
* ectool: Revert: Do not increase buffer size after probe max size from ecGwendal Grignou2015-03-281-16/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 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 be0bd9b83538427cc350ad38d64b821dfcad82a0. 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>
* ectool: Do not increase buffer size after probe max size from ecPuthikorn Voravootivat2014-09-231-6/+16
| | | | | | | | | | | | | | | | 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>
* ectool: add new parameter to identify proper EC.Gwendal Grignou2014-09-141-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* ectool: read max outsize/insize from ec during comm_initPuthikorn Voravootivat2014-08-291-0/+20
| | | | | | | | | | | | | | | | | | | | | | 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>
* samus: add options for device passthru and interfaceRandall Spangler2014-07-161-7/+23
| | | | | | | | | | | | | | | | | | | | | | This allows sending host commands to the PD chip through the EC. The --interface option allows forcing a particular host interface. This is necessary at present because the crosec device driver doesn't support host protocol v3 so only has 8-bit command numbers. BUG=chrome-os-partner:30079 BRANCH=none TEST=from EC console, ectool version -> prints EC version ectool --interface=lpc --dev=0 version -> prints EC version ectool --interface=lpc --dev=1 version -> prints PD version ectool --interface=lpc --dev=2 version -> prints error ectool --interface=i2c version -> can't find EC ectool --interface=dev version -> prints EC version Change-Id: I9dd10578dac77e3e104d19e2f37759814eec6ca2 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207948
* Comm interface now provides max I/O sizes and preallocated buffersRandall Spangler2013-07-011-3/+19
| | | | | | | | | | | | | | | | | | | | The maximum packet / param size differs depending on interface and protocol version. Commands can now ask the comm interface what the limits are, and can use preallocated buffers to avoid needless malloc/free. BUG=chrome-os-partner:20571 BRANCH=none TEST=the following all work on link burn_my_ec ectool version ectool chargedump ectool console ectool i2cxfer 5 0x41 2 Change-Id: Ib847994da3f79721e7fb4e347231b9147a3f485f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60275
* ectool prefers /dev/cros_ec, then falls back to i2c, lpcBill Richardson2013-06-051-0/+77
This is preparation for the common userspace EC interface. If/when that appears, this will be ready. BUG=chromium:239197 BRANCH=all TEST=manual Build, install, run it. Shouldn't be any change. Change-Id: I9fa78515ec5443ba659f10a66bbaadcb7f4802b0 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/56131