summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Remove __7b, __8b and __7bfDenis Brockus2019-07-202-4/+4
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Improve unit test and fuzzer documentation storyCraig Hesling2019-07-201-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update **test** directory description to README.md. * Add ** fuzz** directory description to README.md. * Add unit test and fuzzer make targets to `make help` * Change showboards to print-boards to be more consistent * Change showboards to use auto pretty print * Add print-tests, print-host-tests, and print-host-fuzzers This is necessary to remove the ambiguity about what a special name is for a given unit test. Documentation Story: The idea is to give a brief overview of what the test and fuzz directories are in README.md. README.md also mentions you should see `make help` for more detail. Running `make help` shows you more general test/fuzz commands, including the print-* commands. Running the print-* commands show you exact target names for all possible unit/fuzz test (both the build-only and run target names). BRANCH=none BUG=none TEST=make help TEST=make print-tests TEST=make print-host-tests TEST=make print-host-fuzzers TEST=make print-host-fuzzers | cat TEST=make print-boards TEST=make print-boards | cat TEST=make buildall -j Change-Id: I34b68196ac635ba71a1d45ceb5d35a3b36fd129f Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1684714 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-192-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Fix hexdump and string 0 precisionCraig Hesling2019-07-181-31/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch addresses a few issues with the current formatter. The major points are as follows: 1. Cannot specify precision 0 (truncate all) for string or hexdump 2. Forced safe precision for malformed strings 3. No padding when using hexdump 4. Bad error EC_ERROR_INVAL in vsnprintf 5. Documentation errors For (1), no piece of code explicitly sets the precision to 0 in order to invoke the default behavior, which is currently no precision limit. You can check using the following grep line: grep -rI '%[\*0-9]\{0,20\}\.0\{1,20\}[a-zA-Z]' However, there are many cases where the precision is used to limit the character output (as it should be). grep -rI '%[\*0-9]\{0,20\}\.[\*0-9]\{1,20\}[a-zA-Z]' There are many more instances that use variable precision without checking if the precision is zero. One of which is the following: crrev.com/4a4e2c71a0f6aaa50e0728922f84a7d54c14380a/test/host_command_fuzz.c#116 https://clusterfuzz.com/testcase-detail/5699023975088128 Our current implementation will insert ERROR and stop processing, if a precision of zero is detected when using the hexdump flag. This results in a badly formatted console line or runtime string, when the intended behavior would be to simply read no bytes. In the aforementioned fuzzer case, outputting ERROR triggers a false positive. Our printf should handle explicit zero precision similar to stdlib's printf, which means truncating all the way to zero positions, if specified. For (2), our current implementation uses strlen to identify the length of the input string, regardless of the set precision. Since this is an embedded platform, we should use strnlen to impose safe limits, when a precision is specified. For (3), our implementation should support padding and adjusting of all formatter types, since that is a primary feature of a printf formatter. The remaining commented code highlights odd behavior that should be fixed at some point, but is not critical. BUG=chromium:974084 TEST=Checked for any format lines that rely on a set precision of 0 grep -rI '%[\*0-9]\{0,20\}\.[\*0-9]\{1,20\}[a-zA-Z]' TEST=make run-printf V=1 BRANCH=none Change-Id: I897c53cce20a701fcbe8fb9572eb878817525cc3 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1659835 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: refactor CPRINTF("[%T ...]\n") to CPRINTSJack Rosenthal2019-07-171-1/+1
| | | | | | | | | | | | | | | | Looking at where the non-standard %T printf modifier is used in EC codebase, the majority is cases where CPRINTS could have been used instead of CPRINTF. This is a somewhat-mechanical refactor of these cases, which will make implementing a standard printf easier. BUG=chromium:984041 BRANCH=none TEST=buildall Change-Id: I75ea0be261bfbfa50fb850a0a37fe2ca6ab67cb9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1703128 Reviewed-by: Evan Green <evgreen@chromium.org>
* fpsensor: Extend unit test for FPTPM seed set status.Yicheng Li2019-07-151-27/+48
| | | | | | | | | | | | | | | | Extend the unit test for checking FPTPM seed status, specifically: 1. After seed is set, try set the seed again, expect failure. 2. At this point, check that the seed is still set. BRANCH=nocturne BUG=chromium:952275 TEST=make -j buildall TEST=tested enrollment, matching and multifinger on DUT nocturne. Change-Id: I2be9d2c21b552f242dd88f33361398755b6c2e84 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1643659 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* Test: Disable kb_scan until flakiness is fixedDaisuke Nojiri2019-07-041-1/+1
| | | | | | | | | | | | | | | | | kb_scan is flaky, causing builders to fail randomly. We disable it until its flakiness is fixed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:976974 BRANCH=none TEST=buildall Change-Id: Id896a5928f5a241594fdeb010c4f6bfe24302f3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1684044 Reviewed-by: Luis Lozano <llozano@chromium.org> Commit-Queue: Luis Lozano <llozano@chromium.org> Tested-by: Luis Lozano <llozano@chromium.org>
* printf: Add unit tests for printf.cCraig Hesling2019-06-253-0/+216
| | | | | | | | | | | | | | | | These tests solidify the current behavior of the print formatter in order to verify future changes. Some commented out tests expose odd behavior that will be addressed in the follow up patch. BUG=chromium:974084 TEST=make V=1 run-printf BRANCH=none Change-Id: I9c45a075692992c7713a15d7f83099a2d13441e6 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1659834 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* fpsensor: Add unit tests for fp_set_sensor_modeTom Hughes2019-06-241-0/+54
| | | | | | | | | | | BRANCH=nocturne BUG=b:124773209 TEST=make buildall -j Change-Id: I8337c708005c51435ce8a5ab5d536cccc604f850 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1670347 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* pd_protocol: Don't DRP toggle lower than S0.Aseda Aboagye2019-06-211-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently our USB PD protocol stack has "low power mode" tightly coupled with PD_STATE_DRP_AUTO_TOGGLE. In addition, it has the side effect of us dual role toggling (and resolving as sources) even though we have no intention of being a source. (e.g. DRP toggle in S0, once we suspend we're still toggling, even after shutting down to S5, we're still toggling.) This commit makes it such that we not dual role toggle in those lower power states, but instead behave properly as a sink and present only the Rd's. It also fixes a bug where if a port was previously sourcing in S0 and remained sourcing in suspend, if the sink was unplugged the port would be stuck presenting Rp's until a sink was plugged and unplugged again. BUG=chromium:902437 BUG=b:119055792 BRANCH=firmware-nocturne-10984.B TEST=Flash nocturne, use twinkie verify port does not dual role toggle in suspend or off. TEST=Verify that TCPC goes into low power mode in SNK_DISCONNECTED. TEST=Verify that charging works in suspend and off. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1320909 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Change-Id: Ie44581a1a1a82cf29a786b57a71ce70760862ca2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1667940 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Auto-Submit: Scott Collyer <scollyer@chromium.org>
* cleanup: Fix common spelling typos in commentsTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | Used 'git grep' to fix the following misspelled words across the codebase: * recieved * recieving * delaraction * finctionality * lastest * permanenlty * Callabck BRANCH=none BUG=none TEST=make buildall -j Change-Id: I68ec9c8b967941041e46ff3ed3549ab2a06604ac Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1636848 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* ec.tasklist: Consolidate duplicate commentsTom Hughes2019-06-193-27/+3
| | | | | | | | | | | | | | Same as https://crrev.com/c/1551579, but clean up some files with the old comments that have been added since that change. BRANCH=none BUG=none TEST=make buildall -j Change-Id: I4bc7fdc7cb128c48545ea681ab1381610d54fb6d Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1664604 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-1973-73/+73
| | | | | | | | | | | | | | | | 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>
* fuzz: Cleanup test_config.h and fuzz_config.hCraig Hesling2019-06-151-18/+0
| | | | | | | | | | | | | | | | | This removes the remaining fuzz config that was left in test_config.h. This section had already been duplicated in fuzz_config.h, without being removed from test_config.h. See the original migration CL crrev.com/c/1180179 for more info. BRANCH=none BUG=none TEST=make runtests V=1 -j Change-Id: Icd7158417ac184d7723828e62b968f7f0aa4bfbc Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660126 Reviewed-by: Allen Webb <allenwebb@google.com>
* fpsensor: Add unit test for derive_encryption_key().Yicheng Li2019-06-142-3/+155
| | | | | | | | | | | | | | | | | Mock rollback_get_secret() and use it to test derive_encryption_key(). BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching and multifinger on nocturne DUT TEST=verified test key vectors by running boringSSL's HKDF (https://boringssl.googlesource.com/boringssl/+/c0b4c72b6d4c6f4828a373ec454bd646390017d4/crypto/hkdf/) locally Change-Id: Ie2f51e4f64788d938e43d0c5c18685d1cfdd001c Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652495 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* keyboard_scan: Send kb events at start of debouncing period.Jes Klinke2019-06-111-36/+78
| | | | | | | | | | | | | | | | | | | | Current behavior is to start a timer upon first detecting a transition of any one cell of the keyboard matrix, and then generate a keyboard event (press or release) only after that timer has expired. Due to the fact that the release timer has a longer period than the press timer, in some cases, e.g. releasing the shift key right before depressing another key, events could end up getting re-ordered. BUG=chromium:547131 BRANCH=master TEST=make run-kb_scan Signed-off-by: Jes Klinke <jbk@google.com> Change-Id: If3de2e629dc9df4325d8c17590d6624a41e27187 Bug: 547131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1579905 Tested-by: Jes Klinke <jbk@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org>
* fpsensor: Add API to check FP sensor encryption status.Yicheng Li2019-06-073-0/+118
| | | | | | | | | | | | | | | | | | Add EC command for the host to query FP sensor encryption status. Currently it's just FP TPM seed has been set or not. Add unit test for this command. Also add ectool command for querying encryption status. BRANCH=nocturne BUG=chromium:952275 TEST=ran unittests TEST=tested enrollment, matching and multifinger on DUT nocturne. TEST=tested querying sensor encryption status using ectool. Change-Id: I07d1e471ead85a517105b38d1ddd793c3046ce8f Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633272 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* chocodile_vpdmcu: Firmware refactoringSam Hurst2019-06-051-7/+0
| | | | | | | | | | | | | | | | | Move code in header files into c source files. BUG=b:133341676 BRANCH=none TEST=manual Charge-Through was tested on an Atlas running a DRP USB-C/PD state machine with CTUnattached.SNK and CTAttached.SNK states. Change-Id: Ib1b51a778b937e02908f0bc8866bc91a39831163 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1626036 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com>
* common: queue: Update chunk struct and get read/write logicYuval Peress2019-06-051-17/+61
| | | | | | | | | | | | | | | | | | | | | | | | This change updates the queue_get_write_chunk and queue_get_read_chunk logic to return an updated queue_chunk. The new chunk uses a void * for the buffer and replaces length with count. This more tightly aligns to how the rest of the queue functions operate. Further, it adds the ability to offset the write chunk. This is important as it allows wrapping. For example: With a queue of 8 units, 1 byte each. Assume H=2, T=5. Previously, we were only able to ever get the 3 bytes at 5-7. Using the offset of 3 though, we can now also get the 2 byte write chunk 0-1. BUG=chromium:966506 BRANCH=None TEST=Added unit tests Change-Id: I40216c36aa0dc95ec4d15fc587d4b1f08a17ef73 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637415 Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* common: motion_sense: Require CONFIG_MOTION_SENSOR_MAX_COUNTYuval Peress2019-06-053-62/+71
| | | | | | | | | | | | | | | This changes requires all boards to define the maximum number of sensors they support. This will allow us to later create static arrays with the appropriate length. BUG=chromium:966506 BRANCH=None TEST=make buildall Change-Id: I5a2fa8f0fdcaef69065dfd4c2bfea4e3f371e986 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637414 Reviewed-by: Jett Rink <jettrink@chromium.org>
* nvmem: make page header checksums different between prod and devVadim Bendebury2019-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When moving an H1 between prod and dev Cr50 images, it is important to quickly determine that the NVMEM contents are not retrievable. The first object verified by the initialization routine is the page header, but since SHA value is used for integrity verification, it does not change despite the fact that the mode (and encryption keys as a result) changed. Using encrypted header value for integrity verification guarantees that when transition between prod and dev modes happen the initialization function discovers it right away and reinitializes NVMEM instead of trying to interpret corrupted objects. The host/dcrypto stub used for unit tests and fuzzing needs to be modified to ensure that page headers read from uninitialized flash do not look valid (where encrypted value of 0xffffffff is 0xffffffff). BRANCH=cr50, cr50-mp BUG=b:129710256 TEST=make buildall -j successd, as well as migration of a Chrome OS device from legacy to new nvmem layout. Change-Id: I613513cc67b14f553d2760919d6058f8dbed6e41 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1615423 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* nvmem: do not run when crypto is disabledVadim Bendebury2019-05-241-0/+5
| | | | | | | | | | | | | | | | | | There is no point in trying any nvmem operations when encryption/decryption services are not available. Test changes necessary to make sure test app compiles and runs successfully. BRANCH=cr50, cr50-mp BUG=b:132800220 TEST=The device does not crash any more after tpm is disabled. Change-Id: I97f9afc6e4d5377162500fc757084e4d5a57d37d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1615424 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* flash_log: add api for setting base timestampVadim Bendebury2019-05-231-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | The Cr50 environment does not have a wall clock, which makes it impossible to associate flash log entries with real time. This patch provides an API which allows to set a base time value and then use it plus current Cr50 uptime to generate more sensible flash log timestamps. Care is taken to ensure that attempts to set timestamp base such that it would cause a log timestamps rollback do not succeed. A unit test is being added to verify this behavior. BRANCH=none BUG=b:132287488 TEST='make buildall -j' (which runs the new tests) succeeds. Change-Id: I7521df1bac5aef67e0cf634c183bf1618655f48d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1610719 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* ec: common: Make IS_ENABLED fail on unknown valuesRaul E Rangel2019-05-156-0/+126
| | | | | | | | | | | | | | | | | If IS_ENABLED is called with any unknown values, a compiler error will be thrown. This change requires that the optimizer always be enabled, otherwise errors will be thrown when a value is not defined. BUG=none BRANCH=none TEST=make runtests TEST_LIST_HOST="is_enabled_error is_enabled" Change-Id: I1b166311f81d07e48b3665f4bc0e9502d2ccc4c6 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1592728 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* charge_manager: Revisit charge supplier priority.stabilize-12206.BYilun Lin2019-05-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to USB-C spec 1.3 Table 4-17 "Precedence of power source usage", the supplier's priority should be: USB-C 3.0A/1.5A > BC1.2 > USB-C under 1.5A. This CL propose to raise the BC1.2 priority to fix that charge_manager won't choose BC1.2 when the port reports it can supply both TYPEC 500ma and BC1.2 supplier. According to the spec mentioned aboved, we should prefer BC1.2 rather than TYPEC. Besdies, charge_manager is able to pick the supplier which provides the higheste power. The CL simplifies the supplier priority a bit by taking advantage of the feature. TEST=Charge kukui with 5V/2A charger and see it can drain 1.34A (DCP current bound of mt6370 is 1.5A) rather than 0.5A. TEST=Charge kukui with Type-C 5V3A/CDP/DCP/SDP/PD charger randomly and see that the current it drains is reasonable. TEST=Charge soraka with 'A', and plug another port with 'B', and see it can transist the sinking port from A to B. Here (A, B) are: 1. (SDP 5V0.5A, Type-C 5V3A) 2. (CDP 5V1.5A, PD) 3. (SDP 5V0.5A, CDP 5V1.5A) 4. (CDP 5V1.5A, Type-C 5V3A) 5. (Type-C 5V3A, PD) BUG=b:131126720 BRANCH=None Change-Id: I46384e09d764aa926129358657d0593fca4923c2 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1581859 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Align behavior of strtoi() and strtoul() to match Linux manpage description ↵Jes Klinke2019-05-141-0/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | of strtol(). Behavior changes: 1) Initial '+' character is tolerated. 2) Hexadecimal strings prefixed with "0x" are rejected, if given base parameter is anything other than 16 or 0, rather than parsed as hex, diregarding the given base. 3) If given base is 0, strings starting with leading zero will be parsed as octal, rather than decimal. 4) Initial '-' character allowed before "0x" on hexadecimal numbers. (Note: This is my first time using git or gerrit, please let me know if there is some policy or customs that I am not properly adhering to.) BRANCH=none TEST=make run-utils_str V=1 Bug: 940329 Change-Id: I71654471b77f0df071a58ff6bed7028f00cd46b5 Signed-off-by: Jes Bodi Klinke <jbk@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1577750 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jes Klinke <jbk@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* nvmem: populate default tpm objects after wipeoutVadim Bendebury2019-05-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | TPM memory wipe code is removing all TPM objects from the flash, including the reserved objects, which are supposed to be always present. The assumption was that the Cr50 would be reset after the wipe out and the initialization code would populated the reserved objects with default values. But in fact Cr50 reset is not guaranteed after TPM wipeout, so it is better to call the init function explicitly to make sure that all reserved objects are in the flash at all times. BRANCH=cr50, cr50-mp BUG=b:69907320 TEST='dump' command ran on the Cr50 console after RMA open shows all reserved objects present. Change-Id: Id9e227de0995c6491da9f38fc8ca11df3661c71f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1584658 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* nvmem: add test of recovery from interrupted savesVadim Bendebury2019-05-012-1/+16
| | | | | | | | | | | | | | Add a test which introduces corrupted objects in the flash and verifies that the initialization function is able to recover. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 TEST='make run-nvmem' succeeds Change-Id: Ibb7d8181dfdeb097b79087cdae824564ec28921f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1590044 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* nvmem: fix delimiter creation during setvar()Vadim Bendebury2019-05-012-6/+104
| | | | | | | | | | | | | | | | | | | | The (key, value) objects should not be treated differently from TPM objects when initializing NVMEM from some inconsistent state. Saving of a modified (key, value) object should include the 'incomplete delimiter' phase when the new value has been already saved, but the old value has not yet been eliminated. Added tests verifying various failure modes. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 TEST='make run-nvmem' succeeds Change-Id: Ia53b6cfa2edd59fef28ace6978d752ca3cfbb2aa Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1590043 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* motion sense: Calculate loop time based on sensor needsMathew King2019-04-274-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the motion sense loop bases its sleep time based on the fastest active sensor. This method has several flaws: 1. It does not take into account any task switching overhead 2. With a mix of interrupt driven and forced sensors the sleep time gets recalculated every time there is an interrupt causing the loop to oversleep 3. If multiple sensors do not have rates that are in sync the timing of the slower sensor will be off. For example if there was a sensor running at 50 Hz and one running at 20 Hz the slower sensor would end up being sampled at about 16 Hz instead of 20 Hz This change calculates an ideal read time for every forced mode sensor and calculates the sleep time based on the nearest read time. Every time a sensor is read the next read time is calculated based on the ideal read time not the actual read time so that reading does not drift because of system load or other overhead. BUG=b:129159505 TEST=Ran sensor CTS tests on arcada, without this change the magnetometer was failing 50 Hz tests at about 38 Hz with 30% jitter with this change in place 50 Hz was spot on with about 10% jitter BRANCH=none Change-Id: Ia4fccb083713b490518d45e7398eb3be3b957eae Signed-off-by: Mathew King <mathewk@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1574786 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tests: make lighbar test easier to debugJett Rink2019-04-242-10/+12
| | | | | | | | | | | | | | | | | This test was failing and it is easier to comment out tests that are passing to debug. I needed to add a precondition so each test would pass on its own. I also needed to remove the static modifier to allow each test to be comment out. BRANCH=none BUG=none TEST=builds and passes Change-Id: Ib2a7c0948aee363e1552835222a9700225993e46 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1570605 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* mkbp: handle multiple writes of interruptJett Rink2019-04-181-0/+59
| | | | | | | | | | | | | | | | | | | We need to handle the case of multiple tasks trying to set the mkbp interrupt while the host command task is trying to clear it. The setting of the interrupt may also take a while and we need to ensure that we synchronize correct after a longer delay. BRANCH=none BUG=b:129159505 TEST=passing CTS sensor run (except test 133 nullptr) with this change TEST=pass CTS sensor run on eSPI-based system TEST=pass CTS sensor run on GPIO-based system Change-Id: I056b72c1210d7525c29a8555f97e6f09d773d12f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1560229 Tested-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* ec.tasklist: Consolidate duplicate commentsDaisuke Nojiri2019-04-0856-504/+56
| | | | | | | | | | | | | | | | | | | | | | | It's simply a bad idea to describe a macro in multiple locations. It'll make it hard to change. It'll be difficult to keep all locations in sync. This patch replaces the comment duplicated in all ec.tasklist with a pointer to the CONFIG_TASK_LIST definition. The macro will be described in a single place (just like all/most other macros). Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Id658b9d68e742e4334c692b804d9c98c8de21313 Reviewed-on: https://chromium-review.googlesource.com/1551579 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* chocodile_vpdmcu: Firmware for chocodile mcuSam Hurst2019-04-0815-0/+5094
| | | | | | | | | | | | | | | | | | Implement Chocodile Charge-Through Vconn Powered firmware for mcu using new Type-C/PD State machine stack. BUG=b:115626873 BRANCH=none TEST=manual Charge-Through was tested on an Atlas running a DRP USB-C/PD state machine with CTUnattached.SNK and CTAttached.SNK states. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: I847f1bcd2fc3ce41e66edd133a10c943d5e8c819 Reviewed-on: https://chromium-review.googlesource.com/1225250 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Stefan Reinauer <reinauer@google.com>
* cr50: complete support of the new NVMEM structureVadim Bendebury2019-04-052-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch eliminates unnecessary legacy nvmem.c and nvmem_vars.c code and brings the code base to the state where the new NVMEM layout is fully functional. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 CQ-DEPEND=CL:1450278 TEST=the following tests pass: - test cases in ./test/nvmem.c - TCG suite (passes on par with the existing Cr50 code with the reduced code footprint TPM2 library) - Chrome OS device migrates from legacy to new implementation with user account maintained. - Chrome OS user account is maintained over AP and H1 reboots and deep sleep cycles. Change-Id: If4bc2dd125873a79dbe0e268eb32100a8b8b352d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1496607 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* nvmem: test modifications to support the new schemeVadim Bendebury2019-04-059-1142/+2673
| | | | | | | | | | | | | | | | | | | | | This patch includes changes to support testing of the new nvmem implementation. Making fizz compatible required duplicating a lot of functionality available in the test/ directory (fuzz/nvmem_tpm2_mock.c is very similar to test/nvmem_tpm2_mock.c), but I could not find an easy way to avoid it. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 CQ-DEPEND=CL:1496607 TEST=with the rest of the patches applied 'make buildall -j' succeeds, which confirms both test and fuzz success. Change-Id: Ife999b04d22f8ddbe9ea5d35f4c3e21f57592754 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1450278 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* common: add flash event log facilityVadim Bendebury2019-03-264-0/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds implementation and test for a generic logger saving log entries in the flash. The entries payload are limited to 64 bytes in size, each entry starts with a header, which includes - 8 bit type type to allow to interpret the payload - 6 bit size field (two top bits of the byte are left for user flags, not yet used) - 32 bit timestamp to allow to identify newer log entries (presently this is just a monotonically increasing number) - 8 bit crc field protecting the entire entry The entries are padded to make sure that they are ending on the flash write boundary. The location of the log is defined by the platform using it. There is a provision for allowing the platform to register a callback which is needed to be called to allow write access to the log (as is the case on H1). While the device is running, the log is growing until the allotted flash space is 90% full. If there is an attempt save another entry after that the log is compacted, namely the last 25% worth of flash space is preserved, the log space is erased and the saved contents written back. On restarts the log is compacted if its size exceeds 75% of the allotted flash space. An API is provided to add entries to the log and to retrieve an entry newer than a certain timestamp value. Thus starting with timestamp zero will result in reading the very first log entry. To read the next entry, the read function needs to be called with the timestamp value of the current entry. This allows to browse the entire log, one entry at a time. A CLI command compiled in when CONFIG_CMD_FLASH_LOG is defined, allows to add log and retrieve log entries. BUG=b:63760920 BRANCH=cr50, cr50-mp TEST=the included test case can be invoked by make run-flash_log and it passes. More tests are done when the rest of the patch stack is added. Change-Id: I3dcdf2704a1e08fd3101183e434ac4a4e4cf1b9a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1525143 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* motion_lid: Rewrite lid angle calculation based on chromium codeGwendal Grignou2019-03-2611-30/+2542
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use code from ash/wm/tablet_mode/tablet_mode_controller.cc, in particular TabletModeController::HandleHingeRotation() to calculate lid angle. Add unit tests based on ash/wm/tablet_mode/tablet_mode_controller_unittest.cc and the data file accelerometer_test_data_literals.cc. BUG=b:120346412 BRANCH=none TEST=Check unit tests pass, check it compile on FPU based EC, EC without FPU and no 64 bit support (ampton). Check lid calculation is correct on eve: - with "while true ; do ectool motionsense lid_angle ; sleep 1 ; done" Check when hinge is almost vertical lid angle is close to constant or marked are unrieliable. Check when shaking device, lid angle is also unreliable Check with evtest SW_TABLET_MODE event is trigger when lid angle is available and cross 180 region. Change-Id: I545f7333ed9b53accedb75f238f747f66bae1f5d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1388844 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-261-2/+2
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* chgstv2: Refactor shutdown_on_critical_batteryDaisuke Nojiri2019-03-121-2/+2
| | | | | | | | | | | | | | | | | This patch refactors shutdown_on_critical_battery. There is no change in its functionality. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=nami,strago,coral TEST=Verify Vayne cuts off battery when soc <= 4% in S0 and S5. Change-Id: Ia6d3e2166d01803ae8983afd2d4e15d254845065 Reviewed-on: https://chromium-review.googlesource.com/1512620 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>
* mkbp_event,include/config.h: Clarify MKBP delivery method.Yilun Lin2019-03-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now we have two MKBP delivery methods: 1. define CONFIG_MKBP_USE_HOST_EVENT to notify via host event 2. undef CONFIG_MKBP_USE_HOST_EVENT to notify via GPIO interrupt It may become more complicated if new notification methods introduced. e.g.: mt_scp uses IPI, rather than host event and GPIO interrupt. This CL does: 1. add CONFIG_MKBP_USE_GPIO to explicilty declare that MKBP event are sent via GPIO interrupt. 2. CONFIG_MKBP_USE_CUSTOM for boards which have custmized methods. 3. Remove weak attribute in mkbp_set_host_active (which can be done with CONFIG_MKBP_USE_CUSTOM now. 4. Removes mkbp_set_host_active function in board Nocturne. It only deliver MKBP events through GPIO interrupt now. BRANCH=None BUG=b:120808999 TEST=grep -rn "CONFIG_MKBP_USE_GPIO\|EC_INT_L" board/ baseboard/ and see the result is reasonable: 1. EC_INT_L must be 1-to-1 mapped to define CONFIG_MKBP_USE_GPIO in every board, except that meep, yorp, ampton which are defined in baseboard octopus. 2. undef CONFIG_MKBP_USE_GPIO in bip and casta, which use host event, but also have baseboard octopus. Change-Id: I4af6110e4fd3c009968075c3623ef2d91cbd770b Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1490794 Commit-Ready: Jett Rink <jettrink@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* chgstv2: Make board_critical_shutdown_check specify action on critical socDaisuke Nojiri2019-03-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, board_critical_shutdown_check is used only in the context of CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF. It returns true to cutoff the battery or false to take no action. This patch extends board_critical_shutdown_check to allow it to control what actions to take on critical battery condition. With this change, each board can also customize critical battery actions with more granularity (per OEM, BOARD_VERSION, etc.). Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/123727148 BRANCH=nami TEST=Verify a battery is cutoff at critical low charge on Scarlet and DUT wakes up by AC plugin on cros/firmware-scarlet-10388.B. Change-Id: Id49e860b05e21c3bfa4d75f27c48b55c2a3ad95f Reviewed-on: https://chromium-review.googlesource.com/1487113 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>
* motion: Add config variable to fill LPC sense dataGwendal Grignou2019-03-011-0/+1
| | | | | | | | | | | | | | | | | | Writing sense data in LPC area is required for: - X86 host - unit tests. Add a CONFIG_ variable to make it explicit. BUG=b:120346412 BRANCH=None TEST=Buildall, emerge-* chromeos-ec Change-Id: Ib3db6ec4e53cba3057162d300de943b6c86bfcfe Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1491913 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* stdlib cleanup.Allen Webb2019-01-031-1/+0
| | | | | | | | | | | | | | | | This cleanups some header includes to avoid conflicts between the ec headers and the standard c headers. BRANCH=None BUG=None TEST=make -j buildall && ./build_packages --board=veyron_minnie \ chromeos-ec && FEATURES=test emerge-veyron_minnie chromeos-ec Change-Id: Icf9022d688fd9c749f7a5f8673755188741b40e1 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1378906 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* util: Add macro to swap two variablesDaisuke Nojiri2018-12-101-0/+20
| | | | | | | | | | | | | | | | | | | This patch adds swap(a,b), which swaps the values in two variables. It requires c99 for typeof. Swapping composites (e.g. a+b, x++) doesn't make sense. So, <a> and <b> can only be a variable (x) or a pointer reference (*x) without an operator. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Id656e173d372dfff759d9aee9314a008a6d91786 Reviewed-on: https://chromium-review.googlesource.com/1366306 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cr50: clear TPM NVMEM cache when entering Alt OSVadim Bendebury2018-12-061-0/+4
| | | | | | | | | | | | | | | | | | | | | Each time TPM is disabled for booting Alt OS, NVMEM cache needs to be wiped out, only a few NV indices need to be preserved. We also are making sure that wipeout is possible only if key ladder is disabled. CQ-DEPEND=CL:1362161 BRANCH=cr50, cr50-mp BUG=b:119221935 TEST=on a dual boot machine observed that when booting ALT OS on reboots, key ladder is disabled, but RW AP firmware rollback indices at address 0x1007 are still read properly. Alt OS resume happens pretty quickly. Change-Id: I5326937d0a36b67ac848629faeee42aadcb9e64d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1362203 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* cr50: provide DCRYPTO_ladder_is_enabled() for test and fuzz buildsVadim Bendebury2018-12-061-0/+5
| | | | | | | | | | | | | | | This function is called from common/nvmem.c, it should be available when compiling for tests, the stub could be filled up later when new tests are added. BRANCH=cr50, cr50-mp BUG=b:119221935 TEST=make buildall -j still succeeds. Change-Id: I082292818c7f2b10336c9a7c49e0a9195e25a12b Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1363816 Reviewed-by: Allen Webb <allenwebb@google.com>
* motion_lid: Use CONFIG_TABLET_MODEFurquan Shaikh2018-11-291-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | This change updates motion_lid driver to use CONFIG_TABLET_MODE to decide if device requires reporting of tablet mode. This basically makes the config options CONFIG_LID_ANGLE_INVALID_CHECK and CONFIG_LID_ANGLE_TABLET_MODE obsolete. Now that EC will always report tablet mode aligned with Chrome (at 180 degree), any device that supports tablet mode and uses motion lid driver will require this by default and should not require boards to individually select any special config options. Thus, it also gets rid of unused CONFIG_LID_ANGLE_TABLET_MODE and CONFIG_LID_ANGLE_INVALID_CHECK. BUG=b:120050761 BRANCH=octopus TEST=make -j buildall Change-Id: Ib73af66ca1c17d4033cf54f0b4b86bf41793f3a3 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1350470 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* Battery: Compensate remaining charge to match full capacityDaisuke Nojiri2018-11-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If remaining charge is more than x% of the full capacity, the remaining charge is raised to the full capacity before it's reported to the rest of the system. Some batteries don't update full capacity timely or don't update it at all. On such systems, compensation is required to guarantee the remaining charge will be equal to the full capacity eventually. On some systems, Rohm charger generates audio noise when the battery is fully charged and AC is plugged. A workaround is to do charge- discharge cycles between 93 and 100%. On such systems, compensation was also applied to mask this cycle from users. This used to be done in ACPI, thus, all software components except EC was able to see the compensated charge. This patch is moving the logic to EC. With this and the following changes, EC can see what the rest of the system sees, thus, can control LEDs synchronously (to the display percentage). Another rationale of this move is EC can perform more granular and precise compensation than ACPI since it has more knowledge about the battery and the charger. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> CQ-DEPEND=CL:1320195 BUG=b:109954565,b:80270446 BRANCH=none TEST=Verify charge LED changes to white (full) on Sona synchronously to the display percentage. TEST=Verify charge LED changes to blinking white (low) on Sona within 30 seconds synchronously to the display percentage. Change-Id: I4e3f70efa39e62c91cb8894b603c551cd23511aa Reviewed-on: https://chromium-review.googlesource.com/1312204 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Cr50: Add valid PCR value for pinweaverIgor2018-11-071-28/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to bind the PIN authentication to PCR4, required for additional security, a set of valid PCR criteria is added as metadata in the leaf of the tree. Each criteria has a bitmask of PCR indexes and the digest sha256 that should be obtained from concatenation of PCR values for the respective indexes. Pinweaver will handle both types of requests, in old and the new format. For migration of old leaves that don't have the new field, the process expects cryptohome to detect that the leaf needs migration based on protocol used, leaf version and if the list of PCR criteria is empty. In case the leaf needs migration, cryptohome should insert a new leaf with the same data and remove the old one. The PCR criteria set is created on Chrome OS side. Details of that implementation is in https://chromium-review.googlesource.com/c/chromiumos/platform2/+/1124856 BRANCH=none BUG=chromium:812165 TEST=sudo V=1 make run-pinweaver -j pinweaver_client selftest Deploy old image on a device and create an account setting a PIN code as well. Deploy the new image and new CR50 build. Login and check that the migration works well. Also try to put device to sleep and unlock. Check that a new credential creation with new version works as well and sleep + unlock work as expected. Extend PCR4 on device and check that login/unlock works only for the user which obfuscated_username was used to extend the PCR. Also check that authentication works with cases when old cryptohome and new pinweaver is deployed, or old pinweaver and new cryptohome. CQ-DEPEND=CL:1124856 Change-Id: If778c4e46b9945afadfd2af7d58353005624d668 Signed-off-by: igorcov@chromium.org Reviewed-on: https://chromium-review.googlesource.com/1112014 Commit-Ready: Igor <igorcov@chromium.org> Tested-by: Igor <igorcov@chromium.org> Reviewed-by: Igor <igorcov@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>