summaryrefslogtreecommitdiff
path: root/util
Commit message (Collapse)AuthorAgeFilesLines
* ectool: add pse host commandJeff Chase2020-08-221-0/+66
| | | | | | | | | | | | BUG=b:163786867 TEST=manual BRANCH=none Change-Id: Ibc595f8a887e3fe63a45dc9b29f3bc4f75feb8ad Signed-off-by: Jeff Chase <jnchase@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354545 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Joe Tessler <jrt@chromium.org>
* compare_build.sh: Add private directory handlingCraig Hesling2020-08-211-0/+12
| | | | | | | | | | | | | | | | This allows compare_build.sh to use private libs if available. BRANCH=none BUG=none TEST=# Ensure that you have an ec checkout that has a broken # public build, but working private build. ./compare_build.sh -p # This will only work if private was accessible Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Id5e2d1afe474e0175dbba2cddfd84de7c895a927 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357870
* Revert "util: add gen_bmi_config utility"stabilize-13421.53.B-masterstabilize-13421.42.B-masterKeith Short2020-08-212-308/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f137f2493db5b5ee27ffc784538b766d5192704d. Reason for revert: Compression of BMI260 config no longer needed. Original change's description: > util: add gen_bmi_config utility > > Add the gen_bmi_config utility used to generate a compressed version > of the configuration file required by the BMI260 IMU sensor. > > This is expected to be a temporary solution until the 8 KiB BMI > configuration file can be moved out of the EC code. > > BUG=b:160330682 > BRANCH=none > TEST=make utils > TEST=run "gen_bmi_config compress BMI260_main.tbin > bmi260_compressed.bin" > TEST=run "gen_bmi_config decrompress bmi260_compressed.bin > bmi260_uncompressed.bin", verify uncompressed file matches original > file. BUG=b:160330682 BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I2bfe8d7bef2a35f43b96cc0cd07209bef534ed63 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354195 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* EC: Fix presubmit message to avoid unbounded parallel makeAndrew McRae2020-08-201-2/+5
| | | | | | | | | | | | | | | | | | | | The presubmit message that checks for 'make buildall' having been run suggests using 'make buildall -j', which can cause an unbounded number of processes to be started, especially as the number of EC targets have increased. Suggest a more reasonable value. BUG=none TEST=Check presubmit output. BRANCH=none Change-Id: Ie35a545dc1c4d58a3ad9d0ed0233c62ab5a92464 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2366324 Reviewed-by: Andrew McRae <amcrae@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org> Auto-Submit: Andrew McRae <amcrae@chromium.org>
* util: uut: add npcx7m7fc to the device-to-flash_size mapping tableCHLin2020-08-191-5/+12
| | | | | | | | | | | | | | | | | | | | | uut maintains a mapping table to look up the internal flash size with the device id (chip variant.) This CL adds a new entry in the table for npcx7m7fc. BRANCH=none BUG=b:163910671 TEST=pass "make buildall" TEST="./build/npcx7_evb/util/uartupdatetool --port=pts/15 --baudrate=115200 --read-flash --file=<file_name>" "diff ./build/npcx7_evb/ec.bin <file_name>" Signed-off-by: CHLin <CHLin56@nuvoton.com> Change-Id: I09d8763f5f54d364ecafd17135d8ea00de89da30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2355158 Tested-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: CH Lin <chlin56@nuvoton.com>
* util: ecst: add support for chip variant npcx7m7fcCHLin2020-08-182-114/+77
| | | | | | | | | | | | | | | | | | | | Allow ecst tool to compose the correct firmware header for npcx7m7fc. BRANCH:none BUG=b:163910671 TEST=pass "make buildall" TEST=with the related CLs, change CHIP_VARIANT to npcx7m7fc in board/npcx7_evb/build.mk; "BOARD=npcx7_evb make"; check the image can be built and the image header is correct. Signed-off-by: CHLin <CHLin56@nuvoton.com> Change-Id: If1eb6bc34e53c1ddd9e8f049414dc1e307e6d2c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2355155 Tested-by: CH Lin <chlin56@nuvoton.com> Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: CH Lin <chlin56@nuvoton.com>
* Replace __attribute__((noreturn)) with noreturnTom Hughes2020-08-171-1/+2
| | | | | | | | | | | | | | | _Noreturn was added in C11 and the convenience macro "noreturn" is specified by stdnoreturn.h: https://en.cppreference.com/w/c/language/_Noreturn. BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I30361bb5290cea1c776a7356f7e3a68edf1f8e39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2324816 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* common: motion_sense: Add on-body/off-body detectionGwendal Grignou2020-08-141-0/+1
| | | | | | | | | | | | | | | | This CL adds the interface for on-body/off-body detection - state: 1 : on-body, 0 : off-body. When activity is enabled, EC sends an event when the body detection changes. The host can now query the current value of the activity. BRANCH=None BUG=b:123434029 TEST=compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I007a5fe6c9030ab5c0c47995db3498751218d9c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2229803
* VIF: add \n to separate two linesRuibin Chang2020-08-141-1/+1
| | | | | | | | | | | | | | | | The generated VIF, USB_PD_Support and PD_Port_Type field stick together, so I add \n to separate two lines. BUG=none BRANCH=none TEST=check USB_PD_Support and PD_Port_Type field are separated. Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw> Change-Id: I43453301751523d0005022d039e640ac06244910 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2355633 Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-by: Sam Hurst <shurst@google.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* cbi: add Second Source Factory Cache (SSFC) CBI fieldMarco Chen2020-08-132-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSFC field will be leveraged to record what second source is used in the DUT by probing components in the factory or RMA. Firmware code should refer to this field to judge what driver should be configured for a specific component. For example, the board code can arrange what sensor driver should be set into motion_sensors array if there are multiple sources of base or lid sensor. As the definition of FW_CONFIG, it describe which "features" the firmware code should enable or disable. For example, whether lid / base sensors should be enabled or not but not care about what second source is in this DUT. BRANCH=none BUG=b:163285687 TEST=call `cbi-util` to create the cbi image with SSFC and show created content. TEST=`make buildall -j` TEST=`make runhosttests -j` Change-Id: Icb4aa00ae47ab025198e7fd5edd6aab96a4bf53e Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2344268 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* ectool: Fix "rwsig dump key_id" hex outputCraig Hesling2020-08-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ectool command rwsig dump key_id's output was missing zeros in the hex string output. This is because we print each byte independently using the naked %x formatter, which will print the minimum hex characters necessary to represent the independent number provided. We need to force exactly 2 hex characters for each independent byte printed. BRANCH=none BUG=b:162588911 TEST=# Nocturne make BOARD=nocturne_fp build/nocturne_fp/util/ectool # Copy build/nocturne_fp/util/ectool to fat32 flash drive mkdir /tmp/rem mount /dev/sda1 /tmp/rem ectool --name=cros_fp rwsig dump key_id | tr -d '\n' | wc -c # Identify there are less than 40 chars (39 in my case) /tmp/rem/ectool --name=cros_fp rwsig dump key_id | tr -d '\n' | wc -c # Identify there are exactly 40 chars # Rerun both commands without the byte counting to sanity # check the output Change-Id: I0a43833adb647aa034df87678c9657466cc8aef5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2336865 Commit-Queue: Craig Hesling <hesling@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org> Tested-by: Craig Hesling <hesling@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Auto-Submit: Craig Hesling <hesling@chromium.org>
* util/flash_ec: fix in parse error in getting flash_size from flashromNamyoon Woo2020-08-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes flash_ec to take the last line of grep result from the output of 'flashrom --flash-size'. BUG=b:162771462 BRANCH=none TEST=ran flash_ec on nocturne with suzy-Q connected. $ ./util/flash_ec --image /Downloads/nocturne.bin --board nocturne \ --verbose INFO: Using ccd_cr50. INFO: Using ec image : /Downloads/nocturne.bin INFO: Flashing chip npcx_int_spi. dut-control --port=9999 cold_reset:on dut-control --port=9999 fw_up:on dut-control --port=9999 cold_reset:off INFO: Running flashrom: ... Erasing and writing flash chip... SUCCESS INFO: Flashing done. INFO: Restoring servo settings... dut-control --port=9999 fw_up:off dut-control --port=9999 ccd_ec_boot_mode_uut:off dut-control --port=9999 ccd_ec_boot_mode_bitbang:off dut-control --port=9999 cold_reset:on Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: I1120c828ddb33f327cce46435ec9fa26b10d1908 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2340088 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* ec: change usage of dummySam Hurst2020-08-053-9/+8
| | | | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the term "dummy" with inclusive alternatives. BUG=b:162781382 BRANCH=None TEST=make -j buildall `grep -ir dummy *` The only results are in "private/nordic_keyboard/sdk8.0.0" which is not our code. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I6a42183d998e4db4bb61625f962867fda10722e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335737 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* it8xxx2_pdevb: flash code by SPIRuibin Chang2020-08-051-1/+1
| | | | | | | | | | | | | | | Flash it8xxx2_pdevb code by SPI. BUG=none BRANCH=none TEST=can flash code by SPI on board it81202_pdevb. Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw> Change-Id: Ibc83bd5596f65fe8f9558f9575677feeb3da2f91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2334435 Commit-Queue: Ruibin Chang <Ruibin.Chang@ite.com.tw> Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-by: Jett Rink <jettrink@chromium.org>
* flash_ec: ite_spi: Put FW image at the beginning of temp imagetim2020-08-051-1/+2
| | | | | | | | | | | | | | | When FW image size is less than flash rom SPI size, the temp image should be placed after FW image for ite_spi programming mode. BUG=none BRANCH=none TEST=zephyr.bin(size=18.4k) is successfully burned to it8xxx2_evb to print hello world. Signed-off-by: tim <tim2.lin@ite.corp-partner.google.com> Change-Id: I163d954e91d31a598d0957f7a4de67cef13223f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335525 Reviewed-by: Jett Rink <jettrink@chromium.org>
* vif: Update VIF generator to Revision 1.40, Version 1.0 of the specSam Hurst2020-08-051-336/+769
| | | | | | | | | | | | | | | | | | | | | | | | Update the Vendor Information File generator so that it complies with Revision 1.40, Version 1.0 of the spec. The VIF files are generated when the board is built. So, make -j BOARD=<board> will create build/<board>/<board>_vif.txt A VIF can be generated manually after the board is built with build/<board>/util/genvif -b <board name> -o <out directory> BUG=b:131087690 BRANCH=none TEST=manual Generate VIF for Atlas and checked fields. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: Iaa1eaf1f01f9d36ad3afd2818ebe81359b8531f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1577739 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* ec: change usage of whitelist/blacklistPaul Fagerburg2020-07-281-3/+3
| | | | | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "whitelist", "blacklist", and similar with inclusive alternatives. BUG=b:162262297 BRANCH=None TEST=`grep -Eirl "(white|black)[ _\-]*list" .` The only results are in "private/nordic_keyboard/sdk8.0.0" which is not our code. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie5210b98e1096c22d0e9284c101a42820bd3d79d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321549 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* util/flash_ec: drop support for toad cableJack Rosenthal2020-07-231-30/+0
| | | | | | | | | | | | | | | | | All devices with a servo v1 connector are AUE... assume we can drop this old code from ToT. BUG=none BRANCH=none TEST=run with dry run params for scarlet and attached servo v4... no output diff Change-Id: I09df37e2e287337f7962055c3244eab4afacead8 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2313597 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* util/flash_ec: add --dry_run flagJack Rosenthal2020-07-231-21/+46
| | | | | | | | | | | | | | | | | | | I've found it useful discover what commands are being run to actually flash the EC, without actually flashing it. This CL adds a new flag, --dry_run, which prints the commands necessary to reproduce the flash, instead of running them. Commands which probe hardware presence (e.g., dut_control_get) are not printed. BUG=none BRANCH=none TEST=manual, observe operation with scarlet connected, both with and without --dry_run Change-Id: Ib7de66176625878370d5b24a5fb7a32b37965cb8 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226505 Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec: change usage of "sane" per inclusive languagePaul Fagerburg2020-07-221-1/+1
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "sane", "sanity check", and similar with inclusive/non-stigmatizing alternatives. BUG=b:161832469 BRANCH=None TEST=`make buildall -j` succeeds. `grep -Eir "sane|sanity" .` shows results only in third-party code or documentation. Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I29e78ab27f84f17b1ded75cfa10868fa4e5ae88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311169 Reviewed-by: Jett Rink <jettrink@chromium.org>
* CBI: Add ectool command to remove board infoCheng-Han Yang2020-07-161-2/+27
| | | | | | | | | | | | | | | | Add a ectool command to remove board information in EEPROM. BUG=b:161208512 BRANCH=none TEST=Run `ectool cbi remove <tag>`, then `ectool cbi get <tag>` to verify that the CBI fields are removed and getting INVALID_PARAM error. Change-Id: I6f2aec477f68f258c76d99d1e67d155784b37d42 Signed-off-by: Cheng-Han Yang <chenghan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2299606 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Cheng-Han Yang <chenghan@chromium.org> Tested-by: Cheng-Han Yang <chenghan@chromium.org>
* util: add gen_bmi_config utilityKeith Short2020-07-102-1/+308
| | | | | | | | | | | | | | | | | | | | | | | Add the gen_bmi_config utility used to generate a compressed version of the configuration file required by the BMI260 IMU sensor. This is expected to be a temporary solution until the 8 KiB BMI configuration file can be moved out of the EC code. BUG=b:160330682 BRANCH=none TEST=make utils TEST=run "gen_bmi_config compress BMI260_main.tbin bmi260_compressed.bin" TEST=run "gen_bmi_config decrompress bmi260_compressed.bin bmi260_uncompressed.bin", verify uncompressed file matches original file. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I7ef06414f84169f2e16f26df4f83455c3df37e51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2289215 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* util/ecst: Make sure that copying back arguments doesn't exceed MAX_ARGSPatrick Georgi2020-06-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Newer gcc than we have in CrOS shows a non-helpful error message: util/ecst.c: In function 'main': util/ecst.c:398:7: error: 'strncpy' output may be truncated copying 100 bytes from a string of length 9999 [-Werror=stringop-truncation] 398 | strncpy(hdr_args[arg_ind++], | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 399 | tmp_hdr_args[tmp_ind], | ~~~~~~~~~~~~~~~~~~~~~~ 400 | ARG_SIZE); | ~~~~~~~~~ In the end it's about gcc not being able to ensure that hdr_args[] doesn't overflow. BUG=none BRANCH=none TEST=gcc 9.3 as shipped with debian sid compiles ecst without error Change-Id: I2c30cdfaac0305ea4e4c19477469bcf497469caa Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2273240 Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
* ectool: Show smartdischarge thresholds by charge %Daisuke Nojiri2020-06-301-2/+12
| | | | | | | | | | | | | | | | | | | | | | | Currently, the smartdischarge command prints cutoff and stay-up thresholds by the remaining capacity. This CL makes it print the thresholds by the state of charge as well. $ ectool smartdischarge 2880 1150 65 Hours to zero capacity: 2880 h Stay-up threshold: 3312 mAh (64 %) Cutoff threshold: 187 mAh (3 %) Hibernate discharge rate: 1150 uA Cutoff discharge rate: 65 uA BUG=b:152431365, b:157602162 BRANCH=none TEST=See above Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I9aa163eab861f766a8f1120481c0e1db2608aa77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2268280 Reviewed-by: Mengqi Guo <mqg@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* ectool: motionsense: add commands for fast/manual offset compensationInno.Park2020-06-241-26/+77
| | | | | | | | | | | | | | | | - command 'calibrate' added for accel/gyro calibration - command 'offset' modified so that it can also set offset manually BUG=b:159557101 BRANCH=none TEST=build ectool and run following commands. 'ectool motionsense calibrate 2' 'ectool motionsense offset 2 -- -187 312 -62' Change-Id: I58d0920e0ed48145cad55587ee3ba125d6a5c175 Signed-off-by: Inno.Park <ih.yoo.park@samsung.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256964 Reviewed-by: Jett Rink <jettrink@chromium.org>
* flash_ec: remove verify-whole option for npcx_(int_)spiNamyoon Woo2020-06-231-11/+0
| | | | | | | | | | | | | | | | | | | This patch removes the verification of the whole firmware area for npcx_spi and npcx_int_spi chip. The reason is flash_ec programs WP_RO and EC_RW area only so it should verify partially on those area only, not the whole area. The option "--fast-verify" already was used for that purpose in flash_ec script. BUG=b:158864362 BRANCH=none TEST=ran flash_ec on nami. Signed-off-by: Namyoon Woo <namyoon@google.com> Change-Id: If08194697e1b15b13c592be94d5268359edd6b5a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2254739 Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
* Battery: Implement smart discharge systemDaisuke Nojiri2020-06-201-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, CrOS EC chooses only one of the two powre-saving states when the system is left idle. One is to hibernate and the other is to cut off the battery. And these are determined at compile time. If the system hibernates, EC will not have a chance to cut off the battery before the state of charge reaches critical low. If the system is in cutoff, it requires an AC adapter to wake up. So, neither behavior is ideal. This patch introduces the smart discharge system. Given the number of hours to zero capacity as a target, it tries to choose the better state for idling. For example, if the state of charge is high, it will hibernate the system because the target can be met before the battery completely drains. If the state of charge is low, it will keep the EC up so that it can cutoff the battery. Tests are done on Bloog as follows: Verify EC selects not to hibernate when the remaining capacity is below the stay-up threshold. The ectool smartdischarge command is tested as follows: localhost ~ # ectool smartdischarge Hours to zero capacity: 0 h Stay-up threshold: 0 mAh Cutoff threshold: 0 mAh Hibernate discharge rate: 0 uA Cutoff discharge rate: 0 uA localhost ~ # ectool smartdischarge 2160 Hours to zero capacity: 2160 h Stay-up threshold: 0 mAh Cutoff threshold: 0 mAh Hibernate discharge rate: 0 uA Cutoff discharge rate: 0 uA localhost ~ # ectool smartdischarge 2160 200 1500 EC result 3 (INVALID_PARAM) localhost ~ # ectool smartdischarge 2160 1500 200 Hours to zero capacity: 2160 h Stay-up threshold: 3240 mAh Cutoff threshold: 432 mAh Hibernate discharge rate: 1500 uA Cutoff discharge rate: 200 uA localhost ~ # ectool smartdischarge 2160 1500 0 EC result 3 (INVALID_PARAM) localhost ~ # ectool smartdischarge 0 Hours to zero capacity: 0 h Stay-up threshold: 0 mAh Cutoff threshold: 0 mAh Hibernate discharge rate: 1500 uA Cutoff discharge rate: 200 uA Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:152431365, b:157602162 BRANCH=none TEST=See above Change-Id: I1470b13203f3653ae0e495cd5ec8ed05f3c5102f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216392 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
* util/ide-config: Add basic eclipse supportCraig Hesling2020-06-191-1/+121
| | | | | | | | | | | | | | | | * It can only generate for a single board-image at a time. * It generates an XML that is importable from an existing CDT project. See https://gn.googlesource.com/gn/+/master/docs/reference.md#eclipse-ide-support for a better description about what is generated. BRANCH=none BUG=none TEST=./util/ide-config.sh eclipse nocturne_fp:RW >nocturne_fp-rw.xml Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I891bce7fedf6cf10778618638f7bf5caffe57717 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2084413 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* util/flash_jlink.py: Exit with error codeTom Hughes2020-06-161-2/+8
| | | | | | | | | | | | | | | | | | When flashing fails, the script will exit with non-zero exit code. BRANCH=none BUG=b:151105339 TEST=Stop JLinkRemoteServerCLExe: ./util/flash_jlink.py --board bloonchipper --image \ ./build/bloonchipper/flash_write_protect/flash_write_protect.bin echo $? 1 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I75052eb52d0690e7a6ba3ae9e5ccbf877bee2cd2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2233781 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* makefile: use separate directory for code coveragePaul Fagerburg2020-06-121-9/+13
| | | | | | | | | | | | | | | | | | | | | | | When building host-based unit tests for code coverage, put the build outputs in a different directory. Because the code coverage build has calls into gcov library functions, a partial rebuild without code coverage will result in undefined linker errors. The previous solution was an inefficient cycle of `make clobber` and full rebuild when switching between building with and without code coverage. BUG=b:157091606 BRANCH=None TEST=`make buildall -j ; make coverage -j` Verify that build/host and build/coverage both exist, and that code coverage data (*.gcno, *.gcda, *.info) is only in build/coverage. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Iac0b18068082d34546aa15b174f86efb6a7f41a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242351 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* flash_ec: flashrom: Use google-servo-v2 instead of servo-v2Nicolas Boichat2020-06-081-1/+1
| | | | | | | | | | | | | | | Get rid of deprecation warning. BRANCH=master BUG=b:145175076 TEST=none Change-Id: I4fe9adc3811f8dcd6a75fe9481d7e44a29d5126e Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2234042 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* flash_fp_mcu: fix the volteer gpio settingZhuohao Lee2020-06-081-15/+15
| | | | | | | | | | | | | | | | | Due to the latest coreboot change, the gpiochip252 and gpiochip445 were removed and the gpiochip152 was added. Besides, the GPIO pin also changed. This patch fixes the gpio pin setting. BUG=b:156993750 BRANCH=none TEST=ran flash_fp_mcu on the Volteer Change-Id: I54082eea90e85746976d427523cfc0b53e87ddda Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2214876 Tested-by: Jesper Lin <jesper_lin@wistron.corp-partner.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Alex Levin <levinale@chromium.org>
* util/flash_jlink.py: Reset after flashingCraig Hesling2020-06-041-0/+1
| | | | | | | | | | | | | | | | | | | You must reset the chip after flashing to start the new code. It is possible that the chip was resetting without this fix due to a double fault after flashing. In cases where the CPU is hung before flashing, the CPU would not reset. BRANCH=none BUG=none TEST=# Ensure that the chip is hung in on b/147520242 ./local/flash_jlink.py --ip '' # The UART console should reflect a reset and become interactive again Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I5006eff5d3a955ba9b8e6ecee4f72d7ad851f239 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226520 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* util/flash_jlink.py: Allow USB modeCraig Hesling2020-06-041-3/+8
| | | | | | | | | | | | | | | | | | | | This adds the option to specify "" for --ip, which will disable the TCP/IP mode. Thus, the JLink tool will default to USB direct. BRANCH=none BUG=none TEST=# Ensure JLinkRemoteServerCLExe is not running ./util/flash_jlink.py --ip '' # Ensure JLinkExe uses direct USB and succeeds TEST=# Ensure "JLinkRemoteServerCLExe -Port 2551 -select USB" is running ./util/flash_jlink.py # Ensure JLinkExe uses TCP/IP and succeeds Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I9da2efa8adf155673f14f12dbb354492b0827332 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226880 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* util/flash_jlink.py: Allow using PATH to find JLinkExeCraig Hesling2020-06-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Installing Jlink Debian package places JLinkExe in a PATH area. This allow flash_jlink to find the normal path'ed executable in addition to the hand placed binary. BRANCH=none BUG=none TEST=# Assume JLink_Linux_V670e_x86_64 dir does not exist mkdir ./JLink_Linux_V670e_x86_64 touch ./JLink_Linux_V670e_x86_64/JLinkExe chmod +x ./JLink_Linux_V670e_x86_64/JLinkExe ./util/flash_jlink.py # Should fail TEST=# Ensure the proper JLinkExe is in PATH rm -rf ./JLink_Linux_V670e_x86_64 ./util/flash_jlink.py # Should succeed Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ife0c2b7a47f989877f7b81a81a7dadd2b7cb5c1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226879 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* util/flash_jlink.py: Fix formatting + parsing conventionCraig Hesling2020-06-041-14/+15
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=./util/flash_jlink.py --jlink JLinkExe --ip blah # Ensure that the blah parameter was passed Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Iee38468eb38e91eb3f2b6c19de9c5070f1c0bc5a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226878 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* util/flash_jlink: Enforce python3Craig Hesling2020-06-041-1/+1
| | | | | | | | | | | | | | | | | Python 3 is required for the subprocess.run line. Enforcing python 3 helps our non-chroot devs. BRANCH=none BUG=none TEST=# Outside chroot ./util/flash_jlink.py # Ensure the error does not reference subprocess.run Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I057c1b00696a4b356f162795fd1794eba9c54bd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226877 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* servo_updater: Updates the Servo V4.1 nameBrian J. Nemec2020-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | Updates the Servo V4.1 name from 'servo_v41' to 'servo_v4p1' and the corresponding files and fields. As the VID:PID is used to identify the device, no other changes are required. BUG=b:157059356 BRANCH=servod TEST=Updated the ServoV4.1 from 'servo_v41_v2.0.3735+440cf71e0' to 'servo_v4p1_v2.0.4232-514cb4e92' to verify the servo_updater supports renames. TEST=Verified servo_v4p1 manually: Validated console, firmware update, and servod can connect to the device. Signed-off-by: Brian Nemec <bnemec@chromium.org> Depends-On: Ia05134179fab4ff118355ba9b3b1b92cdf0748f2 Change-Id: Ie470469bf9115bbfef14a08c02b156dcd5aed849 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2219124 Tested-by: Brian Nemec <bnemec@chromium.org> Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
* console: add micro seconds in timestampsEric Yilun Lin2020-05-301-3/+15
| | | | | | | | | | | | | | | | | | | | | A more precise timestamp will be helpful while debugging with AP and EC uart logs. This CL adds extra 3 micro second digits in timestamps, and also uses 'yy' rather than 'YYYY' year format. BRANCH=none BUG=none TEST=sudo emerge ec-devutils; dut-control timestamp:on see cpu_uart_pty in such format: 20-05-27 15:50:36.034 Developer Console 20-05-27 15:50:36.038 20-05-27 15:50:36.038 To return to the browser, press: Change-Id: I782e6e080f38cbaaa31b0b96fac839e118619266 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2217493 Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
* flash_ec: keep h1 awake while flashing with c2d2Jett Rink2020-05-261-4/+12
| | | | | | | | | | | | | | | | | | | | | | | The H1 controls the DUT-side i2c muxes that the C2D2 programming path need to stay active. If the H1 goes to sleep during the flash process the flash will fail. Use new dut-control for cr50 that will keep the cr50 from going into a deep low power mode during flashing Also initialize the c2d2 i2c before turning on the DUT-side i2c muxes; this is not strictly necessary, but seems prudent to change. BRANCH=none BUG=b:153475851 TEST=flash waddledee multiple times without issue Cq-Depend: chromium:2188853 Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I39fac618dc6436f547d723364a2273cc03563593 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2189070 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* util: Fix platform name in flash_fp_mcuTom Hughes2020-05-211-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | cros_config /identity platform-name is specific to mosys and not guaranteed to be the same as the board name. Always use CHROMEOS_RELEASE_BOARD from /etc/lsb-release instead. BRANCH=none BUG=b:156650654 TEST=On ekko: flash_fp_mcu /opt/google/biod/fw/nami*.bin TEST=On kohaku: flash_fp_mcu /opt/google/biod/fw/dartmonkey*.bin TEST=On nocturne: flash_fp_mcu /opt/google/biod/fw/nocturne*.bin TEST=On dratini: flash_fp_mcu /opt/google/biod/fw/bloonchipper*.bin Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ic395e1c6bfdd5c9d4e397a50e594c03d2cf91af1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2212689 Commit-Queue: Yicheng Li <yichengli@chromium.org> Reviewed-by: Yicheng Li <yichengli@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* util: Script for flashing via J-LinkTom Hughes2020-05-151-0/+118
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=make BOARD=bloonchipper -j && \ ./util/flash_jlink.py --board bloonchipper Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ida382ade28451eaab62ca852337256740b81d30f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2191292 Commit-Queue: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* util: Remove unnecessary halt in gdbinitTom Hughes2020-05-111-2/+0
| | | | | | | | | | | | | | The reset on the line before is sufficient. BRANCH=none BUG=none TEST=none Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I7eef41a4263764375ff1c8a16bb462edf7b3209c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2190820 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* ec: fix `make coverage` code coverage reportingPaul Fagerburg2020-05-111-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Fixed problems that were preventing us from building the unit tests with code coverage testing via `make coverage`. * Changed test_util so that programs will cleanly exit on SIGTERM. * Changed run_host_test to wait for the child process to exit, and only proc.kill() if it times out, so the child process will generate code coverage output files on exit. * Changed Makefile.toolchain to use the --coverage flag for both compile and link. * Changed build.mk and Makefile.rules to exclude certain tests from code coverage because they were causing failures either during the individual stage of code coverage, or generating the overall report. BUG=b:143065231 BRANCH=none TEST=`make coverage` produces results Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I8575013551ce1dba3fd249cd933a3cf6d110db8d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2186853 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* uart_stress_tester: import logging instead of cros_loggingNamyoon Woo2020-05-081-1/+1
| | | | | | | | | | | | | | | | | This patch makes uart_stress_tester.py import logging instead of cros_logging from chromite.lib. BUG=none BRANCH=none TEST=ran uart_stress_tester.py on local chroot and on labstation. Signed-off-by: Namyoon Woo <namyoon@google.com> Change-Id: I479e2b7a046d6c7b02fb4aca2c7e1fc83334e294 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2190826 Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
* compare_build.sh: Fix chip boards-with parsingCraig Hesling2020-05-071-3/+2
| | | | | | | | | | | | | | | | | This fixes board expansions that use the boards-with search feature. The boards-with function outputs a newline separated list, while the static board expansions emit a space separated list. This allows read to tokenize either format. BRANCH=none BUG=none TEST=./util/compare_build.sh -bstm32f4 TEST=./util/compare_build.sh -bfp Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Iebf4309fc7ea2ba66a637a5446aa283552ef67c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2187951 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* compare_build.sh: Add stm32f4 and stm32h7 board groupsCraig Hesling2020-05-071-0/+4
| | | | | | | | | | | BRANCH=none BUG=none TEST=./util/compare_build.sh -b "stm32f4 stm32h7" Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ie7645300d3731bbd93449722b674b4806dff8063 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2110536 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* compare_build.sh: Modularize parsing board groupsCraig Hesling2020-05-071-49/+61
| | | | | | | | | | | | | Allow reuse of the board/board-group parsing function. BRANCH=none BUG=none TEST=./util/compare_build.sh -b "mchp fp -nucleo-h743zi" TEST=./util/compare_build.sh Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I7acaeaf93830c10dca2fa49c23593d0940191848 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2110535
* compare_build.sh: Improve board selectionCraig Hesling2020-05-071-29/+135
| | | | | | | | | | | | | | | | | | | | New features: * Add board validation * Add many new board groups BRANCH=none BUG=none TEST=time ./util/compare_build.sh -b "all -all"; echo $? TEST=time ./util/compare_build.sh -b ""; echo $? TEST=time ./util/compare_build.sh -b stm32 -j 7; echo $? TEST=time ./util/compare_build.sh -b hatch_fp -j 7; echo $? TEST=time ./util/compare_build.sh -o -b fp -j 7; echo $? TEST=time ./util/compare_build.sh -o -b bloonchipper; echo $? TEST=time ./util/compare_build.sh -o -b "fp -bloonchipper" -j 7; echo $? Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ia802f3b0c595f2c7aafeee8e247077333625888a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2093897
* util: Add support for flashing and debugging unit tests with gdbTom Hughes2020-05-051-4/+10
| | | | | | | | | | | | | | | | | | | | BRANCH=none BUG=none TEST=On machine with dragonclaw attached to J-Trace: JLink_Linux_V670e_x86_64/JLinkGDBServerCLExe -select USB -device STM32F412CG -endian little -if SWD -speed auto -noir -noLocalhostOnly make BOARD=bloonchipper tests -j BOARD=bloonchipper GDBSERVER=segger BIN_NAME=sha256 gdb --ex "target remote 127.0.0.1:2331" Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I6a130c9d4d676d017969aac579d43f995b4dad09 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2172060 Reviewed-by: Harry Cutts <hcutts@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>