summaryrefslogtreecommitdiff
path: root/util/misc_util.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* util/misc_util: Fix unchecked errorPatrick Georgi2017-10-191-2/+5
| | | | | | | | | | | | | | | | It's unlikely, but let's check for ftell() errors. BUG=b:64477774 BRANCH=none TEST=none Change-Id: I3690da60f756ab056e852e9f485b3c439c82e67b Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #58158 Reviewed-on: https://chromium-review.googlesource.com/719196 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Martin Roth <martinroth@chromium.org>
* ectool: query packet size and set them properly internally.Gwendal Grignou2015-05-301-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Always try v0 of GET_VERSIONS command if v1 failsShawn Nematbakhsh2015-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Support command versioning of new host command rangeVic Yang2015-01-061-2/+9
| | | | | | | | | | | | | | | | | 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>
* Allow bigger flash write commandsRandall Spangler2013-07-011-0/+45
| | | | | | | | | | | | | | | | 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
* Split file read/write functions out of ectool.cRandall Spangler2013-06-281-0/+83
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>